Exemple #1
0
        public static bool ProcessFile(FileInfo file)
        {
            if (!File.Exists(Path.Combine(file.Directory.FullName, AppSettings.TransferComplete)))
            {
                return(false);
            }

            //Process LGD
            var processingFileName = file.FullName.Replace(AppSettings.new_, AppSettings.processing_);

            File.Move(file.FullName, processingFileName);


            var tryCounter   = 0;
            var eadProcessor = false;

            while (!eadProcessor && tryCounter <= 3)
            {
                eadProcessor = new LGD_Processor().ExecuteLGDMacro(processingFileName);
            }
            if (eadProcessor)
            {
                var completedProcessingFileName = processingFileName.Replace(AppSettings.processing_, AppSettings.complete_);
                if (!File.Exists(completedProcessingFileName))
                {
                    File.Move(processingFileName, completedProcessingFileName);
                }

                //transfer file back to master server

                File.Copy(completedProcessingFileName, completedProcessingFileName.Replace(AppSettings.ECLServer3, AppSettings.ECLServer1), true);
                File.Delete(completedProcessingFileName.Replace(AppSettings.ECLServer3, AppSettings.ECLServer1).Replace(AppSettings.complete_, string.Empty));
                File.WriteAllText(Path.Combine(new FileInfo(completedProcessingFileName.Replace(AppSettings.ECLServer3, AppSettings.ECLServer1)).Directory.FullName, AppSettings.LGDComputeComplete), string.Empty);

                // Move FrameworkFile
                if (File.Exists(Path.Combine(new FileInfo(completedProcessingFileName.Replace(AppSettings.ECLServer3, AppSettings.ECLServer1)).Directory.FullName, AppSettings.EADComputeComplete)) && File.Exists(Path.Combine(new FileInfo(completedProcessingFileName.Replace(AppSettings.ECLServer3, AppSettings.ECLServer1)).Directory.FullName, AppSettings.PDComputeComplete)))
                {
                    new Framework_Processor().TransferFrameworkInputFiles(completedProcessingFileName.Replace(AppSettings.ECLServer3, AppSettings.ECLServer1), AppSettings.LGD);
                }
            }
            else
            {
                File.Move(processingFileName, processingFileName.Replace(AppSettings.processing_, AppSettings.error_));
            }
            return(true);
        }
Exemple #2
0
        private void RunECL(List <Loanbook_Data> batchContracts, int batchId, long affiliateId, Guid eclId, EclType eclType, EADParameters eadParam, LGDParameters lgdParam, PDParameters pdParam, FrameworkParameters frameworkParam)
        {
            var affiliatePath = Path.Combine(AppSettings.ECLBasePath, affiliateId.ToString());
            var eclPath       = Path.Combine(affiliatePath, eclId.ToString());
            var batchPath     = Path.Combine(eclPath, batchId.ToString());

            var eadTemplate       = Path.Combine(affiliatePath, "EADTemplate.xlsb");
            var lgdTemplate       = Path.Combine(affiliatePath, "LGDTemplate.xlsb");
            var pdTemplate        = Path.Combine(affiliatePath, "PDTemplate.xlsb");
            var fraemworkTemplate = Path.Combine(affiliatePath, "FrameworkTemplate.xlsb");

            var eadFile       = Path.Combine(batchPath, "EAD.xlsb");
            var lgdFile       = Path.Combine(batchPath, "LGD.xlsb");
            var pdFile        = Path.Combine(batchPath, "PD.xlsb");
            var fraemworkFile = Path.Combine(batchPath, "Framework.xlsb");


            File.Copy(eadTemplate, eadFile);
            File.Copy(lgdTemplate, lgdFile);
            File.Copy(pdTemplate, pdFile);
            File.Copy(fraemworkTemplate, fraemworkFile);

            eadParam.ModelFileName           = eadFile;
            eadParam.BasePath                = batchPath;
            eadParam.LoanBookFileName        = $"{batchId}_{eclId}_EAD_LoanBook.xlsx";
            eadParam.PaymentScheduleFileName = $"{batchId}_{eclId}_PaymentSchedule.xlsx";

            lgdParam.ModelFileName    = lgdFile;
            lgdParam.BasePath         = batchPath;
            lgdParam.LoanBookFileName = $"{batchId}_{eclId}_LGD_LoanBook.xlsx";

            pdParam.ModelFileName    = pdFile;
            pdParam.BasePath         = batchPath;
            pdParam.LoanBookFileName = $"{batchId}_{eclId}_PD_LoanBook.xlsx";

            frameworkParam.ModelFileName = fraemworkFile;
            frameworkParam.BasePath      = batchPath;
            frameworkParam.EadFileName   = "EAD.xlsb";
            frameworkParam.LgdFile       = "LGD.xlsb";
            frameworkParam.PdFileName    = "PD.xlsb";
            var reportPath = Path.Combine(batchPath, "Report");

            if (!Directory.Exists(reportPath))
            {
                Directory.CreateDirectory(reportPath);
            }
            frameworkParam.ReportFolderName = reportPath;


            var taskList     = new List <Task>();
            var tskStatusLst = new List <TaskStatus> {
                TaskStatus.RanToCompletion, TaskStatus.Faulted
            };

            var task1 = Task.Run(() =>
            {
                var eadProcessor = new EAD_Processor().ProcessEAD(eadParam);
            });

            taskList.Add(task1);

            var task2 = Task.Run(() =>
            {
                var lgdProcessor = new LGD_Processor().ProcessLGD(lgdParam);
            });

            taskList.Add(task2);

            var task3 = Task.Run(() =>
            {
                var pdProcessor = new PD_Processor().ProcessPD(pdParam);
            });

            taskList.Add(task3);

            while (0 < 1)
            {
                if (taskList.All(o => tskStatusLst.Contains(o.Status)))
                {
                    foreach (var itm in taskList)
                    {
                        if (itm.Status != TaskStatus.RanToCompletion)
                        {
                            Log4Net.Log.Info("Did not run to Completion");
                            Log4Net.Log.Error(itm.Exception);
                        }
                        else
                        {
                            Log4Net.Log.Info("Ran to Completion");
                        }
                    }
                    break;
                }
                //Do Nothing
            }

            var fwProcessor = new Framework_Processor().ProcessFramework(frameworkParam);

            var fraemworkResultFile = Path.Combine(batchPath, "Framework.xlsb");

            ExtractAndSaveResult(batchContracts, fraemworkResultFile, eclId, eclType);
        }