Exemplo n.º 1
0
        private static void StartPersistantTest(Domain d)
        {
            lock (TestProccessStatusLocker)
            {
                if (ms_tps == TestProcessStatus.Ready)
                {
                    //Domain
                    ms_domain = d;

                    //清空log区
                    ms_dgv.Rows.Clear();

                    //重置Close Flag
                    ms_IsClosed = false;

                    //准备vba脚本对象
                    ms_vbaobjects = new Dictionary <string, IVBAObject>();
                    IVBAObject ivo = new VBATask();
                    ms_vbaobjects.Add(ivo.Name, ivo);

                    //小心处理伪Log对象
                    ms_testlog = new VBATestLog(false);
                    ms_testlog.MessageEvent += new VBATestLog.ScriptPauseEventHandler(MessageHandler);
                    ms_vbaobjects.Add(ms_testlog.Name, ms_testlog);

                    ivo = new VBATestIE();
                    ms_vbaobjects.Add(ivo.Name, ivo);
                    ivo = new VBAUtility();
                    ms_vbaobjects.Add(ivo.Name, ivo);
                    ivo = new VBAHtml();
                    ms_vbaobjects.Add(ivo.Name, ivo);

                    ms_tp = TestPhase.Nonstarted;
                    Thread t = new Thread(BeforeTestHandler);
                    t.Name = "Thread For Persistant Test";
                    t.Start();
                }
                else if (ms_tps == TestProcessStatus.Singlestep_Pause)
                {
                    //改成持续运行模式
                    ms_testlog.TurnPersistance();
                    //放行
                    ms_testlog.PulseOne();
                }

                ms_tps = TestProcessStatus.Persistence;
                RefreshTestToolButtons();
            }
        }
Exemplo n.º 2
0
        public static void AfterTestHandler(object sender, EventArgs e)
        {
            BaseVBAScriptTask whichtask = (BaseVBAScriptTask)sender;

            if (whichtask.Status == TaskStatus.Succeed && ms_IsClosed == false)
            {
                switch (ms_tp)
                {
                case TestPhase.Preparation:
                    SetSyntaxDocumentText(ms_domain.ParserScript);
                    ms_task              = new LocalParserVBAScriptTask(ms_domain.DomainGUID, whichtask.TaskChainGUID, ms_vbaobjects);
                    whichtask.VBAObjs    = null;
                    ms_task.AfterScript += new EventHandler(AfterTestHandler);
                    ms_task.Run();
                    ms_tp = TestPhase.Parser;
                    whichtask.Dispose();
                    break;

                case TestPhase.Parser:
                    SetSyntaxDocumentText(ms_domain.StorageScript);
                    ms_task              = new LocalStorageVBAScriptTask(ms_domain.DomainGUID, whichtask.TaskChainGUID, ms_vbaobjects);
                    whichtask.VBAObjs    = null;
                    ms_task.AfterScript += new EventHandler(AfterTestHandler);
                    ms_task.Run();
                    ms_tp = TestPhase.Storage;
                    whichtask.Dispose();
                    break;

                case TestPhase.Storage:
                    MessageBox.Show("测试结束,请检查日志以确定代码是否正确", "通知", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    whichtask.Dispose();
                    ms_task = null;
                    ms_tps  = TestProcessStatus.Ready;
                    RefreshTestToolButtons();
                    break;
                }
            }
            else
            {
                whichtask.Dispose();
                ms_task = null;
                ms_tps  = TestProcessStatus.Ready;
                RefreshTestToolButtons();
            }
        }
Exemplo n.º 3
0
        public static void MessageHandler(VBALogLevelFlag vflag, string message)
        {
            if (ms_dgv.InvokeRequired)
            {
                MessageHandlerInvokor m1 = new MessageHandlerInvokor(MessageHandler);
                ms_dgv.BeginInvoke(m1, new object[] { vflag, message });
            }
            else
            {
                //加入dataview
                ms_dgv.Rows.Insert(0, new object[] { ms_levelpics[vflag], vflag, message });

                lock (TestProccessStatusLocker)
                {
                    if (ms_tps == TestProcessStatus.Singlestep_Running)
                    {
                        //改变tps
                        ms_tps = TestProcessStatus.Singlestep_Pause;
                        RefreshTestToolButtons();
                    }
                }
            }
        }
        private static void StartPersistantTest(Domain d)
        {
            lock (TestProccessStatusLocker)
            {
                if (ms_tps == TestProcessStatus.Ready)
                {
                    //Domain
                    ms_domain = d;

                    //清空log区
                    ms_dgv.Rows.Clear();

                    //重置Close Flag
                    ms_IsClosed = false;

                    //准备vba脚本对象
                    ms_vbaobjects = new Dictionary<string, IVBAObject>();
                    IVBAObject ivo = new VBATask();
                    ms_vbaobjects.Add(ivo.Name, ivo);

                    //小心处理伪Log对象
                    ms_testlog = new VBATestLog(false);
                    ms_testlog.MessageEvent += new VBATestLog.ScriptPauseEventHandler(MessageHandler);
                    ms_vbaobjects.Add(ms_testlog.Name, ms_testlog);

                    ivo = new VBATestIE();
                    ms_vbaobjects.Add(ivo.Name, ivo);
                    ivo = new VBAUtility();
                    ms_vbaobjects.Add(ivo.Name, ivo);
                    ivo = new VBAHtml();
                    ms_vbaobjects.Add(ivo.Name, ivo);

                    ms_tp = TestPhase.Nonstarted;
                    Thread t = new Thread(BeforeTestHandler);
                    t.Name = "Thread For Persistant Test";
                    t.Start();
                }
                else if (ms_tps == TestProcessStatus.Singlestep_Pause)
                {
                    //改成持续运行模式
                    ms_testlog.TurnPersistance();
                    //放行
                    ms_testlog.PulseOne();
                }

                ms_tps = TestProcessStatus.Persistence;
                RefreshTestToolButtons();
            }
  
        }
        public static void MessageHandler(VBALogLevelFlag vflag, string message)
        {
            if (ms_dgv.InvokeRequired)
            {
                MessageHandlerInvokor m1 = new MessageHandlerInvokor(MessageHandler);
                ms_dgv.BeginInvoke(m1, new object[] { vflag, message });
            }
            else
            {
                //加入dataview
                ms_dgv.Rows.Insert(0, new object[] { ms_levelpics[vflag], vflag, message });

                lock (TestProccessStatusLocker)
                {
                    if (ms_tps == TestProcessStatus.Singlestep_Running)
                    {
                        //改变tps
                        ms_tps = TestProcessStatus.Singlestep_Pause;
                        RefreshTestToolButtons();
                    }
                }
            }
        }
        public static void AfterTestHandler(object sender, EventArgs e)
        {
            BaseVBAScriptTask whichtask = (BaseVBAScriptTask)sender;

            if (whichtask.Status == TaskStatus.Succeed && ms_IsClosed == false)
            {
                switch (ms_tp)
                {
                    case TestPhase.Preparation:
                        SetSyntaxDocumentText(ms_domain.ParserScript);
                        ms_task = new LocalParserVBAScriptTask(ms_domain.DomainGUID, whichtask.TaskChainGUID, ms_vbaobjects);
                        whichtask.VBAObjs = null;
                        ms_task.AfterScript += new EventHandler(AfterTestHandler);
                        ms_task.Run();
                        ms_tp = TestPhase.Parser;
                        whichtask.Dispose();
                        break;
                    case TestPhase.Parser:
                        SetSyntaxDocumentText(ms_domain.StorageScript);
                        ms_task = new LocalStorageVBAScriptTask(ms_domain.DomainGUID, whichtask.TaskChainGUID, ms_vbaobjects);
                        whichtask.VBAObjs = null;
                        ms_task.AfterScript += new EventHandler(AfterTestHandler);
                        ms_task.Run();
                        ms_tp = TestPhase.Storage;
                        whichtask.Dispose();
                        break;
                    case TestPhase.Storage:
                        MessageBox.Show("测试结束,请检查日志以确定代码是否正确", "通知", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        whichtask.Dispose();
                        ms_task = null;
                        ms_tps = TestProcessStatus.Ready;
                        RefreshTestToolButtons();                        
                        break;
                }
            }
            else
            {
                whichtask.Dispose();
                ms_task = null;
                ms_tps = TestProcessStatus.Ready;
                RefreshTestToolButtons();              
            }

            
        }