private async Task <ModuleData> GetModuleDataAsync(int orderPositionId) { var module = new ModuleData(); var folderPath = new OrderImGraphicsFolderPathProvider(_positionImGraphicsFolderPathTemplate) .GetByValue(orderPositionId); DirectoryInfo directoryInfo = new DirectoryInfo(folderPath); if (directoryInfo.Exists) { FileInfo[] files = directoryInfo.GetFiles("*.tif"); if (files.Length > 0) { var file = files.First(); var filePath = file.FullName; var bytes = await File.ReadAllBytesAsync(filePath); module.Base64String = Convert.ToBase64String(bytes); module.Name = file.Name; } } return(module); }
public ModuleMaketProcessor(string orderImFolderTemplate, string dbName) { _orderImFolder = string.Format(orderImFolderTemplate, dbName); _positionImSampleTemplate = _orderImFolder + "{0}\\{1}\\{2}_{3}\\{4}.jpg"; _positionImGraphicsFolderPathTemplate = _orderImFolder + "{0}\\{1}\\Graphics"; _orderImSampleNameProvider = new OrderImSampleNameProvider(_positionImSampleTemplate); _orderImGraphicsFolderPathProvider = new OrderImGraphicsFolderPathProvider(_positionImGraphicsFolderPathTemplate); }
public void DeleteModuleGraphics(int orderPositionId) { var folderPath = new OrderImGraphicsFolderPathProvider(_positionImGraphicsFolderPathTemplate) .GetByValue(orderPositionId); DirectoryInfo directoryInfo = new DirectoryInfo(folderPath); if (directoryInfo.Exists) { FileInfo[] existsFiles = directoryInfo.GetFiles(); // Помечаем все файлы как удалённые. foreach (var fileInfo in existsFiles) { var existsFilePathToDelete = new OrderImDeletedFileNameProvider(fileInfo.FullName) .GetByValue(DateTime.Now); File.Move(fileInfo.FullName, existsFilePathToDelete); } } }