Beispiel #1
0
 protected virtual void PretreatComplete(Checker sender)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new SetTextHandler(SetOperateText), new object[] { "Ԥ�������" });
     }
     else
     {
         SetOperateText("Ԥ�������");
         Application.DoEvents();
     }
 }
Beispiel #2
0
        public void CheckTask()
        {
            ReadyForCheck();

            ThreadStart threadStart = delegate
            {
                if (m_Task == null)
                    return;

                Checker taskChecker = new Checker();

                taskChecker.BaseWorkspace = m_Task.BaseWorkspace;
                taskChecker.QueryConnection = m_Task.QueryConnection;
                taskChecker.QueryWorkspace = m_Task.QueryWorkspace;
                taskChecker.ResultPath = m_Task.GetResultDBPath();
                //TemplateRules templateRules = new TemplateRules(m_Task.SchemaID);
                taskChecker.RuleInfos = this.m_RuleInfoList; //templateRules.CurrentSchemaRules; //Hy.Check.Rule.Helper.RuleInfoHelper.GetRuleInfos(m_Task.SchemaID);
                taskChecker.SchemaID = m_Task.SchemaID;
                taskChecker.TopoDBPath = m_Task.GetResultDBPath();
                taskChecker.TopoTolerance = m_Task.TopoTolerance;

                AdaptCheckerEvents(taskChecker);

                taskChecker.Check();
            };

            m_Thread = new Thread(threadStart);
            m_Thread.Start();

            this.ShowDialog();
        }
Beispiel #3
0
        protected virtual void CheckComplete(Checker sender)
        {
            //Task״̬����[�����ݿ�]
            m_Task.UpdateStateForExcuted();
            m_Task.CreateTaskConfig();
            TaskHelper.UpdateTaskState(m_Task.ID, m_Task.State);

            // ֹͣ��ʱ��д�����־
            m_StringWriter.WriteLine(DateTime.Now.ToString() + "��������");
            m_StringWriter.WriteLine(string.Format("��������:{0}���ɹ���:{1}",this.m_RuleCount, sender.SucceedCount));
            m_StringWriter.WriteLine("�ܴ�����:" + m_ErrorCount.ToString());
            StreamWriter streamWriter = new StreamWriter(m_TaskLog);
            streamWriter.Write(m_StringWriter.ToString());
            streamWriter.Flush();
            streamWriter.Close();
            streamWriter.Dispose();

            timer1.Stop();
            if (this.InvokeRequired)
            {
                this.Invoke(new SetTextHandler(SetOperateText), new object[] { "������" });
                ThreadStart uiChanged = delegate
                {
                    this.Text = "������";
                    this.btnViewLog.Visible = true;
                    this.btnClose.Text = "��˼����";
                };
                this.Invoke(uiChanged);
            }
            else
            {
                SetOperateText("������");
                this.Text = "������";
                this.btnViewLog.Visible = true;
                this.btnClose.Text = "��˼����";
                Application.DoEvents();
            }
            this.m_ExcuteComplete = true;
        }
Beispiel #4
0
 void CheckComplete(Checker sender)
 {
     SendCheckingMessage("检查完成。");
 }
Beispiel #5
0
 void CheckComplete(Checker sender)
 {
     SendCheckingMessage("检查完成。");
 }
Beispiel #6
0
 protected virtual void VerifyedComplete(Checker sender, int availCount)
 {
     this.m_RuleCount = availCount;
     if (this.InvokeRequired)
     {
         this.Invoke(new SetTextHandler(SetAvaliateText), new object[] { availCount.ToString() });
     }
     else
     {
         SetAvaliateText(availCount.ToString());
         Application.DoEvents();
     }
 }
Beispiel #7
0
        public void AdaptCheckerEvents(Checker taskChecker)
        {
            taskChecker.CheckingRuleChanged += new DealingRuleChangedHandler(CheckingRuleChanged);
            taskChecker.VerifyingRuleChanged += new DealingRuleChangedHandler(VerifyingRuleChanged);
            taskChecker.PretreatingRuleChanged += new DealingRuleChangedHandler(PretreatingRuleChanged);
            taskChecker.VerifyedComplete += new VerifyedCompleteHandler(VerifyedComplete);
            taskChecker.PretreatComplete += new CheckEventHandler(PretreatComplete);
            taskChecker.TopoRuleCheckBegin += new CheckEventHandler(TopoRuleCheckBegin);
            taskChecker.RuleChecked += new RuleCheckedHandler(RuleChecked);
            taskChecker.CheckComplete += new CheckEventHandler(CheckComplete);

            taskChecker.Messager = LogDeal;
        }
Beispiel #8
0
        /// <summary>
        /// 使用统一入口进行质检
        /// </summary>
        /// <param name="dsTarget">可以是IWorkspace,IFeatureClass或ITable</param>
        /// <returns></returns>
        public DataTable Check(IDataset dsTarget)
        {
            // 数据导入
            string       strBaseName  = "Base.gdb";
            string       strQueryDB   = "Base.mdb";
            bool         ready        = false;
            enumDataType baseDataType = enumDataType.FileGDB;

            SendCheckingMessage("正在进行数据导入…");

            try
            {
                Clear();
                if (dsTarget is IWorkspace)
                {
                    ready = PrepareForWorkspace(dsTarget as IWorkspace, out strBaseName, out strQueryDB, out baseDataType);
                }
                else if (dsTarget is IFeatureClass)
                {
                    ready        = PrepareForFeatureClass(dsTarget, out strBaseName, out strQueryDB);
                    baseDataType = enumDataType.PGDB;
                }
                else if (dsTarget is ITable)
                {
                    ready        = PrepareForTable(dsTarget, out strBaseName, out strQueryDB);
                    baseDataType = enumDataType.PGDB;
                }


                if (!ready)
                {
                }

                // 开始准备检查

                string        strBaseFullName  = string.Format("{0}\\{1}", TempPath, strBaseName);
                string        strQueryFullName = string.Format("{0}\\{1}", TempPath, strQueryDB);
                IWorkspace    wsBase           = AEAccessFactory.OpenWorkspace(baseDataType, strBaseFullName);
                IWorkspace    wsQuery          = AEAccessFactory.OpenWorkspace(enumDataType.PGDB, strQueryFullName);
                IDbConnection queryConnection  = AdoDbHelper.GetDbConnection(strQueryFullName);

                // 开始执行检查
                Checker curChecker = new Checker();
                curChecker.VerifyingRuleChanged   += new DealingRuleChangedHandler(VerifyingRuleChanged);
                curChecker.VerifyedComplete       += new VerifyedCompleteHandler(VerifyedComplete);
                curChecker.PretreatingRuleChanged += new DealingRuleChangedHandler(PretreatingRuleChanged);
                curChecker.PretreatComplete       += new CheckEventHandler(PretreatComplete);
                curChecker.CheckingRuleChanged    += new DealingRuleChangedHandler(CheckingRuleChanged);
                curChecker.CheckComplete          += new CheckEventHandler(CheckComplete);
                curChecker.RuleChecked            += new RuleCheckedHandler(RuleChecked);
                curChecker.TopoRuleCheckBegin     += new CheckEventHandler(TopoRuleCheckBegin);

                curChecker.BaseWorkspace   = wsBase;
                curChecker.QueryWorkspace  = wsQuery;
                curChecker.QueryConnection = queryConnection;
                curChecker.ResultPath      = TempPath;
                // 如果没有设置SchemaID,获取第一个
                // 如果没有设置RuleInfo列表,获取所有
                if (string.IsNullOrEmpty(this.SchemaID))
                {
                    Dictionary <int, string> dictStandard = SysDbHelper.GetStandardInfo();
                    if (dictStandard == null || dictStandard.Count == 0)
                    {
                        return(null);
                    }

                    Dictionary <string, string> dictSchema = SysDbHelper.GetSchemasInfo(dictStandard.ElementAt(0).Value);
                    if (dictSchema == null || dictSchema.Count == 0)
                    {
                        return(null);
                    }

                    this.SchemaID = dictSchema.ElementAt(0).Key;
                }
                if (this.RuleInfos == null)
                {
                    TemplateRules templateRule = new TemplateRules(this.SchemaID);
                    this.RuleInfos = templateRule.CurrentSchemaRules;
                }

                curChecker.RuleInfos     = this.RuleInfos;
                curChecker.SchemaID      = this.SchemaID;
                curChecker.TopoDBPath    = TempPath;
                curChecker.TopoTolerance = this.TopoTolerence;

                COMMONCONST.TOPOTOLORANCE = this.TopoTolerence;
                COMMONCONST.dAreaThread   = this.MapScale * 0.04;
                COMMONCONST.dLengthThread = this.MapScale * 0.2 / 10000;

                //SendCheckBeginEvent(curChecker);

                curChecker.Check();            // 检查

                // 获取结果
                string        strResultFullName = string.Format("{0}\\{1}", TempPath, "Result.mdb");
                IDbConnection resultConnection  = AdoDbHelper.GetDbConnection(strResultFullName);

                return(GetErrors(resultConnection));
            }
            catch
            {
                return(null);
            }
            finally
            {
                GC.Collect();

                //Clear();
            }
        }
Beispiel #9
0
 void VerifyedComplete(Checker sender, int availCount)
 {
     SendCheckingMessage("验证完成。");
 }
Beispiel #10
0
 void VerifyedComplete(Checker sender, int availCount)
 {
     SendCheckingMessage("验证完成。");
 }
Beispiel #11
0
        void VerifyingRuleChanged(Checker sender, ICheckRule dealingRule)
        {
            if (dealingRule == null)
                return;

            SendCheckingMessage(string.Format("正在验证“{0}”规则…", dealingRule.Name));
        }
Beispiel #12
0
 void TopoRuleCheckBegin(Checker sender)
 {
     SendCheckingMessage("开始检查拓扑规则…");
 }
Beispiel #13
0
 void RuleChecked(Checker sender, ICheckRule checkedRule, int errorCount)
 {
     //SendCheckingMessage(string.Format("规则“{0}”:
 }
Beispiel #14
0
 void PretreatComplete(Checker sender)
 {
     SendCheckingMessage("预处理完成。");
 }
Beispiel #15
0
        protected virtual void RuleChecked(Checker sender, ICheckRule checkedRule, int errorCount)
        {
            m_ErrorCount += errorCount;
            this.m_ExcutedRuleCount++;
            if (this.InvokeRequired)
            {
                ThreadStart errCountChanged = delegate
                {
                    lblErrorCount.Text = m_ErrorCount.ToString();
                    this.lblExcutedRuleCount.Text = this.m_ExcutedRuleCount.ToString();

                    progressBarControl1.Position = m_ExcutedRuleCount;
                    progressBarControl1.Update();
                };
                this.Invoke(errCountChanged);
            }
            else
            {
                    lblErrorCount.Text = m_ErrorCount.ToString();
                    this.lblExcutedRuleCount.Text = this.m_ExcutedRuleCount.ToString();

                    progressBarControl1.Position = m_ExcutedRuleCount;
                    progressBarControl1.Update();
                    Application.DoEvents();
            }
        }
Beispiel #16
0
 void PretreatComplete(Checker sender)
 {
     SendCheckingMessage("预处理完成。");
 }
Beispiel #17
0
 protected virtual void TopoRuleCheckBegin(Checker sender)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new SetTextHandler(SetOperateText), new object[] { "���ڽ������˼�顭" });
     }
     else
     {
         SetOperateText("���ڽ������˼�顭");
         Application.DoEvents();
     }
 }
Beispiel #18
0
 void RuleChecked(Checker sender, ICheckRule checkedRule, int errorCount)
 {
     //SendCheckingMessage(string.Format("规则“{0}”:
 }
Beispiel #19
0
        protected virtual void VerifyingRuleChanged(Checker sender, ICheckRule dealingRule)
        {
            if (dealingRule == null)
                return;

            if (this.InvokeRequired)
            {
                this.Invoke(new SetTextHandler(SetOperateText), new object[] { "������֤��" + dealingRule.InstanceName + "������" });
            }
            else
            {
                SetOperateText("������֤��" + dealingRule.InstanceName + "������");
                Application.DoEvents();
            }
        }
Beispiel #20
0
 void TopoRuleCheckBegin(Checker sender)
 {
     SendCheckingMessage("开始检查拓扑规则…");
 }
Beispiel #21
0
        /// <summary>
        /// 执行
        /// 指创建任务[并执行检查]
        /// </summary>
        /// <returns>返回【至少创建成功了的】任务列表</returns>
        public bool Excute(ref List<Task> availableTasks)
        {
            try
            {
                availableTasks = new List<Task>();

                this.m_SucceedCount = 0;
                this.m_PromptMsg = "";
                if (this.m_TaskList == null || this.m_TaskList.Count == 0)
                {
                    m_PromptMsg="任务列表为空!无法创建质检任务!";
                    return false;
                }

                int count = this.m_TaskList.Count;
                int succeedCount=0;
                int excuteCount=0;
                for (int i = 0; i < count; i++)
                {
                    ExtendTask curTask = this.m_TaskList[i] as ExtendTask;
                    if (curTask == null)
                        continue;

                    // 创建
                    if (this.CreatingTaskChanged != null)
                        this.CreatingTaskChanged.Invoke(curTask);

                    bool isSucceed= curTask.Create();
                    isSucceed = curTask.CreateMXD();

                    if (this.TaskCreated != null)
                        this.TaskCreated.Invoke(curTask);

                    if (!isSucceed)
                    {
                        SendMessage(enumMessageType.Exception,string.Format("任务:{0}创建失败",curTask.Name));
                        continue;
                    }
                    availableTasks.Add(curTask);

                    ////执行质检
                    if (curTask.CheckMode!=enumCheckMode.CreateOnly)
                    {
                        Checker m_TaskChecker = new Checker();

                        if (this.CheckingTaskChanged != null)
                            this.CheckingTaskChanged.Invoke(m_TaskChecker, curTask);

                        curTask.ReadyForCheck();
                        m_TaskChecker.BaseWorkspace = curTask.BaseWorkspace;
                        m_TaskChecker.QueryConnection = curTask.QueryConnection;
                        m_TaskChecker.QueryWorkspace = curTask.QueryWorkspace;
                        m_TaskChecker.ResultPath = curTask.GetResultDBPath();
                        if (curTask.CheckMode == enumCheckMode.CheckAll)
                        {
                            TemplateRules tempRules = new TemplateRules(curTask.SchemaID);
                            m_TaskChecker.RuleInfos = tempRules.CurrentSchemaRules;
                        }
                        else
                        {
                            m_TaskChecker.RuleInfos = curTask.RuleInfos;
                        }
                        m_TaskChecker.SchemaID = curTask.SchemaID;
                        m_TaskChecker.TopoDBPath = curTask.GetResultDBPath();
                        m_TaskChecker.TopoTolerance = curTask.TopoTolerance;
                        COMMONCONST.TOPOTOLORANCE = curTask.TopoTolerance;
                        COMMONCONST.dAreaThread = curTask.MapScale * 0.04;
                        COMMONCONST.dLengthThread = curTask.MapScale * 0.2 / 10000;

                        m_TaskChecker.Check();

                        if (this.TaskChecked != null)
                            this.TaskChecked.Invoke(m_TaskChecker, curTask);

                        excuteCount++;
                    }

                    succeedCount++;
                }

                if(succeedCount==count)
                {
                    if(excuteCount==0)
                       m_PromptMsg=string.Format("{0}个任务全部创建完成!",count);
                    else
                        m_PromptMsg=string.Format("{0}个任务全部创建完成,{1}个任务检查完成!",count,excuteCount);
                }
                else
                {
                    if(excuteCount==0)
                       m_PromptMsg=string.Format("{0}质检任务创建完成,其余质检任务执行失败", succeedCount);
                    else
                        m_PromptMsg=string.Format("{0}质检任务创建完成({1}个任务检查完成),其余质检任务执行失败", succeedCount,excuteCount);

                }
            }
            catch (Exception ex)
            {
                SendMessage(enumMessageType.Exception, "创建任务过程中出现错误,错误原因:" + ex.ToString());
                return false;
            }
            finally
            {
            }

            return true;
        }
Beispiel #22
0
        /// <summary>
        /// 使用统一入口进行质检
        /// </summary>
        /// <param name="dsTarget">可以是IWorkspace,IFeatureClass或ITable</param>
        /// <returns></returns>
        public DataTable Check(IDataset dsTarget)
        {
            // 数据导入
            string strBaseName = "Base.gdb";
            string strQueryDB = "Base.mdb";
            bool ready = false;
            enumDataType baseDataType = enumDataType.FileGDB;

            SendCheckingMessage("正在进行数据导入…");

            try
            {
                Clear();
                if (dsTarget is IWorkspace)
                {
                    ready = PrepareForWorkspace(dsTarget as IWorkspace, out strBaseName, out strQueryDB, out baseDataType);
                }
                else if (dsTarget is IFeatureClass)
                {
                    ready = PrepareForFeatureClass(dsTarget, out strBaseName, out strQueryDB);
                    baseDataType = enumDataType.PGDB;

                }
                else if (dsTarget is ITable)
                {
                    ready = PrepareForTable(dsTarget, out strBaseName, out strQueryDB);
                    baseDataType = enumDataType.PGDB;
                }

                if (!ready)
                {
                }

                // 开始准备检查

                string strBaseFullName = string.Format("{0}\\{1}", TempPath, strBaseName);
                string strQueryFullName = string.Format("{0}\\{1}", TempPath, strQueryDB);
                IWorkspace wsBase = AEAccessFactory.OpenWorkspace(baseDataType, strBaseFullName);
                IWorkspace wsQuery = AEAccessFactory.OpenWorkspace(enumDataType.PGDB, strQueryFullName);
                IDbConnection queryConnection = AdoDbHelper.GetDbConnection(strQueryFullName);

                // 开始执行检查
                Checker curChecker = new Checker();
                curChecker.VerifyingRuleChanged += new DealingRuleChangedHandler(VerifyingRuleChanged);
                curChecker.VerifyedComplete += new VerifyedCompleteHandler(VerifyedComplete);
                curChecker.PretreatingRuleChanged += new DealingRuleChangedHandler(PretreatingRuleChanged);
                curChecker.PretreatComplete += new CheckEventHandler(PretreatComplete);
                curChecker.CheckingRuleChanged += new DealingRuleChangedHandler(CheckingRuleChanged);
                curChecker.CheckComplete += new CheckEventHandler(CheckComplete);
                curChecker.RuleChecked += new RuleCheckedHandler(RuleChecked);
                curChecker.TopoRuleCheckBegin += new CheckEventHandler(TopoRuleCheckBegin);

                curChecker.BaseWorkspace = wsBase;
                curChecker.QueryWorkspace = wsQuery;
                curChecker.QueryConnection = queryConnection;
                curChecker.ResultPath = TempPath;
                // 如果没有设置SchemaID,获取第一个
                // 如果没有设置RuleInfo列表,获取所有
                if (string.IsNullOrEmpty(this.SchemaID))
                {
                    Dictionary<int, string> dictStandard = SysDbHelper.GetStandardInfo();
                    if (dictStandard == null || dictStandard.Count == 0)
                        return null;

                    Dictionary<string, string> dictSchema = SysDbHelper.GetSchemasInfo(dictStandard.ElementAt(0).Value);
                    if (dictSchema == null || dictSchema.Count == 0)
                        return null;

                    this.SchemaID = dictSchema.ElementAt(0).Key;
                }
                if (this.RuleInfos == null)
                {
                    TemplateRules templateRule = new TemplateRules(this.SchemaID);
                    this.RuleInfos = templateRule.CurrentSchemaRules;
                }

                curChecker.RuleInfos = this.RuleInfos;
                curChecker.SchemaID = this.SchemaID;
                curChecker.TopoDBPath = TempPath;
                curChecker.TopoTolerance = this.TopoTolerence;

                COMMONCONST.TOPOTOLORANCE = this.TopoTolerence;
                COMMONCONST.dAreaThread = this.MapScale * 0.04;
                COMMONCONST.dLengthThread = this.MapScale * 0.2 / 10000;

                //SendCheckBeginEvent(curChecker);

                curChecker.Check();            // 检查

                // 获取结果
                string strResultFullName = string.Format("{0}\\{1}", TempPath, "Result.mdb");
                IDbConnection resultConnection = AdoDbHelper.GetDbConnection(strResultFullName);

                return GetErrors(resultConnection);
            }
            catch
            {
                return null;
            }
            finally
            {
                GC.Collect();

                //Clear();
            }
        }