Exemplo n.º 1
0
        /// <summary>
        /// 新增优惠券
        /// </summary>
        /// <param name="maxProductID"></param>
        private static void Add(int maxID, ISqlBLL iBLL, IMySqlBLL iMysqlBLL, string tbName)
        {
            int       errorCount = 0;
            DataTable dTable     = null;
            int       errorSum   = 0;
            int       sucessSum  = 0;

            while (true)
            {
                //  查询新数据
                dTable = iBLL.GetAddList(maxID, Program.UpdateTime, Program.UpdateMaxCount, tbName);
                if (dTable == null || dTable.Rows.Count <= 0)
                {
                    break;
                }
                //  保存
                if (!iMysqlBLL.Add(dTable, out errorCount))
                {
                    errorSum += errorCount;
                    Console.WriteLine(string.Format("{0} 表总共需添加 {1} 条数据,失败:{2}", tbName, dTable.Rows.Count, errorCount));
                }
                else
                {
                    sucessSum += dTable.Rows.Count;
                    Console.WriteLine(string.Format("{0} 表已添加 {1} 条数据", tbName, sucessSum));
                }
                maxID = Convert.ToInt32(dTable.Rows[dTable.Rows.Count - 1][GetTbIDStrByTbName(tbName)]);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 订单相关表数据更新
        /// </summary>
        /// <param name="maxID">最大ID</param>
        /// <param name="iBLL"></param>
        /// <param name="iMysqlBLL"></param>
        /// <param name="tbName"></param>
        /// <param name="flag">更新3个月之前数据还是最近3个月的数据,3个月之前 - true,最近3个月 - false</param>
        private static void AddOrders(int maxID, ISqlBLL iBLL, IMySqlBLL iMysqlBLL, string tbNameAll, string tbName, bool flag)
        {
            int       errorCount = 0;
            DataTable dTable     = null;
            int       errorSum   = 0;
            int       sucessSum  = 0;
            string    msg        = string.Empty;
            string    msgError   = string.Empty;

            if (flag)
            {
                msg      = "{0}表往相应的历史库已添加 {1} 条数据";
                msgError = "{0} 表往相应的历史库总共需添加 {1} 条数据,失败数:{2}";
            }
            else
            {
                msg      = "{0}表往相应的库已添加 {1} 条数据";
                msgError = "{0} 表往相应的库总共需添加 {1} 条数据,失败数:{2}";
            }
            while (true)
            {
                //  查询新数据
                dTable = iBLL.GetAddList(maxID, Program.UpdateTime, Program.UpdateMaxCount, tbNameAll);
                if (dTable == null || dTable.Rows.Count <= 0)
                {
                    break;
                }
                //  保存
                if (!iMysqlBLL.Add(dTable, out errorCount))
                {
                    errorSum += errorCount;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(string.Format(msgError, tbName, dTable.Rows.Count, errorCount));
                }
                else
                {
                    sucessSum += dTable.Rows.Count;
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine(string.Format(msg, tbName, sucessSum));
                }
                maxID = Convert.ToInt32(dTable.Rows[dTable.Rows.Count - 1][GetTbIDStrByTbName(tbName)]);
            }
        }