public FileUploadResponseDTO createFile(FileDTO fileModel) { /*Para sacar la ruta del directorio raiz * string path = HttpRuntime.AppDomainAppVirtualPath != null ? * Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data") : * Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);*/ FileUploadResponseDTO result = new FileUploadResponseDTO() { responseType = 1 }; string fileContent = fileModel.documentContent; string fileName = fileModel.documentName; var memoryStream = new MemoryStream(); using (var ms = new MemoryStream()) { //act on the Base64 data var fileBytes = Convert.FromBase64String(fileContent); memoryStream = new MemoryStream(fileBytes); } try { // cadena de conexion al servicio de azure storage //string connString = "DefaultEndpointsProtocol=https;AccountName=uploadedfiles;AccountKey=M8vvc5JGmOKZWMYiW8qFOMmloZM9GuhShPcNwCSZWNxYStzhLeRPL1DbgjpApua76GoobasudU51mdqNB5Xt7A==;EndpointSuffix=core.windows.net"; string connString = ConfigurationManager.AppSettings["connectionAzureBlobStorage_DeltaCargo"].ToString(); string destContainer = "pdf"; CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference(destContainer); container.CreateIfNotExists(); // method upload Blob CloudBlockBlob blockBlob = container.GetBlockBlobReference(fileName); blockBlob.UploadFromStream(memoryStream); //uploadBlob(container, fileName, memoryStream); } catch (Exception ex) { result.responseType = 2; } finally { if (result.responseType == 1) { // guardar en base de datos var infoFile = new InformationFileDTO { //idTask = request.idTask, // id odoo tarea projectId = fileModel.idProject, format = fileModel.format }; string nameTaskInErp = taskOperationRepository.getNameTaskByIdInERP(fileModel.idTask); infoFile.idTask = taskConfigurationRepository.getFirstOrDefault(tc => tc.nombre.ToLower() == nameTaskInErp).id; // obtener [id_tarea] de la tabla de configuracion de tareas create(infoFile); } } return(result); }
public InformationFileDTO create(InformationFileDTO model) { return((InformationFileDTO)informationFileRepository.create(model)); }
public InformationFileDTO uppdate(InformationFileDTO model) { return((InformationFileDTO)informationFileRepository.edit(model)); }
public ActionResultApi <InformationFileDTO> create([FromBody] InformationFileDTO model) { return(new ActionResultApi <InformationFileDTO>(HttpStatusCode.OK, informationFileDAL.create(model), Request)); }