Exemple #1
0
        public static void Program(string mdbfilePath, string[] ids)
        {
            var _connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}", mdbfilePath);

            using (var connection = new OleDbConnection(_connectionString))
            {
                connection.Open();
                Console.WriteLine("开始检查");
                #region  检查数据库是否存在要求的表
                var tableStructure = new TableStructure();
                Console.WriteLine(string.Format("开始检查{0}", tableStructure.Name));
                tableStructure.Check(connection);
                if (tableStructure.Erros.Count == 0)
                {
                    Console.WriteLine(string.Format("符合{0}", tableStructure.Name.Replace("检查", "")));
                }
                else
                {
                    QuestionManager.AddRange(tableStructure.Erros.Select(e => new Models.Question {
                        Code = "2101", Name = "矢量图层完整", Project = Models.CheckProject.图层完整性, Description = e
                    }).ToList());
                    Console.WriteLine("存在如下错误:");
                    foreach (var error in tableStructure.Erros)
                    {
                        Console.WriteLine(error);
                    }
                }
                #endregion
                if (tableStructure.ExistTables.Contains(DCDYTB))
                {
                    DCDYTBManager.Init(connection);
                }
                var rule = new RuleManager()
                {
                    IDS = ids
                };
                rule.Program(connection);


                #region 检查图斑面积

                Console.WriteLine("正在核对图斑面积一致性;");

                try
                {
                    DCDYTBManager.Program();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }


                Console.WriteLine("完成核对图斑面积一致性;");
                #endregion

                connection.Close();
            }
        }
        public void Program()
        {
            QuestionManager.Clear();
            LogManager.Init();
            ParameterManager.Init(Folder);
            DCDYTBManager.Init();
            ExcelParameterManager.Clear();
            if (!Init())
            {
                OutputMessage("00", "初始化失败,程序终止", ProgressResultTypeEnum.Fail);
                return;
            }
            OutputMessage("00", "成功初始化", ProgressResultTypeEnum.Pass);
            foreach (var id in _ruleIds)
            {
                var rule = _rules.FirstOrDefault(e => e.ID == id.ToString());
                if (rule != null)
                {
                    var sb     = new StringBuilder(rule.RuleName);
                    var result = ProgressResultTypeEnum.Pass;
                    try
                    {
                        rule.Check();
                    }
                    catch (AggregateException ae)
                    {
                        foreach (var exp in ae.InnerExceptions)
                        {
                            sb.Append(exp.Message + "\r\n");
                        }
                        result = ProgressResultTypeEnum.Fail;
                    }
                    catch (Exception ex)
                    {
                        result = ProgressResultTypeEnum.Fail;
                        sb.Append(ex.ToString());
                    }

                    if (result != ProgressResultTypeEnum.Pass)
                    {
                        QuestionManager.Add(new Question {
                            Code = rule.ID, Name = rule.RuleName, Description = sb.ToString()
                        });
                    }
                    if (OutputMessage(rule.ID, sb.ToString(), result) == true)
                    {
                        break;
                    }
                }
            }
            _reportPath = QuestionManager.Save(ReportPath);
            //PDFHelper.Save(_reportPath, ReportPDFPath);
            //PdfHelper2.SavePdf(_reportPath, ReportPDFPath);
            PdfHelper2.Convert(_reportPath, ReportPDFPath);
        }
 public override void Check(OleDbConnection connection)
 {
     base.Check(connection);
     DCDYTBManager.Init(connection);//获取图斑编号、调查单元类型
 }