예제 #1
0
        public static void SEPaymentCardArchiving(string archiveDirPath, string spoolDir, string archiveDir, string indexFile)
        {
            //TODO: nothing wrong here just not very readable, could refactor to below
            //Store current date in yyyymmdd format

            //creates Directory with naming format "PC-Larch_yyyymmdd"
            FileProcessHelper.CreateDirectory(archiveDirPath);
            FileProcessHelper.CreateDirectory(Path.Combine(archiveDirPath, archiveDir));
            //moves PDF files into the "PC-Larch_yyyymmdd" directory
            FileProcessHelper.MoveFiles(spoolDir, Path.Combine(archiveDirPath, archiveDir), "*.pdf");
            FileProcessHelper.MoveFile(spoolDir + "\\" + indexFile, Path.Combine(archiveDirPath, archiveDir), indexFile);


            //ZIPPING ROUTINES
            FileProcessHelper.ZipFolder(archiveDirPath, @"T:\Prod_BU\Simply_Energy\To_Send", archiveDir, false, false);
            FileProcessHelper.ZipFolder(archiveDirPath, spoolDir, archiveDir, false, false);
            //FileProcessHelper.ZipFiles(spoolDir, "", archiveDir + ".zip");
            //TODO: Safer to use Path.Combine(filePath, "\spool","\\PC-Larch_"); when combing paths, will automatically cater for missing '\'
            FileProcessHelper.MoveFiles(archiveDirPath, spoolDir, "*.pdf");
            FileProcessHelper.MoveFile(archiveDirPath + "\\" + indexFile, spoolDir, indexFile);

            FileProcessHelper.DeleteFolders(spoolDir, "PC*");
            //FileProcessHelper.DeleteFolders(spoolDir, archiveDir);

            FileProcessHelper.DeleteFiles(spoolDir, "*.pdf");
            FileProcessHelper.DeleteFile(spoolDir + "\\" + indexFile);
        }
예제 #2
0
        //[ValidationAspect(typeof(CarImagesOperationDtoValidator))]
        public IResult Update(CarImagesOperationDto carImagesOperationDto)
        {
            foreach (var file in carImagesOperationDto.Images)
            {
                var result = BusinessRules.Run(
                    CheckIfCarImagesId(carImagesOperationDto.Id),
                    CheckCarImageCount(carImagesOperationDto.CarId),
                    CheckIfCarId(carImagesOperationDto.CarId)
                    );
                if (result != null)
                {
                    return(result);
                }

                FileProcessHelper.Delete(_carImageDal.Get(p => p.ImageID == carImagesOperationDto.Id).ImagePath);
                _carImageDal.Update(new CarImage
                {
                    ImageID   = carImagesOperationDto.Id,
                    CarID     = carImagesOperationDto.CarId,
                    ImagePath = FileProcessHelper.Upload(DefaultNameOrPath.ImageDirectory, file).Data
                });
            }

            return(new SuccessResult(Messages.EditCarImageMessage));
        }
예제 #3
0
        public IResult Delete(CarImage entity)
        {
            var imageData = _carImageDal.Get(p => p.Id == entity.Id);

            FileProcessHelper.Delete(imageData.ImagePath);
            _carImageDal.Delete(imageData);
            return(new SuccessResult());
        }
예제 #4
0
 public static void SEPaymentCardProcessing(string PClog, string binDir, string filePath)
 {
     //DOC1GENA Routines
     RunProcessHelper.RunProcess(true, @"\\Doc2\Doc1\Generate\doc1gen.exe", @"D:\Prod\Simply_Energy\PaymentCards\bin\PaycardsArch.hip\"" OPS=D:\Prod\Simply_Energy\PaymentCards\bin\DOC1fileA.OPS\""  >> \\doc2\Prod\Simply_Energy\PaymentCards\bin\Error.log");
     FileProcessHelper.AppendFile(binDir + "\\Dtotal.txt", PClog, false);
     //Shrink PDF routine
     AutoShrinkProg1(filePath);
 }
예제 #5
0
 public static void AutoShrinkProg1(string filePath)
 {
     FileProcessHelper.DeleteFiles(@"\\prog1\PDFwork2\simplyPC", "*.pdf");
     FileProcessHelper.CopyFiles(@"\\DOC2\Prod\Simply_Energy\PaymentCards\spool", @"\\prog1\PDFwork2\simplyPC", "*.pdf");
     RunProcessHelper.RunProcess(true, @"\\prog1\Fdrive\utl\PSexec.exe", "\"\\prog1 - u zipform\\elixir - p zipform\" d:\\PDFwork\\AutoBatch SEPC_Shrink.bat");
     FileProcessHelper.CopyFiles(@"\\prog1\PDFwork2\simplyPC", @"\\DOC2\Prod\Simply_Energy\PaymentCards\spool", "*.pdf");
     FileProcessHelper.DeleteFiles(@"\\prog1\PDFwork2\simplyPC", "*.pdf");
 }
예제 #6
0
        public IResult Delete(CarImage carImage)
        {
            IResult result = BusinessRules.Run(
                CheckIfImageExists(carImage.Id)
                );

            if (result != null)
            {
                return(result);
            }
            string path = GetById(carImage.Id).Data.ImagePath;

            FileProcessHelper.Delete(path);
            _carImageDal.Delete(carImage);
            return(new SuccessResult());
        }
예제 #7
0
        public IResult Add(CarImage carImage, IFormFile file)
        {
            IResult result = BusinessRules.Run(
                CheckIfImageLimitExpired(carImage.CarId),
                CheckIfImageExtensionValid(file)
                );

            if (result != null)
            {
                return(result);
            }

            carImage.ImagePath = FileProcessHelper.Add(file);
            carImage.Date      = DateTime.Now;
            _carImageDal.Add(carImage);
            return(new SuccessResult(Messages.AddCarImageMessage));
        }
예제 #8
0
        public IResult Add(CarImagesOperationDto carImagesOperationDto)
        {
            var result = BusinessRules.Run(
                CheckCarImageCount(carImagesOperationDto.CarId));

            if (result != null)
            {
                return(result);
            }

            foreach (var file in carImagesOperationDto.Images)
            {
                _carImageDal.Add(new CarImage
                {
                    CarId     = carImagesOperationDto.CarId,
                    ImagePath = FileProcessHelper.Upload(DefaultNameOrPath.ImageDirectory, file).Data
                });
            }

            return(new SuccessResult());
        }
예제 #9
0
        private async Task <Stream?> decryptFileIntoStream(string filePath)
        {
            var file = new FileInfo(filePath);

            using FileStream inputStream = file.OpenRead();
            bool encrypted = SaveFileHandler.IsFileEncrypted(inputStream);

            if (!encrypted)
            {
                Assert.Fail($"The file \"{file.Name}\" was in an unexpected format.");
                return(null);
            }
            Stream?stream = await FileProcessHelper.Decrypt(inputStream);

            if (stream == null)
            {
                Assert.Fail($"Content of file \"{file.Name}\" could not be converted to a supported format.");
                return(null);
            }
            return(stream);
        }
예제 #10
0
        public IResult Update(CarImage carImage, IFormFile file)
        {
            IResult result = BusinessRules.Run(
                CheckIfImageLimitExpired(carImage.CarId),
                CheckIfImageExtensionValid(file),
                CheckIfImageExists(carImage.Id)
                );

            if (result != null)
            {
                return(result);
            }

            CarImage oldCarImage = GetById(carImage.Id).Data;

            carImage.ImagePath = FileProcessHelper.Update(file, oldCarImage.ImagePath);
            carImage.Date      = DateTime.Now;
            carImage.CarId     = oldCarImage.CarId;
            _carImageDal.Update(carImage);
            return(new SuccessResult());
        }
예제 #11
0
        public static void preProcessingSteps(string filePath, string binDir, string PClog)
        {
            string[]   dirToLookIn       = new string[] { "\\spool", "\\data" };
            string[][] FileTypesToDelete = { new string[] { "pdf", "csv", "txt", "jrn", "zip" }, new string[] { "bsp", "dbf", "dpi", "sum", "trf", "txt", "ntx" } };

            for (int i = 0; i < 2; i++)
            {
                foreach (string extension in FileTypesToDelete[i])
                {
                    FileProcessHelper.DeleteFiles(filePath + dirToLookIn[i], "*." + extension);
                }
            }

            //TODO: IO operations should use try / catch or within wrapper methods when dealing with as considered unsafe operations
            FileProcessHelper.AppendFiles(filePath + "\\in", @"\\doc2\Prod\Simply_Energy\PaymentCards\data\EA_EAPRD_EZYPAY.TXT", "EA*.txt", false);
            RunProcessHelper.RunProcess(true, filePath + @"\data\ZFPROC200pipeDOC2.exe", "/T");

            FileProcessHelper.DeleteFile(PClog);
            FileProcessHelper.DeleteFile(binDir + "\\Dtotal.txt");
            FileProcessHelper.DeleteFile(binDir + "\\pages.txt");
            FileProcessHelper.CopyFile(binDir + "\\blankpages.txt", binDir, "pages.txt");
        }