public bool ProcessCalibrationRunTask() { try { var cali = Queries.CalibrationBehavioural(); var dt = DataAccess.i.GetData(cali); if (dt.Rows.Count > 0) { var qry = ""; var caliId = Guid.NewGuid(); try { var affId = (long)dt.Rows[0]["AffiliateId"]; caliId = (Guid)dt.Rows[0]["Id"]; //qry = Queries.UpdateGuidTableServiceId("CalibrationRunEadBehaviouralTerms", this.serviceId, caliId); //var resp = DataAccess.i.ExecuteQuery(qry); //if (resp == 0) //{ // Log4Net.Log.Info($"Another service has picked Behavioural Calibration with ID {caliId.ToString()}."); // return true; //} qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 4, "Processing", "CalibrationRunEadBehaviouralTerms"); DataAccess.i.ExecuteQuery(qry); var ead_bahavioural = new CalibrationInput_EAD_Behavioural_Terms_Processor(); ead_bahavioural.ProcessCalibration(caliId, affId); qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 5, "Completed", "CalibrationRunEadBehaviouralTerms"); DataAccess.i.ExecuteQuery(qry); } catch (Exception ex) { Log4Net.Log.Info("At Calibration"); Log4Net.Log.Error(ex.ToString()); qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 10, ex.ToString(), "CalibrationRunEadBehaviouralTerms"); DataAccess.i.ExecuteQuery(qry); } } else { Log4Net.Log.Info("No new Calibration found!"); } cali = Queries.CalibrationCCF(); dt = DataAccess.i.GetData(cali); if (dt.Rows.Count > 0) { var qry = ""; var caliId = Guid.NewGuid(); try { var affId = (long)dt.Rows[0]["AffiliateId"]; caliId = (Guid)dt.Rows[0]["Id"]; qry = Queries.UpdateGuidTableServiceId("CalibrationRunEadCcfSummary", this.serviceId, caliId); var resp = DataAccess.i.ExecuteQuery(qry); if (resp == 0) { Log4Net.Log.Info($"Another service has picked CCF Calibration with ID {caliId.ToString()}."); return(true); } qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 4, "Processing", "CalibrationRunEadCcfSummary"); DataAccess.i.ExecuteQuery(qry); var ead_ccf = new CalibrationInput_EAD_CCF_Summary_Processor(); ead_ccf.ProcessCalibration(caliId, affId); qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 5, "Completed", "CalibrationRunEadCcfSummary"); DataAccess.i.ExecuteQuery(qry); } catch (Exception ex) { Log4Net.Log.Info("At Calibration"); Log4Net.Log.Error(ex.ToString()); qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 10, ex.ToString(), "CalibrationRunEadCcfSummary"); DataAccess.i.ExecuteQuery(qry); } } cali = Queries.CalibrationHaircut(); dt = DataAccess.i.GetData(cali); if (dt.Rows.Count > 0) { var qry = ""; var caliId = Guid.NewGuid(); try { var affId = (long)dt.Rows[0]["AffiliateId"]; caliId = (Guid)dt.Rows[0]["Id"]; qry = Queries.UpdateGuidTableServiceId("CalibrationRunLgdHairCut", this.serviceId, caliId); var resp = DataAccess.i.ExecuteQuery(qry); if (resp == 0) { Log4Net.Log.Info($"Another service has picked Haircut Calibration with ID {caliId.ToString()}."); return(true); } qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 4, "Processing", "CalibrationRunLgdHairCut"); DataAccess.i.ExecuteQuery(qry); var lgd_haircut = new CalibrationInput_LGD_Haricut_Processor(); lgd_haircut.ProcessCalibration(caliId, affId); qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 5, "Completed", "CalibrationRunLgdHairCut"); DataAccess.i.ExecuteQuery(qry); } catch (Exception ex) { Log4Net.Log.Error(ex.ToString()); qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 10, ex.ToString(), "CalibrationRunLgdHairCut"); DataAccess.i.ExecuteQuery(qry); } } cali = Queries.CalibrationRecovery(); dt = DataAccess.i.GetData(cali); if (dt.Rows.Count > 0) { var qry = ""; var caliId = Guid.NewGuid(); try { var affId = (long)dt.Rows[0]["AffiliateId"]; caliId = (Guid)dt.Rows[0]["Id"]; qry = Queries.UpdateGuidTableServiceId("CalibrationRunLgdRecoveryRate", this.serviceId, caliId); var resp = DataAccess.i.ExecuteQuery(qry); if (resp == 0) { Log4Net.Log.Info($"Another service has picked Recovery Rate Calibration with ID {caliId.ToString()}."); return(true); } qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 4, "Processing", "CalibrationRunLgdRecoveryRate"); DataAccess.i.ExecuteQuery(qry); var lgd_recoveryR = new CalibrationInput_LGD_RecoveryRate_Processor(); lgd_recoveryR.ProcessCalibration(caliId, affId); qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 5, "Completed", "CalibrationRunLgdRecoveryRate"); DataAccess.i.ExecuteQuery(qry); } catch (Exception ex) { Log4Net.Log.Error(ex.ToString()); qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 10, ex.ToString(), "CalibrationRunLgdRecoveryRate"); DataAccess.i.ExecuteQuery(qry); } } cali = Queries.CalibrationPD(); dt = DataAccess.i.GetData(cali); if (dt.Rows.Count > 0) { var qry = ""; var caliId = Guid.NewGuid(); try { var affId = (long)dt.Rows[0]["AffiliateId"]; caliId = (Guid)dt.Rows[0]["Id"]; qry = Queries.UpdateGuidTableServiceId("CalibrationRunPdCrDrs", this.serviceId, caliId); var resp = DataAccess.i.ExecuteQuery(qry); if (resp == 0) { Log4Net.Log.Info($"Another service has picked PD CR DR Calibration with ID {caliId.ToString()}."); return(true); } qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 4, "Processing", "CalibrationRunPdCrDrs"); DataAccess.i.ExecuteQuery(qry); var pd_cr_dr = new CalibrationInput_PD_CR_RD_Processor(); pd_cr_dr.ProcessCalibration(caliId, affId); qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 5, "Completed", "CalibrationRunPdCrDrs"); DataAccess.i.ExecuteQuery(qry); }catch (Exception ex) { Log4Net.Log.Error(ex); qry = Queries.CalibrationRegisterUpdate(caliId.ToString(), 10, ex.ToString(), "CalibrationRunPdCrDrs"); DataAccess.i.ExecuteQuery(qry); } } }catch (Exception ex) { Log4Net.Log.Info("At Calibration"); Log4Net.Log.Error(ex.ToString()); var x = 0; } return(true); }
internal List <updatedFSV> ComputeUpdatedFSV() { var updatedFSV = new List <updatedFSV>(); var collateral = GetCollateralTypeResult(); var overrideData = GetOverrideDataResult(); var cali = new CalibrationInput_LGD_Haricut_Processor().GetLGDHaircutSummaryData(this.eclId, this._eclType); foreach (var row in collateral) { var newRow = new updatedFSV(); newRow.ContractNo = row.contract_no; var overrideItem = new EclOverrides(); var _overrideItem = overrideData.FirstOrDefault(o => o.ContractId == newRow.ContractNo); if (_overrideItem != null) { overrideItem = _overrideItem; } newRow.Cash = ComputeCollateralValue(row.cash_fsv, row.cash_omv, overrideItem.FSV_Cash, cali.Cash); newRow.CommercialProperty = ComputeCollateralValue( row.commercial_property_fsv, row.commercial_property_omv, overrideItem.FSV_CommercialProperty, cali.Commercial_Property); newRow.Debenture = ComputeCollateralValue( row.debenture_fsv, row.debenture_omv, overrideItem.FSV_Debenture, cali.Debenture); newRow.Inventory = ComputeCollateralValue( row.inventory_fsv, row.inventory_omv, overrideItem.FSV_Inventory, cali.Inventory); newRow.PlantAndEquipment = ComputeCollateralValue( row.plant_and_equipment_fsv, row.plant_and_equipment_omv, overrideItem.FSV_PlantAndEquipment, cali.Plant_And_Equipment); newRow.Receivables = ComputeCollateralValue( row.receivables_fsv, row.receivables_omv, overrideItem.FSV_Receivables, cali.Receivables); newRow.ResidentialProperty = ComputeCollateralValue( row.residential_property_fsv, row.residential_property_omv, overrideItem.FSV_ResidentialProperty, cali.Residential_Property); newRow.Shares = ComputeCollateralValue( row.shares_fsv, row.shares_omv, overrideItem.FSV_Shares, cali.Shares); newRow.Vehicle = ComputeCollateralValue( row.vehicle_fsv, row.vehicle_omv, overrideItem.FSV_Vehicle, cali.Vehicle); //overrideItem.TtrYears = overrideItem.TtrYears ?? 0; if (overrideItem.TtrYears != null) { newRow.Override_TTR_Year = int.Parse(Math.Round(overrideItem.TtrYears.Value, 0).ToString()); } updatedFSV.Add(newRow); } return(updatedFSV); }