correciones en servicio de registro confiable

This commit is contained in:
2020-06-30 19:28:27 -07:00
parent 3f3db6663e
commit 9566c81f82

View File

@@ -26,85 +26,21 @@ public class SIGGPSRCService : IHttpHandler, IRequiresSessionState
}
}
private Usuario ValidaUsuarioSistema(int CveEmpresa)
{
Usuario UsuarioActual = null;
ClsSisUsuarios ObjUsuarios = new ClsSisUsuarios();
if (ObjUsuarios.GetUsuarios(1727))
{
if (ObjUsuarios.DtResultados.Rows.Count > 0)
{
var Usuario = ObjUsuarios.DtResultados.Rows[0]["Usuario"].ToString();
var Contrasenia = ObjUsuarios.DtResultados.Rows[0]["Contraseña"].ToString();
UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, ModExtensiones.IMEI, CveEmpresa);
UsuarioActual.CveEmpresa = CveEmpresa;
UsuarioActual.CveCliente = 183798;
CreaObjetoEmpresa(ref UsuarioActual);
CargaZonasHorarias(ref UsuarioActual);
}
}
ObjUsuarios.Dispose();
return UsuarioActual;
}
private void CreaObjetoEmpresa(ref Usuario UsuarioActual)
{
ClsSisEmpresas ObjEmpresa = new ClsSisEmpresas();
if (ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1"))
{
if (ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa))
{
System.Data.DataTable dttmp = ObjEmpresa.DtResultados;
var EmpresasFuncionalidades = new HybridDictionary();
foreach (System.Data.DataRow Row in dttmp.Rows)
EmpresasFuncionalidades.Add(Convert.ToInt32(Row["CveFuncionalidad"]), Row["Valor"].ToString());
ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades);
}
UsuarioActual.Empresa = ObjEmpresa.Empresa;
}
ObjEmpresa.Dispose();
}
private void CargaZonasHorarias(ref Usuario UsuarioActual)
{
ClsClientes ObjClientes = new ClsClientes();
try
{
if (ObjClientes.GetClientes(UsuarioActual.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1, Estatus: 1))
{
if (ObjClientes.DtResultados.Rows.Count == 1)
UsuarioActual.UTCOffset = ObjClientes.DtResultados.Rows[0]["UTCOffset"].ToString().ToEntero();
}
}
catch (Exception ex)
{
ex.ToString().GuardaLog();
}
finally
{
ObjClientes.Dispose();
}
}
public bool IsReusable => false;
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
bool retorno = false;
try
{
context.Response.ContentType = "text/plain";
bool retorno = false;
string Metodo = context.Request["Metodo"] == null ? "" : context.Request["Metodo"];
switch (Metodo)
{
case "EjecutaServicio":
ModExtensiones.GuardaLogAD("Servicio Ejecutado...........", "LogServicioConfiable");
IniciarTransmision(context);
retorno = true;
retorno = IniciarTransmision();
break;
default:
break;
@@ -123,11 +59,14 @@ public class SIGGPSRCService : IHttpHandler, IRequiresSessionState
{
ex.GuardaLog(ex.Message);
}
context.Response.End();
}
private void IniciarTransmision(HttpContext context)
private bool IniciarTransmision()
{
var UsuarioActual = ValidaUsuarioSistema(121);
var retorno = false;
var TieneError = false;
var WS = new RCGPSService.RCServiceClient();
@@ -142,6 +81,10 @@ public class SIGGPSRCService : IHttpHandler, IRequiresSessionState
{
DtTrackings = ObjGPS.DtResultados.Copy();
}
else
{
TieneError = true;
}
if (DtTrackings != null)
{
@@ -152,6 +95,10 @@ public class SIGGPSRCService : IHttpHandler, IRequiresSessionState
{
dtTracking = ObjGPS.DtResultados.Copy();
}
else
{
TieneError = true;
}
if (dtTracking != null)
{
foreach (DataRow Row in dtTracking.Rows)
@@ -175,6 +122,7 @@ public class SIGGPSRCService : IHttpHandler, IRequiresSessionState
}
catch (Exception ex)
{
TieneError = true;
this.OnError("Ocurrió un error al enviar los datos", ex);
}
ObjGPS.Dispose();
@@ -182,15 +130,22 @@ public class SIGGPSRCService : IHttpHandler, IRequiresSessionState
DtTrackings.Dispose();
DtTrackings = null;
if (ListaEventos.Count > 0)
if (ListaEventos.Count > 0 && !TieneError)
{
var respuesta = WS.GPSAssetTracking(Token.token, ListaEventos.ToArray());
context.Response.Write(JsonConvert.SerializeObject(respuesta));
if (respuesta.Length > 0)
{
retorno = !TieneError;
}
}
else
{
retorno = !TieneError;
}
WS.Close();
//context.Response.Write(JsonConvert.SerializeObject(new { idJob = "1", exception = "" }));
return retorno;
}