} // class HistoryData public CustomerStatusHistory(int?nCustomerID, DateTime?oDateEnd, AConnection oDB) { if (oDB == null) { throw new NullReferenceException("No DB connection specified for loading CustomerStatusHistory."); } Data = new HistoryData(this); FullData = new HistoryData(this); m_oCurrent = new SortedDictionary <int, CustomerStatusChange>(); m_oDateEnd = oDateEnd; oDB.ForEachRowSafe( LoadCurrent, "LoadCustomerStatus", CommandSpecies.StoredProcedure, new QueryParameter("CustomerID", nCustomerID) ); oDB.ForEachRowSafe( LoadHistoryItem, "LoadCustomerStatusHistory", CommandSpecies.StoredProcedure, new QueryParameter("CustomerID", nCustomerID), new QueryParameter("DateEnd") ); } // 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."); }
} // LoadChildrenFromXml protected virtual bool SelfSave(AConnection oDB, ConnectionWrapper oPersistent) { try { oDB.ExecuteNonQuery( oPersistent, DBSaveProcName, CommandSpecies.StoredProcedure, oDB.CreateTableParameter( this.GetType(), "@Tbl", new List <AExperianLtdDataRow> { this }, TypeUtils.GetConvertorToObjectArray(this.GetType()), GetDBColumnTypes() ) ); return(true); } catch (Exception e) { Log.Warn(e, "Failed to save {0} to DB.", this.GetType().Name); return(false); } // try } // SelfSave
public ReportDispatcher(AConnection oDB, ASafeLog oLog = null) : base(oLog) { m_oDropbox = new DropboxReportSaver(oDB, oLog); m_oDropbox.Init(); m_oSender = new BaseReportSender(oLog); } // 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
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 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
} // Save private List <string> LoadColumns(AConnection oDB) { Debug("PayPointBalance.LoadColumns started..."); // List<string> oRes = (from DataRow row in tbl.Rows select row[0].ToString()).ToList(); /* * var oRes = new List<string>(); * * oDB.ForEachRowSafe((sr, bRowsetStart) => { * oRes.Add(sr[0]); * return ActionResult.Continue; * }, LoadColumnsStoredProc.Name, CommandSpecies.StoredProcedure); */ List <string> oRes = ( from SafeReader sr in oDB.ExecuteEnumerable(LoadColumnsStoredProc.Name, CommandSpecies.StoredProcedure) select(string) sr[0] ).ToList(); Info("{0} found.", Grammar.Number(oRes.Count, "count")); Debug("PayPointBalance.LoadColumns complete."); return(oRes); } // LoadColumns
} // DoAfterTheMainInsert protected override bool SelfSave(AConnection oDB, ConnectionWrapper oPersistent) { try { ExperianLtdDL65ID = oDB.ExecuteScalar <long>( oPersistent, DBSaveProcName, CommandSpecies.StoredProcedure, oDB.CreateTableParameter( this.GetType(), "@Tbl", new List <ExperianLtdDL65> { this }, TypeUtils.GetConvertorToObjectArray(this.GetType()), GetDBColumnTypes() ) ); } catch (Exception e) { Log.Warn(e, "Failed to save {0} to DB.", this.GetType().Name); ExperianLtdDL65ID = 0; } // try return(ExperianLtdDL65ID > 0); } // SelfSave
public LoadOfferRanges(int gradeRangeID, int productSubTypeID, AConnection db, ASafeLog log) : this(db, log) { this.workingMode = WorkingMode.SpecificRange; GradeRangeID = gradeRangeID; ProductSubTypeID = productSubTypeID; } // constructor
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
} // GetStatus public void Save(AConnection oDB) { foreach (ScheduleTransaction st in ScheduleTransactions) { st.Save(ID, ScheduleState, oDB); } } // Save
} // Init public virtual void Init(Ezbob.Context.Environment env, AConnection db, ASafeLog log) { Log = log; Env = env; DB = db; Culture = CreateCultureInfo(); } // Init
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 static SortedDictionary <string, Report> GetScheduledReportsList(AConnection oDB) { return(FillReportArgs(oDB, ReportListStoredProc, new QueryParameter("@RptType", "") )); } // GetScheduledReportsList
public void Init() { NHibernateManager.FluentAssemblies.Add(typeof(User).Assembly); NHibernateManager.FluentAssemblies.Add(typeof(Customer).Assembly); NHibernateManager.FluentAssemblies.Add(typeof(eBayDatabaseMarketPlace).Assembly); NHibernateManager.FluentAssemblies.Add(typeof(AmazonDatabaseMarketPlace).Assembly); NHibernateManager.FluentAssemblies.Add(typeof(PayPalDatabaseMarketPlace).Assembly); NHibernateManager.FluentAssemblies.Add(typeof(EkmDatabaseMarketPlace).Assembly); NHibernateManager.FluentAssemblies.Add(typeof(DatabaseMarketPlace).Assembly); NHibernateManager.FluentAssemblies.Add(typeof(YodleeDatabaseMarketPlace).Assembly); NHibernateManager.FluentAssemblies.Add(typeof(PayPointDatabaseMarketPlace).Assembly); NHibernateManager.FluentAssemblies.Add(typeof(FreeAgentDatabaseMarketPlace).Assembly); NHibernateManager.FluentAssemblies.Add(typeof(SageDatabaseMarketPlace).Assembly); NHibernateManager.FluentAssemblies.Add(typeof(CompanyFilesDatabaseMarketPlace).Assembly); Scanner.Register(); ObjectFactory.Configure(x => { x.For <ISession>().LifecycleIs(new ThreadLocalStorageLifecycle()).Use(ctx => NHibernateManager.SessionFactory.OpenSession()); x.For <ISessionFactory>().Use(() => NHibernateManager.SessionFactory); }); _Helper = ObjectFactory.GetInstance <IDatabaseDataHelper>() as DatabaseDataHelper; var oLog4NetCfg = new Log4Net().Init(); m_oLog = new ConsoleLog(new SafeILog(this)); m_oDB = new SqlConnection(oLog4NetCfg.Environment, m_oLog); ConfigManager.CurrentValues.Init(m_oDB, m_oLog); DbConnectionPool.ReuseCount = CurrentValues.Instance.ConnectionPoolReuseCount; AConnection.UpdateConnectionPoolMaxSize(CurrentValues.Instance.ConnectionPoolMaxSize); }
} // constructor public Report(AConnection oDB, string sReportTypeName) : this() { bool bFound = false; oDB.ForEachRowSafe( (sr, bRowsetStart) => { if (sr["Type"] == sReportTypeName) { Init(sr); bFound = true; } // if return(bFound ? ActionResult.SkipAll : ActionResult.Continue); }, ReportListStoredProc, CommandSpecies.StoredProcedure, new QueryParameter("@RptType", sReportTypeName) ); if (!bFound) { throw new Exception(string.Format("Report cannot be found by name {0}", sReportTypeName)); } List <ReportArg> args = LoadReportArgs(oDB, sReportTypeName); foreach (ReportArg row in args) { AddArgument(row.ArgumentName); } } // 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
public EBusinessService(AConnection oDB) { this.retryer = new SqlRetryer(log: log); this.eSeriesUrl = CurrentValues.Instance.ExperianESeriesUrl; this.db = oDB; } // constructor
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
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 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 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
} // constructor public virtual void Init() { PropertyInfo[] propertyInfos = GetType().GetProperties(); foreach (PropertyInfo pi in propertyInfos) { SupportedTypes ignored; bool bInclude = pi.GetGetMethod().IsVirtual&& pi.GetGetMethod().IsPublic&& (pi.GetSetMethod(true) != null) && SupportedTypes.TryParse(pi.PropertyType.Name, out ignored); if (bInclude) { configPropertyInfos.Add(pi.Name, pi); Debug("Configuration property to read from DB: {0}", pi.Name); } // if } // for each property Info("Reading configurations"); try { AConnection oDB = DbConnectionGenerator.Get(this); oDB.ForEachRow((row, bRowsetStart) => { AddSingleConfiguration(row[KeyFieldName].ToString(), row[ValueFieldName].ToString()); return(ActionResult.Continue); }, SpName); } catch (Exception e) { throw new ConfigurationBaseException("Error reading configurations.", e); } // try } // Init
} // RegisterGlobalFilters private void InitOnStart() { Init(); if (_isInitialized) { return; } lock (this) { if (_isInitialized) { return; } try { new Log4Net().Init(); Log.NotifyStart(); var db = DbConnectionGenerator.Get(Log); CurrentValues.Init( db, Log, oLimitations => oLimitations.UpdateWebSiteCfg("Ezbob.Web") ); DbConnectionPool.ReuseCount = CurrentValues.Instance.ConnectionPoolReuseCount; AConnection.UpdateConnectionPoolMaxSize(CurrentValues.Instance.ConnectionPoolMaxSize); RegisterGlobalFilters(GlobalFilters.Filters); } catch (Exception ex) { Log.Error(ex); throw; } // try _isInitialized = true; } // lock } // InitOnStart
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
} // Fetch private void Save(AConnection oDB, PayPointDataSet.TransactionDataTable tbl, List <string> aryColumns) { Debug("PayPointBalance.Save started..."); int nCurRowIdx = 0; foreach (PayPointDataSet.TransactionRow row in tbl.Rows) { QueryParameter[] args = aryColumns.Select(sName => { PropertyInfo pi = row.GetType().GetProperty(sName); var obj = pi.GetGetMethod().Invoke(row, null); if (sName == "date") { DateTime result; obj = DateTime.TryParse(obj.ToString(), out result) ? result : (DateTime?)null; } // if return(new QueryParameter("@" + sName, obj)); }).ToArray(); oDB.ExecuteNonQuery(InsertDataStoredProc.Name, CommandSpecies.StoredProcedure, args); Debug("Row {0} processing complete.", nCurRowIdx); nCurRowIdx++; } // foreach Debug("PayPointBalance.Save complete."); } // Save
public static List <AutoApproveInputRow> Load( AConnection oDB, int nTopCount, int nLastCheckedCustomerID ) { string sTop = (nTopCount > 0) ? "TOP " + nTopCount : string.Empty; string sCondition = (nLastCheckedCustomerID > 0) ? "AND mc.CustomerId < " + nLastCheckedCustomerID : string.Empty; const string sQueryFormat = @" SELECT {0} mc.CustomerId, MedalStr = mc.Medal, MedalTypeStr = mc.MedalType, TurnoverType = mc.InnerFlowName, ISNULL(mc.OfferedLoanAmount, 0) as OfferedLoanAmount FROM MedalCalculations mc WHERE mc.IsActive = 1 {1} ORDER BY mc.CustomerId DESC" ; return(oDB.Fill <AutoApproveInputRow>( string.Format(sQueryFormat, sTop, sCondition), CommandSpecies.Text )); } // Load
public SaveModelOutput( long responseID, Response <Reply> response, AConnection db, ASafeLog log ) : base(db, log) { if ((response == null) || !response.Parsed.HasInference()) { return; } Tbl = new List <DbModelOutput>(); ModelNames[] allModelNames = (ModelNames[])Enum.GetValues(typeof(ModelNames)); foreach (ModelNames name in allModelNames) { var model = response.Parsed.GetParsedModel(name); if (model != null) { Tbl.Add(Create(responseID, name, model)); } } // for each model name } // constructor
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
/** * ## Lifetimes * * If you are using an IOC container its always useful to know the best practices around the lifetime of your objects * In general we advise folks to register their ElasticClient instances as singleton. The client is thread safe * so sharing this instance over threads is ok. * Zooming in however the actual moving part that benefits the most of being static for most of the duration of your * application is ConnectionSettings. Caches are per ConnectionSettings. * In some applications it could make perfect sense to have multiple singleton IElasticClient's registered with different * connectionsettings. e.g if you have 2 functionally isolated Elasticsearch clusters. */ [U] public void InitialDisposeState() { var connection = new AConnection(); var connectionPool = new AConnectionPool(new Uri("http://localhost:9200")); var settings = new AConnectionSettings(connectionPool, connection); settings.IsDisposed.Should().BeFalse(); connectionPool.IsDisposed.Should().BeFalse(); connection.IsDisposed.Should().BeFalse(); }
/** * Disposing the ConnectionSettings will dispose the IConnectionPool and IConnection it has a hold of */ [U] public void DisposingSettingsDisposesMovingParts() { var connection = new AConnection(); var connectionPool = new AConnectionPool(new Uri("http://localhost:9200")); var settings = new AConnectionSettings(connectionPool, connection); using (settings) { } settings.IsDisposed.Should().BeTrue(); connectionPool.IsDisposed.Should().BeTrue(); connection.IsDisposed.Should().BeTrue(); }