public async Task <List <AddedFileDto> > AddUserPlantMediaAsync(List <AddFileDto> files, string userPlantId, string userId) { var path = $"{userId}\\{userPlantId}"; var addedFiles = new List <AddedFileDto>(); foreach (var file in files) { var fileName = $"{Guid.NewGuid().ToString()}{file.FileExtension}"; var containerDefinition = new ContainerDefinition { Name = "UserPlants", Path = path }; var fileDefinition = new FileDefinition { Name = fileName, Data = file.File }; await _fileClient.SaveFile(containerDefinition, fileDefinition); var addedFile = new AddedFileDto { FileName = fileName, FilePath = path }; addedFiles.Add(addedFile); } return(addedFiles); }
private void DownloadObservations() { Debug.WriteLine("Downloading observations"); var xml = ""; using (var client = new WebClient()) { xml = client.DownloadString(_settings.ObservationsUrl); } var estEncoding = Encoding.GetEncoding(1252); var utf = Encoding.UTF8; xml = utf.GetString(Encoding.Convert(estEncoding, utf, estEncoding.GetBytes(xml))); try { XDocument.Parse(xml); } catch (Exception ex) { _logger.LogError(ex, "Error loading EMHI data"); return; } _fileClient.SaveFile("cache", "emhi.xml", Encoding.UTF8.GetBytes(xml)); }
private void DownloadObservations() { Debug.WriteLine("Downloading observations"); var xml = ""; using (var client = new WebClient()) { xml = client.DownloadString(_settings.ObservationsUrl); } var estEncoding = Encoding.GetEncoding(1252); var utf = Encoding.UTF8; xml = utf.GetString(Encoding.Convert(estEncoding, utf, estEncoding.GetBytes(xml))); _fileClient.SaveFile("cache", "emhi.xml", Encoding.UTF8.GetBytes(xml)); }
public async Task <Response> Handle(Request request, CancellationToken cancellationToken) { var path = new FilePath(); path.Container = FileContainers.UserProfiles; //path.File = $"bc267bfd-09ce-4dfa-95b2-c01be7b56a02.png"; path.File = $"{_authenticationService.GetCurrentUser().Id}.png"; foreach (var file in request.Files) { if (file.Length > 0) { _fileClient.SaveFile(path, file); } } return(new Response()); }
public async Task <string> GenerateAsync(List <HotelReportModel> data) { ExcelPackage.LicenseContext = LicenseContext.NonCommercial; using (var p = new ExcelPackage()) { //A workbook must have at least on cell, so lets add one... var ws = p.Workbook.Worksheets.Add("Sheet1"); //write data to excel ws.Cells["A1"].LoadFromCollection(data, true, TableStyles.Light6); ws.Cells.AutoFitColumns(); //save file var storeName = "App_Data"; var filePath = $"{Guid.NewGuid()}.xlsx"; await _fileClient.SaveFile(storeName, filePath, new MemoryStream(await p.GetAsByteArrayAsync())); return($"{storeName}\\{filePath}"); } }