public static async Task <int> Cancelar(DTOODTCancelacion insert, Context ApplicationContext) { int regreso = 0; OperationClient WS = null; try { int detalle = await Utils.CargarFoto(insert.ODTID.ToString(), insert.Foto.Foto, ApplicationContext, insert.Foto.FechaCreacion.Day.ToString() + "/" + insert.Foto.FechaCreacion.Month.ToString() + "/" + insert.Foto.FechaCreacion.Year.ToString()); if (detalle != 0) { insert.FotoID = detalle; insert.Foto.Foto = null; WS = Utils.InitializeServiceClient(); OperationStatus Request = WS.CancelODT(insert); if (Request.IsComplete) { regreso = 1; } } } catch (Exception exc) { regreso = 0; } finally { if (WS != null) { WS.Close(); } } return(regreso); }
void bk_DoWork(object sender, DoWorkEventArgs e) { if (Utils.Internet(ApplicationContext)) { DTOODTCancelacion insert = new DTOODTCancelacion(); OperationClient WS = null; try { insert.ODTID = ODTDet.ID; insert.CuadrilleroID = Convert.ToInt32(iduser); insert.MotivoODTID = ReasonId; insert.Observaciones = comentarios; if (LoadFoto) { insert.FotoID = idevidencia; DTOFoto Evidencia = new DTOFoto(); Evidencia.Nombre = lblInfoFoto.Text; Evidencia.FechaCreacion = datetime; insert.Foto = Evidencia; Request = null; WS = Utils.InitializeServiceClient(); Request = WS.CancelODT(insert); } else { Request.IsComplete = true; memoria = true; DTOFoto Evidencia = new DTOFoto(); Evidencia.Nombre = lblInfoFoto.Text; Evidencia.FechaCreacion = datetime; Evidencia.Foto = bitmapDetalle; insert.Foto = Evidencia; if (ODTDet.EsPospuesta) { Utils.BorrarMemoriaPospuesta(ODTDet); ODTDet.EsPospuesta = false; } List <DTOODTCancelacion> MemCan = Utils.MemoriaCancelacion; if (MemCan != null) { MemCan.Add(insert); Utils.MemoriaCancelacion = MemCan; } else { List <DTOODTCancelacion> Mem = new List <DTOODTCancelacion>(); Mem.Add(insert); Utils.MemoriaCancelacion = Mem; } List <Fotos> MemFotos = null; try{ MemFotos = Utils.FotosMemoria; } catch (Exception exc) { throw exc; } if (MemFotos != null) { Fotos f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageurl; MemFotos.Add(f); Utils.FotosMemoria = MemFotos; } else { List <Fotos> Mem = new List <Fotos>(); Fotos f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageurl; Mem.Add(f); Utils.FotosMemoria = Mem; } } } catch (Exception exc) { Error = "ODT:" + insert.ODTID.ToString() + "Error:" + exc.Message; } finally { if (WS != null) { WS.Close(); } } } else { memoria = true; DTOODTCancelacion insert = new DTOODTCancelacion(); Request.IsComplete = true; insert.ODTID = ODTDet.ID; insert.CuadrilleroID = Convert.ToInt32(iduser); insert.MotivoODTID = ReasonId; insert.Observaciones = comentarios; DTOFoto Evidencia = new DTOFoto(); Evidencia.Foto = bitmapDetalle; Evidencia.FechaCreacion = datetime; insert.Foto = Evidencia; if (ODTDet.EsPospuesta) { Utils.BorrarMemoriaPospuesta(ODTDet); ODTDet.EsPospuesta = false; } List <DTOODTCancelacion> MemCan = Utils.MemoriaCancelacion; if (MemCan != null) { MemCan.Add(insert); Utils.MemoriaCancelacion = MemCan; } else { List <DTOODTCancelacion> Mem = new List <DTOODTCancelacion>(); Mem.Add(insert); Utils.MemoriaCancelacion = Mem; } List <Fotos> MemFotos = null; try{ MemFotos = Utils.FotosMemoria; } catch (Exception exc) { throw exc; } if (MemFotos != null) { Fotos f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageurl; MemFotos.Add(f); Utils.FotosMemoria = MemFotos; } else { List <Fotos> Mem = new List <Fotos>(); Fotos f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageurl; Mem.Add(f); Utils.FotosMemoria = Mem; } } }
public static async Task EjecutarMemoria(Context ApplicationContext) { try { List <DTOODTEjecucion> ejecucion = Utils.MemoriaEjecucion; List <DTOODTCancelacion> cancelacion = Utils.MemoriaCancelacion; List <DTOODTPospuesta> pospone = Utils.MemoriaPosponer; OperationClient WS = null; if (ejecucion != null) { List <DTOODTEjecucion> NoExec = new List <DTOODTEjecucion> (); int CountExec = 0; foreach (DTOODTEjecucion insert in ejecucion) { try { int detalle = await Utils.CargarFoto(insert.ODTID.ToString(), insert.CortaFoto.Foto, ApplicationContext, insert.CortaFoto.FechaCreacion.Day.ToString() + "/" + insert.CortaFoto.FechaCreacion.Month.ToString() + "/" + insert.CortaFoto.FechaCreacion.Year.ToString()); int mediana = await Utils.CargarFoto(insert.ODTID.ToString(), insert.MediaFoto.Foto, ApplicationContext, insert.MediaFoto.FechaCreacion.Day.ToString() + "/" + insert.MediaFoto.FechaCreacion.Month.ToString() + "/" + insert.MediaFoto.FechaCreacion.Year.ToString()); int larga = await Utils.CargarFoto(insert.ODTID.ToString(), insert.LargaFoto.Foto, ApplicationContext, insert.LargaFoto.FechaCreacion.Day.ToString() + "/" + insert.LargaFoto.FechaCreacion.Month.ToString() + "/" + insert.LargaFoto.FechaCreacion.Year.ToString()); if (detalle != 0 && mediana != 0 && larga != 0) { insert.CortaFotoID = detalle; insert.MediaFotoID = mediana; insert.LargaFotoID = larga; insert.CortaFoto.Foto = null; insert.MediaFoto.Foto = null; insert.LargaFoto.Foto = null; WS = Utils.InitializeServiceClient(); OperationStatus Request = WS.InsertODTEjecucion(insert); if (Request != null && Request.IsComplete) { EjecucionMemoria.QuitarMemoriaGlobal(insert.ODTID); EjecucionMemoria.QuitarMemoriaEjecucion(insert.ODTID); } else { NoExec.Add(ejecucion [CountExec]); } } else { NoExec.Add(ejecucion [CountExec]); } } catch (Exception exc) { NoExec.Add(ejecucion [CountExec]); } finally { if (WS != null) { WS.Close(); } } CountExec++; } Utils.MemoriaEjecucion = NoExec; } if (cancelacion != null) { List <DTOODTCancelacion> NoCanc = new List <DTOODTCancelacion> (); int CountCanc = 0; foreach (DTOODTCancelacion insert in cancelacion) { try { int detalle = await Utils.CargarFoto(insert.ODTID.ToString(), insert.Foto.Foto, ApplicationContext, insert.Foto.FechaCreacion.Day.ToString() + "/" + insert.Foto.FechaCreacion.Month.ToString() + "/" + insert.Foto.FechaCreacion.Year.ToString()); if (detalle != 0) { insert.FotoID = detalle; insert.Foto.Foto = null; WS = Utils.InitializeServiceClient(); OperationStatus Request = WS.CancelODT(insert); if (Request != null && Request.IsComplete) { EjecucionMemoria.QuitarMemoriaGlobal(insert.ODTID); EjecucionMemoria.QuitarMemoriaCancelacion(insert.ODTID); } else { NoCanc.Add(cancelacion [CountCanc]); } } else { NoCanc.Add(cancelacion [CountCanc]); } } catch (Exception exc) { NoCanc.Add(cancelacion [CountCanc]); } finally { if (WS != null) { WS.Close(); } } CountCanc++; } Utils.MemoriaCancelacion = NoCanc; } if (pospone != null) { List <DTOODTPospuesta> NoPosp = new List <DTOODTPospuesta> (); int CountPosp = 0; foreach (DTOODTPospuesta insert in pospone) { try { int detalle = await Utils.CargarFoto(insert.ODTID.ToString(), insert.Foto.Foto, ApplicationContext, insert.Foto.FechaCreacion.Day.ToString() + "/" + insert.Foto.FechaCreacion.Month.ToString() + "/" + insert.Foto.FechaCreacion.Year.ToString()); if (detalle != 0) { insert.FotoID = detalle; insert.Foto.Foto = null; WS = Utils.InitializeServiceClient(); OperationStatus Request = WS.PostponeODT(insert); if (Request != null && Request.IsComplete) { EjecucionMemoria.QuitarMemoriaGlobal(insert.ODTID); EjecucionMemoria.QuitarMemoriaPosponer(insert.ODTID); } else { NoPosp.Add(pospone [CountPosp]); } } else { NoPosp.Add(pospone [CountPosp]); } } catch (Exception exc) { NoPosp.Add(pospone[CountPosp]); } finally { if (WS != null) { WS.Close(); } } CountPosp++; } Utils.MemoriaPosponer = NoPosp; } }catch (Exception ex) { throw ex; } }