年度变更建库软件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.
 
 

723 lines
31 KiB

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using KGIS.Framework.AE;
using KGIS.Framework.AE.ExtensionMethod;
using KGIS.Framework.AE.GPHelper;
using KGIS.Framework.DBOperator;
using KGIS.Framework.Maps;
using KGIS.Framework.Platform;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.ExtensionMethod;
using KGIS.Framework.Utils.Helper;
using Kingo.PluginServiceInterface;
using Kingo.PluginServiceInterface.Model;
using Kingo.RuleCheck;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Controls;
namespace Kingo.Plugin.General.Helper
{
public partial class DataOperationHelper_Default
{
private TreeView tvPackges { get; set; }
public ObservableCollection<TreeNode> TreeDataSource { get; set; }
public DataOperationHelper_Default(TreeView _tvPackges)
{
tvPackges = _tvPackges;
}
public IHookHelper hookHelper
{
get
{
return new HookHelperClass
{
Hook = MapsManager.Instance.MapService.getAxMapControl().Object
};
}
}
private ProjectInfo projectInfo
{
get { return MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; }
}
/// <summary>
/// 当前选中节点
/// </summary>
protected TreeNode CurrentSelectNode
{
get
{
return tvPackges.SelectedItem as TreeNode;
}
}
/// <summary>
/// 当前选中任务包
/// </summary>
public TaskPackage CurrentTaskPackage
{
get
{
if (CurrentSelectNode == null || CurrentSelectNode.NodeLevel <= 0)
{
return null;
}
if (CurrentSelectNode.NodeLevel == 1 && CurrentSelectNode.Data is TaskPackage)
{
return CurrentSelectNode.Data as TaskPackage;
}
else if (CurrentSelectNode.NodeLevel == 1 && CurrentSelectNode.Data is IFeatureLayer)
{ //矢量数据获取监测一级图层
return null;
}
else if (CurrentSelectNode.NodeLevel == 2 && CurrentSelectNode.Data is WYRWTB)
{
return CurrentSelectNode.ParentNode.Data as TaskPackage;
}
else if (CurrentSelectNode.NodeLevel == 2 && CurrentSelectNode.Data is DataRow)
{ //矢量数据获取监测图斑
return null;
}
else if (CurrentSelectNode.NodeLevel == 2 && CurrentSelectNode.Data == null)
{
return CurrentSelectNode.PackageNode.Data as TaskPackage;//预处理-二级节点-监测图斑父级
}
else if (CurrentSelectNode.NodeLevel == 3 && CurrentSelectNode.Data is DTBDLTBGX)
{
return CurrentSelectNode.ParentNode.ParentNode.Data as TaskPackage;
}
else if (CurrentSelectNode.NodeLevel == 3 && CurrentSelectNode.Data is DataRow)//预处理
{
if (CurrentSelectNode.PackageNode != null)
{
return CurrentSelectNode.PackageNode.Data as TaskPackage;
}
else
{
return CurrentSelectNode.Data as TaskPackage;
}
}
else
{
return null;
}
}
}
/// <summary>
/// 编辑器
/// </summary>
public static IEngineEditor EngineEditorBG
{
get { return new EngineEditorClass(); }
}
/// <summary>
/// 外业任务图斑
/// </summary>
private IFeatureLayer WyrwFeatureLayer
{
get
{
return MapsManager.Instance.MapService.GetFeatureLayerByName("WYRW");
}
}
/// <summary>
/// 自主图斑图层
/// </summary>
private IFeatureLayer zztbFeatureLayer
{
set { }
get
{
return MapsManager.Instance.MapService.GetFeatureLayerByName("ZZTB");
}
}
/// <summary>
/// 地类图斑变更
/// </summary>
protected IFeatureLayer DtbFeatureLayer
{
set { }
get
{
return MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBBG");
}
}
/// <summary>
/// 地类图斑图层
/// </summary>
protected IFeatureLayer JCKFeatureLayer
{
get
{
return MapsManager.Instance.MapService.GetFeatureLayerByName("DLTB");
}
}
/// <summary>
/// 当前选中外业任务图斑
/// </summary>
public WYRWTB CurrentWYRWTB
{
get
{
if (CurrentSelectNode == null)
{
return null;
}
if (CurrentSelectNode.NodeLevel == 2 && (CurrentSelectNode.Data as WYRWTB) != null)
{
return CurrentSelectNode.Data as WYRWTB;
}
else if (CurrentSelectNode.NodeLevel == 3 && (CurrentSelectNode.ParentNode.Data as WYRWTB) != null)
{
return CurrentSelectNode.ParentNode.Data as WYRWTB;
}
return null;
}
}
public bool IsAutoSaveEdit = true;//是否是自动保存
/// <summary>
/// 当前选择的监测图斑树节点
/// </summary>
private TreeNode CurrentWYRWTBTreeNode
{
get
{
if (CurrentSelectNode == null)
{
return null;
}
if (CurrentSelectNode.NodeLevel == 2 && (CurrentSelectNode.Data as WYRWTB) != null)
{
return CurrentSelectNode;
}
else if (CurrentSelectNode.NodeLevel == 3 && (CurrentSelectNode.ParentNode.Data as WYRWTB) != null)
{
return CurrentSelectNode.ParentNode;
}
return null;
}
}
#region GetFeatureClassTable
/// <summary>
/// GetFeatureClassTable
/// </summary>
/// <param name="featureClass"></param>
/// <param name="queryFilter"></param>
/// <returns></returns>
public DataTable GetFeatureClassTable(IFeatureClass featureClass, IQueryFilter queryFilter = null)
{
DataTable dataTable = new DataTable();
IFeature feature = null;
IFeatureCursor cursor = null;
try
{
var fields = featureClass.Fields;
for (int i = 0; i < fields.FieldCount; i++)
{
var field = fields.get_Field(i);
dataTable.Columns.Add(field.Name, GetSystemType(field.Type));
}
GeoprocessorHelper.RepairGeo(featureClass, true);//修复要素,防止SHAPE_AREA为负数
cursor = featureClass.Search(queryFilter, true);
while ((feature = cursor.NextFeature()) != null)
{
var row = dataTable.NewRow();
for (int i = 0; i < fields.FieldCount; i++)
{
var value = feature.get_Value(i);
row[i] = value is DBNull ? DBNull.Value : value;
}
dataTable.Rows.Add(row);
}
}
catch (Exception ex)
{
LogAPI.Debug("GetFeatureClassTable异常:" + ex.Message);
LogAPI.Debug("GetFeatureClassTable异常:" + ex.StackTrace);
}
finally
{
if (feature != null)
Marshal.ReleaseComObject(feature);
if (cursor != null)
Marshal.ReleaseComObject(cursor);
}
return dataTable;
}
#endregion
#region GetSystemType
/// <summary>
/// 获取字段类型
/// </summary>
/// <param name="fieldType"></param>
/// <returns></returns>
private Type GetSystemType(esriFieldType fieldType)
{
switch (fieldType)
{
case esriFieldType.esriFieldTypeSmallInteger:
case esriFieldType.esriFieldTypeInteger:
return typeof(int);
case esriFieldType.esriFieldTypeSingle:
return typeof(float);
case esriFieldType.esriFieldTypeDouble:
return typeof(double);
case esriFieldType.esriFieldTypeDate:
return typeof(DateTime);
default:
return typeof(string);
}
}
#endregion
#region 开启编辑
/// <summary>
/// 开启编辑
/// </summary>
/// <param name="hookHelper"></param>
/// <param name="featureLayer"></param>
public void StartEdit(IFeatureLayer featureLayer)
{
try
{
if (Platform.Instance.SystemType == SystemTypeEnum.WYZS || EngineEditorBG == null || hookHelper == null || hookHelper.FocusMap == null || featureLayer == null || featureLayer.FeatureClass == null) return;
var jcdltb = MapsManager.Instance.MapService.GetFeatureClassByName("DLTB");
if (projectInfo == null || (string.IsNullOrWhiteSpace(projectInfo.JCKPath) && jcdltb == null))
{
MessageHelper.Show("请先设置工作目录,加载基础库数据!");
return;
}
(featureLayer.FeatureClass as FeatureClass as IFeatureClassLoad).LoadOnlyMode = false;
IWorkspace SchemeWork = (featureLayer.FeatureClass as FeatureClass).Workspace;
if (SchemeWork == null) return;
IEngineEditLayers pEditLayer = EngineEditorBG as IEngineEditLayers;
if (pEditLayer.TargetLayer != null && pEditLayer.TargetLayer.Equals(featureLayer))
return;//前后编辑的图层相同则不再重复开启编辑
//else if (pEditLayer.TargetLayer != null && !pEditLayer.TargetLayer.Equals(featureLayer))
//{
// EngineEditorBG.StopEditing(true);//切换前保存
//}
EngineEditorBG.StartEditing(SchemeWork, hookHelper.FocusMap);
//IEngineEditLayers pEditLayer = EngineEditorBG as IEngineEditLayers;
pEditLayer.SetTargetLayer(featureLayer, 0);
}
catch (Exception ex)
{
MessageHelper.ShowError("打开编辑失败:" + ex.Message);
}
}
#endregion
#region 保存编辑
private ControlsEditingSaveCommandClass saveCommandClass { get; set; }
public void SaveEingineEdit()
{
try
{
if (saveCommandClass == null)
{
saveCommandClass = new ControlsEditingSaveCommandClass();
saveCommandClass.OnCreate(hookHelper.Hook);
}
saveCommandClass.OnClick();
}
catch (Exception ex)
{
LogAPI.Debug("SaveEingineEdit异常:" + ex.Message);
LogAPI.Debug("SaveEingineEdit异常:" + ex.StackTrace);
throw ex;
}
}
#endregion
#region 加载质检结果
/// <summary>
/// 加载质检结果(加载对应任务图斑质检错误)
/// </summary>
public virtual List<RuleEntity> LoadCheckResult(RuleEntity ruleEntity = null, bool isCheck = false)
{
bool ZTIsUploaded = false;
IRDBHelper rDBHelper = null;
List<RuleEntity> ruleEntityList = null;
try
{
if (CurrentTaskPackage == null || !File.Exists(CurrentTaskPackage.PackageTempPath))
return ruleEntityList;
rDBHelper = RDBFactory.CreateDbHelper($"{CurrentTaskPackage.PackageTempPath}{projectInfo.Pathpassword}", DatabaseType.SQLite);
if (ruleEntity != null)
{
rDBHelper.ExecuteNonQueryWithException($"delete from CheckResult where ErrorType='二类错误' and RuleCode='{ruleEntity.RuleCode}' and ErrorId='{ruleEntity.ErrorId}' and tbbsm='{ruleEntity.TBBSM}'", CommandType.Text);
}
string excuteSQL = $"SELECT * FROM CheckResult";
if (CurrentSelectNode != null && CurrentWYRWTB != null)
{
excuteSQL = $"SELECT * FROM CheckResult WHERE TBBSM='{CurrentWYRWTB.TBBSM}'";
}
//已上传状态
ZTIsUploaded = DTBDBLoadHelper.JudgeZTIsUploaded(rDBHelper, CurrentWYRWTB.TBBSM);
DataTable dataTable = rDBHelper.ExecuteDatatable("result", excuteSQL, true);
if (dataTable != null && dataTable.Rows.Count > 0)
{
ruleEntityList = KGIS.Framework.Utils.Utility.TBToList.ToList<RuleEntity>(dataTable);
}
TreeNode treeNode = null;
if (CurrentSelectNode.NodeLevel == 2)
{
treeNode = CurrentSelectNode;
}
else if (CurrentSelectNode.NodeLevel == 3)
{
treeNode = CurrentSelectNode.ParentNode;
}
if (treeNode != null && rDBHelper != null)
{
if (ruleEntityList == null || ruleEntityList.Count <= 0)
{
if (treeNode.PackageState.Equals("质检错误"))
{
if (!ZTIsUploaded)
{
rDBHelper.ExecuteNonQueryWithException($"update wyrw set zt='已完成' where tbbsm='{CurrentWYRWTB.TBBSM}'", CommandType.Text);
treeNode.PackageState = "已完成";
}
}
else if (treeNode.PackageState.Equals("未完成") && isCheck)
{
if (!ZTIsUploaded)
{
rDBHelper.ExecuteNonQueryWithException($"update wyrw set zt='已完成' where tbbsm='{CurrentWYRWTB.TBBSM}'", CommandType.Text);
treeNode.PackageState = "已完成";
}
}
}
else
{
if (!ZTIsUploaded)
{
rDBHelper.ExecuteNonQueryWithException($"update wyrw set zt='质检错误' where tbbsm='{CurrentWYRWTB.TBBSM}'", CommandType.Text);
treeNode.PackageState = "质检错误";
}
}
}
}
catch (Exception ex)
{
LogAPI.Debug("加载质检结果失败:" + ex.Message);
LogAPI.Debug("加载质检结果失败:" + ex.StackTrace);
throw ex;
}
finally
{
if (rDBHelper != null)
rDBHelper.DisConnect();
}
return ruleEntityList;
}
#endregion
#region 结束编辑
private ControlsEditingStopCommand stopCmd = new ControlsEditingStopCommandClass();
/// <summary>
/// 结束编辑
/// </summary>
/// <param name="StopEngineEditor"></param>
public void StopEditForDTBJK(IEngineEditor StopEngineEditor)
{
try
{
if (StopEngineEditor == null || StopEngineEditor.EditState == esriEngineEditState.esriEngineStateNotEditing)
{
return;
}
if (StopEngineEditor.EditWorkspace.WorkspaceFactory.WorkspaceType == esriWorkspaceType.esriFileSystemWorkspace)
{
stopCmd.OnClick();
return;
}
DBLoadHelper dBLoadHelper = new DBLoadHelper();
IWorkspaceEdit2 workspaceEdit2 = (IWorkspaceEdit2)StopEngineEditor.EditWorkspace;
bool ISEditing = false;
workspaceEdit2.HasEdits(ref ISEditing);
//外业任务数据源在基础库内,查询全部图层方式太慢
//IDataChangesEx dataChangesEx = workspaceEdit2.get_EditDataChanges(esriEditDataChangesType.esriEditDataChangesWithinSession);
//获取所有变化的要素集
//IEnumBSTR modifiedClasses = dataChangesEx.ModifiedClasses;
//string hasChange = modifiedClasses.Next();
//if (!string.IsNullOrWhiteSpace(hasChange))
if (ISEditing)
{
//System.Windows.Forms.DialogResult result = MessageHelper.ShowYesNoCancelAndTips("是否保存编辑内容?");
//if (result == System.Windows.Forms.DialogResult.Yes)
//{
dBLoadHelper.SaveEingineEdit(this.hookHelper);
StopEngineEditor.StopEditing(true);
}
else
{
StopEngineEditor.StopEditing(false);
}
MapsManager.Instance.MapService.getAxMapControl().CurrentTool = null;
}
catch (Exception ex)
{
LogAPI.Debug("结束编辑失败:" + ex);
MessageHelper.ShowTips(ex.Message);
throw ex;
}
}
#endregion
#region GenerWYTBNewData
/// <summary>
/// 单图斑建库新增任务图斑-ZZTB
/// </summary>
/// <param name="Newfeature"></param>
/// <param name="rdbHelper"></param>
/// <param name="JCBHValue">接口获取的监测编号</param>
public void GenerWYTBNewData(IFeature Newfeature, IRDBHelper rdbHelper, string JCBHValue, bool NewJCBH)
{
try
{
#region 同步任务包数据
List<IFeature> JCfeatures = FeatureAPI.Identify2(Newfeature.ShapeCopy, DtbFeatureLayer);
string XZDMValue = string.Empty;
string jcmjValue = string.Empty;
foreach (IFeature featureitem in JCfeatures)
{
int ZLDWDMIndex = featureitem.Class.FindField("ZLDWDM");
if (ZLDWDMIndex != -1 && featureitem.Value[ZLDWDMIndex] != null && featureitem.Value[ZLDWDMIndex].ToString().Length >= 16)
{
XZDMValue = featureitem.Value[ZLDWDMIndex].ToString().Substring(0, 9);
jcmjValue = featureitem.Value[ZLDWDMIndex].ToString().Substring(0, 12);
break;
}
}
//删除库中已存在的任务图斑数据
rdbHelper.ExecuteNonQueryWithException($"delete from WYRW where JCBH='{JCBHValue}'", CommandType.Text);
//该方式
rdbHelper.ExecuteNonQueryWithException($"delete from dtbdltbgx where TBBSM='{JCBHValue}'", CommandType.Text);
string egeometry = GeometryConvertHelper.ConverIGometryToJson(Newfeature.ShapeCopy);
double tbmj = Newfeature.ShapeCopy.GetEllipseArea().ToDouble();
double jcmj = tbmj <= 0 ? tbmj : (tbmj / 666.67).ToDouble(2);//平方米转亩
string fields = "TBBSM,TBMJ,JCMJ,XZQDM,XZDM,CJDM,JCBH,EGeometry,ZXDX,ZXDY,MAXX,MAXY,MINX,MINY,SJLY,TBLX";
string values = $"'{JCBHValue}','{tbmj}','{jcmj}','{projectInfo.CODE}','{XZDMValue}','{jcmjValue}','{JCBHValue}','{egeometry}','{""}','{""}','{""}','{""}','{""}','{""}','{"ZZTB"}','{"ZZTB"}'";
string excuteSQL = string.Format("insert into WYRW({0})values({1})", fields, values);
rdbHelper.ExecuteNonQueryWithException(excuteSQL, CommandType.Text);//更新任务包任务图斑
#endregion
#region 填充新增图斑字段
int JCBHIndex = Newfeature.Class.FindField("JCBH");
int SJLYIndex = Newfeature.Class.FindField("SJLY");
int TBLXIndex = Newfeature.Class.FindField("TBLX");
int TBBSMIndex = Newfeature.Class.FindField("TBBSM");
int BSMIndex = Newfeature.Class.FindField("BSM");
int JCMJIndex = Newfeature.Class.FindField("JCMJ");
int TBMJIndex = Newfeature.Class.FindField("TBMJ");
int EGeometryIndex = Newfeature.Class.FindField("EGeometry");
int XZQDMIndex = Newfeature.Class.FindField("XZQDM");
int XZDMIndex = Newfeature.Class.FindField("XZDM");
int CJDMIndex = Newfeature.Class.FindField("CJDM");
if (CJDMIndex != -1)
Newfeature.Value[CJDMIndex] = jcmjValue;
if (XZDMIndex != -1)
Newfeature.Value[XZDMIndex] = XZDMValue;
if (XZQDMIndex != -1)
Newfeature.Value[XZQDMIndex] = projectInfo.CODE;
if (EGeometryIndex != -1)
Newfeature.Value[EGeometryIndex] = egeometry;
if (TBMJIndex != -1)
Newfeature.Value[TBMJIndex] = tbmj;
if (JCMJIndex != -1)
Newfeature.Value[JCMJIndex] = jcmj;
if (BSMIndex != -1)
Newfeature.Value[BSMIndex] = Newfeature.OID.ToString();
if (JCBHIndex != -1)
Newfeature.Value[JCBHIndex] = JCBHValue;
if (TBBSMIndex != -1)
Newfeature.Value[TBBSMIndex] = JCBHValue;
if (SJLYIndex != -1)
Newfeature.Value[SJLYIndex] = "ZZTB";
if (TBLXIndex != -1)
Newfeature.Value[TBLXIndex] = "ZZTB";
Newfeature.Store();
#endregion
#region 同步树节点数据
WYRWTB wYRWTB = new WYRWTB()
{
ObjectID = Newfeature.OID,
JCBH = JCBHValue,
TBBSM = JCBHValue,
JCMJ = jcmj.ToDecimal(),
TBMJ = tbmj.ToDecimal(),
XZQDM = projectInfo != null ? projectInfo.CODE : "",
XZDM = XZDMValue,
CJDM = jcmjValue,
SJLY = "ZZTB",
TBLX = "ZZTB",
ZT = "未完成"
};
if (CurrentSelectNode.Data is TaskPackage)
{
TreeNode treeWYRWNode = null;
if (NewJCBH)
{
//外业任务图斑
treeWYRWNode = new TreeNode()
{
Name = JCBHValue + "(0)",
Paixu = CurrentSelectNode.Nodes.Count + 1,
IsExpanded = false,
Icon = "pack://application:,,,/Kingo.Plugin.General;component/Resources/未星标.png",
Data = wYRWTB,
NodeLevel = 2,
NodeID = wYRWTB.ObjectID,
ParentNode = CurrentSelectNode,
PackageNode = CurrentSelectNode,//任务包树节点
PackageState = wYRWTB.ZT,
cMenu = new ContextMenu()
};
IsAutoSaveEdit = false;//暂时作为避免再次触发保存
CurrentSelectNode.Nodes.Add(treeWYRWNode);
IsAutoSaveEdit = true;
}
else
{
//对于已经存在的任务图斑
treeWYRWNode = GetNodeByName(TreeDataSource[0], JCBHValue, new List<int>() { 2 });
if (treeWYRWNode != null)
{
treeWYRWNode.NodeID = wYRWTB.ObjectID;
treeWYRWNode.Data = wYRWTB;
treeWYRWNode.PackageState = wYRWTB.ZT;
}
}
//StartEditForDTBJK(EngineEditorBG, DtbFeatureLayer);//新增任务图斑-开启变更范围编辑
//InitBGDataByJCSJ(treeWYRWNode);//初始化新增任务图斑-变更范围图斑
//StartEditForDTBJK(EngineEditorBG, WyrwFeatureLayer);
}
#endregion
}
catch (Exception ex)
{
LogAPI.Debug("创建任务图斑失败:" + ex.Message);
MessageHelper.ShowError("创建任务图斑失败:" + ex.Message);
}
}
#endregion
#region 质检-外业任务图斑
/// <summary>
/// 质检-外业任务图斑
/// </summary>
/// <param name="obj">质检</param>
/// <returns></returns>
public virtual List<RuleEntity> DTBCheckPackage(object obj)
{
bool ZTIsUploaded = false;
IRDBHelper rdbHelper = null;
string tbbsm = string.Empty;
List<RuleEntity> CheckResultsTemp = new List<RuleEntity>();
try
{
TreeNode treeNode = obj as TreeNode;
tbbsm = (treeNode.Data as WYRWTB).TBBSM;
string dbPath = (treeNode.PackageNode.Data as TaskPackage).PackageTempPath;
rdbHelper = RDBFactory.CreateDbHelper($"{dbPath}{projectInfo.Pathpassword}", DatabaseType.SQLite);
//已上传状态
ZTIsUploaded = DTBDBLoadHelper.JudgeZTIsUploaded(rdbHelper, tbbsm);
List<RuleEntity> lstResult = new List<RuleEntity>();
rdbHelper.BeginTransaction();
//去除冗余数据
rdbHelper.ExecuteNonQueryWithException("delete from FJGX where tbbsm not in(select bsm from DTBDLTBGX);", CommandType.Text);
rdbHelper.ExecuteNonQueryWithException("delete from DTBDLTBGXGC where bghtbbsm not in(select bsm from DTBDLTBGX);", CommandType.Text);
rdbHelper.ExecuteNonQueryWithException("delete from DTBLSYDGX where bsm not in(select bsm from DTBDLTBGX);", CommandType.Text);
rdbHelper.ExecuteNonQueryWithException("delete from DTBTTQGX where bsm not in(select bsm from DTBDLTBGX);", CommandType.Text);
rdbHelper.ExecuteNonQueryWithException("delete from DTBGFBQGX where bsm not in(select bsm from DTBDLTBGX);", CommandType.Text);
rdbHelper.ExecuteNonQueryWithException("delete from DTBCCWJQGX where bsm not in(select bsm from DTBDLTBGX);", CommandType.Text);
rdbHelper.ExecuteNonQueryWithException("delete from DTBCZCDYDGX where bsm not in(select bsm from DTBDLTBGX);", CommandType.Text);
rdbHelper.ExecuteNonQueryWithException("delete from DTBLMFWGX where bsm not in(select bsm from DTBDLTBGX);", CommandType.Text);
rdbHelper.ExecuteNonQueryWithException("delete from checkresult where tbbsm in(select TBBSM from wyrw where FWY=1);", CommandType.Text);
//返外业的不检查
DataTable dataTable = rdbHelper.ExecuteDatatable("data", $"select TBBSM from wyrw where TBBSM='{tbbsm}' AND FWY=1", true);
if (dataTable != null && dataTable.Rows.Count > 0)
{
treeNode.PackageState = "已完成";
return CheckResultsTemp;
}
rdbHelper.ExecuteNonQueryWithException($"delete from checkresult where tbbsm='{tbbsm}';", CommandType.Text);
//判断当前外业任务图斑下是否存在变更图斑
dataTable = rdbHelper.ExecuteDatatable("data", $"select TBBSM from dtbdltbgx where TBBSM='{tbbsm}'", true);
if (dataTable == null || dataTable.Rows.Count <= 0)
{
lstResult.Add(new RuleEntity() { ErrorId = tbbsm, ErrorTip = "当前外业图斑下不存在变更图斑!", RuleContent = "当前外业图斑下不存在变更图斑", ErrorType = "一类错误" });
}
else
{
try
{
lstResult = RuleCheck.XJRuleCheck.RuleCheckOpertion_DTB.StartXJSHCheck(tbbsm, dbPath, DTBDBLoadHelper.GetBasicData());
}
catch (Exception exce)
{
LogAPI.Debug("质检异常:" + exce);
}
}
if (lstResult != null && lstResult.Count > 0)
{
string excuteSQL = "INSERT INTO CheckResult (XH, CheckObject, ErrorType, ErrorId, ErrorTip,RuleCode, RuleName, RuleContent,TBBSM,GeometryType,Geometry) VALUES({0}, '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}','{8}', {9},'{10}');";
int i = 1;
lstResult.OrderBy(X => X.ErrorId);
foreach (var item in lstResult)
{
item.XH = i++;
rdbHelper.ExecuteNonQueryWithException(string.Format(excuteSQL, item.XH, item.CheckObject, item.ErrorType, item.ErrorId, item.ErrorTip, item.RuleCode, item.RuleName, item.RuleContent, tbbsm, item.GeometryType, item.Geometry), CommandType.Text);
}
if (!ZTIsUploaded)
rdbHelper.ExecuteNonQueryWithException($"update wyrw set ZT='质检错误' where tbbsm='{tbbsm}'", CommandType.Text);
}
else
{
if (!ZTIsUploaded)
rdbHelper.ExecuteNonQueryWithException($"update wyrw set ZT='已完成' where tbbsm='{tbbsm}'", CommandType.Text);
}
if (rdbHelper != null)
{
rdbHelper.Commit();
CheckResultsTemp = LoadCheckResult(null, true);
}
}
catch (Exception ex)
{
if (rdbHelper != null)
{
rdbHelper.Rollback();
if (!ZTIsUploaded)
rdbHelper.ExecuteNonQueryWithException($"update wyrw set ZT='质检错误' where tbbsm='{tbbsm}'", CommandType.Text);
rdbHelper.Commit();
}
LogAPI.Debug(ex);
throw ex;
}
finally
{
if (rdbHelper != null)
rdbHelper.DisConnect();
}
return CheckResultsTemp;
}
#endregion
}
}