Beispiel #1
0
        public List <SmsMobileModel> GetUnknowList(string eprid, string userid, string y, string m, string d)
        {
            List <SmsMobileModel> list = new List <SmsMobileModel>();

            try
            {
                DateTime dt        = DateTime.Now;
                string   begintime = y + "-" + m + "-" + d;   //开始时间
                string   endtime   = begintime + " 23:59:59"; //结果时间
                object[] obj       = { begintime, endtime, eprid, userid };
                string   sql       = string.Format("select Id, [CLIENTMSGID] from TBL_SMS_MOBILES where    SendTime SENDTIME '{0}' and '{1}' and EprId={2}  and UserId='{3}' and [RESULT]=1 and [STATUS]=3 order by Id ", obj);
                using (MySqlDataReader sdr = MySqlHelper.ExecuteReader(MySqlHelper.ConnectionstringLocalTransaction, CommandType.Text, sql, null))
                {
                    while (sdr.Read())
                    {
                        SmsMobileModel smm = new SmsMobileModel();
                        smm.id          = sdr.GetInt32(0);
                        smm.clientMsgId = sdr.GetString(1);
                        list.Add(smm);
                    }
                }
                MyDelegateFunc.WriteFmLog("SmsMobileDAL=>GetUnknowList:SQL:" + sql + ",耗时:" + (DateTime.Now - dt).TotalMilliseconds + "毫秒");
            }
            catch (Exception ex)
            {
                MyDelegateFunc.WriteFmLog("SmsMobileDAL=>GetUnknowList:Exception:" + ex.ToString());
            }

            return(list);
        }
Beispiel #2
0
        private SmsMobileModel FillData(SqlDataReader sdr)
        {
            SmsMobileModel m = new SmsMobileModel();

            m.mobile   = sdr.GetString(0);
            m.smsCount = sdr.GetInt32(1);
            m.sendTime = sdr.GetDateTime(2);
            return(m);
        }
        private void MyWork()
        {
            //37805-30244
            SmsMobileDAL smdal     = new SmsMobileDAL();
            int          cn        = smdal.GetUnknowCount(_cm.EprId, _cm.UserId, _cm.Year, _cm.Month, _cm.Day);
            int          thisCount = (int)Math.Ceiling(cn * _cm.Rate);

            if (times == 1)
            {
                totalCount = thisCount;
                times      = 2;
            }
            _cm.WriteStatus("未知数量共" + cn + "条,处理数量:" + totalCount);
            _cm.WriteFmLog("未知数量共" + cn + "条,处理数量:" + totalCount);
            if (cn > 0 && alreadyChangeCount < totalCount)
            {
                List <SmsMobileModel> list = smdal.GetUnknowList(_cm.EprId, _cm.UserId, _cm.Year, _cm.Month, _cm.Day);
                if (list != null && list.Count > 0)
                {
                    List <string> sqlList = new List <string>();//sql语句
                    int           min     = list[0].id;
                    int           max     = list[list.Count - 1].id;
                    Random        rnd     = new Random();
                    for (int i = 0; i < list.Count; i++)
                    {
                        try
                        {
                            int ii = rnd.Next(0, list.Count);
                            // if (i % 2 == 0)
                            //  {
                            SmsMobileModel sm  = list[ii];
                            string         sql = string.Format("update t_smsmobile set ReportStatus=2 where Id={0} and EprId='{1}'", sm.id, _cm.EprId);
                            sqlList.Add(sql);
                            alreadyChangeCount++;
                            if (alreadyChangeCount > totalCount)
                            {
                                break;
                            }

                            // }
                        }
                        catch (Exception)
                        {
                        }
                    }//for


                    if (sqlList.Count > 0)
                    {
                        List <string> tmpList = new List <string>();
                        for (int j = 0; j < sqlList.Count; j++)
                        {
                            tmpList.Add(sqlList[j]);
                            if (tmpList.Count == 500 || j == sqlList.Count - 1)
                            {
                                bool b = smdal.UpdateUnknowReportStatus(tmpList);
                                _cm.WriteFmLog("已执行:" + tmpList.Count + "条,结果:" + b);
                                tmpList = new List <string>();
                            }
                        }
                    }
                }//if
            }
        }