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);
        }
Exemplo n.º 2
0
        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;
            }
        }