|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using KUI.Windows;
|
|
|
|
|
using Kingo.Plugin.AttributeMaintain.ModelEntity;
|
|
|
|
|
using Kingo.Plugin.AttributeMaintain.Config;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Geometry;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
using KGIS.Framework.DBOperator;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using KGIS.Framework.AE.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.Utils.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.AE.GPHelper;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using ESRI.ArcGIS.DataSourcesGDB;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.DLTB_IDG.Helper
|
|
|
|
|
{
|
|
|
|
|
public class SXWHHelper : IDataChange
|
|
|
|
|
{
|
|
|
|
|
private List<GDEntity> GDEntitys;
|
|
|
|
|
private List<TestData> list;
|
|
|
|
|
public string IDataChangeName { get => "SXWHHelper"; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 图层属性数据源
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<EllipsoidAreaTable> listEllipsoidAreaTable = null;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 图层集合
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<LayerEntity> layers;
|
|
|
|
|
public List<RuleTableEntity> ysdmlistRuleTableEntity = null;
|
|
|
|
|
|
|
|
|
|
public SXWHHelper(List<GDEntity> _GDEntitys = null, List<TestData> _list = null)
|
|
|
|
|
{
|
|
|
|
|
GDEntitys = _GDEntitys;
|
|
|
|
|
list = _list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ExecuteDataChange(DataChangeParameter pParm)
|
|
|
|
|
{
|
|
|
|
|
Implement();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Implement()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (list[i].IsChecked)
|
|
|
|
|
{
|
|
|
|
|
//椭球面积计算
|
|
|
|
|
if (list[i].ItemType == "Area")
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("正在进行椭球面积计算,请稍后 ...");
|
|
|
|
|
TQMJJSInit();
|
|
|
|
|
if (listEllipsoidAreaTable == null || listEllipsoidAreaTable.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("椭球面积计算失败,dataGrid数据源为空!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.UpdateMsg("正在计算椭球面积...");
|
|
|
|
|
foreach (EllipsoidAreaTable item in listEllipsoidAreaTable)
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer pFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName(item.TableName);
|
|
|
|
|
if (pFeatureLayer == null || pFeatureLayer.FeatureClass == null) continue;
|
|
|
|
|
if ((pFeatureLayer.FeatureClass as FeatureClass).BrowseName == item.TableName)
|
|
|
|
|
{
|
|
|
|
|
if (pFeatureLayer == null || pFeatureLayer.FeatureClass == null) continue;
|
|
|
|
|
//获取当前图层需要计算椭球面积要素的总数
|
|
|
|
|
this.UpdateMsg(string.Format("正在计算【{0}】椭球面积…", item.TableAliasName));
|
|
|
|
|
int fieldIndex = pFeatureLayer.FeatureClass.Fields.FindField(item.FieldName);
|
|
|
|
|
if (fieldIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
SetFeatureEllipsoidArea(pFeatureLayer, fieldIndex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (list[i].ItemType == "BSM")
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("正在进行标识码赋值,请稍候...");
|
|
|
|
|
LayerData();
|
|
|
|
|
BSMExecute();
|
|
|
|
|
}
|
|
|
|
|
else if (list[i].ItemType == "YSDM")
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("正在进行要素代码赋值,请稍后 ...");
|
|
|
|
|
YSDMInit();
|
|
|
|
|
YSDMExecute();
|
|
|
|
|
}
|
|
|
|
|
else if (list[i].ItemType == "KCXS")
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("正在进行扣除系数赋值,请稍后 ...");
|
|
|
|
|
KCDLXSExcute();
|
|
|
|
|
}
|
|
|
|
|
else if (list[i].ItemType == "KCMJ")
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("正在进行扣除面积赋值,请稍后 ...");
|
|
|
|
|
KCDLMJExecute();
|
|
|
|
|
}
|
|
|
|
|
else if (list[i].ItemType == "GDPDJB_DLZL")
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("正在进行耕地坡度级别赋值(单纯变化增量),请稍后 ...");
|
|
|
|
|
GDPDJBUpdate_DLZL();
|
|
|
|
|
}
|
|
|
|
|
else if (list[i].ItemType == "KCXS_GDWBH")
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("正在进行扣除系数赋值(耕地未变化),请稍后 ...");
|
|
|
|
|
KCXSUpdate_GDWBH();
|
|
|
|
|
KCDLXSExcute();
|
|
|
|
|
KCDLMJExecute();
|
|
|
|
|
}
|
|
|
|
|
else if (list[i].ItemType == "TBXHDM_GD")
|
|
|
|
|
{
|
|
|
|
|
TBXHDM_GD();
|
|
|
|
|
}
|
|
|
|
|
else if (list[i].ItemType == "XMSX")
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("正在进行项目属性赋值,请稍候...");
|
|
|
|
|
|
|
|
|
|
ProjectInfo projectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
|
|
|
|
|
SetGXField(projectInfo.ProjType, "DLTBGX");
|
|
|
|
|
SetGXField(projectInfo.ProjType, "DLTBGXGC");
|
|
|
|
|
|
|
|
|
|
//测试
|
|
|
|
|
//SetGXField(projectInfo.ProjType, "CZCDYDGX");
|
|
|
|
|
//SetGXField(projectInfo.ProjType, "CZCDYDGXGC");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("请选择其中一项进行属性维护!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("属性维护过程中失败:" + ex.Message);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private IWorkspace CreateDBWorkspace(string pDbPath)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!File.Exists(pDbPath))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(string.Format("指定的文件路径{0}不存在!", pDbPath));
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
IWorkspaceFactory pOutWorkFactory = null;
|
|
|
|
|
pOutWorkFactory = new SqlWorkspaceFactoryClass();
|
|
|
|
|
IWorkspace pOutWork = pOutWorkFactory.OpenFromFile(pDbPath, 0);
|
|
|
|
|
return pOutWork;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Log:CreateDBWorkspace错误:{ex.Message}");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public virtual string CreateTempDB(string pType, string pSubType = "")
|
|
|
|
|
{
|
|
|
|
|
string result = string.Empty;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string dbPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "Temp" + ".db");
|
|
|
|
|
string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\" + pType;
|
|
|
|
|
if (!Directory.Exists(gdbFolder))
|
|
|
|
|
Directory.CreateDirectory(gdbFolder);
|
|
|
|
|
|
|
|
|
|
PluginServiceInterface.CommonHelper.DelectDir(gdbFolder);
|
|
|
|
|
|
|
|
|
|
IWorkspaceFactory pFtWsFct = new FileGDBWorkspaceFactory();
|
|
|
|
|
string gdbFileName = DateTime.Now.ToString("yyyyMMddHHmmssfff");// Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
string path = System.IO.Path.Combine(gdbFolder, string.IsNullOrWhiteSpace(pSubType) ? gdbFileName : pSubType);
|
|
|
|
|
pFtWsFct.Create(path, "TempGDB", null, 0);
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
}
|
|
|
|
|
if (File.Exists(dbPath))
|
|
|
|
|
{
|
|
|
|
|
File.Copy(dbPath, System.IO.Path.Combine(path, "Temp" + ".sqlite"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(string.Format("文件{0}不存在!", dbPath));
|
|
|
|
|
}
|
|
|
|
|
result = path;// System.IO.Path.Combine(path, "TempGDB.gdb");//临时数据存放路径
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("创建临时数据库失败!" + ex.Message);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool TableToTable(IFeatureWorkspace pInWork, IWorkspace pOutWork, string tableName, IQueryFilter queryFilter = null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (pInWork == null || pOutWork == null || string.IsNullOrEmpty(tableName)) return false;
|
|
|
|
|
IWorkspace2 workspace2 = pInWork as IWorkspace2;
|
|
|
|
|
if (workspace2 != null)
|
|
|
|
|
{
|
|
|
|
|
if (!workspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, tableName))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ITable pInTable = pInWork.OpenTable(tableName);
|
|
|
|
|
if (pInTable == null) return false;
|
|
|
|
|
IDataset pIndataset = (IDataset)pInTable;
|
|
|
|
|
IDatasetName pInDatasetName = (IDatasetName)pIndataset.FullName;
|
|
|
|
|
IEnumDataset enumDataset = pOutWork.get_Datasets(esriDatasetType.esriDTTable);
|
|
|
|
|
IDataset dataset;
|
|
|
|
|
enumDataset.Reset();
|
|
|
|
|
while ((dataset = enumDataset.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
string[] names = dataset.Name.Split('.');
|
|
|
|
|
if (string.Equals(names[names.Length - 1], tableName, StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
dataset.Delete();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IDataset pOutDataset = (IDataset)pOutWork;
|
|
|
|
|
IDatasetName pOutDatasetName = new TableNameClass();
|
|
|
|
|
pOutDatasetName.WorkspaceName = (IWorkspaceName)pOutDataset.FullName;
|
|
|
|
|
pOutDatasetName.Name = tableName;
|
|
|
|
|
IFieldChecker fieldChecker = new FieldCheckerClass();
|
|
|
|
|
IFields targetFeatureClassFields = pInTable.Fields;
|
|
|
|
|
IFields sourceFeatureClassFields = pInTable.Fields;
|
|
|
|
|
IEnumFieldError enumFieldError;
|
|
|
|
|
fieldChecker.InputWorkspace = pInWork as IWorkspace;
|
|
|
|
|
fieldChecker.ValidateWorkspace = pOutWork;
|
|
|
|
|
fieldChecker.Validate(sourceFeatureClassFields, out enumFieldError, out targetFeatureClassFields);
|
|
|
|
|
IFeatureDataConverter one2another = new FeatureDataConverterClass();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
one2another.ConvertTable(pInDatasetName, queryFilter, pOutDatasetName, targetFeatureClassFields, "", 1000, 0);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Marshal.ReleaseComObject(one2another);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//LogAPI.Debug(ex);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GDPDJBUpdate_DLZL()
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass DLTBGXFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGX");
|
|
|
|
|
IFeatureClass DLTBGXGCFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGXGC");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (DLTBGXFC == null || DLTBGXGCFC == null) return;
|
|
|
|
|
List<string> testDatas = new List<string>() { "0101", "0102", "0103" };//耕地
|
|
|
|
|
if (DLTBGXFC.FeatureCount(null) == 0 || DLTBGXGCFC.FeatureCount(null) == 0) return;
|
|
|
|
|
ICursor pCur = null;
|
|
|
|
|
IRow row = null;
|
|
|
|
|
string UpDateGCZLOIDs = string.Empty;
|
|
|
|
|
Dictionary<string, int> keyValuePairs = new Dictionary<string, int>();
|
|
|
|
|
Dictionary<string, int> keyValueReMove = new Dictionary<string, int>();
|
|
|
|
|
IQueryDef pQDef = ((DLTBGXGCFC as FeatureClass).Workspace as IFeatureWorkspace).CreateQueryDef();
|
|
|
|
|
pQDef.Tables = "DLTBGXGC";
|
|
|
|
|
//pQDef.WhereClause = " 1=1 AND BGQDLBM like '01%' AND BGHDLBM like '01%' AND BGXW='2'";
|
|
|
|
|
pQDef.WhereClause = " 1=1 ";
|
|
|
|
|
pQDef.SubFields = "BGQTBBSM,BGHTBBSM,BGQDLBM,BGHDLBM";
|
|
|
|
|
pCur = pQDef.Evaluate();
|
|
|
|
|
while ((row = pCur.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
string BGQDL = row.get_Value(2).ToTrim();
|
|
|
|
|
string BGHDL = row.get_Value(3).ToTrim();
|
|
|
|
|
//string BGHDL3 = row.get_Value(1).ToTrim();
|
|
|
|
|
if (!testDatas.Contains(row.get_Value(2).ToTrim()) || !testDatas.Contains(row.get_Value(3).ToTrim()))
|
|
|
|
|
{
|
|
|
|
|
keyValueReMove[row.get_Value(0).ToTrim()] = 0;
|
|
|
|
|
}
|
|
|
|
|
//获取图形变更的
|
|
|
|
|
if (!keyValueReMove.ContainsKey(row.get_Value(0).ToTrim()))
|
|
|
|
|
if (!keyValuePairs.ContainsKey(row.get_Value(0).ToString()))
|
|
|
|
|
keyValuePairs[row.get_Value(0).ToString()] = 1;
|
|
|
|
|
else
|
|
|
|
|
keyValuePairs[row.get_Value(0).ToString()] = 2;
|
|
|
|
|
else if (keyValuePairs.ContainsKey(row.get_Value(0).ToTrim()))
|
|
|
|
|
keyValuePairs.Remove(row.get_Value(0).ToTrim());
|
|
|
|
|
}
|
|
|
|
|
Dictionary<string, int> keyValueDCBG = new Dictionary<string, int>();
|
|
|
|
|
Dictionary<string, int> keyValueReDCBG = new Dictionary<string, int>();
|
|
|
|
|
pCur = pQDef.Evaluate();
|
|
|
|
|
while ((row = pCur.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
string BGQBSMValue = row.get_Value(0).ToTrim();
|
|
|
|
|
string BGHBSMValue = row.get_Value(1).ToTrim();
|
|
|
|
|
if ((keyValuePairs.ContainsKey(BGQBSMValue) && keyValuePairs[BGQBSMValue] == 2) || keyValueDCBG.ContainsKey(BGHBSMValue))
|
|
|
|
|
{
|
|
|
|
|
if (!keyValueDCBG.ContainsKey(BGHBSMValue) && !keyValueReDCBG.ContainsKey(BGHBSMValue))
|
|
|
|
|
keyValueDCBG[BGHBSMValue] = 1;
|
|
|
|
|
else
|
|
|
|
|
keyValueDCBG[BGHBSMValue] = 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
keyValueReDCBG[BGHBSMValue] = 0;
|
|
|
|
|
}
|
|
|
|
|
string UpZLData = string.Empty;
|
|
|
|
|
foreach (var item in keyValueDCBG)
|
|
|
|
|
{
|
|
|
|
|
if (item.Value == 1)
|
|
|
|
|
UpZLData += $"'{item.Key}',";
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(UpZLData)) return;
|
|
|
|
|
|
|
|
|
|
row = null;
|
|
|
|
|
int BGHGDPDJBIndex = DLTBGXGCFC.FindField("BGHGDPDJB");
|
|
|
|
|
int BGHGDLXIndex = DLTBGXGCFC.FindField("BGHGDLX");
|
|
|
|
|
int BGQGDPDJBIndex = DLTBGXGCFC.FindField("BGQGDPDJB");
|
|
|
|
|
int BGQGDLXIndex = DLTBGXGCFC.FindField("BGQGDLX");
|
|
|
|
|
int BGQKCXSIndex = DLTBGXGCFC.FindField("BGQKCXS");
|
|
|
|
|
int BGHKCXSIndex = DLTBGXGCFC.FindField("BGHKCXS");
|
|
|
|
|
int BGQKCDLBMIndex = DLTBGXGCFC.FindField("BGQKCDLBM");
|
|
|
|
|
int BGHKCDLBMIndex = DLTBGXGCFC.FindField("BGHKCDLBM");
|
|
|
|
|
int BGHTBMJIndex = DLTBGXGCFC.FindField("TBBGMJ");
|
|
|
|
|
int BGHTBBSMIndex = DLTBGXGCFC.FindField("BGHTBBSM");
|
|
|
|
|
int GCBSMIndex = DLTBGXGCFC.FindField("BSM");
|
|
|
|
|
int BGQTBBSMIndex = DLTBGXGCFC.FindField("BGQTBBSM");
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> keyValueGDJB = new Dictionary<string, string>();
|
|
|
|
|
IQueryFilter queryFilter = new QueryFilterClass()
|
|
|
|
|
{
|
|
|
|
|
WhereClause = $"BGHTBBSM in({UpZLData.Trim(',')}) AND BGQDLBM like '01%' AND BGHDLBM like '01%' AND BGXW='2' AND BGQDLBM<>BGHDLBM"
|
|
|
|
|
};
|
|
|
|
|
ICursor cursorZL = (DLTBGXGCFC as ITable).Update(queryFilter, true);
|
|
|
|
|
while ((row = cursorZL.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (row.Value[GCBSMIndex].ToString() == "220183211100007020")
|
|
|
|
|
{
|
|
|
|
|
string asdd = row.Value[BGHTBBSMIndex].ToString();
|
|
|
|
|
}
|
|
|
|
|
row.Value[BGHGDPDJBIndex] = row.Value[BGQGDPDJBIndex];
|
|
|
|
|
row.Value[BGHGDLXIndex] = row.Value[BGQGDLXIndex];
|
|
|
|
|
row.Value[BGHKCXSIndex] = row.Value[BGQKCXSIndex];
|
|
|
|
|
row.Value[BGHKCDLBMIndex] = row.Value[BGQKCDLBMIndex];
|
|
|
|
|
keyValueGDJB[row.Value[BGHTBBSMIndex].ToString()] = row.Value[BGQGDPDJBIndex].ToString() + "_" + row.Value[BGQGDLXIndex].ToString() + "_" + row.Value[BGQKCXSIndex].ToString() + "_" + row.Value[BGQKCDLBMIndex].ToString();
|
|
|
|
|
cursorZL.UpdateRow(row);
|
|
|
|
|
}
|
|
|
|
|
cursorZL.Flush();
|
|
|
|
|
#region MyRegion
|
|
|
|
|
row = null;
|
|
|
|
|
int BSMIndex = DLTBGXFC.FindField("BSM");
|
|
|
|
|
int OBJECTIDIndex = DLTBGXFC.FindField("OBJECTID");
|
|
|
|
|
int GDPDJBIndex = DLTBGXFC.FindField("GDPDJB");
|
|
|
|
|
int GDLXIndex = DLTBGXFC.FindField("GDLX");
|
|
|
|
|
int KCXSIndex = DLTBGXFC.FindField("KCXS");
|
|
|
|
|
int KCDLBMIndex = DLTBGXFC.FindField("KCDLBM");
|
|
|
|
|
//int shapeIndex = DLTBGXFC.Fields.FindField("SHAPE");
|
|
|
|
|
queryFilter.WhereClause = $"BSM in({UpZLData.Trim(',')})";
|
|
|
|
|
cursorZL = (DLTBGXFC as ITable).Update(queryFilter, true);
|
|
|
|
|
while ((row = cursorZL.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (keyValueGDJB.ContainsKey(row.Value[BSMIndex].ToString()))
|
|
|
|
|
{
|
|
|
|
|
row.Value[GDPDJBIndex] = keyValueGDJB[row.Value[BSMIndex].ToString()].Split('_')[0];
|
|
|
|
|
row.Value[GDLXIndex] = keyValueGDJB[row.Value[BSMIndex].ToString()].Split('_')[1];
|
|
|
|
|
row.Value[KCXSIndex] = keyValueGDJB[row.Value[BSMIndex].ToString()].Split('_')[2];
|
|
|
|
|
row.Value[KCDLBMIndex] = keyValueGDJB[row.Value[BSMIndex].ToString()].Split('_')[3];
|
|
|
|
|
cursorZL.UpdateRow(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cursorZL.Flush();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 合并-待验证
|
|
|
|
|
string FieldsJH = "DLBM,DLMC,QSXZ,QSDWDM,QSDWMC,ZLDWDM,ZLDWMC,KCDLBM,KCXS,GDLX,GDPDJB,XZDWKD,TBXHDM,TBXHMC,ZZSXDM,ZZSXMC,GDDB,FRDBS,CZCSXM,MSSM,HDMC";
|
|
|
|
|
string DLNMValues = "0101,0102,0103";
|
|
|
|
|
IFeatureCursor featureCursor = DLTBGXFC.Update(queryFilter, true);
|
|
|
|
|
IFeature feature = null;
|
|
|
|
|
//int BSMIndex = DLTBGXFC.FindField("BSM");
|
|
|
|
|
int TBMJIndex = DLTBGXFC.FindField("TBMJ");
|
|
|
|
|
int DLBMIndex = DLTBGXFC.FindField("DLBM");
|
|
|
|
|
int TBBHIndex = DLTBGXFC.FindField("TBBH");
|
|
|
|
|
int BGHTBBHIndex = DLTBGXFC.FindField("BGHTBBH");
|
|
|
|
|
IFeatureLayer featureLayer = new FeatureLayer() { FeatureClass = DLTBGXFC };
|
|
|
|
|
while ((feature = featureCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
List<IFeature> features = FeatureAPI.Identify(feature.ShapeCopy, featureLayer);
|
|
|
|
|
if (features.Count >= 2)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < features.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (features[i].OID.Equals(feature.OID)) continue;//非本身
|
|
|
|
|
if (!DLNMValues.Contains(features[i].Value[DLBMIndex].ToTrim())) continue;//非耕地
|
|
|
|
|
var length = FeatureAPI.LengthOfSide(features[i].ShapeCopy, feature.ShapeCopy);
|
|
|
|
|
if (length <= 0.0) continue;//非正相邻
|
|
|
|
|
bool IsHB = true;
|
|
|
|
|
foreach (var item in FieldsJH.Split(','))
|
|
|
|
|
{
|
|
|
|
|
int tempIndex = DLTBGXFC.FindField(item);
|
|
|
|
|
if (feature.Value[tempIndex].ToTrim() != features[i].Value[tempIndex].ToTrim())
|
|
|
|
|
IsHB = false;
|
|
|
|
|
}
|
|
|
|
|
if (!IsHB) continue;
|
|
|
|
|
feature.Shape = FeatureAPI.Union(feature.Shape, features[i].Shape);
|
|
|
|
|
feature.Value[TBMJIndex] = feature.Value[TBMJIndex].ToDouble() + features[i].Value[TBMJIndex].ToDouble();
|
|
|
|
|
featureCursor.UpdateFeature(feature);
|
|
|
|
|
IFeatureCursor GCCueor = DLTBGXGCFC.Update(new QueryFilterClass() { WhereClause = $"BGHTBBSM='{feature.Value[BSMIndex].ToTrim()}'" }, true);
|
|
|
|
|
IFeatureCursor GCCueorZB = DLTBGXGCFC.Update(new QueryFilterClass() { WhereClause = $"BGHTBBSM='{features[i].Value[BSMIndex].ToTrim()}'" }, true);
|
|
|
|
|
IFeature GCFeature = GCCueor.NextFeature();
|
|
|
|
|
IFeature GCFeatureHB = GCCueorZB.NextFeature();
|
|
|
|
|
if (GCFeature != null && GCFeatureHB != null && GCFeature.Value[BGQTBBSMIndex].ToTrim() == GCFeatureHB.Value[BGQTBBSMIndex].ToTrim())
|
|
|
|
|
{ //变更前标识码一致,过程层图斑才能合并
|
|
|
|
|
GCFeature.Shape = FeatureAPI.Union(GCFeature.Shape, GCFeatureHB.Shape);
|
|
|
|
|
GCFeature.Value[BGHTBMJIndex] = feature.Value[TBMJIndex].ToDouble();
|
|
|
|
|
GCCueor.UpdateFeature(GCFeature);
|
|
|
|
|
GCCueor.Flush();
|
|
|
|
|
GCFeatureHB.Delete();
|
|
|
|
|
GCCueorZB.Flush();
|
|
|
|
|
}
|
|
|
|
|
//(DLTBGXGCFC as FeatureClass).Workspace.ExecuteSQL($"update DLTBGXGC set BGHTBBH='{feature.Value[TBBHIndex].ToTrim()}' where BGHTBBSM='{features[i].Value[BSMIndex].ToTrim()}'");
|
|
|
|
|
//(DLTBGXGCFC as FeatureClass).Workspace.ExecuteSQL($"update DLTBGXGC set BGHTBBSM='{feature.Value[BSMIndex].ToTrim()}' where BGHTBBSM='{features[i].Value[BSMIndex].ToTrim()}'");
|
|
|
|
|
features[i].Delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (feature != null) Marshal.ReleaseComObject(feature);
|
|
|
|
|
}
|
|
|
|
|
featureCursor.Flush();
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("耕地坡度级别赋值(单纯变化增量)异常:" + ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool GetHBData(IFeature feature, IFeature feature2, IFeatureClass featureClass)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string FieldsJH = "DLBM,DLMC,QSXZ,QSDWDM,QSDWMC,ZLDWDM,ZLDWMC,KCDLBM,KCXS,GDLX,GDPDJB,XZDWKD,TBXHDM,TBXHMC,ZZSXDM,ZZSXMC,GDDB,FRDBS,CZCSXM,MSSM,HDMC";
|
|
|
|
|
foreach (var item in FieldsJH)
|
|
|
|
|
{
|
|
|
|
|
if (feature.Value[item].ToTrim() != feature2.Value[item].ToTrim())
|
|
|
|
|
return false;
|
|
|
|
|
//HBDataValueQ += $"{feature.Value[item].ToTrim()}";
|
|
|
|
|
//HBDataValueH += $"{feature.Value[item].ToTrim()}";
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void KCXSUpdate_GDWBH()
|
|
|
|
|
{
|
|
|
|
|
IWorkspace pOutWork = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass DLTBGXGCFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGXGC");
|
|
|
|
|
string TempDir = CreateTempDB("KCXSUpdate");
|
|
|
|
|
string dbPath = TempDir + @"\Temp" + ".sqlite";
|
|
|
|
|
pOutWork = CreateDBWorkspace(dbPath);
|
|
|
|
|
|
|
|
|
|
//CustomGPHelper.TableToTable(Temp_DLTBGXGC, dbPath, "DLTBGXGC");
|
|
|
|
|
|
|
|
|
|
IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
rdbHelper.ExecuteSQL(" drop table DLTBGXGC ");
|
|
|
|
|
TableToTable((DLTBGXGCFC as FeatureClass).Workspace as IFeatureWorkspace, pOutWork, "DLTBGXGC");
|
|
|
|
|
|
|
|
|
|
//DataTable dt = rdbHelper.ExecuteDatatable("dt", @"select bgqtbbsm,bghtbbsm,bgqgdpdjb,bghgdpdjb,bgqkcxs,bghkcxs from dltbgxgc where bgqtbbsm NOT in(
|
|
|
|
|
//select bgqtbbsm from dltbgxgc where substr(bgqdlbm,1,2)='01' and substr(bghdlbm,1,2)!='01'
|
|
|
|
|
//) and substr(bgqdlbm,1,2)='01' and substr(bghdlbm,1,2)='01' and bgxw='2' and bgqkcxs!=bghkcxs
|
|
|
|
|
//", true);
|
|
|
|
|
DataTable dt = rdbHelper.ExecuteDatatable("dt", @" select bgqtbbsm,bghtbbsm,bgqgdpdjb,bghgdpdjb,bgqkcxs,bghkcxs from dltbgxgc where substr(bgqdlbm,1,2)='01' and substr(bghdlbm,1,2)='01' and bgxw='2' and BGQGDPDJB<>BGHGDPDJB ", true);
|
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
(DLTBGXGCFC as FeatureClass).Workspace.ExecuteSQL($"update DLTBGXGC set BGHKCXS={dt.Rows[i]["BGQKCXS"]} where BGHTBBSM='{dt.Rows[i]["BGHTBBSM"]}'");
|
|
|
|
|
(DLTBGXGCFC as FeatureClass).Workspace.ExecuteSQL($"update DLTBGXGC set BGHGDPDJB='{dt.Rows[i]["BGQGDPDJB"]}' where BGHTBBSM='{dt.Rows[i]["BGHTBBSM"]}'");
|
|
|
|
|
|
|
|
|
|
(DLTBGXGCFC as FeatureClass).Workspace.ExecuteSQL($"update DLTBGX set KCXS={dt.Rows[i]["BGQKCXS"]} where BSM='{dt.Rows[i]["BGHTBBSM"]}'");
|
|
|
|
|
(DLTBGXGCFC as FeatureClass).Workspace.ExecuteSQL($"update DLTBGX set GDPDJB='{dt.Rows[i]["BGQGDPDJB"]}' where BSM='{dt.Rows[i]["BGHTBBSM"]}'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("扣除地类面积计算异常:" + ex.Message);
|
|
|
|
|
MessageHelper.ShowError("扣除地类面积计算异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (pOutWork != null)
|
|
|
|
|
Marshal.ReleaseComObject(pOutWork);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void TBXHDM_GD()
|
|
|
|
|
{
|
|
|
|
|
IWorkspace pOutWork = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass DLTBGXGCFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGXGC");
|
|
|
|
|
string TempDir = CreateTempDB("TBXHDM_GD");
|
|
|
|
|
string dbPath = TempDir + @"\Temp" + ".sqlite";
|
|
|
|
|
pOutWork = CreateDBWorkspace(dbPath);
|
|
|
|
|
IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
rdbHelper.ExecuteSQL(" drop table DLTBGXGC ");
|
|
|
|
|
TableToTable((DLTBGXGCFC as FeatureClass).Workspace as IFeatureWorkspace, pOutWork, "DLTBGXGC");
|
|
|
|
|
DataTable dt = rdbHelper.ExecuteDatatable("dt", @"select bgqtbbsm,bghtbbsm,BGQTBXHDM,BGQTBXHMC,BGHTBXHDM,BGHTBXHMC from dltbgxgc
|
|
|
|
|
where substr(bgqdlbm,1,2)='01' and substr(bghdlbm,1,2)='01' and BGQTBXHDM in('LQGD','MQGD','SHGD','SMGD')
|
|
|
|
|
and
|
|
|
|
|
(
|
|
|
|
|
(BGQTBXHMC NOTNULL and BGHTBXHMC ISNULL)
|
|
|
|
|
or
|
|
|
|
|
(BGQTBXHDM NOTNULL and BGHTBXHDM ISNULL)
|
|
|
|
|
or
|
|
|
|
|
BGQTBXHDM<>BGHTBXHDM
|
|
|
|
|
or
|
|
|
|
|
BGQTBXHMC<>BGHTBXHMC
|
|
|
|
|
) ", true);
|
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
(DLTBGXGCFC as FeatureClass).Workspace.ExecuteSQL($"update DLTBGXGC set BGHTBXHDM='{dt.Rows[i]["BGQTBXHDM"]}' where BGHTBBSM='{dt.Rows[i]["BGHTBBSM"]}'");
|
|
|
|
|
(DLTBGXGCFC as FeatureClass).Workspace.ExecuteSQL($"update DLTBGXGC set BGHTBXHMC='{dt.Rows[i]["BGQTBXHMC"]}' where BGHTBBSM='{dt.Rows[i]["BGHTBBSM"]}'");
|
|
|
|
|
|
|
|
|
|
(DLTBGXGCFC as FeatureClass).Workspace.ExecuteSQL($"update DLTBGX set TBXHDM='{dt.Rows[i]["BGQTBXHDM"]}' where BSM='{dt.Rows[i]["BGHTBBSM"]}'");
|
|
|
|
|
(DLTBGXGCFC as FeatureClass).Workspace.ExecuteSQL($"update DLTBGX set TBXHMC='{dt.Rows[i]["BGQTBXHMC"]}' where BSM='{dt.Rows[i]["BGHTBBSM"]}'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("扣除地类面积计算异常:" + ex.Message);
|
|
|
|
|
MessageHelper.ShowError("扣除地类面积计算异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (pOutWork != null)
|
|
|
|
|
Marshal.ReleaseComObject(pOutWork);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void SetGXField(EnumProjType projType, string secondLayerName)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer dltbbg_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBBG");
|
|
|
|
|
IFeatureLayer dltbgx_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName(secondLayerName);
|
|
|
|
|
if (dltbbg_Layer == null || dltbgx_Layer == null) return;
|
|
|
|
|
|
|
|
|
|
GPParamClass gPParamClassGX = new GPParamClass();
|
|
|
|
|
gPParamClassGX.FirstFeatureLayer = dltbbg_Layer;
|
|
|
|
|
gPParamClassGX.GPType = EnumGPType.Union;
|
|
|
|
|
gPParamClassGX.SecondFeatureLayer = dltbgx_Layer;
|
|
|
|
|
gPParamClassGX.FcName = dltbbg_Layer.Name;
|
|
|
|
|
gPParamClassGX.IsGetOutPutFeature = true;
|
|
|
|
|
|
|
|
|
|
IFeatureLayer unionLayer = null;
|
|
|
|
|
GeoprocessorHelper.UnionAnalysis(gPParamClassGX, ref unionLayer);
|
|
|
|
|
if (unionLayer == null) return;
|
|
|
|
|
int fid_DLTBBGIndex = unionLayer.FeatureClass.Fields.FindField("FID_DLTBBG");
|
|
|
|
|
int fid_DLTBGXIndex = unionLayer.FeatureClass.Fields.FindField("FID_" + secondLayerName);
|
|
|
|
|
ITable nmkTable = unionLayer.FeatureClass as ITable;
|
|
|
|
|
int rowCount = nmkTable.RowCount(null);
|
|
|
|
|
if (rowCount <= 0) return;
|
|
|
|
|
ICursor nmkCur = nmkTable.Update(null, true);
|
|
|
|
|
IRow nmkRow = null;
|
|
|
|
|
Dictionary<string, string> fieldKeyValues = new Dictionary<string, string>();
|
|
|
|
|
while ((nmkRow = nmkCur.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
var bgValue = nmkRow.Value[fid_DLTBBGIndex];
|
|
|
|
|
var gxValue = nmkRow.Value[fid_DLTBGXIndex];
|
|
|
|
|
if (!string.IsNullOrEmpty(nmkRow.Value[fid_DLTBBGIndex].ToString()) && nmkRow.Value[fid_DLTBBGIndex].ToString() != "-1" && !string.IsNullOrEmpty(nmkRow.Value[fid_DLTBGXIndex].ToString()) && nmkRow.Value[fid_DLTBGXIndex].ToString() != "-1")
|
|
|
|
|
{
|
|
|
|
|
if (projType == EnumProjType.RCBG_ZJG)
|
|
|
|
|
{
|
|
|
|
|
fieldKeyValues.Clear();
|
|
|
|
|
fieldKeyValues.Add("XMMC", nmkRow.Value[unionLayer.FeatureClass.Fields.FindField("XMMC")].ToString());
|
|
|
|
|
fieldKeyValues.Add("XMQBH", nmkRow.Value[unionLayer.FeatureClass.Fields.FindField("XMQBH")].ToString());
|
|
|
|
|
fieldKeyValues.Add("DKBH", nmkRow.Value[unionLayer.FeatureClass.Fields.FindField("DKBH")].ToString());
|
|
|
|
|
|
|
|
|
|
AlterField(dltbgx_Layer, Convert.ToInt32(nmkRow.Value[fid_DLTBGXIndex]), fieldKeyValues);
|
|
|
|
|
|
|
|
|
|
//string sqlGC = string.Format("UPDATE {0} SET XMMC='{1}', XMQBH='{2}', DKBH='{3}' WHERE OBJECTID='{4}'",
|
|
|
|
|
// (dltbgx_Layer.FeatureClass as FeatureClass).BrowseName,
|
|
|
|
|
// nmkRow.Value[unionLayer.FeatureClass.Fields.FindField("XMMC")].ToString(),
|
|
|
|
|
// nmkRow.Value[unionLayer.FeatureClass.Fields.FindField("XMQBH")].ToString(),
|
|
|
|
|
// nmkRow.Value[unionLayer.FeatureClass.Fields.FindField("DKBH")].ToString(),
|
|
|
|
|
// nmkRow.Value[fid_DLTBGXIndex]);
|
|
|
|
|
//(dltbgx_Layer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(sqlGC);
|
|
|
|
|
}
|
|
|
|
|
else if (projType == EnumProjType.RCBG_BCGD)
|
|
|
|
|
{
|
|
|
|
|
fieldKeyValues.Clear();
|
|
|
|
|
fieldKeyValues.Add("XMMC", nmkRow.Value[unionLayer.FeatureClass.Fields.FindField("XMMC")].ToString());
|
|
|
|
|
fieldKeyValues.Add("BCGDXMQBH", nmkRow.Value[unionLayer.FeatureClass.Fields.FindField("BCGDXMQBH")].ToString());
|
|
|
|
|
|
|
|
|
|
AlterField(dltbgx_Layer, Convert.ToInt32(nmkRow.Value[fid_DLTBGXIndex]), fieldKeyValues);
|
|
|
|
|
|
|
|
|
|
//string sqlGC = string.Format("UPDATE {0} SET XMMC='{1}', BCGDXMQBH='{2}' WHERE OBJECTID='{3}'",
|
|
|
|
|
// (dltbgx_Layer.FeatureClass as FeatureClass).BrowseName,
|
|
|
|
|
// nmkRow.Value[unionLayer.FeatureClass.Fields.FindField("XMMC")].ToString(),
|
|
|
|
|
// nmkRow.Value[unionLayer.FeatureClass.Fields.FindField("BCGDXMQBH")].ToString(),
|
|
|
|
|
// nmkRow.Value[fid_DLTBGXIndex]);
|
|
|
|
|
//(dltbgx_Layer.FeatureClass as FeatureClass).Workspace.ExecuteSQL(sqlGC);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("项目属性维护失败,可能的原因是:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("项目属性维护失败:" + ex.Message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AlterField(IFeatureLayer featureLayer, int objectID, Dictionary<string, string> fieldKeyValues)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IDataset dataset = (IDataset)featureLayer.FeatureClass;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IFeature pFeature = featureLayer.FeatureClass.GetFeature(objectID);
|
|
|
|
|
foreach (var currentField in fieldKeyValues)
|
|
|
|
|
{
|
|
|
|
|
pFeature.set_Value(featureLayer.FeatureClass.FindField(currentField.Key), currentField.Value);
|
|
|
|
|
}
|
|
|
|
|
pFeature.Store();
|
|
|
|
|
Marshal.ReleaseComObject(pFeature);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("当前获取要素失败(不处理):" + ex.Message);
|
|
|
|
|
//throw new Exception("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region TQMJJSInit
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 椭球面积计算-初始化
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void TQMJJSInit()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
#region 初始化Grid数据
|
|
|
|
|
List<RuleTableEntity> listTable = DataCheckTableMappingConfig.BGGetListRuleTableEntity().FindAll(x => x.Columns != null && x.Columns.Count > 0 && x.Columns.FindAll(k => k.IsEllipsoidArea).Count() > 0);
|
|
|
|
|
listEllipsoidAreaTable = new List<EllipsoidAreaTable>();
|
|
|
|
|
int featureID = 0;
|
|
|
|
|
foreach (var ruleTable in listTable)
|
|
|
|
|
{
|
|
|
|
|
EllipsoidAreaTable pEllipsoidArea = new EllipsoidAreaTable
|
|
|
|
|
{
|
|
|
|
|
FeatureClassID = featureID,
|
|
|
|
|
TableName = ruleTable.TableName,
|
|
|
|
|
Workspace = "",//(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetSchemeDBPath(),
|
|
|
|
|
TableAliasName = ruleTable.TableAliasName,
|
|
|
|
|
ListField = new List<AreaField>(),
|
|
|
|
|
FieldName = ruleTable.Columns.FirstOrDefault(x => x.IsEllipsoidArea).ColumnName,
|
|
|
|
|
FieldAliasName = ruleTable.Columns.FirstOrDefault(x => x.IsEllipsoidArea).AliasName
|
|
|
|
|
};
|
|
|
|
|
if (ruleTable.TableAliasName == "生态保护红线更新")
|
|
|
|
|
{
|
|
|
|
|
pEllipsoidArea.FieldAliasName += "(km²)";
|
|
|
|
|
}
|
|
|
|
|
//else if (ruleTable.TableAliasName == "临时用地更新")
|
|
|
|
|
//{
|
|
|
|
|
// pEllipsoidArea.FieldAliasName += "(公顷)";
|
|
|
|
|
//}
|
|
|
|
|
pEllipsoidArea.IsChecked = true;
|
|
|
|
|
listEllipsoidAreaTable.Add(pEllipsoidArea);
|
|
|
|
|
featureID++;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("椭球面积计算界面初始化异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region SetFeatureEllipsoidArea
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计算赋值椭球面积字段
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pFeatureClass">要素类</param>
|
|
|
|
|
/// <param name="listFieldIndex">椭球面积字段Index</param>
|
|
|
|
|
public void SetFeatureEllipsoidArea(IFeatureLayer pFeatureLayer, int fieldIndex)
|
|
|
|
|
{
|
|
|
|
|
if (pFeatureLayer == null || pFeatureLayer.FeatureClass == null)
|
|
|
|
|
return;
|
|
|
|
|
string LayerName = pFeatureLayer.FeatureClass.AliasName;
|
|
|
|
|
ICursor pCursor = null;
|
|
|
|
|
IFeature pFeature = null;
|
|
|
|
|
ISelectionSet pSelectionSet = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
pCursor = (pFeatureLayer.FeatureClass as ITable).Update(null, true);
|
|
|
|
|
int shapeIndex = pFeatureLayer.FeatureClass.Fields.FindField("SHAPE");
|
|
|
|
|
int GXSjIndex = pFeatureLayer.FeatureClass.Fields.FindField("GXSJ");
|
|
|
|
|
if (shapeIndex < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("未找到SHAPE字段");
|
|
|
|
|
}
|
|
|
|
|
IRow pRow = null;
|
|
|
|
|
while ((pRow = pCursor.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
IPolygon pPolygon = pRow.get_Value(shapeIndex) as IPolygon;
|
|
|
|
|
//数据库机制,先清空再赋值
|
|
|
|
|
pRow.set_Value(fieldIndex, null);
|
|
|
|
|
if (pPolygon == null || pPolygon.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
pRow.set_Value(fieldIndex, 0);
|
|
|
|
|
pRow.set_Value(GXSjIndex, DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
double area = pPolygon.GetEllipseArea();
|
|
|
|
|
//图斑面积赋值(计算图斑椭球面积)
|
|
|
|
|
if (LayerName == "生态保护红线更新")
|
|
|
|
|
{
|
|
|
|
|
pRow.set_Value(fieldIndex, Math.Round(area * 0.000001D, 4));
|
|
|
|
|
pRow.set_Value(GXSjIndex, DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31));
|
|
|
|
|
}
|
|
|
|
|
//else if (LayerName == "临时用地更新")
|
|
|
|
|
//{
|
|
|
|
|
// pRow.set_Value(fieldIndex, Math.Round(area * 0.0001, 2));
|
|
|
|
|
// pRow.set_Value(GXSjIndex, DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31););
|
|
|
|
|
//}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pRow.set_Value(fieldIndex, area);
|
|
|
|
|
pRow.set_Value(GXSjIndex, DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pCursor.UpdateRow(pRow);
|
|
|
|
|
}
|
|
|
|
|
pCursor.Flush();
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (pCursor != null)
|
|
|
|
|
{
|
|
|
|
|
Marshal.ReleaseComObject(pCursor);
|
|
|
|
|
}
|
|
|
|
|
if (pFeature != null)
|
|
|
|
|
{
|
|
|
|
|
Marshal.ReleaseComObject(pFeature);
|
|
|
|
|
}
|
|
|
|
|
if (pSelectionSet != null)
|
|
|
|
|
{
|
|
|
|
|
Marshal.ReleaseComObject(pSelectionSet);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 标识码赋值
|
|
|
|
|
public void LayerData()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
layers = new List<LayerEntity>();
|
|
|
|
|
XDocument xDoc = XDocument.Load(SysAppPath.BG_GetMappingConfigPath());
|
|
|
|
|
foreach (XElement item in xDoc.Descendants("Table"))
|
|
|
|
|
{
|
|
|
|
|
if (item.Attributes("TableName") == null || item.Attributes("TableName").Single().Value.ToUpper().Equals("DLTBGX") || item.Attributes("TableName").Single().Value.ToUpper().Equals("XZQGX") || item.Attributes("TableName").Single().Value.ToUpper().Equals("CJDCQGX") || item.Attributes("TableName").Single().Value.ToUpper().Equals("CZCDYDGX") || item.Attributes("TableName").Single().Value.ToUpper().Equals("XZQJXGX") || item.Attributes("TableName").Single().Value.ToUpper().Equals("CJDCQJXGX"))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (item.Attributes("Visiable").SingleOrDefault() == null || item.Attributes("Visiable").SingleOrDefault().Value.Equals("True"))
|
|
|
|
|
{
|
|
|
|
|
LayerEntity layer = new LayerEntity();
|
|
|
|
|
layer.LayerName = item.Attributes("TableName").Single().Value;
|
|
|
|
|
layer.LayerAlias = item.Attributes("Name").Single().Value;
|
|
|
|
|
layer.LayerCDM = item.Attributes("CDM").Single().Value;
|
|
|
|
|
layers.Add(layer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.layers.ForEach(x => x.Check = true);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("初始化图层失败,可能的原因是:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("初始化图层失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 标识码赋值
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool BSMExecute()
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
IWorkspace pWorkspace = null;
|
|
|
|
|
IFeatureWorkspace pFeatureWorkspace = null;
|
|
|
|
|
IFeatureClass pFeatureClass = null;
|
|
|
|
|
IQueryFilter pQueryFilter = null;
|
|
|
|
|
IFeatureCursor pFeatureCursor = null;
|
|
|
|
|
//判断是否存在BSM重复
|
|
|
|
|
IFeatureCursor pExitFeatureCursor = null;
|
|
|
|
|
IQueryFilter filter = new QueryFilter();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE) && (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE.Length == 6)
|
|
|
|
|
{
|
|
|
|
|
//pWorkspaceFactory = new FileGDBWorkspaceFactory();
|
|
|
|
|
if (layers.Where(p => p.Check == true) != null)
|
|
|
|
|
{
|
|
|
|
|
if (layers.Where(p => p.Check == true).Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (LayerEntity layer in layers.Where(p => p.Check == true))
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("正在对" + layer.LayerName + "中的 BSM 赋值");
|
|
|
|
|
//判断图层是否存在
|
|
|
|
|
//bool isExist = (pWorkspace as IWorkspace2).get_NameExists(esriDatasetType.esriDTFeatureClass, layer.LayerName);
|
|
|
|
|
pFeatureClass = MapsManager.Instance.MapService.GetFeatureClassByName(layer.LayerName);
|
|
|
|
|
if (pFeatureClass == null) continue;
|
|
|
|
|
pWorkspace = (pFeatureClass as FeatureClass).Workspace;
|
|
|
|
|
//pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
|
|
|
|
|
//pFeatureClass = pFeatureWorkspace.OpenFeatureClass(layer.LayerName);
|
|
|
|
|
int bsmIndexof = pFeatureClass.FindField("BSM");
|
|
|
|
|
int gxsjIndexof = pFeatureClass.FindField("GXSJ");
|
|
|
|
|
if (bsmIndexof == -1 || gxsjIndexof == -1) continue;
|
|
|
|
|
int maxValue = 0;
|
|
|
|
|
int count = 0;
|
|
|
|
|
string firstEightChar = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE + layer.LayerCDM;
|
|
|
|
|
|
|
|
|
|
pFeatureCursor = pFeatureClass.Update(null, true);
|
|
|
|
|
pExitFeatureCursor = pFeatureClass.Update(null, true);
|
|
|
|
|
count = pFeatureClass.FeatureCount(null);
|
|
|
|
|
|
|
|
|
|
Dictionary<string, List<int>> dicList = new Dictionary<string, List<int>>();
|
|
|
|
|
IFeature pFeature = null;
|
|
|
|
|
IQueryFilter queryFilter = new QueryFilterClass();
|
|
|
|
|
while ((pFeature = pFeatureCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string bsm = pFeature.get_Value(bsmIndexof).ToTrim();
|
|
|
|
|
if (bsm.StartsWith(firstEightChar))
|
|
|
|
|
{
|
|
|
|
|
int bsmNum = Convert.ToInt32(bsm.Replace(firstEightChar, ""));
|
|
|
|
|
if (bsmNum > maxValue)
|
|
|
|
|
{
|
|
|
|
|
maxValue = bsmNum;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!dicList.ContainsKey(bsm))
|
|
|
|
|
{
|
|
|
|
|
dicList.Add(bsm, new List<int>() { pFeature.OID });
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dicList[bsm].Add(pFeature.OID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (var item in dicList.Keys)
|
|
|
|
|
{
|
|
|
|
|
if (!item.StartsWith(firstEightChar))
|
|
|
|
|
{
|
|
|
|
|
foreach (var oid in dicList[item])
|
|
|
|
|
{
|
|
|
|
|
maxValue++;
|
|
|
|
|
filter.WhereClause = string.Format("OBJECTID={0}", oid);
|
|
|
|
|
pFeatureCursor = pFeatureClass.Update(filter, true);
|
|
|
|
|
while ((pFeature = pFeatureCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
pFeature.set_Value(bsmIndexof, firstEightChar + maxValue.ToString().PadLeft(8, '0'));
|
|
|
|
|
if (gxsjIndexof != -1)
|
|
|
|
|
pFeature.set_Value(gxsjIndexof, DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31));
|
|
|
|
|
pFeatureCursor.UpdateFeature(pFeature);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
List<int> oids = dicList[item];
|
|
|
|
|
if (oids.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i < oids.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
maxValue++;
|
|
|
|
|
filter.WhereClause = string.Format("OBJECTID={0}", oids[i]);
|
|
|
|
|
pFeatureCursor = pFeatureClass.Update(filter, true);
|
|
|
|
|
while ((pFeature = pFeatureCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
pFeature.set_Value(bsmIndexof, firstEightChar + maxValue.ToString().PadLeft(8, '0'));
|
|
|
|
|
if (gxsjIndexof != -1)
|
|
|
|
|
pFeature.set_Value(gxsjIndexof, DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31));
|
|
|
|
|
pFeatureCursor.UpdateFeature(pFeature);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pFeatureCursor.Flush();
|
|
|
|
|
}
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("当前工程的行政区代码不对,请前往工程属性重新设置!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("赋值出现错误,可能的原因是:" + ex.StackTrace);
|
|
|
|
|
throw new Exception("赋值出现错误,可能的原因是:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (pFeatureCursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(pFeatureCursor);
|
|
|
|
|
if (pFeatureClass != null)
|
|
|
|
|
Marshal.ReleaseComObject(pFeatureClass);
|
|
|
|
|
if (pWorkspace != null)
|
|
|
|
|
Marshal.ReleaseComObject(pWorkspace);
|
|
|
|
|
if (pFeatureWorkspace != null)
|
|
|
|
|
Marshal.ReleaseComObject(pFeatureWorkspace);
|
|
|
|
|
if (pQueryFilter != null)
|
|
|
|
|
Marshal.ReleaseComObject(pQueryFilter);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扣除地类面积赋值
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void KCDLMJExecute()
|
|
|
|
|
{
|
|
|
|
|
IWorkspace pWorkspace = null;
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("正在进行扣除地类面积计算,请稍候...");
|
|
|
|
|
IFeatureClass DLTBGXFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGX");
|
|
|
|
|
//地类图斑更新层扣除面积计算
|
|
|
|
|
if (DLTBGXFC != null)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClassAPI dltbgxAPI = new FeatureClassAPI(DLTBGXFC);// wsAPI.OpenFeatureClass("DLTBGX");
|
|
|
|
|
pWorkspace = (DLTBGXFC as FeatureClass).Workspace;
|
|
|
|
|
//地类图斑更新层扣除地类系数赋值
|
|
|
|
|
int indexofKCXS = dltbgxAPI.FeatureClass.FindField("KCXS");
|
|
|
|
|
int indexofKCMJ = dltbgxAPI.FeatureClass.FindField("KCMJ");
|
|
|
|
|
int indexofTBMJ = dltbgxAPI.FeatureClass.FindField("TBMJ");
|
|
|
|
|
int indexofTBDLMJ = dltbgxAPI.FeatureClass.FindField("TBDLMJ");
|
|
|
|
|
int indexofKCDLBM = dltbgxAPI.FeatureClass.FindField("KCDLBM");
|
|
|
|
|
if (indexofKCXS == -1 || indexofKCMJ == -1 || indexofTBMJ == -1 || indexofTBDLMJ == -1 || indexofKCDLBM == -1)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show("地类图斑更新层中KCXS字段或者KCMJ字段或者TBMJ字段或者TBDLMJ字段或者KCDLBM字段不存在!!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.UpdateMsg("【地类图斑更新层】正在进行扣除地类面积计算,请稍后...");
|
|
|
|
|
string sql = string.Format("UPDATE DLTBGX SET KCMJ = 0 WHERE TBMJ IS NULL OR TBMJ <= 0 OR KCXS IS NULL OR KCXS <= 0");
|
|
|
|
|
(DLTBGXFC as FeatureClass).Workspace.ExecuteSQL(sql);
|
|
|
|
|
|
|
|
|
|
sql = string.Format("UPDATE DLTBGX SET KCDLBM='',KCXS=0,KCMJ=0,GDLX='' WHERE GDPDJB='1'");
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
|
|
|
|
|
sql = string.Format("UPDATE DLTBGX SET KCMJ = round(TBMJ*KCXS + 0.0000001,2)");
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
|
|
|
|
|
sql = string.Format("UPDATE DLTBGX SET TBDLMJ = round(TBMJ-KCMJ,2)");
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
|
|
|
|
|
sql = string.Format("UPDATE DLTBGX SET KCDLBM='1203' WHERE TBMJ> 0 AND KCXS > 0");
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IFeatureClass DLTBGXGCFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGXGC");
|
|
|
|
|
//地类图斑更新过程层扣除面积计算
|
|
|
|
|
if (DLTBGXGCFC != null)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClassAPI dltbgxgcAPI = new FeatureClassAPI(DLTBGXGCFC);
|
|
|
|
|
pWorkspace = (DLTBGXGCFC as FeatureClass).Workspace;
|
|
|
|
|
int indexofBGHKCXS = dltbgxgcAPI.FeatureClass.FindField("BGHKCXS");
|
|
|
|
|
int indexofBGHKCMJ = dltbgxgcAPI.FeatureClass.FindField("BGHKCMJ");
|
|
|
|
|
int indexofTBBGMJ = dltbgxgcAPI.FeatureClass.FindField("TBBGMJ");
|
|
|
|
|
int indexofBGHTBDLMJ = dltbgxgcAPI.FeatureClass.FindField("BGHTBDLMJ");
|
|
|
|
|
int indexofBGHKCDLBM = dltbgxgcAPI.FeatureClass.FindField("BGHKCDLBM");
|
|
|
|
|
if (indexofBGHKCXS == -1 || indexofBGHKCMJ == -1 || indexofTBBGMJ == -1 || indexofBGHTBDLMJ == -1 || indexofBGHKCDLBM == -1)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show("地类图斑更新过程层中BGHKCXS字段或者BGHKCMJ字段或者TBBGMJ字段或者BGHTBDLMJ字段或者BGHKCDLBM字段不存在!!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.UpdateMsg("【地类图斑更新过程层】正在进行扣除地类面积计算,请稍后...");
|
|
|
|
|
string sql = string.Format("UPDATE DLTBGXGC SET BGHKCMJ = 0 WHERE TBBGMJ IS NULL OR TBBGMJ <= 0 OR BGHKCXS IS NULL OR BGHKCXS <= 0");
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
|
|
|
|
|
sql = string.Format("UPDATE DLTBGXGC SET BGHKCDLBM='',BGHKCXS=0,BGHKCMJ=0,BGHGDLX='' WHERE BGHGDPDJB='1'");
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
|
|
|
|
|
sql = string.Format("UPDATE DLTBGXGC SET BGHKCMJ = round(TBBGMJ*BGHKCXS + 0.0000001,2) WHERE BGXW<>'0' and XZQTZLX <> '2'");
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
|
|
|
|
|
sql = string.Format("UPDATE DLTBGXGC SET BGHTBDLMJ = round(TBBGMJ-BGHKCMJ,2) WHERE BGXW<>'0' and XZQTZLX <> '2'");
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
|
|
|
|
|
sql = string.Format("UPDATE DLTBGXGC SET BGHKCDLBM='1203' WHERE TBBGMJ> 0 AND BGHKCXS > 0");
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
|
|
|
|
|
sql = string.Format("UPDATE DLTBGXGC SET BGHTBDLMJ=0 WHERE XZQTZLX = '2' or XZQTZLX = '4'");
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////变化信息表扣除面积计算
|
|
|
|
|
//string dbPath = System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath()) + @"\BGTJ.sqlite";
|
|
|
|
|
//rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
//if (rdbHelper.TableIsExist("BHXXB"))
|
|
|
|
|
//{
|
|
|
|
|
// this.UpdateMsg("【变化信息表】正在进行扣除地类面积计算,请稍后...");
|
|
|
|
|
// DataTable bhxxbDt = rdbHelper.ExecuteDatatable("BHXXB", "select * from BHXXB", true);
|
|
|
|
|
// if (!bhxxbDt.Columns.Contains("BGHKCXS") || !bhxxbDt.Columns.Contains("BGHKCMJ") || !bhxxbDt.Columns.Contains("BGMJ") || !bhxxbDt.Columns.Contains("BGHKCDLBM"))
|
|
|
|
|
// {
|
|
|
|
|
// MessageHelper.Show("BHXXB中BGHKCXS字段或者BGHKCMJ字段或者BGMJ字段或者BGHKCDLBM字段不存在!!");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// string sql = string.Format("UPDATE BHXXB SET BGHKCMJ = 0 WHERE BGMJ IS NULL OR BGMJ <= 0 OR BGHKCXS IS NULL OR BGHKCXS <= 0");
|
|
|
|
|
// rdbHelper.ExecuteNonQuery(sql);
|
|
|
|
|
|
|
|
|
|
// sql = string.Format("UPDATE BHXXB SET BGHKCDLBM='',BGHKCXS=0,BGHKCMJ = 0 ,BGHGDLX='' WHERE BGHGDPDJB='1'");
|
|
|
|
|
// rdbHelper.ExecuteNonQuery(sql);
|
|
|
|
|
|
|
|
|
|
// sql = string.Format("UPDATE BHXXB SET BGHKCMJ = round(BGMJ*BGHKCXS+ 0.0000001,2) WHERE BGXW<>'0'");
|
|
|
|
|
// rdbHelper.ExecuteNonQuery(sql);
|
|
|
|
|
|
|
|
|
|
// sql = string.Format("UPDATE BHXXB SET BGHKCDLBM='1203' WHERE BGMJ> 0 AND BGHKCXS > 0");
|
|
|
|
|
// rdbHelper.ExecuteNonQuery(sql);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("扣除地类面积计算异常:" + ex.Message);
|
|
|
|
|
MessageHelper.ShowError("扣除地类面积计算异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (pWorkspace != null)
|
|
|
|
|
Marshal.ReleaseComObject(pWorkspace);
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扣除地类系数赋值
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void KCDLXSExcute()
|
|
|
|
|
{
|
|
|
|
|
IWorkspace pWorkspace = null;
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<GDEntity> Entitys = GDEntitys.Where(p => p.Checked == true).ToList();
|
|
|
|
|
this.UpdateMsg("正在进行扣除地类系数赋值,请稍候...");
|
|
|
|
|
IFeatureClass DLTBGXFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGX");
|
|
|
|
|
if (DLTBGXFC != null)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClassAPI dltbgxAPI = new FeatureClassAPI(DLTBGXFC);// wsAPI.OpenFeatureClass("DLTBGX");
|
|
|
|
|
pWorkspace = (DLTBGXFC as FeatureClass).Workspace;
|
|
|
|
|
//地类图斑更新层扣除地类系数赋值
|
|
|
|
|
int indexofKCXS = dltbgxAPI.FeatureClass.FindField("KCXS");
|
|
|
|
|
int indexofKCMJ = dltbgxAPI.FeatureClass.FindField("KCMJ");
|
|
|
|
|
int indexofGDLX = dltbgxAPI.FeatureClass.FindField("GDLX");
|
|
|
|
|
int indexofGDPDJB = dltbgxAPI.FeatureClass.FindField("GDPDJB");
|
|
|
|
|
if (indexofKCXS == -1 || indexofKCMJ == -1 || indexofGDLX == -1 || indexofGDPDJB == -1)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show("地类图斑更新层中KCXS字段或者KCMJ字段或者GDLX字段或者GDPDJB字段不存在!!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int gxindex = 1;
|
|
|
|
|
foreach (GDEntity model in Entitys)
|
|
|
|
|
{
|
|
|
|
|
if (gxindex == 1)
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("【地类图斑更新层】正在赋值" + model.GDPDJBMC + "系数,请稍候...");
|
|
|
|
|
gxindex++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("【地类图斑更新层】正在赋值" + model.GDPDJBMC + "系数,请稍候...");
|
|
|
|
|
}
|
|
|
|
|
string where = string.Empty;
|
|
|
|
|
where += string.Format(" GDLX='{0}' AND GDPDJB='{1}' AND (KCXS=0 OR KCXS Is Null)", model.GDLX, model.GDPDJB);
|
|
|
|
|
string sql = string.Format("update DLTBGX set KCXS={0} where {1}", model.KCDLXS, where);
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
if (model.KCDLXS == 0)
|
|
|
|
|
{
|
|
|
|
|
sql = string.Format("update DLTBGX set KCMJ=0 where {0}", where);
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IFeatureClass DLTBGXGCFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGXGC");
|
|
|
|
|
//地类图斑更新过程层扣除地类系数赋值
|
|
|
|
|
if (DLTBGXGCFC != null)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClassAPI dltbgxgcAPI = new FeatureClassAPI(DLTBGXGCFC);// wsAPI.OpenFeatureClass("DLTBGXGC");
|
|
|
|
|
pWorkspace = (DLTBGXGCFC as FeatureClass).Workspace;
|
|
|
|
|
int indexofBGHKCXS = dltbgxgcAPI.FeatureClass.FindField("BGHKCXS");
|
|
|
|
|
int indexofBGHKCMJ = dltbgxgcAPI.FeatureClass.FindField("BGHKCMJ");
|
|
|
|
|
int indexofBGHGDLX = dltbgxgcAPI.FeatureClass.FindField("BGHGDLX");
|
|
|
|
|
int indexofBGHGDPDJB = dltbgxgcAPI.FeatureClass.FindField("BGHGDPDJB");
|
|
|
|
|
if (indexofBGHKCXS == -1 || indexofBGHKCMJ == -1 || indexofBGHGDLX == -1 || indexofBGHGDPDJB == -1)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show("地类图斑更新过程层中BGHKCXS字段或者BGHKCMJ字段或者BGHGDLX字段或者BGHGDPDJB字段不存在!!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int gxgcindex = 1;
|
|
|
|
|
foreach (GDEntity model in Entitys)
|
|
|
|
|
{
|
|
|
|
|
if (gxgcindex == 1)
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("【地类图斑更新过程层】正在赋值" + model.GDPDJBMC + "系数,请稍候...");
|
|
|
|
|
gxgcindex++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("【地类图斑更新过程层】正在赋值" + model.GDPDJBMC + "系数,请稍候...");
|
|
|
|
|
}
|
|
|
|
|
string where = string.Empty;
|
|
|
|
|
where += string.Format(" BGHGDLX='{0}' AND BGHGDPDJB='{1}' AND (BGHKCXS=0 OR BGHKCXS Is Null)", model.GDLX, model.GDPDJB);
|
|
|
|
|
string sql = string.Format("update DLTBGXGC set BGHKCXS={0} where {1}", model.KCDLXS, where);
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
if (model.KCDLXS == 0)
|
|
|
|
|
{
|
|
|
|
|
sql = string.Format("update DLTBGXGC set BGHKCMJ=0 where {0}", where);
|
|
|
|
|
pWorkspace.ExecuteSQL(sql);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//变化信息表扣除地类系数赋值
|
|
|
|
|
string dbPath = System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath()) + @"\BGTJ.sqlite";
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
DataTable bhxxbDt = new DataTable();
|
|
|
|
|
if (rdbHelper.TableIsExist("BHXXB"))
|
|
|
|
|
{
|
|
|
|
|
bhxxbDt = rdbHelper.ExecuteDatatable("BHXXB", "select * from BHXXB", true);
|
|
|
|
|
if (!bhxxbDt.Columns.Contains("BGHKCXS") || !bhxxbDt.Columns.Contains("BGHKCMJ") || !bhxxbDt.Columns.Contains("BGHGDLX") || !bhxxbDt.Columns.Contains("BGHGDPDJB"))
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show("BHXXB中BGHKCXS字段或者BGHKCMJ字段或者BGHGDLX字段或者BGHGDPDJB字段不存在!!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int bgxxbindex = 1;
|
|
|
|
|
foreach (GDEntity model in Entitys)
|
|
|
|
|
{
|
|
|
|
|
if (bgxxbindex == 1)
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("【变化信息表】正在赋值" + model.GDPDJBMC + "系数,请稍候...");
|
|
|
|
|
bgxxbindex++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("【变化信息表】正在赋值" + model.GDPDJBMC + "系数,请稍候...");
|
|
|
|
|
}
|
|
|
|
|
string where = string.Empty;
|
|
|
|
|
where += string.Format(" BGHGDLX='{0}' AND BGHGDPDJB='{1}' AND (BGHKCXS=0 OR BGHKCXS Is Null)", model.GDLX, model.GDPDJB);
|
|
|
|
|
string sql = string.Format("update BHXXB set BGHKCXS={0} where {1}", model.KCDLXS, where);
|
|
|
|
|
rdbHelper.ExecuteSQL(sql);
|
|
|
|
|
if (model.KCDLXS == 0)
|
|
|
|
|
{
|
|
|
|
|
sql = string.Format("update BHXXB set BGHKCMJ=0 where {0}", where);
|
|
|
|
|
rdbHelper.ExecuteSQL(sql);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("扣除地类系数赋值异常:" + ex.Message);
|
|
|
|
|
MessageHelper.ShowError("扣除地类系数赋值异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (pWorkspace != null)
|
|
|
|
|
Marshal.ReleaseComObject(pWorkspace);
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 耕地实体
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class GDEntity
|
|
|
|
|
{
|
|
|
|
|
public string GDLX { get; set; }
|
|
|
|
|
public string GDPDJB { get; set; }
|
|
|
|
|
public string GDPDJBMC { get; set; }
|
|
|
|
|
private decimal _kcdlxs;
|
|
|
|
|
[Range(typeof(Decimal), "0", "0.9999"), DataType(DataType.Currency)]
|
|
|
|
|
public decimal KCDLXS
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Math.Round(_kcdlxs, 4, MidpointRounding.AwayFromZero);
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_kcdlxs = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public bool Checked { get; set; }
|
|
|
|
|
public string XMSX { get; set; }
|
|
|
|
|
}
|
|
|
|
|
#region 要素代码赋值
|
|
|
|
|
public void YSDMInit()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ysdmlistRuleTableEntity = DataCheckTableMappingConfig.BGGetListRuleTableEntity();
|
|
|
|
|
if (ysdmlistRuleTableEntity != null && ysdmlistRuleTableEntity.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ysdmlistRuleTableEntity = ysdmlistRuleTableEntity.Where(x => !string.IsNullOrWhiteSpace(x.YSDM)).ToList();
|
|
|
|
|
ysdmlistRuleTableEntity.ForEach(x => x.IsChecked = true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("初始化列表失败,可能的原因是:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool YSDMExecute()
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
//string gdbpath = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetSchemeDBPath();
|
|
|
|
|
//IWorkspaceAPI wsAPI = new WorkspaceAPI(gdbpath, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
IFeatureClass TempFC = null;
|
|
|
|
|
IFeatureCursor pFeatureCursor = null;
|
|
|
|
|
IFeature pFeature = null;
|
|
|
|
|
foreach (RuleTableEntity item in ysdmlistRuleTableEntity.Where(p => p.IsChecked == true))
|
|
|
|
|
{
|
|
|
|
|
this.UpdateMsg("正在对【" + item.TableAliasName + "】中的 要素代码 赋值");
|
|
|
|
|
//判断当前表结构中是否包含YSDM字段
|
|
|
|
|
if (item.Columns.FirstOrDefault(x => x.ColumnName.ToUpper() == "YSDM") == null) continue;
|
|
|
|
|
//检查表是否存在
|
|
|
|
|
TempFC = MapsManager.Instance.MapService.GetFeatureClassByName(item.TableName);
|
|
|
|
|
if (TempFC == null) continue;
|
|
|
|
|
int ysdmIndexof = TempFC.FindField("YSDM");
|
|
|
|
|
int gxsjIndexof = TempFC.FindField("GXSJ");
|
|
|
|
|
pFeatureCursor = TempFC.Update(null, true);
|
|
|
|
|
while ((pFeature = pFeatureCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
pFeature.set_Value(ysdmIndexof, item.YSDM);
|
|
|
|
|
if (gxsjIndexof != -1)
|
|
|
|
|
pFeature.set_Value(gxsjIndexof, DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31));
|
|
|
|
|
pFeatureCursor.UpdateFeature(pFeature);
|
|
|
|
|
}
|
|
|
|
|
pFeatureCursor.Flush();
|
|
|
|
|
//执行sql语句修改YSDM
|
|
|
|
|
//string sql = string.Format("UPDATE {0} SET YSDM='{1}'", item.TableName, item.YSDM);
|
|
|
|
|
//(TempFC as FeatureClass).Workspace.ExecuteSQL(sql);
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性维护表数据实体
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class TestData : INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
private bool _IsChecked;
|
|
|
|
|
public bool IsChecked
|
|
|
|
|
{
|
|
|
|
|
get { return _IsChecked; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_IsChecked = value;
|
|
|
|
|
RaisePropertyChanged("IsChecked");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public string ItemType { get; set; }
|
|
|
|
|
public string Descriction { get; set; }
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
protected void RaisePropertyChanged(string propertyName)
|
|
|
|
|
{
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|