} // DoZooplaCheck private void UpdateLogicalGlue(PreliminaryData preData) { if (!this.logicalGlueEnabled) { Log.Debug("Not updating Logical Glue data for {0}: updating disabled.", OuterContextDescription); return; } // if if (preData.TypeOfBusiness.IsRegulated()) { Log.Debug("Not updating Logical Glue data for {0}: regulated company.", OuterContextDescription); return; } // if Log.Debug("Updating Logical Glue data for {0}: non-regulated company.", OuterContextDescription); try { InjectorStub.GetEngine().GetInference( this.customerID, this.monthlyPayment, false, GetInferenceMode.DownloadIfOld ); Log.Debug("Updated Logical Glue data for customer {0}.", this.customerID); } catch (Exception e) { Log.Warn(e, "Logical Glue data was not updated for customer {0}.", this.customerID); } // try } // UpdateLogicalGlue
/// <param name="customerID">ID of customer to infer.</param> public GetHistoryInferences(int customerID) { this.lgEngine = InjectorStub.GetEngine(); // This call should some day be replaced with real injection. this.now = DateTime.UtcNow; this.customerID = customerID; Inferences = new List <Inference>(); } // constructor
protected override void ExecuteStep() { DateTime now = DateTime.UtcNow; var sp = new GetCustomerCompanyID(DB, Log) { CustomerID = this.customerID, Now = now, }; sp.ExecuteNonQuery(); CompanyID = sp.CompanyID; TypeOfBusiness tob; TypeOfBusiness = Enum.TryParse(sp.TypeOfBusiness, true, out tob) ? tob : TypeOfBusiness.Entrepreneur; MonthlyRepayment = InjectorStub.GetEngine().GetMonthlyRepaymentData(this.customerID, now); Log.Debug( "Customer {0} at {1}: company ID is {2}, monthly repayment is {3} (requested {4} for {5}).", this.customerID, now.MomentStr(), CompanyID, MonthlyRepayment.MonthlyPayment.ToString("C0"), MonthlyRepayment.RequestedAmount.ToString("C0"), Grammar.Number(MonthlyRepayment.RequestedTerm, "month") ); } // ExecuteStep
public void TestEndToEndFlow() { IEngine engine = InjectorStub.GetEngine(); Inference inference = engine.GetInference(customerID, 0, false, GetInferenceMode.ForceDownload); Log.Info("Inference read: {0}", inference); } // TestEndToEndFlow
public void TestLoadHistory() { IEngine engine = InjectorStub.GetEngine(); List <Inference> inferences = engine.GetInferenceHistory(1417, DateTime.UtcNow, false, 0); Log.Info("Inferences read:\n\n{0}", string.Join("\n\n", inferences)); } // TestLoadHistory
public void TestGetLatestKnownLogicalGlue() { var lgEngine = InjectorStub.GetEngine(); lgEngine.GetInference(1417, 0, false, GetInferenceMode.DownloadIfOld); var stra = new GetLatestKnownInference(1417, null, false); stra.Execute(); m_oLog.Debug("Inference is: {0}", stra.Inference); } // TestGetLatestKnownLogicalGlue
/// <param name="customerID">ID of customer to infer.</param> /// <param name="forTime">Time of interest.</param> /// <param name="includeTryOuts">Include try out data or not.</param> public GetLatestKnownInference(int customerID, DateTime?forTime, bool includeTryOuts) { this.lgEngine = InjectorStub.GetEngine(); // This call should some day be replaced with real injection. this.customerID = customerID; this.forTime = forTime ?? DateTime.UtcNow; this.includeTryOuts = includeTryOuts; Inference = null; } // constructor
/// <param name="customerID">ID of customer to infer.</param> /// <param name="monthlyRepayment"></param> /// <param name="isTryOut"></param> public GetTryoutInference(int customerID, decimal monthlyRepayment, bool isTryOut) { this.lgEngine = InjectorStub.GetEngine(); // This call should some day be replaced with real injection. this.customerID = customerID; this.monthlyRepayment = monthlyRepayment; this.isTryOut = isTryOut; Inference = null; } // constructor
protected virtual void LoadCompanyAndMonthlyPayment(DateTime now) { var sp = new GetCustomerCompanyID(DB, Log) { CustomerID = CustomerID, Now = now, }; sp.ExecuteNonQuery(); CompanyID = sp.CompanyID; MonthlyRepayment = InjectorStub.GetEngine().GetMonthlyRepaymentData(CustomerID, now); Log.Debug( "Customer {0} at {1}: company ID is {2}, monthly repayment is {3} (requested {4} for {5}).", CustomerID, now.MomentStr(), CompanyID, MonthlyRepayment.MonthlyPayment.ToString("C0"), MonthlyRepayment.RequestedAmount.ToString("C0"), Grammar.Number(MonthlyRepayment.RequestedTerm, "month") ); } // LoadCompanyAndMonthlyPayment
public BackfillLogicalGlueForAll() { this.engine = InjectorStub.GetEngine(); } // constructor
} // RunSecondary private void GatherData(LGRejectionInputData inputData) { var sp = new LoadLGAutoRejectData(DB, Log) { CustomerID = this.args.CustomerID, CompanyID = this.args.CompanyID, Now = this.args.Now, }; sp.ExecuteNonQuery(); inputData.CompanyID = this.args.CompanyID; inputData.TypeOfBusiness = sp.TypeOfBusiness; inputData.CompanyIsRegulated = sp.IsRegulated; inputData.AutoDecisionInternalLogic = sp.AutoDecisionInternalLogic; inputData.CustomerOrigin = customerOrigins.Contains(sp.OriginID) ? (CustomerOriginEnum)sp.OriginID : (CustomerOriginEnum?)null; inputData.LoanSource = loanSources.Contains(sp.LoanSourceID) ? (LoanSourceName)sp.LoanSourceID : (LoanSourceName?)null; Inference inference = InjectorStub.GetEngine().GetInferenceIfExists( this.args.CustomerID, this.args.Now, false, 0 ); if (inference == null) { inputData.RequestID = null; inputData.ResponseID = null; inputData.ResponseErrors = null; inputData.HardReject = false; inputData.Bucket = null; inputData.Score = null; inputData.MatchingGradeRanges = null; } else { inputData.RequestID = inference.UniqueID; inputData.ResponseID = inference.ResponseID; if (inference.ResponseID <= 0) { inputData.ResponseErrors.Add("No response received."); } inputData.ResponseHttpStatus = (inference.Status == null) ? (int?)null : (int)inference.Status.HttpStatus; bool receivedError = (inference.Etl != null) && (inference.Etl.Code != null) && inference.Etl.Code.IsError; if (inference.Error.HasError()) { inputData.ResponseErrors.AddRange( new [] { inference.Error.Message, inference.Error.ParsingExceptionType, inference.Error.ParsingExceptionMessage, }.Where(s => !string.IsNullOrWhiteSpace(s)) ); if (inference.Error.TimeoutSource != null) { inputData.ResponseErrors.Add("Timeout: " + inference.Error.TimeoutSource.Name); } ModelOutput model = inference.ModelOutputs.ContainsKey(ModelNames.NeuralNetwork) ? inference.ModelOutputs[ModelNames.NeuralNetwork] : null; if ((model != null) && !model.Error.IsEmpty) { if (!string.IsNullOrWhiteSpace(model.Error.ErrorCode)) { inputData.ResponseErrors.Add(model.Error.ErrorCode); } if (!string.IsNullOrWhiteSpace(model.Error.Exception)) { inputData.ResponseErrors.Add(model.Error.Exception); } inputData.ResponseErrors.AddRange( model.Error.EncodingFailures.Where(ef => !ef.IsEmpty).Select(ef => ef.ToString()) ); inputData.ResponseErrors.AddRange(model.Error.MissingColumns); inputData.ResponseErrors.AddRange( model.Error.Warnings.Where(w => !w.IsEmpty).Select(w => w.ToString()) ); } // if } // if inference has error inputData.HardReject = (inference.Etl != null) && (inference.Etl.Code != null) && inference.Etl.Code.IsHardReject; inputData.Bucket = inference.Bucket == null ? (LocalBucket?)null : (LocalBucket)(int)inference.Bucket; inputData.Score = inference.Score; inputData.MatchingGradeRanges = new MatchingGradeRanges(); if (inputData.Score.HasValue && inputData.CustomerOrigin.HasValue && inputData.LoanSource.HasValue) { var loader = new LoadOfferRanges( this.args.CustomerID, this.args.CompanyID, this.args.Now, DB, Log ).Execute(); loader.ExportMatchingGradeRanges(inputData.MatchingGradeRanges); } // if } // if inference is null } // GatherData
} // Name public override void Execute() { Success = InjectorStub.GetEngine().SetRequestIsTryOut(this.requestID, this.newIsTryOutStatus); } // Execute