Exemplo n.º 1
0
        public bool ProcessLGD(LGDParameters input, PDParameters pdParam)
        {
            input.CreditPd = pdParam.CreditPd;

            var loanbook = Path.Combine(input.BasePath, input.LoanBookFileName);
            var model    = Path.Combine(input.BasePath, $"{AppSettings.new_}{input.ModelFileName}");

            var loanbookTemp = loanbook.Replace(AppSettings.Drive, AppSettings.ECLServer3);

            if (!(new FileInfo(loanbookTemp).Directory.Exists))
            {
                Directory.CreateDirectory(new FileInfo(loanbookTemp).Directory.FullName);
            }


            var inputFile         = JsonConvert.SerializeObject(input);
            var inputFilePath     = Path.Combine(input.BasePath, AppSettings.ModelInputFileEto);
            var inputFilePathTemp = inputFilePath.Replace(AppSettings.Drive, AppSettings.ECLServer3);

            File.WriteAllText(inputFilePathTemp, inputFile);

            File.Copy(loanbook, loanbookTemp, true);

            var modelTemp = model.Replace(AppSettings.Drive, AppSettings.ECLServer3);

            model = model.Replace(AppSettings.new_, string.Empty);
            File.Copy(model, modelTemp, true);

            File.WriteAllText(Path.Combine(new FileInfo(loanbookTemp).Directory.FullName, AppSettings.TransferComplete), string.Empty);

            //while (!File.Exists(modelTemp.Replace(AppSettings.new_, AppSettings.complete_)) && !File.Exists(modelTemp.Replace(AppSettings.new_, AppSettings.complete_)))
            //{
            //    Thread.Sleep(AppSettings.ServerCallWaitTime);
            //}

            //if (File.Exists(modelTemp.Replace(AppSettings.new_, AppSettings.complete_)))
            //{
            //    File.Copy(modelTemp.Replace(AppSettings.new_, AppSettings.complete_), model, true);
            //}
            //if (File.Exists(modelTemp.Replace(AppSettings.new_, AppSettings.error_)))
            //{
            //    File.Copy(modelTemp.Replace(AppSettings.new_, AppSettings.error_), model, true);
            //    //Log error in Db
            //}

            return(true);
        }
Exemplo n.º 2
0
        private LGDParameters BuildLGDParameter(Guid eclId, DateTime reportingDate, EclType eclType)
        {
            var bt_ead      = new CalibrationInput_EAD_Behavioural_Terms_Processor();
            var bt_ead_data = bt_ead.GetBehaviouralData(eclId, eclType);
            var obj         = new LGDParameters
            {
                BasePath   = AppSettings.ECLBasePath,
                Expired    = bt_ead_data.Expired,
                NonExpired = bt_ead_data.NonExpired,
                ReportDate = reportingDate
            };


            obj.NonExpired = 19;
            obj.Expired    = 26;

            return(obj);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public bool ProcessLGD(LGDParameters input)
        {
            var    loanbook    = Path.Combine(input.BasePath, input.LoanBookFileName);
            var    model       = Path.Combine(input.BasePath, input.ModelFileName);
            string txtLocation = Path.GetFullPath(model);

            object      _missingValue = System.Reflection.Missing.Value;
            Application excel         = new Application();
            var         theWorkbook   = excel.Workbooks.Open(txtLocation,
                                                             _missingValue,
                                                             false,
                                                             _missingValue,
                                                             _missingValue,
                                                             _missingValue,
                                                             true,
                                                             _missingValue,
                                                             _missingValue,
                                                             true,
                                                             _missingValue,
                                                             _missingValue,
                                                             _missingValue);

            try
            {
                Worksheet startSheet = theWorkbook.Sheets[1];
                startSheet.Unprotect(AppSettings.SheetPassword);

                var reportDate = input.ReportDate.ToString("dd MMMM yyyy");
                startSheet.Cells[9, 5]  = reportDate;
                startSheet.Cells[13, 5] = input.NonExpired;
                startSheet.Cells[14, 5] = input.Expired;

                startSheet.Cells[18, 5] = loanbook;
                var fileName = new FileInfo(loanbook).Name;
                startSheet.Cells[19, 5] = fileName;


                excel.Run("unhide_unprotect");
                excel.Run("primary_condition_extractor");
                excel.Run("centre_sheets");
                excel.Run("hide_protect");

                excel.Run("unhide_unprotect");
                excel.Run("resize_LGD_workbook");
                excel.Run("centre_sheets");
                excel.Run("hide_protect");

                theWorkbook.Save();
                theWorkbook.Close(true);
            }
            catch (Exception ex)
            {
                theWorkbook.Close(true);
                Console.WriteLine(ex);
            }
            finally
            {
                excel.Quit();
            }

            return(true);
        }