public bool ProcessFramework(FrameworkParameters input) { 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[3]; startSheet.Unprotect(AppSettings.SheetPassword); Directory.CreateDirectory(Path.Combine(input.BasePath, input.ReportFolderName)); startSheet.Cells[6, 4] = input.ReportDate.ToString("dd MMMM yyyy"); startSheet.Cells[9, 4] = Path.Combine(input.BasePath, input.ReportFolderName); startSheet.Cells[10, 4] = input.PdFileName; startSheet.Cells[11, 4] = Path.Combine(input.BasePath, input.PdFileName); startSheet.Cells[12, 4] = input.LgdFile; startSheet.Cells[13, 4] = Path.Combine(input.BasePath, input.LgdFile); startSheet.Cells[14, 4] = input.EadFileName; startSheet.Cells[15, 4] = Path.Combine(input.BasePath, input.EadFileName); excel.Run("calculate_ecl"); theWorkbook.Save(); theWorkbook.Close(true); } catch (Exception ex) { theWorkbook.Close(true); excel.Quit(); Console.WriteLine(ex); } finally { excel.Quit(); } return(true); }
/// <summary> /// Function that calls the basic start up functions required /// </summary> private void StartUp() { _startTime = Util.GetCurrentTime(); SetRelativePath(); _frameworkParameters = FrameworkParameters.Instance; SetDefaultTestParameters(); }
private String InvokeTestScript(SeleniumTestParameters testParameters) { string testStatus; FrameworkParameters frameworkParameters = FrameworkParameters.Instance; if (frameworkParameters.StopExecution) { testStatus = "Test Execution Aborted"; } else { DriverScript driverScript = new DriverScript(testParameters); try { driverScript.DriveTestExecution(); } catch (AssertFailedException ex) { testStatus = "Failed"; } testStatus = driverScript.TestStatus; } return(testStatus); }
public static String getInstance() { if (_timeStamp == null) { lock (_syncRoot) { if (_timeStamp == null) { FrameworkParameters frameworkParameters = FrameworkParameters.GetInstance(); _timeStamp = frameworkParameters.RunConfiguration + Util.GetFileSeparator() + "Run_" + Util.GetCurrentFormattedTime(ConfigurationManager.AppSettings["DateFormatString"]).Replace(" ", "_").Replace(":", "-"); String reportPathWithTimeStamp = frameworkParameters.RelativePath + Util.GetFileSeparator() + "Results" + Util.GetFileSeparator() + _timeStamp; Directory.CreateDirectory(reportPathWithTimeStamp); Directory.CreateDirectory(reportPathWithTimeStamp + Util.GetFileSeparator() + "Screenshots"); } } } return(_timeStamp); }
public bool ProcessFramework(FrameworkParameters input, List <Loanbook_Data> batchContracts, Guid eclId, EclType eclType) { var model = Path.Combine(input.BasePath, $"{AppSettings.new_}{input.ModelFileName}"); var modelTemp = model.Replace(AppSettings.Drive, AppSettings.ECLServer5); if (!(new FileInfo(modelTemp).Directory.Exists)) { Directory.CreateDirectory(new FileInfo(modelTemp).Directory.FullName); } var inputFile = JsonConvert.SerializeObject(input); var inputFilePath = Path.Combine(input.BasePath, AppSettings.ModelInputFileEto); File.WriteAllText(inputFilePath, inputFile); var inputFilePathTemp = inputFilePath.Replace(AppSettings.Drive, AppSettings.ECLServer5); File.WriteAllText(inputFilePathTemp, inputFile); model = model.Replace(AppSettings.new_, string.Empty); File.Copy(model, modelTemp, true); return(true); }
public bool ProcessFrameworkResult(string filename, FrameworkParameters input) { try { var frameworkResult = FileSystemStorage <ResultDetailDataMore> .ReadCsvData(filename); var c = new ResultDetailDataMore(); Type myObjOriginalType = c.GetType(); PropertyInfo[] myProps = myObjOriginalType.GetProperties(); var dt = new System.Data.DataTable(); for (int i = 0; i < myProps.Length; i++) { dt.Columns.Add(myProps[i].Name, myProps[i].PropertyType); } dt.Columns.Add($"{input.EclType}EclId", typeof(Guid)); //var lstContractNoLog = new List<string>(); foreach (var _d in frameworkResult) { //if (lstContractNoLog.Any(o => o == _d.ContractNo)) // continue; //lstContractNoLog.Add(_d.ContractNo); try { c.OriginalOutstandingBalance = 0.0; } catch { } //(double)batchContracts.FirstOrDefault(o => o.ContractNo == c.ContractNo).OutstandingBalanceLCY; } catch { } var Id = Guid.NewGuid(); dt.Rows.Add(new object[] { Id, _d.Stage, _d.Outstanding_Balance, _d.ECL_Best_Estimate, _d.ECL_Optimistic, _d.ECL_Downturn, _d.Impairment_ModelOutput, _d.Overrides_Stage, _d.Overrides_TTR_Years, _d.Overrides_FSV, _d.Overrides_Overlay, _d.Overrides_ECL_Best_Estimate, _d.Overrides_ECL_Optimistic, _d.Overrides_ECL_Downturn, _d.Overrides_Impairment_Manual, _d.ContractNo, _d.AccountNo, _d.CustomerNo, _d.Segment, _d.ProductType, _d.Sector, _d.OriginalOutstandingBalance, input.EclId }); } //Save to Report Detail var r = DataAccess.i.ExecuteBulkCopy(dt, ECLStringConstants.i.EclFramworkReportDetail(input.EclType)); return(true); } catch (Exception ex) { Log4Net.Log.Error(ex); return(false); } }
public bool ProcessFrameworkOverride(FrameworkParameters input, List <Loanbook_Data> batchContracts, Guid eclId, EclType eclType) { var overrideModel = Path.Combine(input.BasePath, $"{AppSettings.new_}{AppSettings.override_}{input.ModelFileName}"); var modelRemote = overrideModel.Replace(AppSettings.Drive, AppSettings.ECLServer5).Replace(AppSettings.new_, AppSettings.complete_).Replace(AppSettings.override_, string.Empty); File.Copy(modelRemote, overrideModel, true); var overrides = new ProcessECL_LGD(eclId, eclType).GetOverrideData(4); WriteOverrideData(overrides, overrideModel); var modelOverrideRemote = overrideModel.Replace(AppSettings.Drive, AppSettings.ECLServer5); File.Copy(overrideModel, modelOverrideRemote, true); return(true); }
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); }