public ActionResult SubirDocumentoLegal(GestionArchivoSubir archivo)
        {
            try
            {
                //creamos el grupo de byte para guardarlos
                byte[] bytesLegal = Convert.FromBase64String(archivo.Base64);

                var fileLegal = new blobStorage
                {
                    ImageToUploadByte = bytesLegal,
                    ContainerPrefix   = "documentos/ProcesoLegal/" + archivo.Identificacion + "/",
                    ImageExtencion    = ".pdf",
                    ImageToUpload     = archivo.Identificacion,
                    ConnectionString  = "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                };

                if (UtilBlobStorageAzure.ExistsFileInBlob(fileLegal))
                {
                    return(Json("El Documento Legal ya existe. No se permite Remplazarlo"));
                }
                else
                {
                    UtilBlobStorageAzure.UploadBlobStorage(fileLegal, false); // el segundo parametro nos dira si desea hacer copia de respaldo o no, su valor por default es true.
                    return(Json("El Documento Legal se cargo correctamente"));
                }
            }
            catch (Exception ex)
            {
                return(Json("Error al Subir los Archivos"));
            }
        }
        public ActionResult GetImagenSinpe(ImagenSinpe imagen)
        {
            ManagerSolcitudes mang = new ManagerSolcitudes();

            try
            {
                if (Session["agente"] == null)
                {
                    return(RedirectToAction("LogOff", "Login"));
                }
                Tab_ConfigSys        dto_Config         = new Tab_ConfigSys();
                ManagerSolcitudes    managerSolicitudes = new ManagerSolcitudes();
                List <Tab_ConfigSys> CONF = new List <Tab_ConfigSys>();
                dto_Config.llave_Config1 = "SERVICIO";
                dto_Config.llave_Config2 = "CONFIGURACION";
                dto_Config.llave_Config3 = "SERVIDOR";
                dto_Config.llave_Config4 = "URL";
                var dto_interval = managerSolicitudes.ConsultaConfiUrlImagen(dto_Config);
                var dir          = dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_IMAGENSINPE").Select(x => x.Dato_Char1).FirstOrDefault(); //Server.MapPath("/");
                var blobDowland  = new blobStorage
                {
                    ImageToUploadByte = null,
                    ContainerPrefix   = string.Concat(dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_IMAGENSINPE").Select(x => x.Dato_Char1).FirstOrDefault(), "/", imagen.Identificacion), //"documentos/FotoCedula/206560175",
                    ImageExtencion    = ".jpg",
                    ImageToUpload     = imagen.Identificacion,
                    ConnectionString  = dto_interval.Where(x => x.llave_Config5 == "CONECTION").Select(x => x.Dato_Char1).FirstOrDefault(),
                    PatchTempToSave   = AppDomain.CurrentDomain.BaseDirectory + string.Concat(dto_interval.Where(x => x.llave_Config5 == "IMAGENSINPE").Select(x => x.Dato_Char1).FirstOrDefault(), imagen.Identificacion)//@"C:\IVAN\images\FotoCedulas\206560175"
                };
                string LimpiarCarpeta = blobDowland.PatchTempToSave;
                if (Directory.Exists(LimpiarCarpeta))
                {
                    List <string> strDirectories = Directory.GetDirectories(LimpiarCarpeta, "*", SearchOption.AllDirectories).ToList();
                    foreach (string directorio in strDirectories)
                    {
                        Directory.Delete(directorio, true);
                    }
                }
                if (!Directory.Exists(blobDowland.PatchTempToSave))
                {
                    Directory.CreateDirectory(blobDowland.PatchTempToSave);
                }
                if (UtilBlobStorageAzure.ExistsFileInBlob(blobDowland))
                {
                    UtilBlobStorageAzure.DownloadBlobStorage(blobDowland);
                    imagen.UrlImagenSinpe = string.Concat(dto_interval.Where(x => x.llave_Config5 == "IMAGENSINPE").Select(x => x.Dato_Char1).FirstOrDefault()) + @"\" + imagen.Identificacion + @"\" + imagen.Identificacion + blobDowland.ImageExtencion;
                    imagen.Mensaje        = "Completo";
                }
                else
                {
                    imagen.Mensaje = "Este cliente no tiene imagen sinpe.";
                }
                return(Json(imagen));
            }
            catch (Exception ex)
            {
                imagen.Mensaje = "Error al mostrar la imagen";
                return(Json(imagen));
            }
        }
        public ActionResult EditaComprobante(comprobantepago compPago)
        {
            ManagerUser       manager            = new ManagerUser();
            ManagerSolcitudes managerSolicitudes = new ManagerSolcitudes();
            var dto_ret = new System.Collections.Generic.List <comprobantepago>();
            var tempId  = compPago.Identificacion;

            compPago.Identificacion = null;
            try
            {
                compPago.Accion = "CONSULTA";
                compPago.UsuarioModificacion = Session["agente"].ToString();
                dto_ret = manager.comrobantePago(compPago);

                Tab_ConfigSys dto_Config = new Tab_ConfigSys();


                dto_Config.llave_Config1 = "SERVICIO";
                dto_Config.llave_Config2 = "CONFIGURACION";
                dto_Config.llave_Config3 = "SERVIDOR";
                dto_Config.llave_Config4 = "URL";

                var dto_interval = managerSolicitudes.ConsultaConfiUrlImagen(dto_Config);

                compPago.Identificacion = tempId;

                var blob = new blobStorage
                {
                    ImageToUploadByte = null,
                    ContainerPrefix   = string.Concat(dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_COMP_PAGO").Select(x => x.Dato_Char1).FirstOrDefault(), "/", compPago.Identificacion), //"documentos/FotoCedula/206560175",
                    ImageExtencion    = ".jpg",
                    ImageToUpload     = Path.GetFileName(dto_ret.FirstOrDefault().RutaBlob).Replace(".jpg", string.Empty),
                    ConnectionString  = dto_interval.Where(x => x.llave_Config5 == "CONECTION").Select(x => x.Dato_Char1).FirstOrDefault(),// "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                    PatchTempToSave   = string.Empty
                };
                UtilBlobStorageAzure.DownloadBlobStorageBytes(blob);
                if (blob.ImageToUploadByte != null)
                {
                    dto_ret.FirstOrDefault().ImageComprobante = Convert.ToBase64String(blob.ImageToUploadByte);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Json(dto_ret));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ventas"></param>
        /// <param name="dto_interval"></param>
        /// <param name="tipoImagen">1=FotoCedula, 2=CedultaTrasera, 3=firma, 4= selfie, 5=pagare PDF</param>
        private void descargarImagenes(DTO_SOLICITUD_VENTAS ventas, List <Tab_ConfigSys> dto_interval, int tipoImagen)
        {
            try
            {
                var dir = dto_interval.Where(x => x.llave_Config5 == "RUTA_REMOVE").Select(x => x.Dato_Char1).FirstOrDefault(); //Server.MapPath("/");
                var _ContainerPrefix = string.Empty;
                var _PatchTempToSave = string.Empty;
                var _ImageExtencion  = string.Empty; //Path.GetExtension();

                switch (tipoImagen)
                {
                case 1:
                    _ContainerPrefix     = string.Concat(dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_CEDULA").Select(x => x.Dato_Char1).FirstOrDefault(), "/", ventas.Identificacion);
                    _PatchTempToSave     = string.Concat(dto_interval.Where(x => x.llave_Config5 == "FOTOCEDULA").Select(x => x.Dato_Char1).FirstOrDefault(), ventas.Identificacion);
                    _ImageExtencion      = Path.GetExtension(ventas.UrlFotoCedula);
                    ventas.UrlFotoCedula = string.Concat(_PatchTempToSave, "/", ventas.Identificacion, _ImageExtencion).Replace(dir, "");
                    break;

                case 2:
                    _ContainerPrefix            = string.Concat(dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_CEDULATRASERA").Select(x => x.Dato_Char1).FirstOrDefault(), "/", ventas.Identificacion);
                    _PatchTempToSave            = string.Concat(dto_interval.Where(x => x.llave_Config5 == "FOTOCEDULATRASERA").Select(x => x.Dato_Char1).FirstOrDefault(), ventas.Identificacion);
                    _ImageExtencion             = Path.GetExtension(ventas.UrlFotoCedulaTrasera);
                    ventas.UrlFotoCedulaTrasera = string.Concat(_PatchTempToSave, "/", ventas.Identificacion, _ImageExtencion).Replace(dir, "");
                    break;

                case 3:
                    _ContainerPrefix    = string.Concat(dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_FOTOFIRMA").Select(x => x.Dato_Char1).FirstOrDefault(), "/", ventas.Identificacion);
                    _PatchTempToSave    = string.Concat(dto_interval.Where(x => x.llave_Config5 == "FOTOFIRMA").Select(x => x.Dato_Char1).FirstOrDefault(), ventas.Identificacion);
                    _ImageExtencion     = Path.GetExtension(ventas.UrlFotoFirma);
                    ventas.UrlFotoFirma = string.Concat(_PatchTempToSave, "/", ventas.Identificacion, _ImageExtencion).Replace(dir, "");
                    break;

                case 4:
                    _ContainerPrefix     = string.Concat(dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_SELFIE").Select(x => x.Dato_Char1).FirstOrDefault(), "/", ventas.Identificacion);
                    _PatchTempToSave     = string.Concat(dto_interval.Where(x => x.llave_Config5 == "FOTOSELFIE").Select(x => x.Dato_Char1).FirstOrDefault(), ventas.Identificacion);
                    _ImageExtencion      = Path.GetExtension(ventas.UrlFotoSelfie);
                    ventas.UrlFotoSelfie = string.Concat(_PatchTempToSave, "/", ventas.Identificacion, _ImageExtencion).Replace(dir, "");
                    break;

                case 5:
                    _ContainerPrefix           = string.Concat(dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_PAGARE").Select(x => x.Dato_Char1).FirstOrDefault(), "/", ventas.Identificacion);
                    _PatchTempToSave           = string.Concat(dto_interval.Where(x => x.llave_Config5 == "CONTRATOPAGARE").Select(x => x.Dato_Char1).FirstOrDefault(), ventas.Identificacion);
                    _ImageExtencion            = Path.GetExtension(ventas.UrlDirectorioPagare);
                    ventas.UrlDirectorioPagare = string.Concat(_PatchTempToSave, "/", ventas.Identificacion, _ImageExtencion).Replace(dir, "");
                    break;
                }

                var blobDowland = new blobStorage
                {
                    ImageToUploadByte = null,
                    ContainerPrefix   = _ContainerPrefix,
                    ImageExtencion    = _ImageExtencion,
                    ImageToUpload     = ventas.Identificacion,
                    ConnectionString  = dto_interval.Where(x => x.llave_Config5 == "CONECTION").Select(x => x.Dato_Char1).FirstOrDefault(),// "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                    PatchTempToSave   = _PatchTempToSave
                };

                if (!Directory.Exists(blobDowland.PatchTempToSave))
                {
                    Directory.CreateDirectory(blobDowland.PatchTempToSave);
                }
                var fileDelete = string.Concat(_PatchTempToSave, "/", ventas.Identificacion, _ImageExtencion);
                if (System.IO.File.Exists(fileDelete))
                {
                    System.IO.File.Delete(fileDelete);
                }

                UtilBlobStorageAzure.DownloadBlobStorage(blobDowland);
            }
            catch (Exception ex) { }
            //return ventas;
        }
        public ActionResult DescargarDocumentoLegal(string identificacion)
        {
            blobStorage fileLegal = null;
            dto_file    dto_File  = null;

            try
            {
                fileLegal = new blobStorage
                {
                    ImageToUploadByte = null,
                    ContainerPrefix   = "documentos/ProcesoLegal/" + identificacion + "/",
                    ImageExtencion    = ".pdf",
                    ImageToUpload     = identificacion,
                    ConnectionString  = "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                    PatchTempToSave   = @"C:\DescargasDocumentosLegalTemp"
                };

                if (UtilBlobStorageAzure.ExistsFileInBlob(fileLegal))
                {
                    if (!Directory.Exists(fileLegal.PatchTempToSave))
                    {
                        Directory.CreateDirectory(fileLegal.PatchTempToSave);
                    }

                    UtilBlobStorageAzure.DownloadBlobStorage(fileLegal);
                    var rutaPagare = fileLegal.PatchTempToSave + "/" + fileLegal.ImageToUpload + ".pdf";

                    dto_File        = new dto_file();
                    dto_File.Type   = TwoFunTwoMe_DataAccess.Utility.GetMimeType(".pdf");
                    dto_File.Base64 = string.Format("data:{0};base64,{1}", dto_File.Type, Convert.ToBase64String(System.IO.File.ReadAllBytes(rutaPagare)));
                    dto_File.Name   = "DocumentoLegal-" + fileLegal.ImageToUpload;

                    //Borramos la carpeta temporal con los archivos creados para limpiarla
                    if (Directory.Exists(fileLegal.PatchTempToSave))
                    {
                        Directory.Delete(fileLegal.PatchTempToSave, true);
                    }

                    return(Json(dto_File));
                }
                else
                {
                    //Si no existe el archivo con el numero de cedula de nombre, verificamos si el archivo existe con el nombre "identificacion_1"
                    fileLegal.ImageToUpload = identificacion + "_1";
                    if (UtilBlobStorageAzure.ExistsFileInBlob(fileLegal))
                    {
                        if (!Directory.Exists(fileLegal.PatchTempToSave))
                        {
                            Directory.CreateDirectory(fileLegal.PatchTempToSave);
                        }

                        UtilBlobStorageAzure.DownloadBlobStorage(fileLegal);
                        var rutaPagare = fileLegal.PatchTempToSave + "/" + fileLegal.ImageToUpload + fileLegal.ImageExtencion;

                        dto_File        = new dto_file();
                        dto_File.Type   = TwoFunTwoMe_DataAccess.Utility.GetMimeType(".pdf");
                        dto_File.Base64 = string.Format("data:{0};base64,{1}", dto_File.Type, Convert.ToBase64String(System.IO.File.ReadAllBytes(rutaPagare)));
                        dto_File.Name   = "DocumentoLegal-" + fileLegal.ImageToUpload;

                        //Borramos la carpeta temporal con los archivos creados para limpiarla
                        if (Directory.Exists(fileLegal.PatchTempToSave))
                        {
                            Directory.Delete(fileLegal.PatchTempToSave, true);
                        }

                        return(Json(dto_File));
                    }
                    else
                    {
                        return(Json("Documento Legal no existe"));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json("Error al Descargar el archivo"));
            }
        }
        public ActionResult ExisteDocumento(string tipoDocumento, string identificacion)
        {
            if (Session["agente"] == null)
            {
                return(RedirectToAction("LogOff", "Login"));
            }

            blobStorage blob   = null;
            blobStorage blob_1 = null;

            if (tipoDocumento == "PAGARE")
            {
                blob = new blobStorage
                {
                    ImageToUploadByte = null,
                    ContainerPrefix   = "documentos/Pagare/" + identificacion,
                    ImageToUpload     = identificacion,
                    ImageExtencion    = ".pdf",
                    ConnectionString  = "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                    PatchTempToSave   = null
                };
                blob_1 = new blobStorage
                {
                    ImageToUploadByte = null,
                    ContainerPrefix   = "documentos/Pagare/" + identificacion,
                    ImageToUpload     = identificacion + "_1",
                    ImageExtencion    = ".pdf",
                    ConnectionString  = "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                    PatchTempToSave   = null
                };
            }
            if (tipoDocumento == "LEGAL")
            {
                blob = new blobStorage
                {
                    ImageToUploadByte = null,
                    ContainerPrefix   = "documentos/ProcesoLegal/" + identificacion,
                    ImageToUpload     = identificacion,
                    ImageExtencion    = ".pdf",
                    ConnectionString  = "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                    PatchTempToSave   = null
                };
                blob_1 = new blobStorage
                {
                    ImageToUploadByte = null,
                    ContainerPrefix   = "documentos/ProcesoLegal/" + identificacion,
                    ImageToUpload     = identificacion + "_1",
                    ImageExtencion    = ".pdf",
                    ConnectionString  = "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                    PatchTempToSave   = null
                };
            }
            if (blob != null && blob_1 != null)
            {
                if (UtilBlobStorageAzure.ExistsFileInBlob(blob) || UtilBlobStorageAzure.ExistsFileInBlob(blob_1))
                {
                    return(Json("SI"));
                }
                else
                {
                    return(Json("NO"));
                }
            }
            else
            {
                return(Json("NULL"));
            }
        }
        public ActionResult GiraFotoFirma(DTO_SOLICITUD_VENTAS solicitudes)
        {
            ManagerSolcitudes    manager = new ManagerSolcitudes();
            List <Tab_ConfigSys> CONF    = new List <Tab_ConfigSys>();
            string xClase        = string.Format("{0}|{1}", MethodBase.GetCurrentMethod().Module.Name, MethodBase.GetCurrentMethod().DeclaringType.Name);
            string xProceso      = MethodBase.GetCurrentMethod().Name;
            string strHostName   = System.Net.Dns.GetHostName();
            var    dto_listLogin = new List <DTO_SOLICITUD_VENTAS>();
            //IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName()); <-- Obsolete
            IPHostEntry ipHostInfo    = Dns.GetHostEntry(strHostName);
            IPAddress   ipAddress     = ipHostInfo.AddressList[0];
            AWSAccess   wSAccess      = new AWSAccess();
            var         dto_excepcion = new UTL_TRA_EXCEPCION
            {
                STR_CLASE      = xClase,
                STR_EVENTO     = xProceso,
                STR_APLICATIVO = ConfigurationManager.AppSettings["APLICATIVO"].ToString(),
                STR_SERVIDOR   = System.Net.Dns.GetHostName(),
                STR_PARAMETROS = JsonConvert.SerializeObject(solicitudes),
                FEC_CREACION   = DateTime.Now
            };

            Tab_ConfigSys dto_Config = new Tab_ConfigSys();

            dto_Config.llave_Config1 = "SERVICIO";
            dto_Config.llave_Config2 = "CONFIGURACION";
            dto_Config.llave_Config3 = "SERVIDOR";
            dto_Config.llave_Config4 = "URL";
            //dto_Config.llave_Config5 = "FOTOFIRMA";
            byte[] bytes = null;
            try
            {
                int    rotate       = 0;
                var    dto_interval = manager.ConsultaConfiUrlImagen(dto_Config);
                string URL          = dto_interval.Where(x => x.llave_Config5 == "FOTOFIRMA").Select(x => x.Dato_Char1).FirstOrDefault();


                var    SOL_TEMP = manager.ConsultaDirectorioImagen(solicitudes);
                string ext      = Path.GetExtension(SOL_TEMP.FirstOrDefault().UrlFotoFirma);
                ext = ext == null ? ".jpg" : ext;
                //solicitudes.UrlFotoFirma = String.Concat(URL + solicitudes.Identificacion + "/" + solicitudes.Identificacion, ext);

                // FileStream fileStream = new FileStream(SOL_TEMP.FirstOrDefault().UrlFotoCedula, FileMode.Open);

                var blobDowland = new blobStorage
                {
                    ImageToUploadByte = null,
                    ContainerPrefix   = string.Concat(dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_FOTOFIRMA").Select(x => x.Dato_Char1).FirstOrDefault(), "/", solicitudes.Identificacion), //"documentos/FotoCedula/206560175",
                    ImageExtencion    = ".jpg",
                    ImageToUpload     = solicitudes.Identificacion,
                    ConnectionString  = dto_interval.Where(x => x.llave_Config5 == "CONECTION").Select(x => x.Dato_Char1).FirstOrDefault(), // "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                    PatchTempToSave   = dto_interval.Where(x => x.llave_Config5 == "FOTOFIRMA").Select(x => x.Dato_Char1).FirstOrDefault()  //@"C:\IVAN\images\FotoCedulas\206560175"
                };

                //FileStream fileStream = new FileStream(solicitudes.UrlFotoFirma, FileMode.Open);

                UtilBlobStorageAzure.DownloadBlobStorageBytes(blobDowland);

                if (blobDowland.ImageToUploadByte != null)
                {
                    bytes = blobDowland.ImageToUploadByte;
                }

                Image image = Image.FromStream(new MemoryStream(bytes));
                //fileStream.Close();
                rotate = 8;
                //int orientationValue = image.GetPropertyItem(prop.Id).Value[0];
                RotateFlipType rotateFlipType = wSAccess.GetOrientationToFlipType(rotate);
                image.RotateFlip(rotateFlipType);
                bytes = (byte[])(new ImageConverter()).ConvertTo(image, typeof(byte[]));
                //if (Utilitarios.ValidarFichero(solicitudes.UrlFotoFirma))
                //{
                //    image.Save(solicitudes.UrlFotoFirma);
                //    image.Dispose();
                //}

                var blob = new blobStorage
                {
                    ImageToUploadByte = bytes,
                    ContainerPrefix   = string.Concat(dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_FOTOFIRMA").Select(x => x.Dato_Char1).FirstOrDefault(), "/", solicitudes.Identificacion), //"documentos/FotoCedula/206560175",
                    ImageExtencion    = ext,
                    ImageToUpload     = solicitudes.Identificacion,
                    ConnectionString  = dto_interval.Where(x => x.llave_Config5 == "CONECTION").Select(x => x.Dato_Char1).FirstOrDefault(), // "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                    PatchTempToSave   = dto_interval.Where(x => x.llave_Config5 == "FOTOFIRMA").Select(x => x.Dato_Char1).FirstOrDefault()  //@"C:\IVAN\images\FotoCedulas\206560175"
                };
                UtilBlobStorageAzure.UploadBlobStorage(blob);
                //Thread threadObj = new Thread(new ThreadStart(() => UtilBlobStorageAzure.UploadBlobStorage(blob)));
                //threadObj.Start();

                solicitudes.UrlFotoFirma = string.Concat(blob.ContainerPrefix, "/", solicitudes.Identificacion, blob.ImageExtencion);

                dto_listLogin = manager.MetodoGuardaFoto(solicitudes);

                return(Json(dto_listLogin));

                //	return Ok();
            }
            catch (ArgumentException)
            {
                solicitudes.Respuesta = "Ocurrio un Error";
            }
            return(Json(dto_listLogin));
        }
Exemplo n.º 8
0
        public ActionResult SubirArchivosCobros(ArchivoCobros[] cobros)
        {
            //ManagerUser mang = new ManagerUser();
            ManagerSolcitudes    mang       = new ManagerSolcitudes();
            Tab_ConfigSys        dto_Config = new Tab_ConfigSys();
            List <Tab_ConfigSys> CONF       = new List <Tab_ConfigSys>();

            dto_Config.llave_Config1 = "SERVICIO";
            dto_Config.llave_Config2 = "CONFIGURACION";
            dto_Config.llave_Config3 = "SERVIDOR";
            dto_Config.llave_Config4 = "URL";

            try
            {
                var dto_interval = mang.ConsultaConfiUrlImagen(dto_Config);

                //creamos el grupo de byte para guardarlos
                byte[] bytesBCR = Convert.FromBase64String(cobros[0].Base64);
                byte[] bytesBAC = Convert.FromBase64String(cobros[1].Base64);
                byte[] bytesBN  = Convert.FromBase64String(cobros[2].Base64);

                //guardamos los grupos de bytes con los nombres y rutas por defecto
                //System.IO.File.WriteAllBytes(path + "ECBCR.xlsx", bytesBCR);
                //System.IO.File.WriteAllBytes(path + "ECBAC.xlsx", bytesBCR);
                //System.IO.File.WriteAllBytes(path + "ECBN.csv", bytesBCR);
                var fileBCR = new blobStorage
                {
                    ImageToUploadByte = bytesBCR,
                    ContainerPrefix   = dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_DOC_DOMICILIACION").Select(x => x.Dato_Char1).FirstOrDefault(),
                    ImageExtencion    = dto_interval.Where(x => x.llave_Config5 == "EXTENCION_DESCARGA_2").Select(x => x.Dato_Char1).FirstOrDefault(),
                    ImageToUpload     = dto_interval.Where(x => x.llave_Config5 == "ENTIDA_DESCARGA_1").Select(x => x.Dato_Char1).FirstOrDefault(),
                    ConnectionString  = dto_interval.Where(x => x.llave_Config5 == "CONECTION").Select(x => x.Dato_Char1).FirstOrDefault(),
                    PatchTempToSave   = dto_interval.Where(x => x.llave_Config5 == "RUTA_DESCARGA").Select(x => x.Dato_Char1).FirstOrDefault()
                                        //ContainerPrefix = "documentosdomiciliacion",
                                        //ImageExtencion = ".xlsx",
                                        //ImageToUpload = "ECBCR",
                                        //ConnectionString = "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                                        //PatchTempToSave = @"C:\IVAN\"
                };
                var fileBAC = new blobStorage
                {
                    ImageToUploadByte = bytesBAC,
                    ContainerPrefix   = dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_DOC_DOMICILIACION").Select(x => x.Dato_Char1).FirstOrDefault(),
                    ImageExtencion    = dto_interval.Where(x => x.llave_Config5 == "EXTENCION_DESCARGA_2").Select(x => x.Dato_Char1).FirstOrDefault(),
                    ImageToUpload     = dto_interval.Where(x => x.llave_Config5 == "ENTIDA_DESCARGA_2").Select(x => x.Dato_Char1).FirstOrDefault(),
                    ConnectionString  = dto_interval.Where(x => x.llave_Config5 == "CONECTION").Select(x => x.Dato_Char1).FirstOrDefault(),
                    PatchTempToSave   = dto_interval.Where(x => x.llave_Config5 == "RUTA_DESCARGA").Select(x => x.Dato_Char1).FirstOrDefault()
                                        //ContainerPrefix = "documentosdomiciliacion",
                                        //ImageExtencion = ".xlsx",
                                        //ImageToUpload = "ECBAC",
                                        //ConnectionString = "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                                        //PatchTempToSave = @"C:\IVAN\"
                };
                var fileBN = new blobStorage
                {
                    ImageToUploadByte = bytesBN,
                    ContainerPrefix   = dto_interval.Where(x => x.llave_Config5 == "RUTA_BLOB_DOC_DOMICILIACION").Select(x => x.Dato_Char1).FirstOrDefault(),
                    ImageExtencion    = dto_interval.Where(x => x.llave_Config5 == "EXTENCION_DESCARGA_1").Select(x => x.Dato_Char1).FirstOrDefault(),
                    ImageToUpload     = dto_interval.Where(x => x.llave_Config5 == "ENTIDA_DESCARGA_3").Select(x => x.Dato_Char1).FirstOrDefault(),
                    ConnectionString  = dto_interval.Where(x => x.llave_Config5 == "CONECTION").Select(x => x.Dato_Char1).FirstOrDefault(),
                    PatchTempToSave   = dto_interval.Where(x => x.llave_Config5 == "RUTA_DESCARGA").Select(x => x.Dato_Char1).FirstOrDefault()
                                        //ContainerPrefix = "documentosdomiciliacion",
                                        //ImageExtencion = ".csv",
                                        //ImageToUpload = "ECBN",
                                        //ConnectionString = "DefaultEndpointsProtocol=https;AccountName=fenix2fun2me;AccountKey=qEZhKqhySrIvLgiplmWIVwTR9kCFtznIFEmMhrfF56jWwlSnUJuh2fCXYmBtKl2dafQb+f/UYBUv1RQP5n9/Mg==;EndpointSuffix=core.windows.net",
                                        //PatchTempToSave = @"C:\IVAN\"
                };
                //Thread threadObj = new Thread(new ThreadStart(()=>UtilBlobStorageAzure.UploadBlobStorage(fileBCR)));
                //threadObj.Start();
                UtilBlobStorageAzure.UploadBlobStorage(fileBCR, false); // el segundo parametro nos dira si desea hacer copia de respaldo o no, su valor por default es true.
                UtilBlobStorageAzure.UploadBlobStorage(fileBAC, false);
                UtilBlobStorageAzure.UploadBlobStorage(fileBN, false);
                //mang.bndSubirArchivos(1);
                mang.InsertaCobroAutomatico(new AplicaCobrosAutomaticos {
                    Action = "INSERTA"
                });
                return(Json("Los archivos se subieron correctamente"));
            }
            catch (Exception ex)
            {
                return(Json("Error al Subir los Archivos"));
            }
        }