public ActionResult CrearDocumentoDom(PagareContrato documentoDom) { ManagerSolcitudes manager = new ManagerSolcitudes(); dto_file dto_File = new dto_file(); 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]; 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(documentoDom), FEC_CREACION = DateTime.Now }; DTO_SOLICITUD_VENTAS solicitudes = new DTO_SOLICITUD_VENTAS(); solicitudes.Identificacion = documentoDom.Identificacion; solicitudes.IdSolicitud = documentoDom.IdSolicitud; try { //creamos el documento de domiciliacion y guardamos al url del archivo dto_File = manager.CrearDocDom(documentoDom); } catch (ArgumentException) { dto_File.Respuesta = "Ocurrio un Error"; } return(Json(dto_File)); ///System.IO.File.Delete(rutaDocDom); }
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")); } }