コード例 #1
0
 public static Domain NewDomain()
 {
     Domain d = new Domain();
     d.Name = d.DomainGUID;
     AddDomain(d);
     return d;
 }
 /// <summary>
 /// 构造函数(输入站点domain, 将自动从站点中抽取PreparationScript)
 /// </summary>
 public RemotePreparationVBAScriptTask(Domain d)
 {
     m_domainGUID = d.DomainGUID;
     m_script = d.PreparationScript;
     m_vbaobjs = GetVBAObjectForNewTaskChain(d);
     m_taskchainGUID = Guid.NewGuid().ToString();
     m_timestamp = GetTimeStamp();
 }
コード例 #3
0
 public static void RemoveDomain(Domain whichdomain)
 {
     lock (m_DomainList)
     {
         if (m_DomainList.ContainsKey(whichdomain.DomainGUID))
             m_DomainList.Remove(whichdomain.DomainGUID);
     }
     
 }
コード例 #4
0
 public static void AddDomain(Domain whichdomain)
 {
     lock (m_DomainList)
     {
         if (!m_DomainList.ContainsKey(whichdomain.DomainGUID))
             m_DomainList.Add(whichdomain.DomainGUID, whichdomain);
         else
             m_DomainList[whichdomain.DomainGUID] = whichdomain;
     }
 }
 protected virtual Dictionary<string, IVBAObject> GetVBAObjectForNewTaskChain(Domain d)
 {
     Dictionary<string, IVBAObject> l = new Dictionary<string, IVBAObject>();
     IVBAObject ivo = new VBATask();
     l.Add(ivo.Name, ivo);
     ivo = new VBALog(d.LogLevelFlag);
     l.Add(ivo.Name, ivo);
     ivo = new VBAIE();
     l.Add(ivo.Name, ivo);
     ivo = new VBAUtility();
     l.Add(ivo.Name, ivo);
     ivo = new VBAHtml();
     l.Add(ivo.Name, ivo);
     return l;
 }
コード例 #6
0
 public static void TooltripSinglestepTest(Domain d)
 {            
     StartSinglestepTest(d);
 }
コード例 #7
0
 public static void DataGridViewLoadLog(Domain d, string TaskGUID, System.Windows.Forms.DataGridView dgv, Dictionary<VBALogLevelFlag, Image> levelpics, VBALogLevelFlag dflags, int logloadlimit)
 {
     LoadLogBase(d, TaskGUID, dgv, levelpics, dflags ,logloadlimit);
 }
コード例 #8
0
 public TreeNode TreeViewAddDomain(Domain d, bool IsSelected, bool IsExpanded)
 {
     TreeNode t = TreeViewAddDomain(d);
     if (IsSelected)
         m_treeview.SelectedNode = t;
     if (IsExpanded)
         t.Expand();
     else
         t.Collapse();
     return t;
 }
コード例 #9
0
 private void WindowLoadScript(Domain d, TreeViewFocus t)
 {
     switch (t)
     {
         case TreeViewFocus.Script_Preparation:
             this.syntaxDocumentWindow.Text = d.PreparationScript;
             this.syntaxDocumentWindow.Modified = false;
             
             break;
         case TreeViewFocus.Script_Parser:
             this.syntaxDocumentWindow.Text = d.ParserScript;
             this.syntaxDocumentWindow.Modified = false;
             
             break;
         case TreeViewFocus.Script_Storage:
             this.syntaxDocumentWindow.Text = d.StorageScript;
             this.syntaxDocumentWindow.Modified = false;
             
             break;
     }
 }
コード例 #10
0
        private void WindowLoadDomainProperty(Domain d)
        {
            //控制
            RefreshDomainPropertyControl(d);

            //统计信息
            RefreshDomainPropertySTATs(d);

            //属性
            this.textBoxDomainName.Text = d.Name;            
            this.comboBoxPriority.SelectedIndex = (int)d.Priority;
            this.comboBoxDomainLogLevel.SelectedIndex = LevelFlagToInt(d.LogLevelFlag);

            //设定修改值
            this.panelProperty.Tag = false;
        }
コード例 #11
0
        private bool JudgeAndSaveModifiedScript(Domain d, TreeViewFocus t)
        {
            if (this.syntaxDocumentWindow.Modified)
            {
                DialogResult r = MessageBox.Show("是否需要保存对该脚本的修改?", "保存确认", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (r == DialogResult.Yes)
                {                    
                    switch (t)
                    {
                        case TreeViewFocus.Script_Preparation:
                            d.PreparationScript = this.syntaxDocumentWindow.Text;
                            break;
                        case TreeViewFocus.Script_Parser:
                            d.ParserScript = this.syntaxDocumentWindow.Text;
                            break;
                        case TreeViewFocus.Script_Storage:
                            d.StorageScript = this.syntaxDocumentWindow.Text;
                            break;
                    }
                    return true;
                }
                else
                {
                    if (r == DialogResult.Cancel)
                    {                        
                        return false;
                    }
                    else
                        return true;

                }
            }
            else
                return true;
            
        }
コード例 #12
0
        private void SaveModifiedDomainProperty(Domain d)
        {
            d.Name = this.textBoxDomainName.Text;            
            d.Priority = (DomainPriority)(this.comboBoxPriority.SelectedIndex);
            d.LogLevelFlag = IntToLevelFlag(this.comboBoxDomainLogLevel.SelectedIndex);

            //更新条件
            ServerControlManager.CheckForReservedPool();
        }
コード例 #13
0
 private void RefreshDomainPropertySTATs(Domain d)
 {
     //统计信息
     int total = d.TotalTask;
     int succeed = d.TotalSucceedTask;
     int runningtime = d.TotalRunningTime;
     double sp = (double)succeed / (double)total;
     double ef = (double)total / (double)runningtime;
     this.labelTotalTask.Text = total.ToString();
     this.labelSucceedTask.Text = succeed.ToString();
     this.labelRunningTime.Text = runningtime.ToString();
     this.labelSucceedPercentage.Text = sp.ToString("p");
     this.labelEfficiency.Text = ef.ToString("p");
 }
コード例 #14
0
 private void RefreshDomainPropertyControl(Domain d)
 {
     if (d.Enable)
     {
         this.buttonEnableDomain.Enabled = false;
         this.buttonDisableDomain.Enabled = true;
     }
     else
     {
         this.buttonEnableDomain.Enabled = true;
         this.buttonDisableDomain.Enabled = false;
     }
 }
コード例 #15
0
 public static void SaveDomainFile(Domain d)
 {
     using (SaveFileDialog saveFileDialog = new SaveFileDialog())
     {
         saveFileDialog.Filter = "解决方案文件|*.domain|所有文件|*.*";
         saveFileDialog.RestoreDirectory = true;
         saveFileDialog.FilterIndex = 1;
         if (saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 IFormatter formatter = new SoapFormatter();
                 using (Stream stream = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.Write, FileShare.None))
                 {                           
                     formatter.Serialize(stream, d);
                 }
             }
             catch (Exception e)
             {
                 log.Error("Domain文件保存失败: " + saveFileDialog.FileName, e);
                 MessageBox.Show("保存解决方案文件失败: " + saveFileDialog.FileName, "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             }
         }
     }            
 }
コード例 #16
0
 public static void TooltripStartTest(Domain d)
 {
     StartPersistantTest(d);
 }
コード例 #17
0
 public static void TooltripSinglestepTest(Domain d)
 {
     StartSinglestepTest(d);
 }
コード例 #18
0
 private void WindowLoadDomainLog(Domain d, string taskchainGUID)
 {
     //取log数据            
     this.dataGridViewDomainLog.Rows.Clear();
     LogDatabaseManager.DataGridViewLoadLog(d, taskchainGUID, this.dataGridViewDomainLog, m_levelpics, ButtonStatusToLevelFlags(), ServerControlManager.LogLoadingLimit);
     this.toolStripButtonDomianLogShowAll.Enabled = true;
     this.dataGridViewDomainLog.Tag = taskchainGUID;
 }
コード例 #19
0
 private void WindowLoadTest(Domain d)
 {
     TestManager.WindowRefresh();
 }
コード例 #20
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();
            }
  
        }
コード例 #21
0
        public static void InitDomainForTaskManager(ITaskManager<IRemoteTask> tm, Domain whichdomain)
        {
            if (!m_DomainList.ContainsValue(whichdomain))
                AddDomain(whichdomain);

            if (ms_IsServerModeRemote)
                tm.AddTask(new RemotePreparationVBAScriptTask(whichdomain));         
            else
                tm.AddTask(new LocalPreparationVBAScriptTask(whichdomain));

        }
コード例 #22
0
 public static void TooltripStartTest(Domain d)
 {
     StartPersistantTest(d);
 }
コード例 #23
0
        public TreeNode TreeViewAddDomain(Domain d)
        {
            //生成节点
            TreeNode treeNodePreparationScript = new TreeNode("数据初始化脚本");
            treeNodePreparationScript.ImageKey = "script.png";
            treeNodePreparationScript.SelectedImageKey = "script.png";
            treeNodePreparationScript.Tag = "PreparationScript";
            //treeNodePreparationScript.Name = d."PreparationScriptTreeNode";

            TreeNode treeNodeParserScript = new TreeNode("数据采集脚本");
            treeNodeParserScript.ImageKey = "script.png";
            treeNodeParserScript.SelectedImageKey = "script.png";
            treeNodeParserScript.Tag = "ParserScript";
            //treeNodeParserScript.Name = "ParserScriptTreeNode";

            TreeNode treeNodeStorageScript = new TreeNode("数据入库脚本");
            treeNodeStorageScript.ImageKey = "script.png";
            treeNodeStorageScript.SelectedImageKey = "script.png";
            treeNodeStorageScript.Tag = "StorageScript";
            //treeNodeStorageScript.Name = "StorageScriptTreeNode";

            TreeNode treeNodeTest = new TreeNode("测试");
            treeNodeTest.ImageKey = "testcenter.png";
            treeNodeTest.SelectedImageKey = "testcenter.png";
            treeNodeTest.Tag = "Test";

            TreeNode treeNodeDomainLog = new TreeNode("日志");
            treeNodeDomainLog.ImageKey = "dblog.png";
            treeNodeDomainLog.SelectedImageKey = "dblog.png";
            treeNodeDomainLog.Tag = "Log";
            //treeNodeDomainLog.Name = "DomainLogTreeNode";

            TreeNode treeNodeDomain = new TreeNode("解决方案 " + d.Name, new TreeNode[]{
                        treeNodePreparationScript,
                        treeNodeParserScript,
                        treeNodeStorageScript,
                        treeNodeTest,
                        treeNodeDomainLog});
            treeNodeDomain.Tag = d;
            SetDomainNodeStatus(treeNodeDomain);

            //加入根目录
            m_root.Nodes.Add(treeNodeDomain);
            return treeNodeDomain;
        }
コード例 #24
0
        //public static void DataGridViewLoadLog(Domain d, System.Windows.Forms.DataGridView dgv, Dictionary<string, Image> levelpics)
        //{
        //    using (OleDbConnection logdbcon = new OleDbConnection(ms_connstring))
        //    {
        //        string cmdstr = null;
        //        OleDbDataReader dr = null;
        //        Image levelpic = null;
        //        string levelstring = null;
        //        try
        //        {
        //            logdbcon.Open();
        //            cmdstr = "SELECT TOP 1000 TaskChainGUID,LogTime,LogLevel,LogMessage FROM Log WHERE DomainGUID = '" + d.DomainGUID + "' ORDER BY LogTime DESC";
        //            OleDbCommand cmd = new OleDbCommand(cmdstr, logdbcon);
        //            dr = cmd.ExecuteReader();
                    
        //            while (dr.Read())
        //            {
        //                //得到level图片
        //                switch (((string)dr["LogLevel"]).ToLower())
        //                {
        //                    case "debug":
        //                        levelpic = levelpics["Debug"];
        //                        levelstring = "调试";
        //                        break;
        //                    case "info":
        //                        levelpic = levelpics["Info"];
        //                        levelstring = "信息";
        //                        break;
        //                    case "warn":
        //                        levelpic = levelpics["Warn"];
        //                        levelstring = "警告";
        //                        break;
        //                    case "error":
        //                        levelpic = levelpics["Error"];
        //                        levelstring = "错误";
        //                        break;
        //                    case "fatal":
        //                        levelpic = levelpics["Fatal"];
        //                        levelstring = "致命错误";
        //                        break;
        //                }

        //                DataGridViewRow r = new DataGridViewRow();                        
        //                dgv.Rows.Add(new object[] { levelpic, levelstring, dr["LogTime"], dr["TaskChainGUID"], dr["LogMessage"] });
        //            }
        //        }
        //        catch (OleDbException e)
        //        {
        //            log.Error("读取Log数据库错误:" + cmdstr, e);
        //        }
        //        catch (Exception e)
        //        {
        //            log.Error(e);
        //        }

        //    }
        //}

        private static void LoadLogBase(Domain d, string TaskGUID, System.Windows.Forms.DataGridView dgv, Dictionary<VBALogLevelFlag, Image> levelpics, VBALogLevelFlag dflags, int logloadlimit)
        {

            using (OleDbConnection logdbcon = new OleDbConnection(ms_connstring))
            {
                string cmdstr = null;
                OleDbDataReader dr = null;
                Image levelpic = null;
                string levelstring = null;
                string wherestring = null;
                List<string> levelflagstring = new List<string>();

                //一个都没的情况
                if (dflags == 0)
                    return;
                else
                {
                    //全有的情况
                    if (dflags == (VBALogLevelFlag.Debug | VBALogLevelFlag.Error | VBALogLevelFlag.Fatal |
                                  VBALogLevelFlag.Info | VBALogLevelFlag.Warn))
                        if (TaskGUID == null)
                        {
                            wherestring = "WHERE DomainGUID = '" + d.DomainGUID + "'";
                        }
                        else
                        {
                            wherestring = "WHERE DomainGUID = '" + d.DomainGUID + "' AND TaskChainGUID = '" + TaskGUID + "'";
                        }
                    else
                    {
                        //Debug
                        if ((VBALogLevelFlag.Debug & dflags) != 0)
                            levelflagstring.Add("LogLevel = 'Debug'");
                        //Info
                        if ((VBALogLevelFlag.Info & dflags) != 0)
                            levelflagstring.Add("LogLevel = 'Info'");
                        //Warn
                        if ((VBALogLevelFlag.Warn & dflags) != 0)
                            levelflagstring.Add("LogLevel = 'Warn'");
                        //Error
                        if ((VBALogLevelFlag.Error & dflags) != 0)
                            levelflagstring.Add("LogLevel = 'Error'");
                        //Fatal
                        if ((VBALogLevelFlag.Fatal & dflags) != 0)
                            levelflagstring.Add("LogLevel = 'Fatal'");

                        //构造查询WHERE字段
                        int i = 1;

                        if (TaskGUID == null)
                        {
                            wherestring = "WHERE DomainGUID = '" + d.DomainGUID + "' AND (";
                        }
                        else
                        {
                            wherestring = "WHERE DomainGUID = '"+ d.DomainGUID+ "' AND TaskChainGUID = '" + TaskGUID + "' AND (";
                        }

                        foreach (string s in levelflagstring)
                        {
                            wherestring = wherestring + s;
                            if (i != levelflagstring.Count)
                                wherestring = wherestring + " OR ";
                            i++;
                        }
                        wherestring = wherestring + ")";
                    }
                }

                try
                {
                    //关闭复杂排版
                    dgv.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
                    dgv.Columns["DomainLogLevel"].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                    dgv.Columns["DomainLogDateTime"].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;

                    //读取Log数据
                    logdbcon.Open();
                    cmdstr = "SELECT TOP " + logloadlimit.ToString() + " TaskChainGUID,LogTime,LogLevel,LogMessage FROM Log " + wherestring + " ORDER BY logtime DESC;";
                    OleDbCommand cmd = new OleDbCommand(cmdstr, logdbcon);
                    dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        //得到level图片
                        switch (((string)dr["LogLevel"]).ToLower())
                        {
                            case "debug":
                                levelpic = levelpics[VBALogLevelFlag.Debug];
                                levelstring = "调试";
                                break;
                            case "info":
                                levelpic = levelpics[VBALogLevelFlag.Info];
                                levelstring = "信息";
                                break;
                            case "warn":
                                levelpic = levelpics[VBALogLevelFlag.Warn];
                                levelstring = "警告";
                                break;
                            case "error":
                                levelpic = levelpics[VBALogLevelFlag.Error];
                                levelstring = "错误";
                                break;
                            case "fatal":
                                levelpic = levelpics[VBALogLevelFlag.Fatal];
                                levelstring = "致命错误";
                                break;
                        }
                        dgv.Rows.Add(new object[] { levelpic, levelstring, dr["LogTime"], dr["TaskChainGUID"], dr["LogMessage"] });
                        Application.DoEvents();

                    }

                    //排版
                    dgv.Columns["DomainLogLevel"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    dgv.Columns["DomainLogDateTime"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
                    dgv.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
                }
                catch (OleDbException e)
                {
                    log.Error("读取Log数据库错误:" + cmdstr, e);
                }
                catch (Exception e)
                {
                    log.Error(e);
                }

            }
        }