private void BKEjecucion(DTOODTEjecucion OE) { if (Utils.Internet(ApplicationContext)) { _progressDialog.Show(); ExecGlobal = OE; bk_DoWorkE(); } else { Toast.MakeText(ApplicationContext, "No tienes acceso a internet para enviar la ODT.", ToastLength.Long).Show(); } }
public static DTOODTEjecucion FindEjecucion(DTOODTCustom odt) { DTOODTEjecucion RetExec = null; List <DTOODTEjecucion> ejecucion = Utils.MemoriaEjecucion; if (ejecucion != null) { foreach (DTOODTEjecucion ex in ejecucion) { if (ex.ODTID == odt.ID) { RetExec = ex; } } } return(RetExec); }
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; } } }
private async Task CargarMemoria() { try{ DTOODTCustom[] ArrayODTMem = Utils.Memoria; LinearLayout linearPadre = FindViewById <LinearLayout>(Resource.Id.Layout_OrdenTrabajo); linearPadre.RemoveAllViews(); foreach (DTOODTCustom ODTDet in ArrayODTMem) { LinearLayout LY = new LinearLayout(this); LY.Id = ODTDet.ID; LY.Orientation = Android.Widget.Orientation.Vertical; LY.SetGravity(GravityFlags.Center); TextView tvTitulo = new TextView(this); tvTitulo.Text = ODTDet.Folio + " - " + ODTDet.NumeroVista; tvTitulo.SetBackgroundResource(Resource.Drawable.ListViewOrden_Trabajo); tvTitulo.Gravity = Android.Views.GravityFlags.Center; switch (ODTDet.EstatusID) { case 113: //programada--blanco tvTitulo.SetTextColor(Color.ParseColor(color[0])); break; case 114: //Ejecutada-Verde tvTitulo.SetTextColor(Color.ParseColor(color[3])); break; case 115: //Ejecutada-Verde tvTitulo.SetTextColor(Color.ParseColor(color[4])); break; case 116: //Ejecutada-Verde tvTitulo.SetTextColor(Color.ParseColor(color[3])); break; case 117: //Cancelada --Rojo tvTitulo.SetTextColor(Color.ParseColor(color [2])); break; } if (ODTDet.EsPospuesta == true && ODTDet.EstatusID == 113) { tvTitulo.SetTextColor(Color.ParseColor(color [1])); } tvTitulo.Click += delegate { //primero preguntar si hay internet //despues buscar la odt si se encuentra en memoria de ejecucion, cancelacion, pospuesta. //al dar click que se haga el envio de la odt. if (Utils.Internet(ApplicationContext)) //Hay internet { if (ODTDet.EstatusID == 113 && ODTDet.EsPospuesta == false) { var activityMain = new Intent(this, typeof(Orden_De_Trabajo)); string alan = ODTDet.ToString(); activityMain.PutExtra("ODT", Utils.Serialize(typeof(DTOODTCustom), ODTDet)); StartActivityForResult(activityMain, 1); } else if (ODTDet.EstatusID == 113 && ODTDet.EsPospuesta == true) { DTOODTPospuesta pos = EjecucionMemoria.FindPospuesta(ODTDet); if (pos != null) { BKPospones(pos); } else { var activityMain = new Intent(this, typeof(Orden_De_Trabajo)); string alan = ODTDet.ToString(); activityMain.PutExtra("ODT", Utils.Serialize(typeof(DTOODTCustom), ODTDet)); StartActivityForResult(activityMain, 1); } } else if (ODTDet.EstatusID == 114) { DTOODTEjecucion Exec = EjecucionMemoria.FindEjecucion(ODTDet); if (Exec != null) { BKEjecucion(Exec); } else { Toast.MakeText(this, "No cuentas con internet para el envio de ODT, solo se pueden modificar ODT programadas", ToastLength.Long).Show(); return; } } else if (ODTDet.EstatusID == 117) { DTOODTCancelacion can = EjecucionMemoria.FindCancelacion(ODTDet); if (can != null) { BKCancelacion(can); } else { Toast.MakeText(this, "No cuentas con internet para el envio de ODT, solo se pueden modificar ODT programadas", ToastLength.Long).Show(); return; } } } else //No hay internet { if (ODTDet.EstatusID == 113 || (ODTDet.EstatusID == 113 && ODTDet.EsPospuesta == true)) { var activityMain = new Intent(this, typeof(Orden_De_Trabajo)); string alan = ODTDet.ToString(); activityMain.PutExtra("ODT", Utils.Serialize(typeof(DTOODTCustom), ODTDet)); StartActivityForResult(activityMain, 1); } else { Toast.MakeText(this, "No cuentas con internet para el envio de ODT, solo se pueden modificar ODT programadas", ToastLength.Long).Show(); return; } } }; tvTitulo.Clickable = true; LY.AddView(tvTitulo, 410, 70); linearPadre.AddView(LY, 410, 80); } }catch (Exception ex) { throw ex; } }
async Task Load() { try{ LinearLayout linearPadre = FindViewById <LinearLayout> (Resource.Id.Layout_OrdenTrabajo); linearPadre.RemoveAllViews(); LinkedList <DTOODTCustom> ListaODT = new LinkedList <DTOODTCustom> (); foreach (DTOODTCustom ODTDet in ArrayODT) { DTOODTCustom Find = Utils.FindODT(ODTDet); LinearLayout LY = new LinearLayout(this); LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent); linearLayoutParams.SetMargins(0, 0, 0, 0); LY.LayoutParameters = linearLayoutParams; LY.Id = ODTDet.ID; LY.Orientation = Android.Widget.Orientation.Vertical; LY.SetGravity(GravityFlags.Center); TextView tvTitulo = new TextView(this); tvTitulo.Text = ODTDet.Folio + " - " + ODTDet.NumeroVista; tvTitulo.SetBackgroundResource(Resource.Drawable.ListViewOrden_Trabajo); tvTitulo.Gravity = Android.Views.GravityFlags.Center; if (Find == null) { if (ODTDet.EsPospuesta == true) { tvTitulo.SetTextColor(Color.ParseColor(color [1])); } else { tvTitulo.SetTextColor(Color.ParseColor(color [0])); } tvTitulo.Click += delegate { var activityMain = new Intent(this, typeof(Orden_De_Trabajo)); activityMain.PutExtra("ODT", Utils.Serialize(typeof(DTOODTCustom), ODTDet)); StartActivityForResult(activityMain, 1); }; ListaODT.AddLast(ODTDet); } else { if (Find.EstatusID == 114) { DTOODTEjecucion Exec = EjecucionMemoria.FindEjecucion(Find); if (Exec != null) { tvTitulo.SetTextColor(Color.ParseColor(color [3])); tvTitulo.Click += delegate { BKEjecucion(Exec); }; ListaODT.AddLast(Find); } else { if (ODTDet.EsPospuesta == true) { tvTitulo.SetTextColor(Color.ParseColor(color [1])); } else { tvTitulo.SetTextColor(Color.ParseColor(color [0])); } tvTitulo.Click += delegate { var activityMain = new Intent(this, typeof(Orden_De_Trabajo)); activityMain.PutExtra("ODT", Utils.Serialize(typeof(DTOODTCustom), ODTDet)); StartActivityForResult(activityMain, 1); }; ListaODT.AddLast(ODTDet); } } else if (Find.EstatusID == 113) { DTOODTPospuesta pos = EjecucionMemoria.FindPospuesta(Find); if (pos != null) { tvTitulo.SetTextColor(Color.ParseColor(color [1])); tvTitulo.Click += delegate { BKPospones(pos); }; ListaODT.AddLast(Find); } else { if (ODTDet.EsPospuesta == true) { tvTitulo.SetTextColor(Color.ParseColor(color [1])); } else { tvTitulo.SetTextColor(Color.ParseColor(color [0])); } tvTitulo.Click += delegate { var activityMain = new Intent(this, typeof(Orden_De_Trabajo)); activityMain.PutExtra("ODT", Utils.Serialize(typeof(DTOODTCustom), ODTDet)); StartActivityForResult(activityMain, 1); }; ListaODT.AddLast(ODTDet); } } else if (Find.EstatusID == 117) { DTOODTCancelacion can = EjecucionMemoria.FindCancelacion(Find); if (can != null) { tvTitulo.SetTextColor(Color.ParseColor(color [2])); tvTitulo.Click += delegate { BKCancelacion(can); }; ListaODT.AddLast(Find); } else { if (ODTDet.EsPospuesta == true) { tvTitulo.SetTextColor(Color.ParseColor(color [1])); } else { tvTitulo.SetTextColor(Color.ParseColor(color [0])); } tvTitulo.Click += delegate { var activityMain = new Intent(this, typeof(Orden_De_Trabajo)); activityMain.PutExtra("ODT", Utils.Serialize(typeof(DTOODTCustom), ODTDet)); StartActivityForResult(activityMain, 1); }; ListaODT.AddLast(ODTDet); } } } tvTitulo.Clickable = true; LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent); p.SetMargins(10, 0, 15, 20); tvTitulo.LayoutParameters = p; LY.AddView(tvTitulo); linearPadre.AddView(LY); } Utils.Memoria = ListaODT.ToArray <DTOODTCustom>(); }catch (Exception ex) { throw ex; } }