} // constructor public Loan(DbDataReader row, ASafeLog log = null) : this(log) { ID = Convert.ToInt32(row["LoanID"]); int nLoanType = Convert.ToInt32(row["LoanTypeID"]); switch (nLoanType) { case 1: LoanType = LoanType.Standard; break; case 2: LoanType = LoanType.Halfway; break; default: string sErr = string.Format("Unsupported loan type: {0} for loan {1}", nLoanType, ID); Alert(sErr); throw new Exception(sErr); } // switch Transactions.Add(new Transaction(row, this)); DeclaredLoanAmount = Convert.ToDecimal(row["LoanAmount"]); FillPlanned(row["AgreementModel"].ToString()); } // Loan
public void Parse(XmlNode oRoot, ASafeLog log) { if (ReferenceEquals(m_oFieldGroup, null)) { throw new OwnException("Cannot parse: field group is not specified."); } var oLog = new SafeLog(log); oLog.Debug("Parsing group {0}", m_oFieldGroup.Name); if (!string.IsNullOrWhiteSpace(m_oFieldGroup.PathToParent)) { XmlNodeList lst = oRoot.SelectNodes(m_oFieldGroup.PathToParent); if (lst != null) { oLog.Debug("{0} nodes found matching PathToParent", lst.Count); foreach (XmlNode oNode in lst) { ParseOne(oNode, oLog); } } // if nodes found } // if path to parent specified else { ParseOne(oRoot, oLog); } } // Parse
public InferenceHistoryLoader( AConnection db, ASafeLog log, int customerID, DateTime now, bool includeTryOutData, int historyLength, BucketRepository bucketRepo, TimeoutSourceRepository timeoutSourceRepo, EtlCodeRepository etlCodeRepo ) : base( db, log, 0, customerID, now, historyLength, includeTryOutData, 0, bucketRepo, timeoutSourceRepo, etlCodeRepo ) { } // constructor
public ObjectPool(int nMaxSize, ASafeLog oLog = null) { this.idGenerator = 0; var log = oLog.Safe(); Log = log; this.name = string.Format("ObjectPool<{0}>", typeof(T)); if (nMaxSize < 1) { string sMsg = string.Format("Cannot create {0}: pool size must be greater than 0.", StringifyStatus()); log.Alert("{0}", sMsg); throw new ArgumentOutOfRangeException("nMaxSize", sMsg); } // if this.pool = new Queue <T>(); this.locker = new object(); this.m_nMaxSize = nMaxSize; this.m_nCurrentlyOut = 0; log.Debug("New {0} has been created with max size of {1}.", this, MaxSize); } // constructor
public SaveMissingColumn( SortedDictionary <ModelNames, long> map, Response <Reply> response, AConnection db, ASafeLog log ) : base(db, log) { if ((map == null) || (map.Count < 1) || (response == null) || !response.Parsed.HasInference()) { return; } Tbl = new List <DbMissingColumn>(); ModelNames[] allModelNames = (ModelNames[])Enum.GetValues(typeof(ModelNames)); foreach (ModelNames name in allModelNames) { var model = response.Parsed.GetParsedModel(name); if (model != null) { Tbl.AddRange(Create(map, name, model.MissingColumns)); } } // for each model name } // constructor
public SpSaveVatReturnData(AStrategy oStrategy, AConnection oDB, ASafeLog oLog) : base(oDB, oLog) { HistoryItems = new List <HistoryItem>(); this.m_oOldDeletedItems = new SortedSet <int>(); this.m_oStrategy = oStrategy; } // constructor
public Mandrill(ASafeLog log, string apiKey) { _log = log; _apiKey = apiKey; _client = new RestClient(BaseSecureUrl); _client.AddHandler("application/json", new JsonDeserializer()); }
public OfferCalculator( AutoDecisionFlowTypes flowType, int customerID, int loanSourceID, int loanAmount, int repaymentPeriod, bool hasLoans, bool aspireToMinSetupFee, int smallLoanScenarioLimit, decimal minInterestRate, decimal maxInterestRate, decimal minSetupFee, decimal maxSetupFee, ASafeLog log ) { this.flowType = flowType; this.customerID = customerID; this.loanSourceID = loanSourceID; this.loanAmount = loanAmount; this.repaymentPeriod = repaymentPeriod; this.hasLoans = hasLoans; this.aspireToMinSetupFee = aspireToMinSetupFee; this.smallLoanScenarioLimit = smallLoanScenarioLimit; this.minInterestRate = minInterestRate; this.maxInterestRate = maxInterestRate; this.minSetupFee = minSetupFee; this.maxSetupFee = maxSetupFee; this.log = log.Safe(); Success = false; InterestRate = 0; SetupFee = 0; } // constructor
public SaveEtlData( long responseID, Response <Reply> response, EtlCodeRepository etlCodeRepo, AConnection db, ASafeLog log ) : base(db, log) { if ((response == null) || !response.Parsed.HasEtl()) { return; } this.etlCode = response.Parsed.Etl.Code; this.dbe = new DbEtlData { ResponseID = responseID, Message = response.Parsed.Etl.Message, }; Tbl = new List <DbEtlData> { this.dbe, }; this.etlCodeRepo = etlCodeRepo; } // constructor
} // static constructor public static bool IsSubclassOf(Type typeToTest, Type baseTypeCandidate, ASafeLog log = null) { if ((typeToTest == null) || (baseTypeCandidate == null)) { if (log != null) { log.Warn( "IsSubclassOf('{0}', '{1}') returns false because at least one of the operands is null.", typeToTest, baseTypeCandidate ); } // if return(false); } // if bool isSubclass = (typeToTest == baseTypeCandidate) || typeToTest.IsSubclassOf(baseTypeCandidate); if (log != null) { log.Warn("IsSubclassOf('{0}', '{1}') = {2}.", typeToTest, baseTypeCandidate, isSubclass); } return(isSubclass); } // IsSubclassOf
public SameDataAgent( int nCustomerID, long?cashRequestID, long?nlCashRequestID, decimal nSystemCalculatedAmount, AutomationCalculator.Common.Medal nMedal, AutomationCalculator.Common.MedalType nMedalType, AutomationCalculator.Common.TurnoverType?turnoverType, DateTime now, AConnection oDB, ASafeLog oLog ) : base( nCustomerID, cashRequestID, nlCashRequestID, nSystemCalculatedAmount, nMedal, nMedalType, turnoverType, oDB, oLog ) { this.now = now; } // constructor
public EarnedInterest( AConnection oDB, WorkingMode nMode, bool bAccountingMode, DateTime oDateOne, DateTime oDateTwo, ASafeLog oLog = null ) : base(oLog) { VerboseLogging = false; this.m_oDB = oDB; if (oDateTwo < oDateOne) { DateTime tmp = oDateOne; oDateOne = oDateTwo; oDateTwo = tmp; } // if this.m_oDateStart = oDateOne; this.m_oDateEnd = oDateTwo; this.m_oLoans = new SortedDictionary <int, LoanData>(); this.m_oFreezePeriods = new SortedDictionary <int, InterestFreezePeriods>(); this.m_oBadPeriods = new SortedDictionary <int, BadPeriods>(); this.m_nMode = nMode; this.m_bAccountingMode = bAccountingMode; } // constructor
public void Validate(ASafeLog log) { if (Types == null) { Types = new List <string>(); } m_oTypes.Clear(); foreach (string sType in Types) { if (string.IsNullOrWhiteSpace(sType)) { throw new OwnException("Transformation type not specified."); } TransformationType nType = TransformationType.None; if (!TransformationType.TryParse(sType.Trim(), true, out nType)) { throw new OwnException("Unsupported transformation type: {0}", sType); } m_oTypes.Add(nType); } // for each type } // Validate
internal InferenceLoader( AConnection db, ASafeLog log, int customerID, DateTime now, bool includeTryOutData, decimal monthlyPayment, BucketRepository bucketRepo, TimeoutSourceRepository timeoutSourceRepo, EtlCodeRepository etlCodeRepo ) : base( db, log, 0, customerID, now, 1, includeTryOutData, monthlyPayment, bucketRepo, timeoutSourceRepo, etlCodeRepo ) { } // constructor
public AutoApprovalArguments( int customerID, long?cashRequestID, long?nlCashRequestID, decimal systemCalculatedAmount, Medal medal, MedalType medalType, TurnoverType?turnoverType, AutoDecisionFlowTypes flowType, bool errorInLGData, string tag, DateTime now, AConnection db, ASafeLog log ) { CustomerID = customerID; CashRequestID = cashRequestID; NLCashRequestID = nlCashRequestID; SystemCalculatedAmount = systemCalculatedAmount; Medal = medal; MedalType = medalType; TurnoverType = turnoverType; FlowType = flowType; ErrorInLGData = errorInLGData; Tag = tag; Now = now; DB = db; Log = log.Safe(); TrailUniqueID = Guid.NewGuid(); } // constructor
private static void ActionTest(int x, string s, AConnection oDB, ASafeLog log) { log.Info("ActionTest started..."); var sp = new UpdateBroker(oDB, log); sp.ExecuteNonQuery(); /* * * var sp = new BrokerLoadCustomerList(oDB, log) { Email = "*****@*****.**", }; * * sp.ForEachResult<BrokerLoadCustomerList.ResultRow>(oRow => { * log.Debug("Result row: {0}", oRow); * return ActionResult.Continue; * }); */ if (ms_nActionTestCounter < 3) { ms_nActionTestCounter++; throw new ForceRetryException("just a force retry"); } // if log.Info("ActionTest: x = {0}", x); log.Info("ActionTest: s = {0}", s); log.Info("ActionTest complete."); }
protected AInferenceLoaderBase( AConnection db, ASafeLog log, long responseID, int customerID, DateTime now, int historyLength, bool includeTryOutData, decimal monthlyPayment, BucketRepository bucketRepo, TimeoutSourceRepository timeoutSourceRepo, EtlCodeRepository etlCodeRepo ) : base(db, log, customerID, now) { this.resultSet = new SortedDictionary <long, Inference>(); this.models = new SortedDictionary <long, PublicModelOutput>(); Results = new List <Inference>(); this.responseID = responseID; this.historyLength = historyLength; this.includeTryOutData = includeTryOutData; this.monthlyPayment = monthlyPayment; this.bucketRepo = bucketRepo; this.timeoutSourceRepo = timeoutSourceRepo; this.etlCodeRepo = etlCodeRepo; } // constructor
private static void TestInterestFreeze(AConnection oDB, ASafeLog log) { var oPeriods = new SortedDictionary <int, InterestFreezePeriods>(); oDB.ForEachRowSafe( (sr, bRowsetStart) => { int nLoanID = sr["LoanId"]; DateTime?oStart = sr["StartDate"]; DateTime?oEnd = sr["EndDate"]; decimal nRate = sr["InterestRate"]; DateTime?oDeactivation = sr["DeactivationDate"]; DateTime?oTo = oDeactivation.HasValue ? (oEnd.HasValue ? DateInterval.Min(oEnd.Value, oDeactivation.Value) : oDeactivation) : oEnd; if (!oPeriods.ContainsKey(nLoanID)) { oPeriods[nLoanID] = new InterestFreezePeriods(); } oPeriods[nLoanID].Add(oStart, oTo, nRate); return(ActionResult.Continue); }, "RptEarnedInterest_Freeze", CommandSpecies.StoredProcedure ); foreach (var pair in oPeriods) { log.Msg("LoanID: {0} Freeze Periods: {1}", pair.Key, pair.Value); } }
public void Write(ASafeLog oLog) { DateTime oTime; if (!DateTime.TryParseExact(eventTime, "yyyy-MM-dd=HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out oTime)) { oLog.Alert("Failed to parse entry time '{0}', using current UTC time instead.", eventTime); oTime = DateTime.UtcNow; } // if failed to parse time Severity nSeverity; if (!Enum.TryParse <Severity>(severity, true, out nSeverity)) { oLog.Alert("Failed to parse severity '{0}', using Info instead.", severity); nSeverity = Severity.Info; } // if failed to parse severity oLog.Say( nSeverity, "FROM CLIENT at {0}, user '{1}', event id {2}: {3}", oTime.ToString("dd/MMM/yyyy HH:mm:ss", CultureInfo.InvariantCulture), userName, eventID, msg ); } // Save
public SqlRetryer(int retryCount = 3, int sleepBeforeRetryMilliseconds = 0, ASafeLog log = null) { RetryCount = retryCount; SleepBeforeRetry = sleepBeforeRetryMilliseconds; Log = log.Safe(); this.logVerbosityLevel = LogVerbosityLevel.Compact; } // constructor
protected ATrail( int nCustomerID, long?cashRequestID, long?nlCashRequestID, DecisionStatus nDecisionStatus, ASafeLog oLog, string toExplanationEmailAddress, string fromEmailAddress, string fromEmailName ) { this.m_bIsDecisionLocked = false; this.m_oDiffNotes = new List <string>(); this.m_oSteps = new List <ATrace>(); this.stepsWithDecision = new List <StepWithDecision>(); CustomerID = nCustomerID; CashRequestID = cashRequestID; NLCashRequestID = nlCashRequestID; this.m_nDecisionStatus = nDecisionStatus; this.m_sToExplanationEmailAddress = toExplanationEmailAddress; this.m_sFromEmailAddress = fromEmailAddress; this.m_sFromEmailName = fromEmailName; this.m_oLog = oLog.Safe(); this.timer = new TimeCounter(); HasApprovalChance = false; } // constructor
public TypeRepository(ASafeLog oLog) { m_oLog = oLog.Safe(); m_oTypes = new List <IType>(); Type oBase = typeof(AType <>); foreach (Type t in oBase.Assembly.GetTypes()) { if ((t != oBase) && t.IsClass && t.HasInterface(typeof(IType))) { m_oTypes.Add(Activator.CreateInstance(t) as IType); } } // for each type if (m_oTypes.Count < 1) { m_oLog.Alert("No types were found for argument type repository!"); } else { m_oLog.Debug("Creating a type repository completed with {0} in it.", Grammar.Number(m_oTypes.Count, "type")); foreach (var t in m_oTypes) { m_oLog.Debug("Type in repository: {0}", t); } m_oLog.Debug("End of repository type list."); } // if } // constructor
} // constructor public Request(RequestTypes requestType, DateTime time, ASafeLog log) { RequestType = requestType; Time = time; log.Debug("New request created: {0}", this); } // constructor
} // class SignedDoc public EchoSignFacade(AConnection oDB, ASafeLog oLog) { this.isReady = false; this.log = oLog.Safe(); if (oDB == null) { throw new Alert(this.log, "Cannot create EchoSign façade: database connection not specified."); } this.db = oDB; try { LoadConfiguration(); CreateClient(); } catch (Exception e) { this.log.Alert(e, "Failed to initialize EchoSign façade."); this.isReady = false; } // try this.log.Say( this.isReady ? Severity.Msg : Severity.Warn, "EchoSign façade is {0}ready.", this.isReady ? string.Empty : "NOT " ); // this.restClient = new EchoSignRestClient("3AAABLblqZhABY-QxNfpgWJizd4ybsQa4hakBWBma-TYNXRyJYtAvqcU6TjK-zqtPRF4TqM-kLw0*", "96A2AM24676Z7M", "98867629f92bfc28c8fd8df662d74626", "https://redirect.ezbob.com"); this.restClient = new EchoSignRestClient(CurrentValues.Instance.EchoSignRefreshToken, CurrentValues.Instance.EchoSignClientId, CurrentValues.Instance.EchoSignClientSecret, CurrentValues.Instance.EchoSignRedirectUri); } // constructor
} // constructor public Schedule(DbDataReader row, ASafeLog log = null) : base(log) { ID = Convert.ToInt32(row["ItemID"]); Date = Convert.ToDateTime(row["ItemDate"]).Date; Principal = Convert.ToDecimal(row["Principal"]); IsAlreadyProcessed = row["ProcessedID"] != System.DBNull.Value; } // constructor
protected AStoredProc( AConnection oDB, ASafeLog oLog = null, CommandSpecies nSpecies = CommandSpecies.StoredProcedure ) : base(oDB, oLog, nSpecies) { } // constructor
public ReportDispatcher(AConnection oDB, ASafeLog oLog = null) : base(oLog) { m_oDropbox = new DropboxReportSaver(oDB, oLog); m_oDropbox.Init(); m_oSender = new BaseReportSender(oLog); } // constructor
} // FireToBackground protected void FireToBackground(string description, Action task, Action <Exception> onFailedToExecute = null) { if (task == null) { return; } string taskID = Guid.NewGuid() .ToString("N"); ASafeLog log = Log; log.Debug("Starting background task '{1}' with id '{0}'...", taskID, description); try { Task.Run(() => { try { task(); log.Debug("Background task '{1}' (id: '{0}') completed successfully.", taskID, description); } catch (Exception e) { log.Alert(e, "Background task '{1}' (id: '{0}') failed.", taskID, description); } // try }); } catch (Exception e) { Log.Alert(e, "Failed to fire task '{1}' (id: '{0}') to background.", taskID, description); if (onFailedToExecute != null) { onFailedToExecute(e); } } // try } // FireToBackground
public Agent( int nCustomerID, long?cashRequestID, long?nlCashRequestID, decimal nSystemCalculatedAmount, AutomationCalculator.Common.Medal nMedal, AutomationCalculator.Common.MedalType medalType, AutomationCalculator.Common.TurnoverType?turnoverType, AConnection oDB, ASafeLog oLog ) { DB = oDB; Log = oLog.Safe(); Args = new Arguments( nCustomerID, cashRequestID, nlCashRequestID, nSystemCalculatedAmount, nMedal, medalType, turnoverType ); this.caisAccounts = new List <ExperianConsumerDataCaisAccounts>(); } // constructor
} // Init public virtual void Init(ASafeLog log = null) { Log = log.Safe(); Env = new Ezbob.Context.Environment(Log); DB = new SqlConnection(Env, Log); Culture = CreateCultureInfo(); } // Init