年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

468 lines
22 KiB

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
{
/// <summary>
/// 省级单图斑建库和审核任务包检查
/// </summary>
/// <param name="dbPath"></param>
/// <param name="workspace"></param>
/// <param name="primityKey"></param>
/// <param name="excuteRules">系统设置-需执行规则</param>
/// <returns></returns>
public static List<RuleEntity> StartSJSHCheck(string dbPath, Dictionary<string, IFeatureClass> workspace, string primityKey = "", List<Tuple<string>> 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<RuleEntity> result = new List<RuleEntity>();
List<RuleType> 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<RuleEntity> rules = StartCheck(row[0] + string.Empty, tempDBPath, workspace, item, excuteRules);
if (rules != null && rules.Count > 0)
{
result.AddRange(rules);
}
}
}
return result;
}
/// <summary>
/// 开始检查
/// </summary>
/// <param name="sourcePath"></param>
/// <param name="workspace"></param>
/// <param name="ruleType"></param>
/// <param name="excuteRules">系统设置-需执行规则</param>
/// <param name="disExecuteRules">不执行规则</param>
/// <returns></returns>
public static List<RuleEntity> StartCheck(string tbbsm, string sourcePath, Dictionary<string, IFeatureClass> workspace, RuleType ruleType, List<Tuple<string>> excuteRules = null, List<string> disExecuteRules = null)
{
List<RuleEntity> checkRst = new List<RuleEntity>();
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;
}
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;
}
/// <summary>
/// 获取所有规则(20210721添加省级审核单图斑规则设置)
/// </summary>
/// <returns></returns>
public static List<Tuple<string, string>> GetAllRules()
{
List<Tuple<string, string>> lisRules = new List<Tuple<string, string>>();
Type trypInfo = typeof(DLSXYJZZPCheck_DTB);// Program为类名 地类属性与举证照片逻辑性检查
//获得方法名
MethodInfo[] methodInfo = trypInfo.GetMethods();
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple<string, string>(x, RuleType..ToString())));
trypInfo = typeof(SJJCCheck_DTB);// Program为类名 数学基础规范性检查
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple<string, string>(x, RuleType..ToString())));
trypInfo = typeof(TXSXCheck_DTB);// Program为类名 图形属性规范性检查
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple<string, string>(x, RuleType..ToString())));
trypInfo = typeof(TYLBBNLJXCheck_DTB);// Program为类名 通用类表内逻辑性检查
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple<string, string>(x, RuleType..ToString())));
trypInfo = typeof(TYLBJLJXCheck_DTB);// Program为类名 通用类表间逻辑性检查
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple<string, string>(x, RuleType..ToString())));
trypInfo = typeof(RGJCCheck);// Program为类名 单图斑建库人工检查
trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple<string, string>(x, RuleType..ToString())));
//trypInfo = typeof(JZZPCheck);// Program为类名 举证照片规范性检查
//trypInfo.GetMethods().Select(m => m.Name).ToList().ForEach(x => lisRules.Add(new Tuple<string, string>(x, RuleType.举证照片规范性检查.ToString())));
trypInfo = typeof(RuleCheckBase_DTB);// Program为类名
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;
}
/// <summary>
/// 县级预处理重叠检查
/// </summary>
/// <param name="dbPath"></param>
/// <param name="primityKey"></param>
/// <returns></returns>
public static List<RuleEntity> StartYCLCheck(string dbPath, string primityKey = "")
{
try
{
if (!System.IO.File.Exists(dbPath))
{
throw new Exception("输入参数错误");
}
return YCLOverlapCheck.YCLCheck(dbPath);
}
catch (Exception ex)
{
throw ex;
}
}
#region 弃用
///// <summary>
///// 开始检查
///// </summary>
///// <param name="sourcePath"></param>
///// <param name="workspace"></param>
///// <param name="ruleType"></param>
///// <param name="bFirstRun">是否为首轮执行</param>
///// <param name="sProcessDataPath">过程数据路径</param>
///// <param name="excuteRules">系统设置-需执行规则</param>
///// <param name="disExecuteRules">不执行规则</param>
///// <returns></returns>
//public static List<RuleEntity> StartCheck(string sourcePath, Dictionary<string, IWorkspace> workspace, RuleType ruleType, bool bFirstRun = true, string sProcessDataPath = "", List<Tuple<string>> excuteRules = null, List<string> disExecuteRules = null)
//{
// List<RuleEntity> checkRst = new List<RuleEntity>();
// RuleCheckBase ruleCheck = null;
// switch (ruleType)
// {
// case RuleType.举证照片规范性检查:
// ruleCheck = new JZZPCheck();
// break;
// case RuleType.地类属性与举证照片逻辑性检查:
// ruleCheck = new DLSXYJZZPCheck();
// break;
// case RuleType.数学基础规范性检查:
// ruleCheck = new SXJCCheck();
// break;
// case RuleType.图形属性规范性检查:
// ruleCheck = new TXSXCheck();
// break;
// case RuleType.通用类表内逻辑性检查:
// ruleCheck = new TYLBBNLJXCheck();
// break;
// case RuleType.通用类表间逻辑性检查:
// ruleCheck = new TYLBJLJXCheck();
// break;
// case RuleType.数据库业务类逻辑检查:
// break;
// case RuleType.单图斑建库人工检查:
// //ruleCheck = new RGJCCheck();
// break;
// case RuleType.数据库成果人工检查:
// break;
// case RuleType.内业预审处理检查:
// break;
// default:
// break;
// }
// if (ruleCheck != null)
// {
// ruleCheck.ExcuteRules = excuteRules;
// ruleCheck.DisExecuteRules = disExecuteRules;
// ruleCheck.ProcessDataPath = sProcessDataPath;
// ruleCheck.FirstRun = bFirstRun;
// checkRst = ruleCheck.ExcuteCheck(sourcePath, workspace);
// if (ruleType == RuleType.单图斑建库人工检查)
// checkRst = ruleCheck.AllRGError;
// }
// return checkRst;
//}
//public static List<RuleEntity> StartCheck(string sourcePath, Dictionary<string, IWorkspace> workspace, List<RuleType> ruleTypes)
//{
// if (!System.IO.File.Exists(sourcePath) || workspace == null)
// {
// throw new Exception("输入参数错误");
// }
// DLParams.Init();
// List<RuleEntity> result = new List<RuleEntity>();
// foreach (var item in ruleTypes)
// {
// List<RuleEntity> rules = StartCheck(sourcePath, workspace, item);
// if (rules != null && rules.Count > 0)
// {
// result.AddRange(rules);
// }
// }
// return result;
//}
///// <summary>
///// 县级单图斑建库和审核任务包检查
///// </summary>
///// <param name="dbPath"></param>
///// <param name="workspace"></param>
///// <param name="dicReferenceData">参考数据dicReferenceData = new Dictionary<string, string> {{ "JCK_DLTB", @"F:\KINGO\基础数据下发\基础数据库\(4401)广州市\(440103)荔湾区\440103\XYBASE.gdb\DLTB" },};</param>
///// <param name="sProcessDataPath">过程数据路径</param>
///// <param name="primityKey"></param>
///// <param name="excuteRules">系统设置-需执行规则</param>
///// <returns></returns>
//public static List<RuleEntity> StartXJSHCheck(string dbPath, Dictionary<string, IWorkspace> workspace, Dictionary<string, string> dicReferenceData, out string sProcessDataPath, string primityKey = "", List<Tuple<string>> excuteRules = null)
//{
// if (!System.IO.File.Exists(dbPath) || workspace == null)
// {
// throw new Exception("输入参数错误");
// }
// CheckHelper.DBToMDBHelper dBToMDBHelper = new CheckHelper.DBToMDBHelper();
// List<string> mdbPaths = dBToMDBHelper.DBToMdb(dbPath, out sProcessDataPath, primityKey);
// dBToMDBHelper.CreateProcessData(dicReferenceData, sProcessDataPath);
// List<RuleEntity> result = new List<RuleEntity>();
// List<RuleType> ruleTypes = new List<RuleType>()
// {
// RuleType.地类属性与举证照片逻辑性检查,
// RuleType.数学基础规范性检查,
// RuleType.图形属性规范性检查,
// RuleType.通用类表内逻辑性检查,
// RuleType.通用类表间逻辑性检查,
// };
// DLParams.Init();
// //过程MDB可创建表
// var mdbHelper = new CheckHelper.MDBHelper(sProcessDataPath);
// mdbHelper.connOpen();
// mdbHelper.ExecuteNonQuery("CREATE TABLE ErrorRecords(XH INTEGER,RuleCode TEXT,CheckObject TEXT,RuleName TEXT,RuleContent TEXT,ErrorType TEXT,ErrorId TEXT,ErrorTip TEXT)");
// bool bFirstRun = true;
// if (mdbPaths != null && mdbPaths.Count > 0)
// {
// foreach (var mdbPath in mdbPaths)
// {
// foreach (var item in ruleTypes)
// {
// List<RuleEntity> rules = StartCheck(mdbPath, workspace, item, bFirstRun, sProcessDataPath, excuteRules, new List<string> { "JZ005", "JZ007" });
// if (rules != null && rules.Count > 0)
// {
// result.AddRange(rules);
// //错误记录插入mdb
// foreach (var ru in rules)
// {
// mdbHelper.ExecuteNonQuery($"insert into ErrorRecords(XH,RuleCode,CheckObject,RuleName,RuleContent,ErrorType,ErrorId,ErrorTip) " +
// $"values ({ru.XH},'{ru.RuleCode}','{ru.CheckObject}','{ru.RuleName}','{ru.RuleContent}','{ru.ErrorType}','{ru.ErrorTip}')");
// }
// }
// }
// bFirstRun = false;
// }
// }
// mdbHelper.DisConn();
// return result;
//}
///// <summary>
///// 县级单图斑建库和审核任务包检查
///// </summary>
///// <param name="dbPath"></param>
///// <param name="workspace"></param>
///// <param name="primityKey"></param>
///// <param name="excuteRules">系统设置-需执行规则</param>
///// <returns></returns>
//public static List<RuleEntity> StartXJSHCheck(string dbPath, Dictionary<string, IWorkspace> workspace, string primityKey = "", List<Tuple<string>> excuteRules = null)
//{
// if (!System.IO.File.Exists(dbPath) || workspace == null)
// {
// throw new Exception("输入参数错误");
// }
// CheckHelper.DBToMDBHelper dBToMDBHelper = new CheckHelper.DBToMDBHelper();
// List<string> mdbPaths = dBToMDBHelper.DBToMdb(dbPath, out string sProcessDataPath, primityKey);
// List<RuleEntity> result = new List<RuleEntity>();
// List<RuleType> ruleTypes = new List<RuleType>()
// {
// RuleType.地类属性与举证照片逻辑性检查,
// RuleType.数学基础规范性检查,
// RuleType.图形属性规范性检查,
// RuleType.通用类表内逻辑性检查,
// RuleType.通用类表间逻辑性检查,
// };
// DLParams.Init();
// bool bFirstRun = true;
// if (mdbPaths != null && mdbPaths.Count > 0)
// {
// foreach (var mdbPath in mdbPaths)
// {
// foreach (var item in ruleTypes)
// {
// List<RuleEntity> rules = StartCheck(mdbPath, workspace, item, bFirstRun, sProcessDataPath, excuteRules, new List<string> { "JZ005", "JZ007", "TX021", "TX022", "TX023", "TX024", "LNGD001", "LNGD002", "LNGD003", "LNGD004", "HFSX001", "HFSX002", "HFSX003" });
// if (rules != null && rules.Count > 0)
// {
// result.AddRange(rules);
// }
// }
// bFirstRun = false;
// }
// }
// return result;
//}
///// <summary>
///// 省级单图斑建库和审核任务包检查
///// </summary>
///// <param name="dbPath"></param>
///// <param name="workspace"></param>
///// <param name="primityKey"></param>
///// <param name="excuteRules">系统设置-需执行规则</param>
///// <returns></returns>
//public static List<RuleEntity> StartSJSHCheckOld(string dbPath, Dictionary<string, IWorkspace> workspace, string primityKey = "", List<Tuple<string>> excuteRules = null)
//{
// if (!System.IO.File.Exists(dbPath) || workspace == null)
// {
// throw new Exception("输入参数错误");
// }
// CheckHelper.DBToMDBHelper dBToMDBHelper = new CheckHelper.DBToMDBHelper();
// List<string> mdbPaths = dBToMDBHelper.DBToMdb(dbPath, out string sProcessDataPath, primityKey);
// List<RuleEntity> result = new List<RuleEntity>();
// List<RuleType> ruleTypes = new List<RuleType>()
// {
// RuleType.地类属性与举证照片逻辑性检查,
// RuleType.数学基础规范性检查,
// RuleType.图形属性规范性检查,
// RuleType.通用类表内逻辑性检查,
// RuleType.通用类表间逻辑性检查,
// RuleType.单图斑建库人工检查
// };
// DLParams.Init();
// bool bFirstRun = true;
// if (mdbPaths != null && mdbPaths.Count > 0)
// {
// foreach (var mdbPath in mdbPaths)
// {
// foreach (var item in ruleTypes)
// {
// List<RuleEntity> rules = StartCheck(mdbPath, workspace, item, bFirstRun, sProcessDataPath, excuteRules);
// if (rules != null && rules.Count > 0)
// {
// result.AddRange(rules);
// }
// }
// bFirstRun = false;
// }
// }
// return result;
//}
///// <summary>
///// 省级单图斑建库和审核任务包检查
///// </summary>
///// <param name="dbPath"></param>
///// <param name="workspace"></param>
///// <param name="dicReferenceData">参考数据dicReferenceData = new Dictionary<string, string> {{ "JCK_DLTB", @"F:\KINGO\基础数据下发\基础数据库\(4401)广州市\(440103)荔湾区\440103\XYBASE.gdb\DLTB" },};</param>
///// <param name="sProcessDataPath">过程数据路径</param>
///// <param name="primityKey"></param>
///// <param name="excuteRules">系统设置-需执行规则</param>
///// <returns></returns>
//public static List<RuleEntity> StartSJSHCheck(string dbPath, Dictionary<string, IWorkspace> workspace, Dictionary<string, string> dicReferenceData, out string sProcessDataPath, string primityKey = "", List<Tuple<string>> excuteRules = null)
//{
// if (!System.IO.File.Exists(dbPath) || workspace == null)
// {
// throw new Exception("输入参数错误");
// }
// CheckHelper.DBToMDBHelper dBToMDBHelper = new CheckHelper.DBToMDBHelper();
// List<string> mdbPaths = dBToMDBHelper.DBToMdb(dbPath, out sProcessDataPath, primityKey);
// dBToMDBHelper.CreateProcessData(dicReferenceData, sProcessDataPath);
// List<RuleEntity> result = new List<RuleEntity>();
// List<RuleType> ruleTypes = new List<RuleType>()
// {
// RuleType.地类属性与举证照片逻辑性检查,
// RuleType.数学基础规范性检查,
// RuleType.图形属性规范性检查,
// RuleType.通用类表内逻辑性检查,
// RuleType.通用类表间逻辑性检查,
// RuleType.单图斑建库人工检查
// };
// DLParams.Init();
// //过程MDB可创建表
// var mdbHelper = new CheckHelper.MDBHelper(sProcessDataPath);
// mdbHelper.connOpen();
// mdbHelper.ExecuteNonQuery("CREATE TABLE ErrorRecords(XH INTEGER,RuleCode TEXT,CheckObject TEXT,RuleName TEXT,RuleContent TEXT,ErrorType TEXT,ErrorId TEXT,ErrorTip TEXT)");
// bool bFirstRun = true;
// if (mdbPaths != null && mdbPaths.Count > 0)
// {
// foreach (var mdbPath in mdbPaths)
// {
// foreach (var item in ruleTypes)
// {
// List<RuleEntity> rules = StartCheck(mdbPath, workspace, item, bFirstRun, sProcessDataPath, excuteRules);
// if (rules != null && rules.Count > 0)
// {
// result.AddRange(rules);
// //错误记录插入mdb
// foreach (var ru in rules)
// {
// mdbHelper.ExecuteNonQuery($"insert into ErrorRecords(XH,RuleCode,CheckObject,RuleName,RuleContent,ErrorType,ErrorId,ErrorTip) " +
// $"values ({ru.XH},'{ru.RuleCode}','{ru.CheckObject}','{ru.RuleName}','{ru.RuleContent}','{ru.ErrorType}','{ru.ErrorId}','{ru.ErrorTip}')");
// }
// }
// }
// bFirstRun = false;
// }
// }
// mdbHelper.DisConn();
// return result;
//}
#endregion
}
}