public bool ProcessPD(PDParameters input) { 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.ECLServer4); 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.ECLServer4); File.WriteAllText(inputFilePathTemp, inputFile); File.Copy(loanbook, loanbookTemp, true); var modelTemp = model.Replace(AppSettings.Drive, AppSettings.ECLServer4); 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); return(true); }
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); }
private PDParameters BuildPDParameter(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 pdCali = new CalibrationInput_PD_CR_RD_Processor().GetPDRedefaultFactorCureRate(eclId, eclType); double readjustmentFactor = pdCali[0]; var obj = new PDParameters { BasePath = AppSettings.ECLBasePath, Expired = bt_ead_data.Expired, NonExpired = bt_ead_data.NonExpired, ReportDate = reportingDate, SandPMapping = "Best Fit", RedefaultAdjustmentFactor = readjustmentFactor }; obj.NonExpired = 19; obj.Expired = 26; obj.RedefaultAdjustmentFactor = 1; return(obj); }
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); }
public bool ProcessPD(PDParameters 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); startSheet.Cells[9, 5] = input.ReportDate.ToString("dd MMMM yyyy"); startSheet.Cells[12, 5] = input.RedefaultAdjustmentFactor; startSheet.Cells[13, 5] = input.SandPMapping; startSheet.Cells[15, 5] = input.NonExpired; startSheet.Cells[16, 5] = input.Expired; startSheet.Cells[20, 5] = loanbook; var fileName = new FileInfo(loanbook).Name; startSheet.Cells[21, 5] = fileName; excel.ScreenUpdating = false; excel.Run("unhide_unprotect"); excel.Run("primary_condition_extractor"); excel.Run("centre_sheets"); excel.Run("hide_protect"); excel.Run("unhide_unprotect"); excel.Run("primary_condition_extractor"); excel.Run("centre_sheets"); excel.Run("hide_protect"); excel.Run("unhide_unprotect"); excel.Run("resize_pd_workbook"); excel.Run("centre_sheets"); excel.Run("hide_protect"); excel.ScreenUpdating = true; theWorkbook.Save(); theWorkbook.Close(true); } catch (Exception ex) { theWorkbook.Close(true); excel.Quit(); Console.WriteLine(ex); } finally { excel.Quit(); } return(true); }