-- cambios stringbuilder, performance

This commit is contained in:
rrene
2020-05-27 13:50:22 -07:00
parent 9288e4ce8e
commit 0324c2fb85
5 changed files with 81 additions and 38 deletions

View File

@@ -96,7 +96,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
Retorno = 200
End If
ObjConta.Dispose()
Empresa = Nothing
'context.Response.Write(CveUsuario.ToString())
context.Response.StatusCode = Retorno
End Sub
@@ -114,7 +114,8 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
context.Response.WriteFile(FileInfo.FullName)
context.Response.End()
End If
FileInfo = Nothing
Url = ""
End If
End Sub
@@ -127,6 +128,8 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
savepath = context.Server.MapPath(tempPath)
Dim nombre As String = String.Format("{0}\{1}", savepath, context.Request("nombre"))
File.Delete(nombre)
tempPath = ""
savepath = ""
context.Response.StatusCode = 200
End Sub
@@ -149,16 +152,18 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
If copyFile <> "" Then
Dim ext As Integer = copyFile.IndexOf(","c) + 1
Dim extncion As String = copyFile.Substring(5, ext - 5)
If extncion.Contains("image/") Then extncion = extncion.Replace("image/", "").Replace(";base64,", "")
Dim extension As String = copyFile.Substring(5, ext - 5)
If extension.Contains("image/") Then extension = extension.Replace("image/", "").Replace(";base64,", "")
'Dim extncion As String =
filename = String.Format("{0}-{1}.{2}", tick, Cve, extncion)
filename = String.Format("{0}-{1}.{2}", tick, Cve, extension)
Dim msf As New MemoryStream(Convert.FromBase64String(copyFile.Substring(ext)))
Dim stem As Stream = New FileStream(String.Format("{0}\{1}", savepath, filename), FileMode.Create)
msf.WriteTo(stem)
msf.Close()
stem.Close()
msf.Dispose()
stem.Dispose()
End If
Else
@@ -166,10 +171,13 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
postedFile = context.Request.Files(0)
filename = String.Format("{0}-{1}", tick, postedFile.FileName)
postedFile.SaveAs((savepath & "\") + filename)
postedFile.SaveAs(String.Format("{0}\{1}", savepath, filename))
End If
context.Response.Write(tick)
context.Response.StatusCode = 200
savepath = ""
tempPath = "" : filename = ""
postedFile = Nothing
End Sub
#End Region
@@ -206,9 +214,9 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
'End If
'ObjClientes.Dispose()
Dim dt As DataTable = DirectCast(context.Application(AppNombre), DataTable).FiltraParametros($"CveEmpresa = {CveEmpresa}")
Dim dt As DataTable = DirectCast(context.Application(AppNombre), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa))
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
DtRetorno = dt.FiltraParametros($"NombreComercial like '%{Name}%' OR Nombre like '%{Name}%' ")
DtRetorno = dt.FiltraParametros(String.Format("NombreComercial like '%{0}%' OR Nombre like '%{0}%' ", Name))
End If
dt.Dispose()
End If
@@ -254,9 +262,9 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
' DtRetorno = ObjProveedores.DtResultados
'End If
'ObjProveedores.Dispose()
Dim dt As DataTable = DirectCast(context.Application(AppNombre), DataTable).FiltraParametros($"CveEmpresa = {CveEmpresa}")
Dim dt As DataTable = DirectCast(context.Application(AppNombre), DataTable).FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa))
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
DtRetorno = dt.FiltraParametros($"NombreCortoProveedor like '%{Name}%'")
DtRetorno = dt.FiltraParametros(String.Format("NombreCortoProveedor like '%{0}%'", Name))
End If
dt.Dispose()
End If
@@ -321,6 +329,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
Else
context.Response.Write("[]")
End If
DtPSRetorno.Dispose()
Return retorno
End Function
@@ -485,9 +494,9 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
If usuario.TienePermisoProceso(300) And usuario.TienePermisoProceso(301) Then
DTClasificacionesComprobaciones = ObjClasificaciones.DtResultados
ElseIf usuario.TienePermisoProceso(300) Then 'TipoComprobacion 1 Biaticos
ElseIf usuario.TienePermisoProceso(300) Then 'TipoComprobacion 1 Viaticos
DTClasificacionesComprobaciones = ObjClasificaciones.DtResultados.FiltraParametros("TipoComprobacion = 1")
Else 'TipoComprobacion 2 Compreobacines
Else 'TipoComprobacion 2 caja chica
DTClasificacionesComprobaciones = ObjClasificaciones.DtResultados.FiltraParametros("TipoComprobacion = 2")
End If
@@ -515,6 +524,8 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
'no regresar datos herror al consultar
DtPSRetorno.Clear()
End If
DTTmp.Dispose()
ObjClasificaciones.Dispose()
End If
@@ -556,7 +567,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
#Region "Funciones"
Public Function GetJson(ByVal dt As DataTable) As String
Dim Retorno As String = ""
Dim serializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer()
Dim rows As New List(Of Dictionary(Of String, Object))
Dim row As Dictionary(Of String, Object)
@@ -568,7 +579,11 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
Next
rows.Add(row)
Next
Return serializer.Serialize(rows)
If dt IsNot Nothing Then dt.Dispose()
Retorno = serializer.Serialize(rows)
rows = Nothing
serializer = Nothing
Return Retorno
End Function
ReadOnly Property UsuarioActual(ByVal context As HttpContext) As Usuario
Get
@@ -631,6 +646,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
DtPSRetorno.Columns("ClaveNombre").ColumnName = "text"
retorno = JsonConvert.SerializeObject(DtPSRetorno).ToString
context.Response.Write(retorno)
DtPSRetorno.Dispose()
Else
context.Response.Write("[]")
End If
@@ -738,6 +754,8 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
Catch ex As Exception
DtPSRetorno = Nothing
End Try
DTPS = Nothing
End If
End If
@@ -745,6 +763,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
DtPSRetorno.Columns("CvePS").ColumnName = "id"
DtPSRetorno.Columns("PSCodigo").ColumnName = "text"
retorno = JsonConvert.SerializeObject(DtPSRetorno).ToString
DtPSRetorno.Dispose()
context.Response.Write(retorno)
Else
context.Response.Write("[]")
@@ -795,6 +814,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
DtRetorno.Columns("CvePersonal").ColumnName = "id"
DtRetorno.Columns("NombreCompleto").ColumnName = "text"
retorno = JsonConvert.SerializeObject(DtRetorno).ToString
DtRetorno.Dispose()
context.Response.Write(retorno)
Else
context.Response.Write("[]")