示例#1
0
        }         // constructor

        public override void Execute()
        {
            Prerequisite();

            List <SourceData> lst = DB.Fill <SourceData>(LoadSourceQuery, CommandSpecies.Text);

            var pc = new ProgressCounter("{0} of " + lst.Count + " history items processed.", Log, 100);

            foreach (SourceData sd in lst)
            {
                if (!this.types.ContainsKey(sd.InternalId))
                {
                    Log.Alert("Unexpected marketplace type internal id: {0}", sd.InternalId);
                    pc++;
                    continue;
                }                 // if

                ServiceInfo si = this.types[sd.InternalId];
                Log.Info("Start to update for {0} with history id {1}...", si.Info.DisplayName, sd.Id);

                try {
                    DB.ExecuteNonQuery(si.SpName, CommandSpecies.StoredProcedure, new QueryParameter("HistoryID", sd.Id));
                    Log.Info("End to update for {0} with history id {1} completed.", si.Info.DisplayName, sd.Id);
                } catch (Exception ex) {
                    Log.Warn(ex, "Update for {0} with history id {1} failed.", si.Info.DisplayName, sd.Id);
                }                 // try

                pc++;
            }             // for each

            pc.Log();
        }         // Execute
示例#2
0
        }         // constructor

        private void Run()
        {
            m_oEventsProgress = new ProgressCounter("{0} user events processed.", m_oLog, 100);
            m_oDB.ForEachRow(
                SaveEvent,
                Query(true),
                CommandSpecies.Text
                );
            m_oEventsProgress.Log();

            m_oAddressProgress = new ProgressCounter("{0} address events processed.", m_oLog, 100);
            m_oDB.ForEachRow(
                ProcessAddress,
                Query(false),
                CommandSpecies.Text
                );
            m_oAddressProgress.Log();

            m_oLog.Info("Last known events - begin:");
            foreach (string s in m_oLastKnown)
            {
                m_oLog.Info(s);
            }
            m_oLog.Info("Last known events - end");
        }         // Run
示例#3
0
        }         // ExtractAndProcess

        private void ProcessFileContent(StreamReader rdr, DateTime time)
        {
            var pc = new ProgressCounter("{0} lines processed.", this.log, 25000UL);

            for ( ; ;)
            {
                string line = rdr.ReadLine();

                if (line == null)
                {
                    break;
                }

                ProcessLine(line, time);
                pc.Next();
            }             // for

            pc.Log();

            rdr.Dispose();
        }         // ProcessFileContent
示例#4
0
        }         // Name

        public override void Execute()
        {
            this.loanSources.Clear();
            this.crLoans.Clear();
            this.defaultCustomers.Clear();

            DB.ForEachRowSafe(
                srdc => defaultCustomers.Add(srdc["CustomerID"]),
                "LoadDefaultCustomers",
                CommandSpecies.StoredProcedure
                );

            DB.ForEachResult <LoanMetaData>(
                lmd => {
                if (this.crLoans.ContainsKey(lmd.CashRequestID))
                {
                    this.crLoans[lmd.CashRequestID].Add(lmd);
                }
                else
                {
                    this.crLoans[lmd.CashRequestID] = new List <LoanMetaData> {
                        lmd
                    }
                };

                this.loanSources.Add(lmd.LoanSourceName);
            },
                "LoadAllLoansMetaData",
                CommandSpecies.StoredProcedure
                );

            string top = (topCount > 0) ? "TOP " + topCount : string.Empty;

            string condition = (lastCheckedID > 0)
                                ? "AND r.Id < " + lastCheckedID
                                : string.Empty;

            this.data.Clear();

            DB.ForEachRowSafe(
                ProcessRow,
                string.Format(QueryTemplate, top, condition),
                CommandSpecies.Text
                );

            var pc = new ProgressCounter("{0} cash requests processed.", Log, 50);

            foreach (Datum d in this.data)
            {
                d.IsDefault = defaultCustomers.Contains(d.CustomerID);
                bool isHomeOwner = IsHomeOwner(d.CustomerID);

                d.CheckAutoReject(DB, Log);

                d.AutoThen.Calculate(d.CustomerID, isHomeOwner, DB, Log);
                d.AutoNow.Calculate(d.CustomerID, isHomeOwner, DB, Log);

                pc++;
            }             // for

            pc.Log();

            var lst = new List <string>();

            Log.Debug("Output data - begin:");

            foreach (Datum d in this.data)
            {
                Log.Debug("{0}", d);

                lst.Add(d.ToCsv(crLoans, loanSources));
            }             // for each

            Log.Debug("Output data - end.");

            Log.Debug(
                "\n\nCSV output - begin:\n{0}\n{1}\nCSV output - end.\n",
                Datum.CsvTitles(loanSources),
                string.Join("\n", lst)
                );
        }         // Execute
示例#5
0
        static void Main(string[] args)
        {
            using (var oLog = new FileLog(oLog: new ConsoleLog())) {
                // var oEnv = new Ezbob.Context.Environment(Name.Dev, "alexbo", oLog: oLog);
                var oEnv = new Ezbob.Context.Environment(Name.Production, oLog: oLog);

                var oDB = new SqlConnection(oEnv, oLog);

                var oLoans = new SortedDictionary <int, Loan>();

                var oProgress = new ProgressCounter("{0} transaction entries processed.", oLog, 64);

                oDB.ForEachRow(
                    (oReader, bRowsetStart) => {
                    int nLoanID = Convert.ToInt32(oReader["LoanID"]);

                    if (oLoans.ContainsKey(nLoanID))
                    {
                        oLoans[nLoanID].Transactions.Add(new Transaction(oReader, oLog));
                    }
                    else
                    {
                        oLoans[nLoanID] = new Loan(oReader, oLog);
                    }

                    oProgress++;

                    return(ActionResult.Continue);
                },
                    GetQuery("Transactions")
                    );

                oProgress.Log();

                oProgress = new ProgressCounter("{0} schedule entries processed.", oLog, 64);

                oDB.ForEachRow(
                    (oReader, bRowsetStart) => {
                    int nLoanID = Convert.ToInt32(oReader["LoanID"]);

                    if (oLoans.ContainsKey(nLoanID))
                    {
                        var oSh = new Schedule(oReader, oLog);
                        oLoans[nLoanID].Actual.Add(oSh);
                    }                             // if

                    oProgress++;

                    return(ActionResult.Continue);
                },
                    GetQuery("Schedule")
                    );

                oProgress.Log();

                oLog.Msg("Loans status:");

                var oStateStat = new SortedDictionary <ScheduleState, int>();

                foreach (Loan l in oLoans.Values)
                {
                    if (!Loan.Step2.Contains(l.ID))
                    {
                        continue;
                    }

                    if (l.ProcessedTransactionCount == l.Transactions.Count)
                    {
                        continue;
                    }

                    l.BuildWorkingSet();

                    l.Calculate();

                    oLog.Msg("{0}", l.ToString());

                    if (oStateStat.ContainsKey(l.ScheduleState))
                    {
                        oStateStat[l.ScheduleState]++;
                    }
                    else
                    {
                        oStateStat[l.ScheduleState] = 1;
                    }

                    l.Save(oDB);
                }                 // for each loan

                double nTotal = (double)oStateStat.Values.Sum();

                foreach (KeyValuePair <ScheduleState, int> pair in oStateStat)
                {
                    oLog.Msg("Status {0}: {1} loans = {2}", pair.Key, pair.Value, ((double)pair.Value / nTotal).ToString("p2"));
                }
            }     // using log file
        }         // Main
示例#6
0
        }         // FillTitle

        private void LoadCashRequests()
        {
            Msg("Loan Stats: loading cash requests...");

            Data = new SortedDictionary <int, List <LoanStatsDataEntry> >();

            Debug("Loan Stats: processing raw data...");

            var oCounter = new ProgressCounter("Loan Stats: {0} rows processed", this);

            LoanStatsDataEntry oCurrent = null;

            m_oDB.ForEachRowSafe(
                (sr, bRowsetStart) => {
                if (oCurrent == null)
                {
                    oCurrent = CreateEntry(sr);
                }
                else
                {
                    int nCustomerID = sr["CustomerID"];

                    if (oCurrent.CustomerID == nCustomerID)
                    {
                        oCurrent.Update(sr);
                    }
                    else
                    {
                        oCurrent = CreateEntry(sr);
                    }
                }                         // if

                if (oCurrent.LoanID != 0)
                {
                    oCurrent = null;
                }

                ++oCounter;

                return(ActionResult.Continue);
            },
                "RptLoanStats_CashRequests",
                CommandSpecies.StoredProcedure
                );

            oCounter.Log();

            Debug("Loan Stats: processing raw data complete.");

            foreach (KeyValuePair <int, List <LoanStatsDataEntry> > pair in Data)
            {
                int num = 1;

                foreach (LoanStatsDataEntry lse in pair.Value)
                {
                    lse.LoanSeqNo = num;
                    ++num;
                }         // for
            }             // for

            Msg("Loan Stats: loading cash requests complete.");
        }         // LoadCashRequests