Yeah!!!
Un poco de C#,JScript,VB, y CRM, Drupal, SQL , MSDCRM y MSDSL VBTools, developer, project lider, Social Media Activist, BlackBerry developer, telerik tools. (MCITP)
martes, 14 de julio de 2009
lunes, 12 de noviembre de 2007
Leer una imágen de Sql y guardar imágen en Sql
Una vez más con algo para leer y guardar imágenes en sql, con estas 2 fuciones que les pongo a continuación podemos convertir la imágen en un objeto image de sql y también lo podemos leer el campotipo image y obtener la imágen, y la podemos almacenar en un archivo temporal por si deseamos guardar la misma imágen.
#Region "Función Image2SqlImage"
Public Function Image2SqlImage(ByVal File As Object) As Byte()
Try
Dim ruta As New FileStream(File, FileMode.OpenOrCreate, FileAccess.ReadWrite)
Dim binario(ruta.Length) As Byte
ruta.Read(binario, 0, ruta.Length)
ruta.Close()
Return binario
Catch
Return Nothing
End Try
End Function
#End Region
#Region "Función sqlImagen2Image"
Public Function sqlImagen2Image(ByVal FieldImage As Object) As Bitmap
Try
Dim bits As Byte() = CType(FieldImage, Byte())
Dim memorybits As New MemoryStream(bits)
Dim bitmap As New Bitmap(memorybits)
bitmap.Save("C:\TempRMSImage.tmp")
Return bitmap
Catch EX As Exception
Return Nothing
End Try
End Function
#End Region
Saludos mis queridos amigos y lectores, espero les sea útil.
#Region "Función Image2SqlImage"
Public Function Image2SqlImage(ByVal File As Object) As Byte()
Try
Dim ruta As New FileStream(File, FileMode.OpenOrCreate, FileAccess.ReadWrite)
Dim binario(ruta.Length) As Byte
ruta.Read(binario, 0, ruta.Length)
ruta.Close()
Return binario
Catch
Return Nothing
End Try
End Function
#End Region
#Region "Función sqlImagen2Image"
Public Function sqlImagen2Image(ByVal FieldImage As Object) As Bitmap
Try
Dim bits As Byte() = CType(FieldImage, Byte())
Dim memorybits As New MemoryStream(bits)
Dim bitmap As New Bitmap(memorybits)
bitmap.Save("C:\TempRMSImage.tmp")
Return bitmap
Catch EX As Exception
Return Nothing
End Try
End Function
#End Region
Saludos mis queridos amigos y lectores, espero les sea útil.
Encriptar y desencriptar una cadena .Net
Hola Amigos, aqui estoy de nuevo, con unas funciones que me parecen muy útiles para cuando queramos encriptar y desencriptar una cadena de texto, que podríamos usar para cuando guardamos las cadenas de conexión de una base de datos, o alguna contraseña que no queremos que sea vista, no es la super seguridad pero es funcional.
#Region "Función Encrypt"
'Encripta cadenas de texto
Public Function Encrypt(ByVal string_encriptar As String) As String
Dim R As Integer
Dim I As Integer
R = Len(Trim(string_encriptar))
For I = 1 To R
Mid(string_encriptar, I, 1) = Chr(Asc(Mid(string_encriptar, I, 1)) - 2)
Next I
Dim b As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(string_encriptar)
Dim encryptedConnectionString As String = Convert.ToBase64String(b)
Return encryptedConnectionString
End Function
#End Region
#Region "Función UnEncrypt"
'Desencripta cades de texto encriptadas por Encrypt
Public Function UnEncrypt(ByVal string_desencriptar As String) As String
Dim R As Integer
Dim i As Integer
Dim b As Byte() = Convert.FromBase64String(string_desencriptar)
Dim decryptedConnectionString As String = System.Text.ASCIIEncoding.ASCII.GetString(b)
R = Len(Trim(decryptedConnectionString))
For i = 1 To R
Mid(decryptedConnectionString, i, 1) = Chr(Asc(Mid(decryptedConnectionString, i, 1)) + 2)
Next i
Return decryptedConnectionString
End Function
#End Region
Saludos espero les sea muy útil.
#Region "Función Encrypt"
'Encripta cadenas de texto
Public Function Encrypt(ByVal string_encriptar As String) As String
Dim R As Integer
Dim I As Integer
R = Len(Trim(string_encriptar))
For I = 1 To R
Mid(string_encriptar, I, 1) = Chr(Asc(Mid(string_encriptar, I, 1)) - 2)
Next I
Dim b As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(string_encriptar)
Dim encryptedConnectionString As String = Convert.ToBase64String(b)
Return encryptedConnectionString
End Function
#End Region
#Region "Función UnEncrypt"
'Desencripta cades de texto encriptadas por Encrypt
Public Function UnEncrypt(ByVal string_desencriptar As String) As String
Dim R As Integer
Dim i As Integer
Dim b As Byte() = Convert.FromBase64String(string_desencriptar)
Dim decryptedConnectionString As String = System.Text.ASCIIEncoding.ASCII.GetString(b)
R = Len(Trim(decryptedConnectionString))
For i = 1 To R
Mid(decryptedConnectionString, i, 1) = Chr(Asc(Mid(decryptedConnectionString, i, 1)) + 2)
Next i
Return decryptedConnectionString
End Function
#End Region
Saludos espero les sea muy útil.
lunes, 22 de octubre de 2007
Get User Role For CRM from .Net App.
//Para obtener el Guid Id del usuario que ejecuta el WS.
WhoAmIRequest userRequest = new WhoAmIRequest();
WhoAmIResponse userResp = (WhoAmIResponse)
oCrmService.Execute(userRequest);
userResp.UserId; string
UserRole=GetRole(userResp.UserId;)
private String GetRole(Guid UserID) {
//Guid userid = new Guid(UserID);
CrmService oCrmService = new CrmService();
oCrmService.Credentials = System.Net.CredentialCache.DefaultCredentials;
QueryExpression qe = new QueryExpression();
qe.EntityName = "role";
qe.ColumnSet = new AllColumns();
LinkEntity le = new LinkEntity();
le.LinkFromEntityName = "role";
le.LinkFromAttributeName = "roleid";
le.LinkToEntityName = "systemuserroles";
le.LinkToAttributeName = "roleid";
LinkEntity le2 = new LinkEntity();
le2.LinkFromEntityName = "systemuserroles";
le2.LinkFromAttributeName = "systemuserid";
le2.LinkToEntityName = "systemuser";
le2.LinkToAttributeName = "systemuserid";
ConditionExpression ce = new ConditionExpression();
ce.AttributeName = "systemuserid";
ce.Operator = ConditionOperator.Equal;
ce.Values = new object[]{UserID};
le2.LinkCriteria = new FilterExpression();
le2.LinkCriteria.Conditions = new ConditionExpression[]{ce};
le.LinkEntities = new LinkEntity[]{le2};
qe.LinkEntities = new LinkEntity[]{le};
BusinessEntityCollection bec = oCrmService.RetrieveMultiple(qe);
if (bec.BusinessEntities.Length > 0)
{
return ((role)bec.BusinessEntities[0]).name.ToString();
}
else throw new Exception("User not found");
// return "";
}
WhoAmIRequest userRequest = new WhoAmIRequest();
WhoAmIResponse userResp = (WhoAmIResponse)
oCrmService.Execute(userRequest);
userResp.UserId; string
UserRole=GetRole(userResp.UserId;)
private String GetRole(Guid UserID) {
//Guid userid = new Guid(UserID);
CrmService oCrmService = new CrmService();
oCrmService.Credentials = System.Net.CredentialCache.DefaultCredentials;
QueryExpression qe = new QueryExpression();
qe.EntityName = "role";
qe.ColumnSet = new AllColumns();
LinkEntity le = new LinkEntity();
le.LinkFromEntityName = "role";
le.LinkFromAttributeName = "roleid";
le.LinkToEntityName = "systemuserroles";
le.LinkToAttributeName = "roleid";
LinkEntity le2 = new LinkEntity();
le2.LinkFromEntityName = "systemuserroles";
le2.LinkFromAttributeName = "systemuserid";
le2.LinkToEntityName = "systemuser";
le2.LinkToAttributeName = "systemuserid";
ConditionExpression ce = new ConditionExpression();
ce.AttributeName = "systemuserid";
ce.Operator = ConditionOperator.Equal;
ce.Values = new object[]{UserID};
le2.LinkCriteria = new FilterExpression();
le2.LinkCriteria.Conditions = new ConditionExpression[]{ce};
le.LinkEntities = new LinkEntity[]{le2};
qe.LinkEntities = new LinkEntity[]{le};
BusinessEntityCollection bec = oCrmService.RetrieveMultiple(qe);
if (bec.BusinessEntities.Length > 0)
{
return ((role)bec.BusinessEntities[0]).name.ToString();
}
else throw new Exception("User not found");
// return "";
}
How to do a Read Only Form into CRM
How to do a Read Only Form into CRM, this sample was designed for the validation of the field oStatus, but you can change this validation for other :
Para Hacer una Forma de solo lectura para CRM, este ejemplo fue hecho en base a una validación de oStatus, pero se puede hacer para cualquier otra validación:
var oStatus = crmForm.all.gicsa_statusultimus;
if (typeof(oStatus) != "undefined" && oStatus != null)
{
if (oStatus.value > 2 && crmForm.FormType != 3)
{ window.navigate("
Para Hacer una Forma de solo lectura para CRM, este ejemplo fue hecho en base a una validación de oStatus, pero se puede hacer para cualquier otra validación:
var oStatus = crmForm.all.gicsa_statusultimus;
if (typeof(oStatus) != "undefined" && oStatus != null)
{
if (oStatus.value > 2 && crmForm.FormType != 3)
{ window.navigate("
VbCurrency Words en español para RMS.
Amigos, he tratado de cambiar el idioma del VbCurrencyWords a español, pero no he podido saber cómo agregar una dll a RMS, pero tan pronto lo sepa, seguro se los comparto.
I had been trying to change the english lenguage to spanish of de vbCurrencyWords but I can't and, Microsoft support said this:
SCOPE:I understand that you wanted to covert the amount in English to Spanish and you're looking for ways to have this done.
ENVIRONMENT:Product Line: Microsoft Retail Management
Topic: Point Of Sale or Store Operations
Version: 2.0
Application Language: English (US)
Database: SQL Server 2005Server
OS: Windows Server 2003
ASSESSMENT:Customization and/or dealing with *.dll files is already beyond our support boundaries. In addition to that, the only supported language version is English. I do hope you understand our situation on this one. The best thing I could do for you is to provide you the following information that might point you to the right direction:
I had been trying to change the english lenguage to spanish of de vbCurrencyWords but I can't and, Microsoft support said this:
SCOPE:I understand that you wanted to covert the amount in English to Spanish and you're looking for ways to have this done.
ENVIRONMENT:Product Line: Microsoft Retail Management
Topic: Point Of Sale or Store Operations
Version: 2.0
Application Language: English (US)
Database: SQL Server 2005Server
OS: Windows Server 2003
ASSESSMENT:Customization and/or dealing with *.dll files is already beyond our support boundaries. In addition to that, the only supported language version is English. I do hope you understand our situation on this one. The best thing I could do for you is to provide you the following information that might point you to the right direction:
viernes, 5 de octubre de 2007
Por una mejor cultura,programación en 3 capas
Hola mis queridos lectores, como no compartir esto que se vuelto una cultura, un standar, parte de las mejores prácticas de Desarrollo y es esto conocido como la programación en 3 capas.
Al igual que con aplicaciones de dos capas, una aplicación de tres capas se puede actualizar de manera vertical o de manera horizontal y a mi parecer es mucho mejor por la facilidad que nos da para darle mantenimiento.
Al seleccionar una estrategia horizontal, se puede actualizar toda o parte de una capa y dejar las otras capas como están. El código actualizado puede utilizar características de interoperabilidad para accesar el código que no se ha cambiado. Después, se pueden actualizar las otras capas gradualmente e integrarlas a la aplicación.
Otra característica que es importante mencionar de una arquitectura de tres capas es que nos permite aprovechar las habilidades especializadas que podamos tener los desarrolladores involucrados en el proyecto, y podemos trabajar paralelamente. Por ejemplo, un desarrollador o equipo pueden trabajar en los componentes modulares de interfaz de usuario mientras que otros desarrolladores actualizan y ajustan componentes en las capas de lógica de negocios y acceso a datos.
Aquí les dejo una imágen de una arquitectura de programación en 3 capas.
Saludos espero les halla quedado claro la ventaja de esto.
Suscribirse a:
Entradas (Atom)