Exemple #1
0
        public void GuardarFoto(DTOFoto auxFoto)
        {
            var VImgData = Convert.FromBase64String(auxFoto.Blob.Remove(0, auxFoto.Blob.IndexOf(",") + 1));
            var SW       = new FileStream(auxFoto.PathFoto, FileMode.Create);

            SW.Write(VImgData);
            SW.Close();
            SW.Dispose();
        }
Exemple #2
0
        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;
                }
            }
        }