using ESRI.ArcGIS.Geodatabase;
using Kingo.RuleCheck.XJRuleCheck;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Kingo.RuleCheck
{
public class RuleCheckOpertion
{
///
/// 省级单图斑建库和审核任务包检查
///
///
///
///
/// 系统设置-需执行规则
///
public static List StartSJSHCheck(string dbPath, Dictionary workspace, string primityKey = "", List> excuteRules = null)
{
if (!System.IO.File.Exists(dbPath) || workspace == null)
{
throw new Exception("输入参数错误");
}
//解密DB包
CheckHelper.DBToMDBHelper dBToMDBHelper = new CheckHelper.DBToMDBHelper();
DataTable dt = dBToMDBHelper.SJDecryptDB(dbPath, primityKey,out string tempDBPath);
List result = new List();
List ruleTypes = new List()
{
RuleType.地类属性与举证照片逻辑性检查,
RuleType.数学基础规范性检查,
RuleType.图形属性规范性检查,
RuleType.通用类表内逻辑性检查,
RuleType.通用类表间逻辑性检查,
//RuleType.单图斑建库人工检查,
RuleType.城镇村属性上图检查
};
DLParams.Init();
foreach (var item in ruleTypes)
{
//循环外业任务TBBSM检查
foreach (DataRow row in dt.Rows)
{
List rules = StartCheck(row[0] + string.Empty, tempDBPath, workspace, item, excuteRules);
if (rules != null && rules.Count > 0)
{
result.AddRange(rules);
}
}
}
return result;
}
///
/// 开始检查
///
///
///
///
/// 系统设置-需执行规则
/// 不执行规则
///
public static List StartCheck(string tbbsm, string sourcePath, Dictionary workspace, RuleType ruleType, List> excuteRules = null, List disExecuteRules = null)
{
List checkRst = new List();
RuleCheckBase_DTB ruleCheck = null;
switch (ruleType)
{
case RuleType.地类属性与举证照片逻辑性检查:
ruleCheck = new DLSXYJZZPCheck_DTB();
break;
case RuleType.数学基础规范性检查:
ruleCheck = new SJJCCheck_DTB();
break;
case RuleType.图形属性规范性检查:
ruleCheck = new TXSXCheck_DTB();
break;
case RuleType.通用类表内逻辑性检查:
ruleCheck = new TYLBBNLJXCheck_DTB();
break;
case RuleType.通用类表间逻辑性检查:
ruleCheck = new TYLBJLJXCheck_DTB();
break;
case RuleType.单图斑建库人工检查:
ruleCheck = new RGJCCheck();
break;
case RuleType.城镇村属性上图检查:
ruleCheck = new CZCSXCheck_DTB();
break;
}
if (ruleCheck != null)
{
ruleCheck.TBBSM = tbbsm;
ruleCheck.ExcuteRules = excuteRules;
ruleCheck.DisExecuteRules = disExecuteRules;
checkRst = ruleCheck.ExcuteCheck(tbbsm, sourcePath, workspace);
if (ruleType == RuleType.单图斑建库人工检查)
checkRst = ruleCheck.AllRGError;
}
return checkRst;
}
///
/// 获取所有规则(20210721添加省级审核单图斑规则设置)
///
///
public static List> GetAllRules()
{
List> lisRules = new List>();
Type trypInfo = typeof(DLSXYJZZPCheck_DTB);// Program为类名 地类属性与举证照片逻辑性检查
//获得方法名
MethodInfo[] methodInfo = trypInfo.GetMethods();
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple(x, RuleType.地类属性与举证照片逻辑性检查.ToString())));
trypInfo = typeof(SJJCCheck_DTB);// Program为类名 数学基础规范性检查
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple(x, RuleType.数学基础规范性检查.ToString())));
trypInfo = typeof(TXSXCheck_DTB);// Program为类名 图形属性规范性检查
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple(x, RuleType.图形属性规范性检查.ToString())));
trypInfo = typeof(TYLBBNLJXCheck_DTB);// Program为类名 通用类表内逻辑性检查
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple(x, RuleType.通用类表内逻辑性检查.ToString())));
trypInfo = typeof(TYLBJLJXCheck_DTB);// Program为类名 通用类表间逻辑性检查
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple(x, RuleType.通用类表间逻辑性检查.ToString())));
trypInfo = typeof(CZCSXCheck_DTB);// Program为类名 城镇村属性上图检查
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple(x, RuleType.城镇村属性上图检查.ToString())));
trypInfo = typeof(RuleCheckBase_DTB);// Program为类名
WLHRGChecker.DLRuleNames.Union(WLHRGChecker.CZCRuleNames).ToList().ForEach(x => lisRules.Add(new Tuple(x, RuleType.单图斑建库人工检查.ToString())));
var rules = lisRules.Where(x => !trypInfo.GetMethods().Select(m => m.Name).Contains(x.Item1)).Distinct().ToList();
rules.Sort((x, y) => x.Item2 == y.Item2 ? x.Item1.CompareTo(y.Item1) : x.Item2.CompareTo(y.Item2));
return rules;
}
///
/// 县级预处理重叠检查
///
///
///
///
public static List StartYCLCheck(string dbPath, string primityKey = "")
{
try
{
if (!System.IO.File.Exists(dbPath))
{
throw new Exception("输入参数错误");
}
return YCLOverlapCheck.YCLCheck(dbPath);
}
catch (Exception ex)
{
throw ex;
}
}
}
}