Beispiel #1
0
            public void start()
            {
                var accounts = AccountBLL.GetAllAccount();

                AccountBLL.UpdateUseState();
                var iHour = DateTime.Now.Hour;

                foreach (DataRow dr in accounts.Rows)
                {
                    // Task.Factory.StartNew(() =>
                    //  {
                    int contentNum = 0;
                    if (AutoWeb.isSend(dr, ref contentNum, iHour))
                    {
                        string useid      = dr["id"].ToString();
                        string webGroupId = dr["id1"].ToString();
                        int    context    = int.Parse(dr["groupCount"].ToString());
                        var    task       = AutoWeb.GetWebSiteAwaitTask(webGroupId);
                        task.Wait();
                        if (task != null && task.Result != null && task.Result.Rows.Count > 0)
                        {
                            var hostDataTable = task.Result;
                            AutoWeb.AutoWebSit(contentNum, useid, hostDataTable, iHour, webGroupId, context);
                        }
                    }
                    //  });
                }
                //aTimer.Elapsed += new ElapsedEventHandler(TimedEvent);
                //aTimer.Interval = 1000;    //配置文件中配置的秒数
                //aTimer.Enabled = true;
            }
Beispiel #2
0
            /// <summary>
            /// 售后服务单状态及物流更新
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void TimedEvent(object sender, ElapsedEventArgs e)
            {
                int iHour   = e.SignalTime.Hour;
                int iMinute = e.SignalTime.Minute;

                aTimer.Enabled = false;
                try
                {
                    var accounts = AccountBLL.GetAllAccount();
                    if (iHour == 1 && iMinute == 30)
                    {
                        AccountBLL.UpdateUseState();
                    }
                    foreach (DataRow dr in accounts.Rows)
                    {
                        // Task.Factory.StartNew(() =>
                        //  {
                        int contentNum = 0;
                        if (AutoWeb.isSend(dr, ref contentNum, iHour))
                        {
                            string useid      = dr["id"].ToString();
                            string webGroupId = dr["id1"].ToString();
                            int    context    = int.Parse(dr["groupCount"].ToString());
                            var    task       = AutoWeb.GetWebSiteAwaitTask(webGroupId);
                            task.Wait();
                            if (task != null && task.Result != null)
                            {
                                var hostDataTable = task.Result;
                                AutoWeb.AutoWebSit(contentNum, useid, hostDataTable, iHour, webGroupId, context);
                            }
                        }
                        //  });
                    }
                }
                catch (Exception ex)
                {
                    LogWrite.Write("自动发布" + ex.Message);
                }
                finally
                {
                    aTimer.Enabled = true;
                }
            }