Ejemplo n.º 1
0
        private async Task UpdateFileRoots(IEnumerable <Core.Domain.File> files, int number, Order order)
        {
            var           filePaths    = files.Select(x => x.Path).Where(x => x != string.Empty).ToList();
            List <string> newFilesPath = new List <string>();

            foreach (var file in filePaths)
            {
                var path = file;
                if (path == string.Empty)
                {
                    continue;
                }
                var   fileName = Path.GetFileNameWithoutExtension(path);
                Regex re       = new Regex(@"([a-zA-Z]+)(\d+)");
                Match result   = re.Match(fileName);

                string alphaPart  = result.Groups[1].Value;
                string numberPart = result.Groups[2].Value;
                if (!(alphaPart == "fvk"))
                {
                    numberPart = OrderFolderNameGenerator.AddLeadingZeros(number);
                }
                newFilesPath.Add($"{order.GetPathToFolder()}{alphaPart}{numberPart}.pdf");
            }
            await _fileRepository.UpdateFileNames(filePaths, newFilesPath);
        }