private Dictionary <string, int> getProcessors()
        {
            Dictionary <string, int> processorList = new Dictionary <string, int>();
            //query list for mySql
            List <MySqlCommand> queries = new List <MySqlCommand>();
            //String timestamp =
            db_connect connection = new db_connect();

            connection.connect();
            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection = connection.getConnection();

            cmd.CommandText = string.Format("SELECT id, name FROM e_processors");

            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                processorList.Add(reader.GetString(1), reader.GetInt32(0));
            }
            reader.Close();

            return(processorList);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            log.Info("Starting Report Application...");
            DateTime timestamp = DateTime.Now;


            List <String> reports = new List <String> {
                "Funded Report",
                "Not Purchased Report",
                "Not CTC Report < 60 days",
                "Processors Report",
                "Locked for Files CTC, Not Funded Report",
                "Funded w/o Investor Lock Report",
                "Accounting Report for Current Month",
                "db testing",
                "db update: 'My Pipeline'",
                "db update: 'Completed Loans'",
                "db update: 'Servicing'",
                "db update: 'Adverse'",
                "db update: ALL"
            };

            parseArgs(args);
            new EllieMae.Encompass.Runtime.RuntimeServices().Initialize();

            if (args.Length == 0)
            {
                debug = true;
                Console.Out.WriteLine("----------------------");
                Console.Out.WriteLine("Select report to run:");
                for (int i = 0; i < reports.Count; i++)
                {
                    Console.Out.WriteLine(i + " " + reports[i]);
                }
                Console.Out.WriteLine("----------------------");
                int input = Int32.Parse(Console.In.ReadLine());
                report = input;
                Console.Out.WriteLine("Selection: " + reports[input]);
            }
            else
            {
                debug = false;
            }
            String text = null;

            mySession = new SessionManager();

            log.Info("Encompass Session begin");
            switch (report)
            {
            case 0:
                FundedReport report1 = new FundedReport();
                text = report1.run();
                outputReport(reports[report], text);
                break;

            case 1:
                NotPurchasedReport report2 = new NotPurchasedReport();
                text = report2.run();
                outputReport(reports[report], text);
                break;

            case 2:
                NotCTCReport report3 = new NotCTCReport();
                text = report3.run();
                outputReport(reports[report], text);
                break;

            case 3:
                ProcessorsReport report4 = new ProcessorsReport();
                text = report4.run();
                outputReport(reports[report], text);
                break;

            case 4:
                Locks4CTCNotFundedReport report5 = new Locks4CTCNotFundedReport();
                text = report5.run();
                outputReport(reports[report], text);
                break;

            case 5:
                FundedNotLockedReport report6 = new FundedNotLockedReport();
                text = report6.run();
                outputReport(reports[report], text);
                break;

            case 6:
                Accounting report7 = new Accounting();
                text = report7.run();
                outputReport(reports[report], text);
                break;

            case 7:
                db.db_connect connection = new db.db_connect();
                connection.connect();
                log.Debug("everything working");
                connection.close();
                break;

            case 8:
                db.EncompassUpdate update = new db.EncompassUpdate();
                update.run(report);
                break;

            case 9:
                db.EncompassUpdate update1 = new db.EncompassUpdate();
                update1.run(report);
                break;

            case 10:
                db.EncompassUpdate update2 = new db.EncompassUpdate();
                update2.run(report);
                break;

            case 11:
                db.EncompassUpdate update3 = new db.EncompassUpdate();
                update3.run(report);
                break;

            case 12:
                db.EncompassUpdate updateAll = new db.EncompassUpdate();
                updateAll.run(8);
                updateAll.run(9);
                updateAll.run(10);
                updateAll.run(11);
                updateAll.run(12);
                break;

            default:
                log.Error("No report chosen");
                break;
            }
            log.Info("Encompass session closing..");
            mySession.closeSession();

            TimeSpan time = DateTime.Now.Subtract(timestamp);

            log.Info("Report Application Finished in " +
                     String.Format("{0} min {1}.{2} sec"
                                   , time.Minutes
                                   , time.Seconds
                                   , time.Milliseconds));
            //log.Info("Report Application Finished!");
        }
        private void startApplication()
        {
            log.Debug("Program running...");

            //setup folder query
            StringFieldCriterion folderCri = selectLoanFolder();

            //execute encompass query
            LoanReportCursor results = encompassQueryBuilder(folderCri);
            int total = results.Count;
            int count = 0;

            log.Info("Total Files: " + total);


            //query list for mySql
            //List<MySqlCommand> queries = new List<MySqlCommand>();

            log.Debug("connecting to MySQL...");
            db_connect connection = new db_connect();

            connection.connect();
            log.Debug("connected to MySQL");
            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection = connection.getConnection();


            foreach (LoanReportData data in results)
            {
                Dictionary <String, String> map = dbQueryBuilder(data);

                /*cmd.CommandText = string.Format(
                 *  "INSERT INTO loans(guid, investor, investorNum, createdAt, b1_lname, b1_fname, loanAmt, loanNum, fundedDate, processor, loan_officer, purchasedDate) " +
                 *  "values(@v1, @v2, @v3, @createdAt, @v4, @v5, @v6, @v7, @v8, @v9, @v10, " +
                 *  "@v11, @currMilestone) " +
                 *  "ON DUPLICATE KEY UPDATE guid=@v1, investor=@v2, investorNum=@v3, updatedAt=@updatedAt, b1_lname=@v4, b1_fname=@v5, "+
                 *  "loanAmt=@v6, loanNum=@v7, fundedDate=@v8, processor=@v9, loan_officer=@v10, " +
                 *  "purchasedDate=@v11"
                 *  );*/

                var now = timestamp.ToString("yyyy - MM - dd HH: mm:ss");


                StringBuilder insert = new StringBuilder();
                insert.Append("INSERT INTO loans(guid, createdAt, loanFolder ");
                //cols
                foreach (String key in map.Keys)
                {
                    insert.Append(", " + key);
                }
                //values
                insert.Append(") ");
                StringBuilder values = new StringBuilder();
                values.Append("VALUES('" + data.Guid + "', '" + now + "', '" + folderCri.Value + "'");
                foreach (String key in map.Keys)
                {
                    if (map[key] != null)
                    {
                        values.Append(", '" + MySqlHelper.EscapeString(" " + map[key]) + "'");
                    }
                    else
                    {
                        values.Append(", NULL");
                    }
                }
                values.Append(") ");
                StringBuilder update2 = new StringBuilder();
                update2.Append("ON DUPLICATE KEY UPDATE updatedAt='" + now + "', loanFolder='" + folderCri.Value + "'");
                foreach (String key in map.Keys)
                {
                    if (map[key] != null)
                    {
                        update2.Append(", " + key + "='" + MySqlHelper.EscapeString(" " + map[key]) + "'");
                    }
                    else
                    {
                        update2.Append(", " + key + "=NULL");
                    }
                }

                //mysql command
                cmd.CommandText = insert.ToString() + values.ToString() + update2.ToString();

                /* cmd.Parameters.Clear();
                 * cmd.Parameters.AddWithValue("@v1", data.Guid);
                 * cmd.Parameters.AddWithValue("@v2", map["investor"]);
                 * cmd.Parameters.AddWithValue("@v3", map["investorNum"]);
                 * cmd.Parameters.AddWithValue("@createdAt", timestamp.ToString("yyyy-MM-dd HH:mm:ss"));
                 * cmd.Parameters.AddWithValue("@updatedAt", timestamp.ToString("yyyy-MM-dd HH:mm:ss"));
                 * cmd.Parameters.AddWithValue("@v4", map["b1_lname"]);
                 * cmd.Parameters.AddWithValue("@v5", map["b1_fname"]);
                 * cmd.Parameters.AddWithValue("@v6", map["loanAmt"]);
                 * cmd.Parameters.AddWithValue("@v7", map["loanNum"]);
                 * cmd.Parameters.AddWithValue("@v8", map["fundedDate"]);
                 * cmd.Parameters.AddWithValue("@v9", map["processor"]);
                 * cmd.Parameters.AddWithValue("@v10", map["loanOfficer"]);
                 * cmd.Parameters.AddWithValue("@v11", map["purchasedDate"]);
                 * cmd.Prepare();*/

                cmd.ExecuteNonQuery();

                //status output
                count++;
                if (count % 10 == 0)
                {
                    Console.Write("\r{0}   ", "writing: " + count + "/" + total);
                }
            }
            Console.Out.WriteLine("");
            results.Close();

            TimeSpan time = DateTime.Now.Subtract(timestamp);

            /*connection.addLog("db_update", "updated: " + folderCri.Value + total + " rows in " +
             *  String.Format("{0} min {1}.{2} sec"
             *      , time.Minutes
             *      , time.Seconds
             *      , time.Milliseconds) );*/

            connection.close();

            log.Info("Finished updating db in " +
                     String.Format("{0} min {1}.{2} sec"
                                   , time.Minutes
                                   , time.Seconds
                                   , time.Milliseconds));
        }