public ReceiveStatusFromTCatMgr(string connectionString)
 {
     logisticsTcatSodDao = new LogisticsTcatSodDao(connectionString);
     _accessMySql = DBFactory.getDBAccess(DBType.MySql, connectionString);
     mySqlConnectionString = connectionString;
 }
Esempio n. 2
0
        public bool Start(string schedule_code,DateTime startTime)
        {

            DeliverStatusDao dsDao = new DeliverStatusDao(mySqlConnectionString);
           // DateTime startTime = DateTime.Now;
            string HourNum = string.Empty;
            MailModel mailModel = new MailModel();
            mailModel.MysqlConnectionString = mySqlConnectionString;

            string GroupCode = string.Empty;
            string MailTitle = string.Empty;
            string MailBody = string.Empty;
            //bool IsSeparate = false;
            //bool IsDisplyName = true;
            //獲取該排程參數
            List<ScheduleConfigQuery> store_config = new List<ScheduleConfigQuery>();
            ScheduleConfigQuery query_config = new ScheduleConfigQuery();
            query_config.schedule_code = schedule_code;
            ScheduleServiceMgr _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString);
            store_config = _secheduleServiceMgr.GetScheduleConfig(query_config);
            foreach (ScheduleConfigQuery item in store_config)
            {
                if (item.parameterCode.Equals("HourNum"))
                {
                    HourNum = item.value;
                }
                else if (item.parameterCode.Equals("MailFromAddress"))
                {
                    mailModel.MailFromAddress = item.value;
                }
                else if (item.parameterCode.Equals("MailHost"))
                {
                    mailModel.MailHost = item.value;
                }
                else if (item.parameterCode.Equals("MailPort"))
                {
                    mailModel.MailPort = item.value;
                }
                else if (item.parameterCode.Equals("MailFromUser"))
                {
                    mailModel.MailFromUser = item.value;
                }
                else if (item.parameterCode.Equals("MailFormPwd"))
                {
                    mailModel.MailFormPwd = item.value;
                }
                else if (item.parameterCode.Equals("GroupCode"))
                {
                    GroupCode = item.value;
                }
                else if (item.parameterCode.Equals("MailTitle"))
                {
                    MailTitle = item.value;
                }
                else if (item.parameterCode.Equals("MailTitle"))
                {
                    MailTitle = item.value;
                }
                else if (item.parameterCode.Equals("MailBody"))
                {
                    MailBody = item.value;
                }
            }
            IDeliverMasterImplMgr DeliverMaster = new DeliverMasterMgr(mySqlConnectionString);
            DataTable table = DeliverMaster.GetDeliverMaster(HourNum);
            int delNumber = table.Rows.Count;
            int updateNumber = 0;
            if (delNumber > 0)
            {
                DeliveryInfo Model;
                LogisticsTcatSodDao LTSDao=new LogisticsTcatSodDao(mySqlConnectionString);
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    table.Rows[i]["gettime"] = "";
                    Model =LTSDao.GetLogisticsTcatSod(table.Rows[i]["delivery_code"].ToString());
                    if (Model.Status == "順利送達")
                    {
                        table.Rows[i]["gettime"] = Model.CreateTime;
                        updateNumber++;
                        DeliverStatus dsmodel = new DeliverStatus();

                        dsmodel.freight_type = 11;//物流配送模式
                        dsmodel.Logistics_providers = 1;//物流商
                        dsmodel.deliver_id = Int64.Parse(table.Rows[i]["deliver_id"].ToString());
                        dsmodel.state = 99;
                        dsmodel.settime = Model.CreateTime;
                        dsmodel.endtime = Model.CreateTime;
                        dsDao.InsertDeliverStatus(dsmodel);
                    }
                }
            }
            DateTime endTime = DateTime.Now;
            TimeSpan ts = endTime - startTime;
            double Second = ts.TotalSeconds;
            int num1 = 0;//期望到貨日<運達時間的物流單個數
            int num2 = 0;//期望到貨日>今天的物流單個數
            MailHelper mail = new MailHelper(mailModel);
            StringBuilder sbmailBody = new StringBuilder();
            string tablestr = GetHtmlByDataTable(GetSendTable(table), out num1, out num2);
            sbmailBody.Append("物流狀態抓取排程執行成功<br/>");
            sbmailBody.Append("更新<span style=\"font-size:large;\">" + delNumber + "</span>個出貨單<br/>");
            sbmailBody.Append("更新<span style=\"font-size:large;\">" + updateNumber + "</span>個物流單<br/>");
            sbmailBody.Append("期望到貨日小於運達時間的物流單個數:<span style=\"font-size:large;\">" + num1 + "</span><br/>");
            sbmailBody.Append("期望到貨日小於今天的物流單個數:<span style=\"font-size:large;\">" + num2 + "</span><br/>");
            sbmailBody.Append("共耗時<span style=\"font-size:large;\">" + Second + "</span>秒<br/>");
            sbmailBody.Append("更新出貨單詳情如下:<br/><br/>");
            sbmailBody.Append(tablestr);
            return mail.SendToGroup(GroupCode, MailTitle,sbmailBody.ToString(), false, true);
        }