async Task <DTOODTCustom[]> LoadODTs() { DTOODTCustom[] Odts = null; return(await Task.Factory.StartNew(() => { OperationClient WS = null; try{ WS = Utils.InitializeServiceClient(); Odts = WS.GetODTByCuadrilleroID(int.Parse(Utils.UsuarioApp.Iduser)); }catch (Exception ex) { throw ex; } finally { if (WS != null) { WS.Close(); } } return Odts; })); }
public static async Task <int> Posponer(DTOODTPospuesta insert, Context ApplicationContext) { OperationClient WS = null; int regreso = 0; 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.IsComplete) { regreso = 1; } } } catch (Exception exc) { regreso = 0; } finally { if (WS != null) { WS.Close(); } } return(regreso); }
public static async Task <int> CargarFoto(string folio, byte[] Foto, Context ApplicationContext, string fecha) { int retorno = 0; return(await Task.Factory.StartNew(() => { OperationClient WS = null; try{ WS = Utils.InitializeServiceClient(); OperationStatus Request = WS.UploadODTFotoForMovil(folio, Utils.compress(Convert.ToBase64String(Foto, Base64FormattingOptions.InsertLineBreaks))); if (Request.IsComplete) { retorno = Convert.ToInt32(Request.RecordId); } }catch (Exception ex) { retorno = 0; } finally { if (WS != null) { WS.Close(); } } return retorno; })); }
public static async Task <int> Finalizar(DTOODTEjecucion insert, Context ApplicationContext) { int regreso = 0; OperationClient WS = null; 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.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)) { OperationClient WS = null; try { DTOODTEjecucion insert = new DTOODTEjecucion(); insert.ODTID = ODTDet.ID; insert.CuadrilleroID = Convert.ToInt32(iduser); insert.Observaciones = comentarios; if (LoadFotos) { insert.CortaFotoID = iddetalle; insert.MediaFotoID = idmediana; insert.LargaFotoID = idlarga; DTOFoto Detalle = new DTOFoto(); Detalle.FechaCreacion = datetimedetalle; Detalle.Nombre = lblFotoDetalle.Text; insert.CortaFoto = Detalle; DTOFoto Mediana = new DTOFoto(); Mediana.FechaCreacion = datetimemediana; Mediana.Nombre = lblFotoMediana.Text; insert.MediaFoto = Mediana; DTOFoto Larga = new DTOFoto(); Larga.FechaCreacion = datetimelarga; Larga.Nombre = lblFotoLarga.Text; insert.LargaFoto = Larga; Request = null; WS = Utils.InitializeServiceClient(); Request = WS.InsertODTEjecucion(insert); } else { Request.IsComplete = true; memoria = true; DTOFoto Detalle = new DTOFoto(); Detalle.Foto = bitmapDetalle; Detalle.FechaCreacion = datetimedetalle; DTOFoto Mediana = new DTOFoto(); Mediana.Foto = bitmapMediana; Mediana.FechaCreacion = datetimemediana; DTOFoto Larga = new DTOFoto(); Larga.Foto = bitmapLarga; Larga.FechaCreacion = datetimelarga; insert.CortaFoto = Detalle; insert.MediaFoto = Mediana; insert.LargaFoto = Larga; if (ODTDet.EsPospuesta) { Utils.BorrarMemoriaPospuesta(ODTDet); ODTDet.EsPospuesta = false; } List <DTOODTEjecucion> MemEje = null; try{ MemEje = Utils.MemoriaEjecucion; } catch (Exception exc) { errr = exc.Message; } List <Fotos> MemFotos = null; try{ MemFotos = Utils.FotosMemoria; } catch (Exception exc) { errr = exc.Message; } if (MemEje != null) { MemEje.Add(insert); Utils.MemoriaEjecucion = MemEje; } else { List <DTOODTEjecucion> Mem = new List <DTOODTEjecucion>(); Mem.Add(insert); Utils.MemoriaEjecucion = Mem; } if (MemFotos != null) { Fotos f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl1; f.UrlId = imageurlId1; MemFotos.Add(f); f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl2; f.UrlId = imageurlId2; MemFotos.Add(f); f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl3; f.UrlId = imageurlId3; MemFotos.Add(f); Utils.FotosMemoria = MemFotos; } else { List <Fotos> MemF = new List <Fotos>(); Fotos f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl1; f.UrlId = imageurlId1; MemF.Add(f); f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl2; f.UrlId = imageurlId2; MemF.Add(f); f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl3; f.UrlId = imageurlId3; MemF.Add(f); Utils.FotosMemoria = MemF; } } } catch (Exception ex) { errr = ex.Message; } finally { if (WS != null) { WS.Close(); } } } else { memoria = true; DTOODTEjecucion insert = new DTOODTEjecucion(); Request.IsComplete = true; insert.ODTID = ODTDet.ID; insert.CuadrilleroID = Convert.ToInt32(iduser); insert.Observaciones = comentarios; DTOFoto Detalle = new DTOFoto(); Detalle.Foto = bitmapDetalle; Detalle.FechaCreacion = datetimedetalle; DTOFoto Mediana = new DTOFoto(); Mediana.Foto = bitmapMediana; Mediana.FechaCreacion = datetimemediana; DTOFoto Larga = new DTOFoto(); Larga.Foto = bitmapLarga; Larga.FechaCreacion = datetimelarga; insert.CortaFoto = Detalle; insert.MediaFoto = Mediana; insert.LargaFoto = Larga; if (ODTDet.EsPospuesta) { Utils.BorrarMemoriaPospuesta(ODTDet); ODTDet.EsPospuesta = false; } List <DTOODTEjecucion> MemEje = null; try{ MemEje = Utils.MemoriaEjecucion; } catch (Exception exc) { errr = exc.Message; } List <Fotos> MemFotos = null; try{ MemFotos = Utils.FotosMemoria; } catch (Exception exc) { errr = exc.Message; } if (MemEje != null) { MemEje.Add(insert); Utils.MemoriaEjecucion = MemEje; } else { List <DTOODTEjecucion> Mem = new List <DTOODTEjecucion>(); Mem.Add(insert); Utils.MemoriaEjecucion = Mem; } if (MemFotos != null) { Fotos f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl1; f.UrlId = imageurlId1; MemFotos.Add(f); f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl2; f.UrlId = imageurlId2; MemFotos.Add(f); f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl3; f.UrlId = imageurlId3; MemFotos.Add(f); Utils.FotosMemoria = MemFotos; } else { List <Fotos> MemF = new List <Fotos>(); Fotos f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl1; f.UrlId = imageurlId1; MemF.Add(f); f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl2; f.UrlId = imageurlId2; MemF.Add(f); f = new Fotos(); f.IdODT = ODTDet.ID.ToString(); f.Url = imageUrl3; f.UrlId = imageurlId3; MemF.Add(f); Utils.FotosMemoria = MemF; } } }
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; } }