コード例 #1
0
        public async Task <ProcessFileResultModel> ProcessFiles(ProcessFileModel fileModel)
        {
            try
            {
                FileFacade    fileFacede      = new FileFacade(_fileValidators, _fileFormatValidators, _businessRuleValidators);
                string        folder          = System.Web.Hosting.HostingEnvironment.MapPath("~/CSVFiles/");
                List <string> serverFilePaths = new List <string>();
                foreach (string filePath in fileModel.FilePaths)
                {
                    serverFilePaths.Add(folder + filePath);
                }
                var fileResultTasks = fileFacede.ProcessFiles <Shipment>(serverFilePaths.ToArray());

                var fileResults = await Task.WhenAll(fileResultTasks);

                return(new ProcessFileResultModel {
                    Message = "File processing successful", FileResults = fileResults
                });
            }
            catch
            {
                //ToDo: Proper logging at business logic level
                return(new ProcessFileResultModel {
                    Message = "Error in processing file/s!"
                });
            }
        }
コード例 #2
0
        public void ProcessFiles_InvalidBusiness_Test()
        {
            //No assertion for this test case, needs enhancements (currently verified manually)
            FileFacade fileFacade = new FileFacade(_fileValidators, _fileFormatValidators, _businessRuleValidators);

            fileFacade.ProcessFiles <Shipment>("Shipment_Input_BusinessInvalid.csv");
        }