Ejemplo n.º 1
0
        public void Execute(object sender, DateTime dtBegin, DateTime dtEnd, ExceptionEventHandler handler)
        {
            if (!Enabled)
            {
                return;
            }

            var listEvent = new List <Object>();

            Schedule.AddEventsInInterval(dtBegin, dtEnd, listEvent);

            if (Filter != null)
            {
                Filter.FilterResultsInInterval(dtBegin, dtEnd, listEvent);
            }

            foreach (DateTime EventTime in listEvent)
            {
                if (IsSyncronized)
                {
                    _ExecuteHandler(sender, EventTime, handler);
                }
                else
                {
                    _ExecuteHandler.BeginInvoke(sender, EventTime, handler, null, null);
                }
            }
        }
Ejemplo n.º 2
0
        public void Execute(object sender, DateTime Begin, DateTime End, ExceptionEventHandler Error)
        {
            if (!Enabled)
            {
                return;
            }

            ArrayList EventList = new ArrayList();

            Schedule.AddEventsInInterval(Begin, End, EventList);

            if (Filter != null)
            {
                Filter.FilterResultsInInterval(Begin, End, EventList);
            }

            foreach (DateTime EventTime in EventList)
            {
                if (SyncronizedEvent)
                {
                    _executeHandler(sender, EventTime, Error);
                }
                else
                {
                    _executeHandler.BeginInvoke(sender, EventTime, Error, null, null);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 执行
        /// </summary>
        protected virtual void ExecuteTasks()
        {
            var infos = GetTaskEntitys();

            if (infos == null || infos.Count == 0)
            {
                return;
            }
            var handler = new ExecuteHandler(Execute);

            foreach (var info in infos)
            {
                handler.BeginInvoke(info, null, null);
            }
        }
Ejemplo n.º 4
0
        public void runcheckStripButton_Click(object sender, EventArgs e)
        {
            if ((this.ActiveDocument != null) && File.Exists(this.ActiveDocument.FilePath))
            {
                if (!runcheckStripButton.Enabled)
                {
                    return;
                }

                PageResult pageresult = null;
                string     filepath   = ActiveDocument.FilePath;
                string     xml        = ActiveDocument.Scintilla.Text;

                this.runcheckStripButton.Enabled   = false;
                this.progressStripStatusLabel.Text = "检测中,请稍后 ...";
                this.outputPanel.ClearResult();

                ExecuteHandler handler = (obj, args) =>
                {
                    string remark = "";
                    try
                    {
                        AppConfigManager.Setting.Db.CanAccess = TestConnection();
                        pageresult = Run(filepath, xml);
                        context.Post(OnPageResultShown, pageresult);
                        remark  = new FileInfo(filepath).Name;
                        remark += ",result count:" + pageresult.Results.Count;
                    }
                    catch (Exception ex)
                    {
                        remark += "\r\n" + ex.Message;
                        FileHelper.Write("error.log", string.Format("---\t{0}\t---\r\n{1}\r\n-------------\r\n", DateTime.Now, ex.StackTrace), Encoding.UTF8, true);
                        //弹出消息,弹出框归属MainForm窗体,否则弹出框不容易被发现
                        context.Post(d => MessageBox.Show(this, d.ToString()), ex.Message);
                    }
                    finally
                    {
                        context.Post(OnRunFinished, null);
                        //统计验证次数
                        StatisticsManager.IncreaseCounter(OperationOption.Check, Identity, remark);
                    }
                };

                handler.BeginInvoke(sender, e, null, null);
            }
        }
Ejemplo n.º 5
0
        private void btntest_Click(object sender, EventArgs e)
        {
            string connstring = string.Format("Server={0};database={1};user id={2};password={3}",
                                              txbServer.Text,
                                              txbDb.Text,
                                              txbUserId.Text,
                                              txbPwd.Text);

            ExecuteHandler handler = (o, args) =>
            {
                bool flag = CanAccessDb(connstring);

                context.Post(d =>
                {
                    MessageBox.Show(this, (bool)d ? "Succeed!" : "Failed!");
                    btntest.Enabled = true;
                }, flag);
            };

            btntest.Enabled = false;
            handler.BeginInvoke(sender, e, null, null);
        }