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

2714 lines
136 KiB

6 months ago
using DevExpress.Xpf.Editors.Settings;
using DevExpress.Xpf.Grid;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using KGIS.Framework.AE;
using KGIS.Framework.AE.ExtensionMethod;
using KGIS.Framework.AE.GPHelper;
using KGIS.Framework.Maps;
using KGIS.Framework.OpenData.Control;
using KGIS.Framework.Platform;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.ExtensionMethod;
using KGIS.Framework.Utils.Helper;
using KGIS.Plugin.BoundaryReadjust;
using Kingo.Plugin.BoundaryReadjust.EntityModel;
using Kingo.PluginServiceInterface;
using KUI.Windows;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
namespace Kingo.Plugin.BoundaryReadjust.View
{
/// <summary>
/// 区划调整页面视图逻辑 的交互逻辑
/// </summary>
public partial class UCRegionAdjust : BaseWindow
{
/// <summary>
/// 新县级控制界限
/// </summary>
private IFeatureClass New_XJKZJX_FC = null;
private IFeatureLayer New_XJXZQJX_Layer = null;
private IFeatureLayer XJJXTQTB_Layer = null;
/// <summary>
/// 新增/划入数据
/// </summary>
private IFeatureLayer XZDLTB_Layer = null;
/// <summary>
/// 基础_地类图斑
/// </summary>
private IFeatureLayer JCDLTB_Layer = null;
/// <summary>
/// 基础_城镇村
/// </summary>
private IFeatureLayer JCCZC_Layer = null;
private IFeatureLayer YSDLTBLayer = null;
/// <summary>
/// 基础地类图斑API_FC
/// </summary>
private IFeatureClassAPI FcAPI_JC_DLTB { get; set; }
/// <summary>
/// 基础行政区API_FC
/// </summary>
private IFeatureClassAPI FcAPI_JC_XZQ { get; set; }
/// <summary>
/// 县级控制界限API_FC
/// </summary>
private IFeatureClassAPI FcAPI_XJKZJX { get; set; }
private IFeatureClassAPI FcAPI_XJJXTQTB { get; set; }
/// <summary>
/// 地类图斑变更API_FC
/// </summary>
private IFeatureClassAPI FcAPI_DLTBBG { get; set; }
/// <summary>
/// 地类图斑划入过程FcAPI_DLTBHRGC
/// </summary>
private IFeatureClassAPI FcAPI_DLTBHRGC { get; set; }
/// <summary>
/// 县级控制界限图斑
/// </summary>
private IGeometry XJKZJX_IGeo { get; set; }
/// <summary>
/// 当前工程信息
/// </summary>
public static ProjectInfo ProjectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
/// <summary>
/// 基础库工作空间
/// </summary>
private WorkspaceAPI JcWsAPI { get; set; }
/// <summary>
/// 县级控制界限Union基础行政区
/// </summary>
private IFeatureLayer tempKZJXUnionxzqLayer = null;
/// <summary>
/// 视图数据
/// </summary>
private List<DataModel> Data { get; set; }
/// <summary>
/// 变更视图数据
/// </summary>
private List<DataModel> SaveDatas { get; set; }
/// <summary>
/// 提取图斑视图数据
/// </summary>
private DataTable IntoData { get; set; }
/// <summary>
/// 坐落单位字典
/// </summary>
private List<DataDicTionary> ZLDMdataDic = null;
public UCRegionAdjust()
{
try
{
InitializeComponent();
DevExpress.Xpf.Core.ThemeManager.SetTheme(this, DevExpress.Xpf.Core.Theme.Office2013LightGray);
InitData();
//初始禁用新加数据
btnAddData.IsEnabled = false;
btn.IsEnabled = false;
}
catch (Exception ex)
{
LogAPI.Debug(ex);
throw;
}
}
/// <summary>
/// 初始化数据
/// </summary>
private void InitData()
{
try
{
New_XJKZJX_FC = MapsManager.Instance.MapService.GetFeatureClassByName("XJKZJX");
XJJXTQTB_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("XJJXTQTB");
if (XJJXTQTB_Layer != null)
FcAPI_XJJXTQTB = new FeatureClassAPI(XJJXTQTB_Layer.FeatureClass);
if (New_XJKZJX_FC != null)
{
New_XJXZQJX_Layer = GeoDBAPI.CreateFeatureLayerInmemeory("XJKZJX", "新县级控制界线", (New_XJKZJX_FC as IGeoDataset).SpatialReference, New_XJKZJX_FC.ShapeType, New_XJKZJX_FC.Fields);
JXTZBGHelper.InsertDataToMemeoryLayer(New_XJKZJX_FC, New_XJXZQJX_Layer.FeatureClass, null);
}
JCDLTB_Layer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("地类图斑");
IFeatureLayer JCXZQ_layer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("行政区");
JCCZC_Layer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("城镇村等用地");
if (JCDLTB_Layer != null)
FcAPI_JC_DLTB = new FeatureClassAPI(JCDLTB_Layer.FeatureClass);
if (JCXZQ_layer != null)
FcAPI_JC_XZQ = new FeatureClassAPI(JCXZQ_layer.FeatureClass);
if (JCDLTB_Layer != null && JCDLTB_Layer.FeatureClass.FindField("XZQTZLX") == -1)
{
//添加字段
IFieldEdit _field = new FieldClass();
_field.Name_2 = "XZQTZLX";
_field.AliasName_2 = "行政区调整类型";
_field.Type_2 = esriFieldType.esriFieldTypeString;
_field.Length_2 = 5;
JCDLTB_Layer.FeatureClass.AddField(_field as IField);
}
if (YSDLTBLayer == null)
YSDLTBLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("YSDLTB");
IQueryFilter queryFilter = new QueryFilterClass() { WhereClause = "XZQTZLX is Null OR XZQTZLX =''" };
int fieldIndex = JCDLTB_Layer.FeatureClass.FindField("XZQTZLX");
if (fieldIndex > -1)
{
IField field = JCDLTB_Layer.FeatureClass.Fields.Field[fieldIndex];
if (field.Type != esriFieldType.esriFieldTypeString)
{
IFieldEdit fieldEdit = field as IFieldEdit;
fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
fieldEdit.Length_2 = 20;
field = fieldEdit as IField;
}
}
if (YSDLTBLayer != null && YSDLTBLayer.FeatureClass.FeatureCount(null) == 0)//不存在数据,则备份
FcAPI_JC_DLTB.FcToFc(YSDLTBLayer.FeatureClass, queryFilter, false);//避免原始地类图斑混淆数据
//JXTZBGHelper.InsertDataToMemeoryLayer(JCDLTB_Layer.FeatureClass, YSDLTBLayer.FeatureClass, queryFilter);
if (JCCZC_Layer != null && JCCZC_Layer.FeatureClass.FindField("XZQTZLX") == -1)
{
//添加字段
IFieldEdit _field = new FieldClass();
_field.Name_2 = "XZQTZLX";
_field.AliasName_2 = "行政区调整类型";
_field.Type_2 = esriFieldType.esriFieldTypeString;
_field.Length_2 = 5;
JCCZC_Layer.FeatureClass.AddField(_field as IField);
}
FcAPI_DLTBBG = new FeatureClassAPI(MapsManager.Instance.MapService.GetFeatureClassByName("DLTBBG"));
FcAPI_DLTBHRGC = new FeatureClassAPI(MapsManager.Instance.MapService.GetFeatureClassByName("DLTBHRGC"));
LoadData(true);
if (XJJXTQTB_Layer != null)
LoadXJJXTQTBToData();
if (ProjectInfo.KZMJ != null)//填充系统配置(平方米)
{
txtTZQLDMJ.Text = ProjectInfo.KZMJ.TZQ_LDMJ.ToString();
txtTZHLDMJ.Text = ProjectInfo.KZMJ.TZH_LDMJ.ToString();
txtTZQHDMJ.Text = ProjectInfo.KZMJ.TZQ_HDMJ.ToString();
txtTZHHDMJ.Text = ProjectInfo.KZMJ.TZH_HDMJ.ToString();
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
throw;
}
}
/// <summary>
/// 加载视图数据
/// </summary>
private void LoadData()
{
IFeatureCursor cursor = null;
IFeature xzqtqtbFeature = null;
try
{
if (FcAPI_DLTBHRGC.FeatureClass == null || FcAPI_DLTBHRGC.FeatureClass.FeatureCount(null) <= 0) return;
IntoData = new DataTable();//从地类图斑图层取数据
ConstructColumn(FcAPI_DLTBHRGC.FeatureClass.Fields);
IQueryFilter queryfilter = new QueryFilterClass
{
WhereClause = string.Format("XZQTZLX='1' or XZQTZLX='2' or XZQTZLX='3' or XZQTZLX='4'")
};
cursor = FcAPI_DLTBHRGC.FeatureClass.Search(queryfilter, true);
int BGMJ = FcAPI_DLTBHRGC.FeatureClass.FindField("TBBGMJ");
int XZQLX = FcAPI_DLTBHRGC.FeatureClass.FindField("XZQTZLX");
double XZQLX1 = 0;
double XZQLX2 = 0;
double XZQLX3 = 0;
double XZQLX4 = 0;
while ((xzqtqtbFeature = cursor.NextFeature()) != null)
{
if (string.IsNullOrWhiteSpace(xzqtqtbFeature.Value[BGMJ].ToTrim())) continue;
if (xzqtqtbFeature.Value[XZQLX].ToTrim() == "1")
XZQLX1 += Convert.ToDouble(xzqtqtbFeature.Value[BGMJ]);
else if (xzqtqtbFeature.Value[XZQLX].ToTrim() == "2")
XZQLX2 += Convert.ToDouble(xzqtqtbFeature.Value[BGMJ]);
else if (xzqtqtbFeature.Value[XZQLX].ToTrim() == "3")
XZQLX3 += Convert.ToDouble(xzqtqtbFeature.Value[BGMJ]);
else if (xzqtqtbFeature.Value[XZQLX].ToTrim() == "4")
XZQLX4 += Convert.ToDouble(xzqtqtbFeature.Value[BGMJ]);
}
cursor = null;
cursor = FcAPI_DLTBHRGC.FeatureClass.Search(queryfilter, true);
int lxIndex = (int)IntoData.Columns["XZQTZLX"].ExtendedProperties["index"];
while ((xzqtqtbFeature = cursor.NextFeature()) != null)
{
DataRow dr = IntoData.NewRow();
bool IsInto = true;
dr[0] = false;
for (int i = 0; i < IntoData.Columns.Count; i++)
{
if (i == 0)
{
dr[i] = false;
continue;
}
object obj = xzqtqtbFeature.get_Value((int)IntoData.Columns[i].ExtendedProperties["index"]);
if (obj == null)
{
continue;
}
else
{
if (obj.ToString().Contains("1899/12/30 0:00:00"))
{
obj = DBNull.Value;
}
}
if (obj is string)
obj = obj.ToString().Trim();
dr[i] = obj;
}
string XZQLXValue = xzqtqtbFeature.Value[XZQLX].ToTrim();
if (XZQLXValue == "1" && XZQLX1 != 0)
dr[lxIndex] = xzqtqtbFeature.get_Value(lxIndex) + " " + $"总面积:{XZQLX1}";
else if (XZQLXValue == "2" && XZQLX2 != 0)
dr[lxIndex] = xzqtqtbFeature.get_Value(lxIndex) + " " + $"总面积:{XZQLX2}";
else if (XZQLXValue == "3" && XZQLX3 != 0)
dr[lxIndex] = xzqtqtbFeature.get_Value(lxIndex) + " " + $"总面积:{XZQLX3}";
else if (XZQLXValue == "4" && XZQLX4 != 0)
dr[lxIndex] = xzqtqtbFeature.get_Value(lxIndex) + " " + $"总面积:{XZQLX4}";
if (IsInto)
IntoData.Rows.Add(dr);
Marshal.ReleaseComObject(xzqtqtbFeature);
}
dgInto2.ItemsSource = null;
dgInto2.ItemsSource = IntoData;
dgInto2.ClearGrouping();
dgInto2.GroupBy("XZQTZLX", true);//是否分组
//绑定权属字典
if (ZLDMdataDic == null)
{
//List<DataDicTionary> dataDics = Platform.Instance.DicHelper.GetAllDic();
ZLDMdataDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM);
if (ZLDMdataDic == null)
MessageHelper.Show("权属字典未生成!");
else
ZLDMdataDic = ZLDMdataDic.Where(x => x.CODE.Length == 19).ToList();
}
//cobZLDW.ItemsSource = ZLDMdataDic;
//cobZLDW.DisplayMember = "NAME";
//cobZLDW.ValueMember = "CODE";
for (int i = 0; i < ZLDMdataDic.Count; i++)
{
if (ZLDMdataDic.Count(x => x.CODE == ZLDMdataDic[i].CODE) == 2)
{
ZLDMdataDic.Remove(ZLDMdataDic[i]);
i--;//去重
}
}
BGQZL.ItemsSource = BingBGQZL();
BGHZL.ItemsSource = ZLDMdataDic;
}
catch (Exception ex)
{
LogAPI.Debug("加载区划调整数据失败,异常信息如下:");
LogAPI.Debug(ex);
MessageHelper.ShowError("加载区划调整数据失败:" + ex.Message);
}
}
/// <summary>
/// 自定义创建列加载DLTBHRGC数据
/// </summary>
/// <param name="IsUSerDefinedFileds">是否由自定义字段加载数据</param>
private void LoadData(bool IsUSerDefinedFileds = true)
{
IFeatureCursor cursor = null;
IFeature xzqtqtbFeature = null;
try
{
if (FcAPI_DLTBHRGC.FeatureClass == null || FcAPI_DLTBHRGC.FeatureClass.FeatureCount(null) <= 0) return;
IntoData = new DataTable();//从地类图斑图层取数据
ConstructColumn();
IQueryFilter queryfilter = new QueryFilterClass
{
WhereClause = string.Format("XZQTZLX='0' or XZQTZLX='1' or XZQTZLX='2' or XZQTZLX='3' or XZQTZLX='4'")
};
cursor = FcAPI_DLTBHRGC.FeatureClass.Search(queryfilter, true);
int BGMJ = FcAPI_DLTBHRGC.FeatureClass.FindField("TBBGMJ");
int XZQLX = FcAPI_DLTBHRGC.FeatureClass.FindField("XZQTZLX");
double XZQLX0 = 0;
double XZQLX1 = 0;
double XZQLX2 = 0;
double XZQLX3 = 0;
double XZQLX4 = 0;
while ((xzqtqtbFeature = cursor.NextFeature()) != null)
{
if (string.IsNullOrWhiteSpace(xzqtqtbFeature.Value[BGMJ].ToTrim())) continue;
if (xzqtqtbFeature.Value[XZQLX].ToTrim() == "0")
XZQLX0 += Convert.ToDouble(xzqtqtbFeature.Value[BGMJ]);
else if (xzqtqtbFeature.Value[XZQLX].ToTrim() == "1")
XZQLX1 += Convert.ToDouble(xzqtqtbFeature.Value[BGMJ]);
else if (xzqtqtbFeature.Value[XZQLX].ToTrim() == "2")
XZQLX2 += Convert.ToDouble(xzqtqtbFeature.Value[BGMJ]);
else if (xzqtqtbFeature.Value[XZQLX].ToTrim() == "3")
XZQLX3 += Convert.ToDouble(xzqtqtbFeature.Value[BGMJ]);
else if (xzqtqtbFeature.Value[XZQLX].ToTrim() == "4")
XZQLX4 += Convert.ToDouble(xzqtqtbFeature.Value[BGMJ]);
}
cursor = null;
cursor = FcAPI_DLTBHRGC.FeatureClass.Search(queryfilter, true);
int lxIndex = (int)IntoData.Columns["XZQTZLX"].ExtendedProperties["index"];
int BGQQSDMIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("BGQQSDWDM");
int BGQQSMCIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("BGQQSDWMC");
int BGQZLDMIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("BGQZLDWDM");
int BGQZLMCIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("BGQZLDWMC");
int BGHQSDMIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("BGHQSDWDM");
int BGHQSMCIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("BGHQSDWMC");
int BGHZLDMIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("BGHZLDWDM");
int BGHZLMCIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("BGHZLDWMC");
int JCTBBSMIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("JCTBBSM");
int IsCompleteOutIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("IsCompleteOut");
while ((xzqtqtbFeature = cursor.NextFeature()) != null)
{
DataRow dr = IntoData.NewRow();
bool IsInto = true;
dr[0] = false;
for (int i = 0; i < IntoData.Columns.Count; i++)
{
if (i == 0)
{
dr[i] = false;
continue;
}
else if (i == 1) { dr[i] = xzqtqtbFeature.OID.ToTrim(); }
else if (IntoData.Columns[i].ColumnName == "TBBGMJ")
{
dr[i] = xzqtqtbFeature.Value[BGMJ].ToTrim();
}
else if (IntoData.Columns[i].ColumnName == "BGQQS")
{
dr[i] = xzqtqtbFeature.Value[BGQQSMCIndex].ToTrim() + "-" + xzqtqtbFeature.Value[BGQQSDMIndex].ToTrim();
}
else if (IntoData.Columns[i].ColumnName == "BGHQS" && !string.IsNullOrWhiteSpace(xzqtqtbFeature.Value[BGHQSDMIndex].ToTrim()))
{
dr[i] = xzqtqtbFeature.Value[BGHQSMCIndex].ToTrim() + "-" + xzqtqtbFeature.Value[BGHQSDMIndex].ToTrim();
}
else if (IntoData.Columns[i].ColumnName == "BGQZL")
{
dr[i] = xzqtqtbFeature.Value[BGQZLMCIndex].ToTrim() + "-" + xzqtqtbFeature.Value[BGQZLDMIndex].ToTrim();
}
else if (IntoData.Columns[i].ColumnName == "BGHZL")
{
dr[i] = xzqtqtbFeature.Value[BGHZLMCIndex].ToTrim() + "-" + xzqtqtbFeature.Value[BGHZLDMIndex].ToTrim();
}
else if (IntoData.Columns[i].ColumnName == "JCTBBSM")
{
dr[i] = xzqtqtbFeature.Value[JCTBBSMIndex].ToTrim();
}
else if (IntoData.Columns[i].ColumnName == "IsCompleteOut")
{
dr[i] = xzqtqtbFeature.Value[IsCompleteOutIndex].ToTrim();
}
}
string XZQLXValue = xzqtqtbFeature.Value[XZQLX].ToTrim();
if (XZQLXValue == "0" && XZQLX0 != 0)
dr[lxIndex] = XZQLXValue + " " + $"总面积:{XZQLX0.ToDouble(2)}";
else if (XZQLXValue == "1" && XZQLX1 != 0)
dr[lxIndex] = XZQLXValue + " " + $"总面积:{XZQLX1.ToDouble(2)}";
else if (XZQLXValue == "2" && XZQLX2 != 0)
dr[lxIndex] = XZQLXValue + " " + $"总面积:{XZQLX2.ToDouble(2)}";
else if (XZQLXValue == "3" && XZQLX3 != 0)
dr[lxIndex] = XZQLXValue + " " + $"总面积:{XZQLX3.ToDouble(2)}";
else if (XZQLXValue == "4" && XZQLX4 != 0)
dr[lxIndex] = XZQLXValue + " " + $"总面积:{XZQLX4.ToDouble(2)}";
if (IsInto)
IntoData.Rows.Add(dr);
Marshal.ReleaseComObject(xzqtqtbFeature);
}
dgInto2.ItemsSource = null;
dgInto2.ItemsSource = IntoData;
dgInto2.ClearGrouping();
if (ckbBGQZLDWDMByGroup.IsChecked == false && ckbBGHZLDWDMByGroup.IsChecked == false)//是否
{
dgInto2.GroupBy("XZQTZLX", true);
}
else
{
if (ckbBGQZLDWDMByGroup.IsChecked == true)
{
dgInto2.GroupBy("BGQZL", true);
}
if (ckbBGHZLDWDMByGroup.IsChecked == true)
{
dgInto2.GroupBy("BGHZL", true);
}
}
//绑定权属字典
if (ZLDMdataDic == null)
{
ZLDMdataDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM);
if (ZLDMdataDic == null)
MessageHelper.Show("权属字典未生成!");
else
ZLDMdataDic = ZLDMdataDic.Where(x => x.CODE.Length == 19).ToList();
}
for (int i = 0; i < ZLDMdataDic.Count; i++)
{
if (ZLDMdataDic.Count(x => x.CODE == ZLDMdataDic[i].CODE) == 2)
{
ZLDMdataDic.Remove(ZLDMdataDic[i]);
i--;//去重
}
}
BGQZL.ItemsSource = BingBGQZL();
BGHZL.ItemsSource = ZLDMdataDic;
}
catch (Exception ex)
{
LogAPI.Debug("加载区划调整数据失败,异常信息如下:");
LogAPI.Debug(ex);
MessageHelper.ShowError("加载区划调整数据失败:" + ex.Message);
}
}
private List<DataDicTionary> BingBGQZL()
{
IQueryFilter filter = new QueryFilterClass
{
WhereClause = "XZQTZLX = '1' OR XZQTZLX = '3'"
};
ICursor cursor = (FcAPI_DLTBHRGC.FeatureClass as ITable).Search(filter, true);
IRow rowHR = null;
int BGQZLDMIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("BGQZLDWDM");
int BGQZLMCIndex = FcAPI_DLTBHRGC.FeatureClass.FindField("BGQZLDWMC");
List<DataDicTionary> keyValuePairs = new List<DataDicTionary>();
while ((rowHR = cursor.NextRow()) != null)
{
if (!string.IsNullOrWhiteSpace(rowHR.Value[BGQZLDMIndex].ToTrim()))
{
DataDicTionary zLDMMC = new DataDicTionary
{
DisplayName = rowHR.Value[BGQZLDMIndex].ToTrim() + "-" + rowHR.Value[BGQZLMCIndex].ToTrim(),
CODE = rowHR.Value[BGQZLDMIndex].ToTrim(),
NAME = rowHR.Value[BGQZLMCIndex].ToTrim()
};
if (keyValuePairs.FirstOrDefault(x => x.CODE == rowHR.Value[BGQZLDMIndex].ToTrim()) == null)
keyValuePairs.Add(zLDMMC);
}
}
return keyValuePairs;
}
/// <summary>
/// 提取范围(灭失/划出数据)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnGetBGRange_Click(object sender, RoutedEventArgs e)
{
try
{
if (tempKZJXUnionxzqLayer != null)
tempKZJXUnionxzqLayer = null;
if (New_XJXZQJX_Layer == null || New_XJXZQJX_Layer.FeatureClass.FeatureCount(null) == 0)
{
MessageHelper.ShowTips("县级控制界线数据不存在!");
return;
}
//if (FcAPI_JC_XZQ == null || FcAPI_JC_XZQ.FeatureClass.FeatureCount(null) == 0)
if (FcAPI_JC_XZQ == null)
{
MessageHelper.ShowTips("基础行政区数据不存在!");
return;
}
this.ShowLoading("正在进行提取范围操作......", 0, 0);
IFeatureLayer JCXZQ_Layer = GeoDBAPI.CreateFeatureLayerInmemeory("JC_XZQ", "基础行政区", (FcAPI_JC_XZQ.FeatureClass as IGeoDataset).SpatialReference, FcAPI_JC_XZQ.FeatureClass.ShapeType, FcAPI_JC_XZQ.FeatureClass.Fields);
(JCXZQ_Layer.FeatureClass as ITable).DeleteSearchedRows(null);
JXTZBGHelper.InsertDataToMemeoryLayer(FcAPI_JC_XZQ.FeatureClass, JCXZQ_Layer.FeatureClass, null);
//存放结果在APP运行目录下
string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\QHTZDataSet";
if (!Directory.Exists(gdbFolder))
Directory.CreateDirectory(gdbFolder);
try
{
JXTZBGHelper.DelectDir(gdbFolder);//能删除就删除 删除报错不处理
}
catch
{ }
string gdbFileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".gdb";
string path = System.IO.Path.Combine(gdbFolder, gdbFileName);
IWorkspaceFactory pFtWsFct = new FileGDBWorkspaceFactory();
IWorkspaceName workspaceName = pFtWsFct.Create(gdbFolder, gdbFileName, null, 0);
if (New_XJXZQJX_Layer.FeatureClass.FeatureCount(null) > 0)
XJKZJX_IGeo = (New_XJXZQJX_Layer.FeatureClass.Search(null, false) as IFeatureCursor).NextFeature().ShapeCopy;
else
return;
//将合并后的基础行政区与调整后控制界线进行联合
GPParamClass gPParamClass = new GPParamClass();
gPParamClass = new GPParamClass
{
FirstFeatureLayer = JCXZQ_Layer,
OutFeatureClassPath = path + "\\" + "JC_XZQ",
IsGetOutPutFeature = true,
ListDissolveFiledName = new List<string>() { "MSSM" }
};
IFeatureLayer tempLayers = null;
GeoprocessorHelper.DissolveAnalysis(gPParamClass, ref tempLayers);
//IWorkspaceAPI psTempWorkspaceAPI = new WorkspaceAPI(path, WorkspaceTypeEnum.GDBFile, true);
gPParamClass = new GPParamClass
{
FirstFeatureLayer = New_XJXZQJX_Layer,
SecondFeatureLayer = tempLayers,
OutFeatureClassPath = path + "\\" + "TempXZQUnionKZJX2",
IsGetOutPutFeature = true
};
IFeatureLayer tempLayer = null;
GeoprocessorHelper.UnionAnalysis(gPParamClass, ref tempLayer);
gPParamClass = new GPParamClass
{
FirstFeatureLayer = tempLayer,
OutFeatureClassPath = path + "\\" + "TempXZQUnionKZJX",
IsGetOutPutFeature = true
};
GeoprocessorHelper.MultipartToSinglePath(gPParamClass, ref tempKZJXUnionxzqLayer);
IQueryFilter queryfilter = new QueryFilterClass
{
WhereClause = ""//获取灭失/划出的图斑
};
//if (JCXZQ_Layer.FeatureClass.FeatureCount(queryfilter) > 0)
//{
// MessageHelper.ShowTips("新县级控制界线MSSM字段不能为空!");
// return;
//}
Data = new List<DataModel>();
this.UpdateMsg("正在进行数据赋值......");
//queryfilter.WhereClause = string.Format("FID_XJKZJX=-1 OR FID_JC_XZQ=-1 OR (MSSM='00' AND MSSM_1='01')");//获取灭失/划出的图斑
queryfilter.WhereClause = string.Format("FID_XJKZJX=-1 OR FID_JC_XZQ=-1)");//获取灭失/划出的图斑
if (tempKZJXUnionxzqLayer == null || tempKZJXUnionxzqLayer.FeatureClass.FeatureCount(null) <= 0) return;
IFeatureCursor msCursor = tempKZJXUnionxzqLayer.FeatureClass.Search(null, true);//涉及海岛转陆地设置queryfilter=null
IFeature DelFearure = null;
int XJ_XZQDM = tempKZJXUnionxzqLayer.FeatureClass.FindField("XZQDM");
int XJ_XZQMC = tempKZJXUnionxzqLayer.FeatureClass.FindField("XZQMC");
int FID_XJKZJX = tempKZJXUnionxzqLayer.FeatureClass.FindField("FID_XJKZJX");
int FID_JC_XZQ = tempKZJXUnionxzqLayer.FeatureClass.FindField("FID_JC_XZQ");
int XJ_MSSM = tempKZJXUnionxzqLayer.FeatureClass.FindField("MSSM");
int XZQ_MSSM = tempKZJXUnionxzqLayer.FeatureClass.FindField("MSSM_1");
while ((DelFearure = msCursor.NextFeature()) != null)
{
double area = DelFearure.ShapeCopy.GetEllipseArea();
if (area == 0) continue;
DataModel modelItem = new DataModel();
modelItem.TC = "XZQUnionXJKZJX";
modelItem.DLTBOid = DelFearure.OID;
if (DelFearure.Value[FID_JC_XZQ].ToString() == "-1")//划入-新增
{
modelItem.XZQDM = DelFearure.Value[XJ_XZQDM].ToString();
modelItem.XZQMC = DelFearure.Value[XJ_XZQMC].ToString();
modelItem.XZQInfo = DelFearure.Value[XJ_XZQDM].ToString() + "-" + DelFearure.Value[XJ_XZQMC].ToString();
modelItem.IsAdd = true;
modelItem.BGZT = "";
}
else if (DelFearure.Value[FID_XJKZJX].ToString() == "-1")//划出-灭失
{
modelItem.XZQDM = DelFearure.Value[XJ_XZQDM].ToString();
modelItem.XZQMC = DelFearure.Value[XJ_XZQMC].ToString();
modelItem.XZQInfo = DelFearure.Value[XJ_XZQDM].ToString() + "-" + DelFearure.Value[XJ_XZQMC].ToString();
modelItem.IsOut = true;
modelItem.BGZT = "";
}
else if (!string.IsNullOrWhiteSpace(DelFearure.Value[XJ_MSSM].ToTrim()) && DelFearure.Value[XZQ_MSSM].ToTrim() == "01")
{
if (DelFearure.Value[XJ_MSSM].ToTrim() != DelFearure.Value[XZQ_MSSM].ToTrim())
{
modelItem.XZQDM = DelFearure.Value[XJ_XZQDM].ToString();
modelItem.XZQMC = DelFearure.Value[XJ_XZQMC].ToString();
modelItem.XZQInfo = DelFearure.Value[XJ_XZQDM].ToString() + "-" + DelFearure.Value[XJ_XZQMC].ToString();
modelItem.IsHDZLD = true;
modelItem.BGZT = "属性变化";
}
else
{
modelItem = null;
continue;
}
}
else
{
continue;
}
modelItem.Geo = DelFearure.ShapeCopy;
Data.Add(modelItem);
}
if (XJJXTQTB_Layer != null)
ImprotDataToXJJXTQTB();
dgInto.ItemsSource = Data.FindAll(x => x.IsHDZLD == false).ToList();
this.CloseLoading();
MessageHelper.ShowTips("提取完成!");
}
catch (Exception ex)
{
this.CloseLoading();
LogAPI.Debug("提取范围失败:" + ex.Message);
MessageHelper.ShowError("提取范围失败!");
LogAPI.Debug(ex);
}
finally
{
this.CloseLoading();
}
}
private void ImprotDataToXJJXTQTB()
{
IFeatureCursor cursor = XJJXTQTB_Layer.FeatureClass.Insert(true);
(XJJXTQTB_Layer.FeatureClass as ITable).DeleteSearchedRows(null);
int XZQDMIndex = XJJXTQTB_Layer.FeatureClass.FindField("XZQDM");
int XZQMCIndex = XJJXTQTB_Layer.FeatureClass.FindField("XZQMC");
int BZIndex = XJJXTQTB_Layer.FeatureClass.FindField("BZ");
int JSMJIndex = XJJXTQTB_Layer.FeatureClass.FindField("JSMJ");
int MSSMIndex = XJJXTQTB_Layer.FeatureClass.FindField("MSSM");
int HDMCIndex = XJJXTQTB_Layer.FeatureClass.FindField("HDMC");
int TZZTIndex = XJJXTQTB_Layer.FeatureClass.FindField("TZZT");
foreach (DataModel itemTQ in Data)
{
IFeatureBuffer featureBuffer = XJJXTQTB_Layer.FeatureClass.CreateFeatureBuffer();
featureBuffer.Shape = itemTQ.Geo;
featureBuffer.Value[XZQDMIndex] = itemTQ.XZQDM;
featureBuffer.Value[XZQMCIndex] = itemTQ.XZQMC;
featureBuffer.Value[JSMJIndex] = itemTQ.Geo.GetEllipseArea();
if (itemTQ.IsAdd == true)
featureBuffer.Value[TZZTIndex] = "Add";
else if (itemTQ.IsOut == true)
featureBuffer.Value[TZZTIndex] = "Out";
else if (itemTQ.IsHDZLD == true)
featureBuffer.Value[TZZTIndex] = "AttChange";//海岛转陆地,属性变化
cursor.InsertFeature(featureBuffer);
}
cursor.Flush();
}
private void LoadXJJXTQTBToData()
{
IFeatureCursor cursor = XJJXTQTB_Layer.FeatureClass.Search(null, true);
int XZQDMIndex = XJJXTQTB_Layer.FeatureClass.FindField("XZQDM");
int XZQMCIndex = XJJXTQTB_Layer.FeatureClass.FindField("XZQMC");
int BZIndex = XJJXTQTB_Layer.FeatureClass.FindField("BZ");
int MSSMIndex = XJJXTQTB_Layer.FeatureClass.FindField("MSSM");
int TZZTIndex = XJJXTQTB_Layer.FeatureClass.FindField("TZZT");
IFeature feature = null;
Data = new List<DataModel>();
while ((feature = cursor.NextFeature()) != null)
{
DataModel modelItem = new DataModel();
modelItem.XZQInfo = modelItem.XZQMC + "-" + modelItem.XZQDM;
modelItem.DLTBOid = feature.OID;
modelItem.Geo = feature.ShapeCopy;
modelItem.XZQDM = feature.Value[XZQDMIndex].ToString();
modelItem.XZQMC = feature.Value[XZQMCIndex].ToString();
modelItem.TC = "XZQUnionXJKZJX";
if (feature.Value[TZZTIndex].ToString() == "AttChange")
{
modelItem.BGZT = "属性变化";
modelItem.IsHDZLD = true;
}
else
{
modelItem.IsAdd = feature.Value[TZZTIndex].ToString() == "Add" ? true : false;
modelItem.IsOut = feature.Value[TZZTIndex].ToString() == "Out" ? true : false;
}
Data.Add(modelItem);
}
dgInto.ItemsSource = Data.FindAll(x => x.IsHDZLD == false).ToList();
}
/// <summary>
/// 数据入库
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnAddData_Click(object sender, RoutedEventArgs e)
{
try
{
if (!(double.TryParse(txtTZQLDMJ.Text, out double TryPaseResults) && double.TryParse(txtTZHLDMJ.Text, out TryPaseResults) && double.TryParse(txtTZQHDMJ.Text, out TryPaseResults) && double.TryParse(txtTZHHDMJ.Text, out TryPaseResults)))
{
MessageHelper.ShowError("当前控制面积信息填写不符合规范,请重新填写!");
return;
}
if (Data != null && Data.FirstOrDefault(x => x.BGZT == "" && x.IsHDZLD != true) == null)
{
if (Data.FirstOrDefault(x => x.BGZT.ToTrim() == "新增" || x.BGZT.ToTrim() == "划入") != null && XZDLTB_Layer == null)
{
MessageHelper.ShowTips("未获取到新增/划入图斑-新增/划入图斑数据为空.");
return;
}
SaveDatas = new List<DataModel>();
this.ShowLoading("正在进行数据入库操作......", 0, 0);
//if (JCDLTB_Layer == null || JCDLTB_Layer.FeatureClass == null || JCDLTB_Layer.FeatureClass.FeatureCount(null) == 0)
if (JCDLTB_Layer == null || JCDLTB_Layer.FeatureClass == null)
{
MessageHelper.ShowTips("未获取到基础地类图斑/基础地类图斑数据为空.");
return;
}
IQueryFilter queryFilter = new QueryFilterClass() { WhereClause = "XZQTZLX IS NOT NULL AND XZQTZLX <>''" };
if (JCDLTB_Layer.FeatureClass.FeatureCount(queryFilter) != 0)//发生变化,则还原(再次入库遵循条件是否还原基础数据库)
{
(JCDLTB_Layer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From DLTB WHERE 1=1");//DeleteSearchedRows重复操作出现BUG
JXTZBGHelper.InsertDataToMemeoryLayer(YSDLTBLayer.FeatureClass, JCDLTB_Layer.FeatureClass, null);
}
#region 注释
//在内存上创建一个基础地类图斑用于后续操作
//JCDLTB_Layer = GeoDBAPI.CreateFeatureLayerInmemeory("JC_DLTB", "基础地类图斑", (FcAPI_JC_DLTB.FeatureClass as IGeoDataset).SpatialReference, FcAPI_JC_DLTB.FeatureClass.ShapeType, FcAPI_JC_DLTB.FeatureClass.Fields);
//(JCDLTB_Layer.FeatureClass as ITable).DeleteSearchedRows(null);
//JXTZBGHelper.InsertDataToMemeoryLayer(FcAPI_JC_DLTB.FeatureClass, JCDLTB_Layer.FeatureClass, null);
//JCDLTB_Layer.FeatureClass = FcAPI_JC_DLTB.FeatureClass;
#endregion
IFeatureLayer JCXZQ_Layer = GeoDBAPI.CreateFeatureLayerInmemeory("JC_XZQ", "基础行政区", (FcAPI_JC_XZQ.FeatureClass as IGeoDataset).SpatialReference, FcAPI_JC_XZQ.FeatureClass.ShapeType, FcAPI_JC_XZQ.FeatureClass.Fields);
(JCXZQ_Layer.FeatureClass as ITable).DeleteSearchedRows(null);
JXTZBGHelper.InsertDataToMemeoryLayer(FcAPI_JC_XZQ.FeatureClass, JCXZQ_Layer.FeatureClass, null);
#region 国界零米线调整
if (Data.FirstOrDefault(x => x.BGZT.ToTrim() == "灭失" || x.BGZT.ToTrim() == "新增") != null)
{
this.UpdateMsg("正在进行国界零米线调整操作......");
foreach (DataModel item in Data.FindAll(x => x.IsHDZLD == true))
{
ExtractHDZLDData(item.Geo);
}
foreach (DataModel item in Data.FindAll(x => x.BGZT.ToTrim().Contains("灭失")))
{
ExtractMSData(item.Geo);//暂存SaveDatas
}
double BGQLDKZMJ = double.TryParse(txtTZQLDMJ.Text, out double TryPaseResult) ? TryPaseResult : 0;
double BGHLDKZMJ = double.TryParse(txtTZHLDMJ.Text, out TryPaseResult) ? TryPaseResult : 0;
double BGQHDKZMJ = double.TryParse(txtTZQHDMJ.Text, out TryPaseResult) ? TryPaseResult : 0;
double BGHHDKZMJ = double.TryParse(txtTZHHDMJ.Text, out TryPaseResult) ? TryPaseResult : 0;
//海岛转陆地实际面积
double HDZLDMJ = SaveDatas.Where(w => w.IsHDZLD).Sum(s => s.BGMJ).ToDouble(2);
//陆地-海岛灭失数据-陆地-海岛新增图斑
double LDMSMJ = SaveDatas.Where(w => w.IsOut && w.BGZT.Contains("灭失") && w.MSSM == "00").Sum(s => s.BGMJ);
double HDMSMJ = SaveDatas.Where(w => w.IsOut && w.BGZT.Contains("灭失") && w.MSSM == "01").Sum(s => s.BGMJ);
//海岛转陆地控制面积 = (变更前海岛控制面积-变更后海岛控制面积-灭失面积)
double HDZLDKZMJ = Math.Round((BGQHDKZMJ - BGHHDKZMJ - HDMSMJ).ToDouble(2), 2);
//调整后的平差总面积(海岛/陆地)
double LDXZMJ = Math.Round(BGHLDKZMJ - HDZLDKZMJ - (BGQLDKZMJ - LDMSMJ).ToDouble(2), 2);
double HDXZMJ = Math.Round(BGHHDKZMJ + HDZLDKZMJ - (BGQHDKZMJ - HDMSMJ).ToDouble(2), 2);
if (BGQLDKZMJ == 0 && BGHLDKZMJ == 0)
{
HDXZMJ = LDXZMJ;
LDXZMJ = 0;
HDZLDKZMJ = 0;
}
if (SaveDatas.Count != 0 && SaveDatas.FirstOrDefault(w => w.IsOut && w.BGZT.Contains("灭失")) != null)
SaveDataInsertDLTBHRGC(JCDLTB_Layer.FeatureClass, "灭失", "4");
//SaveDatasInsertDLTBBG(JCDLTB_Layer.FeatureClass, FcAPI_DLTBBG.FeatureClass, "灭失", "4");
foreach (DataModel item in Data.FindAll(x => x.BGZT.ToTrim().Contains("新增")))
{
ExtractXZData(item.Geo);//暂存SaveDatas
}
//新增陆地/海岛面积
double PCQ_LDXZMJ = SaveDatas.Where(w => w.IsAdd && w.BGZT.Contains("新增") && w.MSSM == "00").Sum(s => s.BGMJ);
double PCQ_HDXZMJ = SaveDatas.Where(w => w.IsAdd && w.BGZT.Contains("新增") && w.MSSM == "01").Sum(s => s.BGMJ);
#region 新增地类图斑面积平差
this.UpdateMsg("正在进行地类图斑面积平差......");
while ((HDZLDKZMJ - HDZLDMJ).ToDecimal(2) != 0)//海岛转陆地进行平差
{
double mjc = Math.Round(HDZLDKZMJ - HDZLDMJ, 2);
SaveDatas = SaveDatas.OrderByDescending(o => o.BGMJ).ToList();
foreach (var item in SaveDatas)
{
if (!item.IsHDZLD) continue;
if (mjc < 0)
{
item.BGMJ = Math.Round(item.BGMJ - 0.01, 2);
mjc = Math.Round(mjc + 0.01, 2);
}
else
{
item.BGMJ = Math.Round(item.BGMJ + 0.01, 2);
mjc = Math.Round(mjc - 0.01, 2);
}
if (mjc == 0)
break;
}
HDZLDMJ = SaveDatas.Where(w => w.IsHDZLD).Sum(s => s.BGMJ);
}
if (SaveDatas.FirstOrDefault(x => x.IsHDZLD == true) != null)
SaveDataInsertDLTBHRGC(JCDLTB_Layer.FeatureClass, "属性变化", "0");
while ((PCQ_LDXZMJ - LDXZMJ).ToDecimal(2) != 0)
{
double mjc = Math.Round(LDXZMJ - PCQ_LDXZMJ, 2);
SaveDatas = SaveDatas.OrderByDescending(o => o.BGMJ).ToList();
foreach (var item in SaveDatas)
{
if (!item.IsAdd && !item.BGZT.Contains("新增")) continue;
if (mjc < 0)
{
item.BGMJ = Math.Round(item.BGMJ - 0.01, 2);
mjc = Math.Round(mjc + 0.01, 2);
}
else
{
item.BGMJ = Math.Round(item.BGMJ + 0.01, 2);
mjc = Math.Round(mjc - 0.01, 2);
}
if (mjc == 0)
break;
}
PCQ_LDXZMJ = SaveDatas.Where(w => w.IsAdd && w.BGZT.Contains("新增") && w.MSSM == "00").Sum(s => s.BGMJ);
}
while ((PCQ_HDXZMJ - HDXZMJ).ToDecimal(2) != 0 && PCQ_HDXZMJ != 0)
{
double mjc = Math.Round(HDXZMJ - PCQ_HDXZMJ, 2);
SaveDatas = SaveDatas.OrderByDescending(o => o.BGMJ).ToList();
foreach (var item in SaveDatas)
{
if (!item.IsAdd && !item.BGZT.Contains("新增")) continue;
if (mjc < 0)
{
item.BGMJ = Math.Round(item.BGMJ - 0.01, 2);
mjc = Math.Round(mjc + 0.01, 2);
}
else
{
item.BGMJ = Math.Round(item.BGMJ + 0.01, 2);
mjc = Math.Round(mjc - 0.01, 2);
}
if (mjc == 0)
break;
}
PCQ_HDXZMJ = SaveDatas.Where(w => w.IsAdd && w.BGZT.Contains("新增") && w.MSSM == "01").Sum(s => s.BGMJ);
}
#endregion
if (SaveDatas.FindAll(x => x.BGZT.Contains("新增")).Count != 0)
SaveDataInsertDLTBHRGC(XZDLTB_Layer.FeatureClass, "新增", "3");
}
#endregion
foreach (DataModel item in Data.FindAll(x => x.BGZT.Contains("划出")))
{
this.UpdateMsg("正在进行行政区划出操作......");
ExtractHCSaveDatas(item.Geo);//暂存SaveDatas
SetCZCDYDZT(item.Geo, "2");
}
if (SaveDatas.FindAll(x => x.BGZT.Contains("划出")).Count != 0)
{
//SaveDatasInsertDLTBBG(JCDLTB_Layer.FeatureClass, FcAPI_DLTBBG.FeatureClass, "划出", "2");
SaveDataInsertDLTBHRGC(JCDLTB_Layer.FeatureClass, "划出", "2");
}
queryFilter.WhereClause = "XZQTZLX='1'";
if (FcAPI_DLTBHRGC != null)
(FcAPI_DLTBHRGC.FeatureClass as ITable).DeleteSearchedRows(queryFilter);//插入之前做一次清空
foreach (DataModel item in Data.FindAll(x => x.BGZT.Contains("划入")))
{
this.UpdateMsg("正在进行行政区划入操作......");
ExtractHR(item.Geo);
}
//加载全部数据
this.UpdateMsg("正在进行数据加载,入库成功!");
LoadData(true);
this.CloseLoading();
MessageHelper.ShowTips("入库成功!");
}
else
{
MessageHelper.ShowError("范围图斑数据变更状态缺失,请修改状态!");
}
}
catch (Exception ex)
{
this.CloseLoading();
MessageHelper.ShowError("入库失败:" + ex.Message);
LogAPI.Debug("入库失败:" + ex.Message);
LogAPI.Debug(ex);
}
finally
{
this.CloseLoading();
}
}
/// <summary>
/// 地类图斑划入过程图斑插入到变更层
/// </summary>
private void IntoTBDataToDLTBBG(object sender, RoutedEventArgs e)
{
IFeatureClass targetFc = null;
IWorkspaceFactory pFtWsFct = null;
IWorkspaceName workspaceName = null;
try
{
if (FcAPI_DLTBHRGC != null)
targetFc = FcAPI_DLTBHRGC.FeatureClass;//地类图斑划入过程图斑
QueryFilter queryfilter = new QueryFilterClass
{
WhereClause = string.Format("XZQTZLX='0' OR XZQTZLX='1' OR XZQTZLX='2' OR XZQTZLX='3' OR XZQTZLX='4'")//XZQTZLX-行政区调整类型
};
if (targetFc.FeatureCount(queryfilter) == 0) return;
//(FcAPI_DLTBBG.FeatureClass as ITable).DeleteSearchedRows(queryfilter);
if (FcAPI_DLTBBG == null || FcAPI_DLTBBG.FeatureClass == null)
FcAPI_DLTBBG = new FeatureClassAPI(MapsManager.Instance.MapService.GetFeatureClassByName("DLTBBG"));
(FcAPI_DLTBBG.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From DLTBBG WHERE XZQTZLX='0' OR XZQTZLX='1' OR XZQTZLX='2' OR XZQTZLX='3' OR XZQTZLX='4'");
this.ShowLoading("正在进行地类图斑划入过程图斑插入到变更层操作......", 0, 0);
if (FcAPI_DLTBBG.FeatureClass.FeatureCount(null) != 0)
{
pFtWsFct = new FileGDBWorkspaceFactory();
string saveFile = SysAppPath.GetTempPath() + @"QYTZTemp\";//临时GDB数据
if (!Directory.Exists(saveFile))
Directory.CreateDirectory(saveFile);
//删除saveFile当前路径下,所有的文件和目录
PluginServiceInterface.CommonHelper.DelectDir(saveFile);
IFeatureLayer HRBGDataLayer = null;
IFeatureLayer HRBGMultipartDataLayer = null;
string path = System.IO.Path.Combine(saveFile, DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".gdb");
workspaceName = pFtWsFct.Create(saveFile, DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".gdb", null, 0);
IFeatureLayer dltbbg_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBBG");
IFeatureLayer DLTBHRGC_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBHRGC");
GPParamClass gPParamClass = new GPParamClass();
gPParamClass.FirstFeatureLayer = DLTBHRGC_Layer;
gPParamClass.SecondFeatureLayer = dltbbg_Layer;
gPParamClass.IsGetOutPutFeature = true;
gPParamClass.GPType = EnumGPType.Erase;
gPParamClass.OutFeatureClassPath = System.IO.Path.Combine(path, "QYTZTempHR");
IDGForNDBG.GPHelper.Instance.ExeGPForProces(gPParamClass, ref HRBGDataLayer);
gPParamClass = new GPParamClass();
gPParamClass.FirstFeatureLayer = HRBGDataLayer;
gPParamClass.OutFeatureClassPath = $"{path}\\QYTZTempHRMultipart";
gPParamClass.IsGetOutPutFeature = true;
gPParamClass.GPType = EnumGPType.MultipartToSinglePath;
IDGForNDBG.GPHelper.Instance.ExeGPForProces(gPParamClass, ref HRBGMultipartDataLayer);
targetFc = HRBGMultipartDataLayer.FeatureClass;
}
if (targetFc == null) return;
IFeatureCursor cursor = targetFc.Search(null, true);
IFeature f = null;
IFeatureClassLoad pFclsLoad = FcAPI_DLTBBG.FeatureClass as IFeatureClassLoad;
if (pFclsLoad != null)
pFclsLoad.LoadOnlyMode = true;
IFeatureCursor gxCursor = FcAPI_DLTBBG.FeatureClass.Insert(true);
while ((f = cursor.NextFeature()) != null)//地类图斑划入过程图斑要素
{
IFeatureBuffer gxBuff = CreateGxFeature(f, FcAPI_DLTBBG.FeatureClass);
gxCursor.InsertFeature(gxBuff);
Marshal.ReleaseComObject(gxBuff);
}
gxCursor.Flush();
if (pFclsLoad != null)
pFclsLoad.LoadOnlyMode = false;
if (pFclsLoad != null)
Marshal.ReleaseComObject(pFclsLoad);
#region
try
{
IQueryFilter filter = new QueryFilterClass
{
WhereClause = "XZQTZLX = '3'"
};
int idx = JCDLTB_Layer.FeatureClass.FindField("XZQTZLX");
if (idx != -1)
{
(JCDLTB_Layer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("Delete From DLTB WHERE XZQTZLX = '3'");
FcAPI_DLTBBG.FcToFc(JCDLTB_Layer.FeatureClass, filter, false);
//JXTZBGHelper.InsertDataToMemeoryLayer(FcAPI_DLTBBG.FeatureClass, JCDLTB_Layer.FeatureClass, filter);
}
}
catch (Exception ex)
{
MessageHelper.ShowError(ex.Message);
LogAPI.Debug(ex);
}
#endregion
this.CloseLoading();
MessageHelper.ShowTips("统赋后数据入变更库成功!");
if (gxCursor != null)
Marshal.ReleaseComObject(gxCursor);
if (cursor != null)
Marshal.ReleaseComObject(cursor);
}
catch (Exception ex)
{
this.CloseLoading();
LogAPI.Debug(ex);
MessageHelper.ShowTips("统赋后数据入变更库失败!");
}
finally
{
this.CloseLoading();
}
}
/// <summary>
///
/// </summary>
/// <param name="pBgFeature">地类图斑划入过程数据</param>
/// <param name="pGxFc">地类图斑变更层</param>
/// <returns></returns>
private IFeatureBuffer CreateGxFeature(IFeature pBgFeature, IFeatureClass pBGTBFC)
{
IFeatureBuffer buffer = pBGTBFC.CreateFeatureBuffer();
IGeometry _Geo = pBgFeature.ShapeCopy;
try
{
buffer.Shape = _Geo;
int idxBGMJ = pBgFeature.Fields.FindField("TBBGMJ");
int idxTBMJ = pBGTBFC.FindField("TBMJ");
for (int i = 0; i < buffer.Fields.FieldCount; i++)
{
IField field = buffer.Fields.Field[i];
if (field.Name.Contains(pBGTBFC.ShapeFieldName) || !field.Editable) continue;
if (field.Name.ToUpper() == "XZQTZLX")
{
buffer.Value[i] = pBgFeature.Value[FcAPI_DLTBHRGC.FeatureClass.FindField("XZQTZLX")];
continue;
}
int index = pBgFeature.Fields.FindField("BGH" + field.Name);
if ("2,4".Contains(pBgFeature.Value[pBGTBFC.FindField("XZQTZLX")].ToTrim()))
{
index = pBgFeature.Fields.FindField("BGQ" + field.Name);
}
if (index == -1) continue;
if (string.IsNullOrWhiteSpace(pBgFeature.Value[index].ToTrim()))
buffer.Value[i] = DBNull.Value;
else
buffer.Value[i] = pBgFeature.Value[index];
}
if (idxTBMJ != -1 && idxBGMJ != -1)
buffer.Value[idxTBMJ] = pBgFeature.Value[idxBGMJ];
return buffer;
}
catch (Exception)
{
LogAPI.Debug("划入过程数据加载到变更层失败,OIDBging:" + pBgFeature != null ? pBgFeature.OID.ToString() : "-1");
return null;
}
}
/// <summary>
/// 存储划入数据ToDLTBHRGC
/// </summary>
/// <param name="HRgeometry"></param>
private void ExtractHR(IGeometry HRgeometry)
{
if (XZDLTB_Layer == null) return;
IFeatureCursor tarCursor = null;
IFeatureCursor jcCursor = null;
IGeometry tempGeo = HRgeometry;//县级控制界限
ITopologicalOperator topo = HRgeometry as ITopologicalOperator;
tempGeo = topo.Buffer(-.01);
List<IFeature> features = FeatureAPI.Identify(tempGeo, XZDLTB_Layer);//tempGeo-县级控制界限,layer-选择的新增图斑
IGeometry tempGeo_B = topo.Buffer(0.01);
IRelationalOperator rele = tempGeo_B as IRelationalOperator;
int tbmjindex = XZDLTB_Layer.FeatureClass.FindField("TBMJ");//新增的图斑面积
IFeatureClass targetFc = FcAPI_DLTBHRGC.FeatureClass;//MapsManager.Instance.MapService.GetFeatureClassByName("DLTBHRGC");
tarCursor = targetFc.Insert(true);//地类图斑划入过程游标
jcCursor = JCDLTB_Layer.FeatureClass.Insert(true);
int XZQTZLXIndex = JCDLTB_Layer.FeatureClass.FindField("XZQTZLX");
foreach (var f in features)
{
List<IFeature> jcFeature = FeatureAPI.Identify2(f.ShapeCopy, JCDLTB_Layer);
foreach (IFeature item in jcFeature)
{
IGeometry jcGeo = FeatureAPI.Difference(item.ShapeCopy, f.ShapeCopy);
item.Shape = jcGeo;
item.Store();
}
IFeatureBuffer jcBuff = JCDLTB_Layer.FeatureClass.CreateFeatureBuffer();
jcBuff.Shape = f.ShapeCopy;
for (int i = 0; i < jcBuff.Fields.FieldCount; i++)
{
IField field = jcBuff.Fields.Field[i];
if (field.Name.Contains(targetFc.ShapeFieldName) || !field.Editable)
continue;
int index = XZDLTB_Layer.FeatureClass.FindField(field.Name);
if (index != -1)
{
jcBuff.Value[i] = f.Value[index];
}
jcBuff.Value[XZQTZLXIndex] = "1";
}
jcCursor.InsertFeature(jcBuff);
IFeatureBuffer tFBuff = targetFc.CreateFeatureBuffer();
for (int i = 0; i < tFBuff.Fields.FieldCount; i++)
{
IField field = tFBuff.Fields.Field[i];
if (field.Name.Contains(targetFc.ShapeFieldName) || field.Name.ToUpper() == "OBJECTID" || field.Name.ToUpper() == "BSM" || "BGHTBBH,BGHTBBSM,BGHZLDWDM,BGHQSDWDM,BGHZLDWMC,BGHQSDWMC".Contains(field.Name))
continue;
if (field.Name == "XZQTZLX")
{
tFBuff.Value[i] = "1";
continue;
}
string fieldName = field.Name.Replace("BGQ", "");
fieldName = fieldName.Replace("BGH", "");
if (fieldName == "TBBSM")
{
fieldName = "BSM";
}
if (fieldName == "TBBGMJ")
{
fieldName = "TBMJ";
}
int index = XZDLTB_Layer.FeatureClass.FindField(fieldName);
if (index != -1)
{
tFBuff.Value[i] = f.Value[index];
}
}
if (rele.Contains(f.ShapeCopy))//在界限内-整图斑划入
{
tFBuff.Shape = f.ShapeCopy;
int index = targetFc.FindField("IsCompleteOut");
if (index > -1)
{
tFBuff.Value[targetFc.FindField("IsCompleteOut")] = "True";
}
if (string.IsNullOrWhiteSpace(f.Value[tbmjindex].ToTrim()))
tFBuff.Value[targetFc.FindField("TBBGMJ")] = f.ShapeCopy.GetEllipseArea();
}
else
{
double kzmj = f.Value[tbmjindex].ToDouble();
IGeometry geo = FeatureAPI.InterSect(f.ShapeCopy, HRgeometry);
List<IGeometry> geoList = FeatureAPI.DissolveGeometryByRing(geo);
//geo如果存在重叠问题,会导致geoListNULL
List<DataModel> dataList = new List<DataModel>();
foreach (var item in geoList)
{
DataModel model = new DataModel();
dataList.Add(model);
model.TC = "DLTB";
model.Geo = item;
model.BGMJ = (item as IPolygon).GetEllipseArea();
model.IsOut = true;
model.DLTBOid = f.OID;
model.BGZT = "划入";
}
JXTZBGHelper.AreaAdjustment(dataList, "BGMJ", kzmj);//平差
foreach (DataModel item in dataList)
{
tFBuff.Shape = item.Geo;
tFBuff.Value[targetFc.FindField("IsCompleteOut")] = "False";
tFBuff.Value[targetFc.FindField("TBBGMJ")] = item.BGMJ;
}
}
tarCursor.InsertFeature(tFBuff);
}
jcCursor.Flush();
tarCursor.Flush();
}
/// <summary>
/// 入库数据(灭失-新增-划出)存入变更层
/// </summary>
/// <param name="jcFc"></param>
/// <param name="BGFc"></param>
/// <param name="BGZTTemp"></param>
private void SaveDatasInsertDLTBBG(IFeatureClass jcFc, IFeatureClass tzFc, string BGZTTemp, string XZQTZLXIndex)
{
IFeatureCursor tzCursor = tzFc.Insert(true);
try
{
(tzFc as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = string.Format("XZQTZLX='{0}'", XZQTZLXIndex) });
foreach (var item in SaveDatas)
{
if ((item.IsOut || item.IsAdd) && item.BGZT.Contains(BGZTTemp))
{
IFeature jc_f = jcFc.GetFeature(item.DLTBOid);
int idxJCXZQTZLX = jcFc.FindField("XZQTZLX");
if (idxJCXZQTZLX != -1)
{
jc_f.Value[idxJCXZQTZLX] = XZQTZLXIndex;
jc_f.Store();
}
IFeatureBuffer gxBuff = CreateXzqGxFeature(jc_f, item.Geo, tzFc, false, "", item.BGZT);
int index = gxBuff.Fields.FindField("XZQTZLX");
if (index != -1)
gxBuff.Value[index] = XZQTZLXIndex;
if (item.BGZT.Contains("新增") || item.BGZT.Contains("灭失"))
{
int bgmjIndex = gxBuff.Fields.FindField("TBMJ");
if (bgmjIndex != -1)
gxBuff.Value[bgmjIndex] = item.BGMJ.ToDecimal(2);
}
tzCursor.InsertFeature(gxBuff);
}
}
tzCursor.Flush();
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
finally
{
Marshal.ReleaseComObject(tzCursor);
}
}
/// <summary>
/// 将SaveDatas数据存入地类图斑划入过程层
/// </summary>
private void SaveDataInsertDLTBHRGC(IFeatureClass jcFc, string BGZTTemp, string XZQTZLXIndex)
{
IFeatureCursor tzCursor = FcAPI_DLTBHRGC.FeatureClass.Insert(true);
try
{
(FcAPI_DLTBHRGC.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = string.Format("XZQTZLX='{0}'", XZQTZLXIndex) });
foreach (var item in SaveDatas)
{
if ((item.IsOut || item.IsAdd) && item.BGZT.Contains(BGZTTemp))
{
IFeature jc_f = jcFc.GetFeature(item.DLTBOid);
int idxJCXZQTZLX = jcFc.FindField("XZQTZLX");
int idxTBMJ = jcFc.FindField("TBMJ");
int idxBSM = jcFc.FindField("BSM");
string bsm = jc_f.Value[idxBSM].ToTrim();
double kzmj = jc_f.Value[idxTBMJ].ToDouble();
#region 注释
//if (item.IsCompleteOut == false && item.IsOut)
//{
// IGeometry geo = FeatureAPI.InterSect(jc_f.ShapeCopy, item.Geo);
// if (!geo.IsEmpty)
// {
// List<IGeometry> geoList = FeatureAPI.DissolveGeometryByRing(geo);
// List<DataModel> dataList = new List<DataModel>();
// foreach (var itemF in geoList)
// {
// DataModel model = new DataModel
// {
// TC = "DLTB",
// Geo = itemF,
// DLTBOid = jc_f.OID,
// IsOut = true,
// BGMJ = (itemF as IPolygon).GetEllipseArea()
// };
// dataList.Add(model);
// }
// IGeometry geo_out = FeatureAPI.Difference(jc_f.ShapeCopy, item.Geo);
// geoList = FeatureAPI.DissolveGeometryByRing(geo_out);
// foreach (var itemF in geoList)
// {
// DataModel model = new DataModel
// {
// TC = "DLTB",
// Geo = itemF,
// DLTBOid = jc_f.OID,
// BGMJ = (itemF as IPolygon).GetEllipseArea()
// };
// dataList.Add(model);
// }
// if (dataList.Count > 0)
// {
// JXTZBGHelper.AreaAdjustment<DataModel>(dataList, "BGMJ", kzmj);
// //IFeatureCursor cursorJCDLTB = jcFc.Insert(true);
// //foreach (DataModel itemXZDLTB in dataList.FindAll(x => x.IsOut == true))
// //{
// // IFeatureBuffer buffer = jcFc.CreateFeatureBuffer();
// // buffer.Shape = itemXZDLTB.Geo;
// // for (int i = 0; i < jc_f.Fields.FieldCount; i++)
// // {
// // IField field = jc_f.Fields.Field[i];
// // if (field.Editable == false || field.Name.ToUpper().Contains("SHAPE")) continue;
// // if (field.Name.ToUpper().Contains("TBMJ"))
// // {
// // buffer.Value[i] = kzmj;// itemXZDLTB.BGMJ;
// // continue;
// // }
// // buffer.Value[i] = jc_f.Value[i];
// // }
// // buffer.Value[idxJCXZQTZLX] = XZQTZLXIndex;
// // cursorJCDLTB.InsertFeature(buffer);
// // cursorJCDLTB.Flush();
// //}
// //for (int i = 0; i < dataList.Count; i++)
// //{
// // if (i == 0)
// // {
// // jc_f.Shape = dataList[i].Geo;
// // if (dataList[i].IsOut)
// // jc_f.Value[idxJCXZQTZLX] = XZQTZLXIndex;
// // //jc_f.Value[idxTBMJ] = kzmj;
// // jc_f.Store();
// // }
// // else
// // {
// // IFeatureBuffer buffer = jcFc.CreateFeatureBuffer();
// // buffer.Shape = dataList[i].Geo;
// // for (int j = 0; j < jc_f.Fields.FieldCount; j++)
// // {
// // IField field = jc_f.Fields.Field[j];
// // if (field.Editable == false || field.Name.ToUpper().Contains("SHAPE")) continue;
// // if (field.Name.ToUpper().Contains("TBMJ"))
// // {
// // buffer.Value[j] = kzmj;// itemXZDLTB.BGMJ;
// // continue;
// // }
// // buffer.Value[j] = jc_f.Value[j];
// // }
// // if (dataList[i].IsOut)
// // buffer.Value[idxJCXZQTZLX] = XZQTZLXIndex;
// // else
// // buffer.Value[idxJCXZQTZLX] = DBNull.Value;
// // cursorJCDLTB.InsertFeature(buffer);
// // cursorJCDLTB.Flush();
// // }
// //}
// //jc_f.Shape = dataList.FirstOrDefault(x => x.IsOut == false).Geo;
// //jc_f.Value[idxTBMJ] = kzmj;// dataList.FirstOrDefault(x => x.IsOut == true).BGMJ;
// ////jc_f.Value[idxJCXZQTZLX] = XZQTZLXIndex;
// //jc_f.Store();
// }
// }
//}
//if (idxJCXZQTZLX != -1 && item.IsCompleteOut)
//{
// jc_f.Value[idxJCXZQTZLX] = XZQTZLXIndex;
// jc_f.Store();
//}
#endregion
IFeatureBuffer gxBuff = FcAPI_DLTBHRGC.FeatureClass.CreateFeatureBuffer();
gxBuff.Shape = item.Geo;
for (int i = 0; i < jc_f.Fields.FieldCount; i++)//划出-灭失
{
IField field = jc_f.Fields.Field[i];
int indexs = gxBuff.Fields.FindField("BGQ" + field.Name);
if (BGZTTemp.Trim() == "新增")
indexs = gxBuff.Fields.FindField("BGH" + field.Name);
if (indexs == -1) continue;
if (string.IsNullOrWhiteSpace(jc_f.Value[i].ToTrim()))
gxBuff.Value[indexs] = DBNull.Value;
else
gxBuff.Value[indexs] = jc_f.Value[i];
}
int index = gxBuff.Fields.FindField("XZQTZLX");
int IsCompleteOutIndex = gxBuff.Fields.FindField("IsCompleteOut");
if (index != -1)
gxBuff.Value[index] = XZQTZLXIndex;
if (IsCompleteOutIndex != -1)
gxBuff.Value[IsCompleteOutIndex] = item.IsCompleteOut ? "true" : "false";
if (item.BGZT.Contains("新增") || item.BGZT.Contains("灭失") || item.BGZT.Contains("划出"))
{
int bgmjIndex = gxBuff.Fields.FindField("TBBGMJ");
if (bgmjIndex != -1)
gxBuff.Value[bgmjIndex] = item.BGMJ.ToDecimal(2);
}
tzCursor.InsertFeature(gxBuff);
}
else if (item.IsHDZLD && BGZTTemp == "属性变化")
{
IFeature jc_f = jcFc.GetFeature(item.DLTBOid);
int idxJCXZQTZLX = jcFc.FindField("XZQTZLX");
if (idxJCXZQTZLX != -1)
{
//jc_f.Value[idxJCXZQTZLX] = XZQTZLXIndex;
//jc_f.Store();
}
IFeatureBuffer gxBuff = FcAPI_DLTBHRGC.FeatureClass.CreateFeatureBuffer();
gxBuff.Shape = item.Geo;
for (int i = 0; i < jc_f.Fields.FieldCount; i++)
{
IField field = jc_f.Fields.Field[i];
int indexBGQ = gxBuff.Fields.FindField("BGQ" + field.Name);
if (indexBGQ != -1)
{
if (string.IsNullOrWhiteSpace(jc_f.Value[i].ToTrim()))
gxBuff.Value[indexBGQ] = DBNull.Value;
else
gxBuff.Value[indexBGQ] = jc_f.Value[i];
}
int indexBGH = gxBuff.Fields.FindField("BGH" + field.Name);
if (indexBGH != -1)
{
if (string.IsNullOrWhiteSpace(jc_f.Value[i].ToTrim()))
gxBuff.Value[indexBGH] = DBNull.Value;
else
gxBuff.Value[indexBGH] = jc_f.Value[i];
if (field.Name.Contains("MSSM"))
{
gxBuff.Value[indexBGH] = "00";//海岛转陆地-变更后描述说明00
}
int indexBGHHDMC = gxBuff.Fields.FindField("BGHMSSM");
if (field.Name.Contains("HDMC") && gxBuff.Value[indexBGHHDMC].ToTrim() == "00")
{
gxBuff.Value[indexBGH] = "";//海岛转陆地-清空海岛名称
}
}
}
int index = gxBuff.Fields.FindField("XZQTZLX");
int IsCompleteOutIndex = gxBuff.Fields.FindField("IsCompleteOut");
if (index != -1)
gxBuff.Value[index] = XZQTZLXIndex;
if (IsCompleteOutIndex != -1)
gxBuff.Value[IsCompleteOutIndex] = item.IsCompleteOut ? "true" : "false";
int bgmjIndex = gxBuff.Fields.FindField("TBBGMJ");
if (bgmjIndex != -1)
gxBuff.Value[bgmjIndex] = item.BGMJ.ToDecimal(2);
tzCursor.InsertFeature(gxBuff);
}
}
tzCursor.Flush();
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
finally
{
Marshal.ReleaseComObject(tzCursor);
}
}
/// <summary>
/// 划入数据存入SaveDatas
/// </summary>
/// <param name="msGeo"></param>
private void ExtractHCSaveDatas(IGeometry msGeo)
{
ITopologicalOperator topo = msGeo as ITopologicalOperator;
IGeometry tempGeo = msGeo;// topo.Buffer(-.0001);
List<IFeature> features = FeatureAPI.Identify(tempGeo, JCDLTB_Layer);
IGeometry tempGeo_B = msGeo;// topo.Buffer(0.01);
IRelationalOperator rele = tempGeo_B as IRelationalOperator;
int zldmindex = JCDLTB_Layer.FeatureClass.FindField("ZLDWDM");
int zlmcindex = JCDLTB_Layer.FeatureClass.FindField("ZLDWMC");
int tbmjindex = JCDLTB_Layer.FeatureClass.FindField("TBMJ");
int idxBSM = JCDLTB_Layer.FeatureClass.FindField("BSM");
int idxJCXZQTZLX = JCDLTB_Layer.FeatureClass.FindField("XZQTZLX");
int completeCount = 0;
//double completeSumMJ = 0;
int splitCount = 0;
double splitSumMJ = 0;
IFeatureCursor cursorJCDLTB = JCDLTB_Layer.FeatureClass.Insert(true);
foreach (var f in features)
{
IGeometry jc_Geo = f.ShapeCopy;
if (f.OID == 297803)
{
}
string bsm = f.Value[idxBSM].ToTrim();
//if (bsm == "330604211000009840" || bsm == "330604211000014881" || bsm == "330604211000009841" || bsm == "330604211000150767")
//{
// //continue;
//}
DataModel modelItem = new DataModel();
modelItem.TC = "DLTB";
if (rele.Contains(jc_Geo))
{
f.Value[idxJCXZQTZLX] = "2";
f.Store();
SaveDatas.Add(modelItem);
modelItem.IsCompleteOut = true;
modelItem.DLTBOid = f.OID;
modelItem.IsOut = true;
if (zldmindex != -1)
{
modelItem.CJDCQInfo = f.Value[zlmcindex].ToTrim() + "-" + f.Value[zldmindex].ToTrim().Substring(0, 12);
modelItem.XZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 9);
modelItem.XJXZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 6);
}
modelItem.BGMJ = f.Value[tbmjindex].ToDouble();
modelItem.Geo = jc_Geo;
modelItem.BGZT = "划出";
completeCount++;
//completeSumMJ += modelItem.BGMJ;
continue;
}
else
{
double kzmj = f.Value[tbmjindex].ToDouble();
splitCount++;
IGeometry geo = FeatureAPI.InterSect(jc_Geo, msGeo);
if (geo.IsEmpty) continue;
List<IGeometry> geoList = FeatureAPI.DissolveGeometryByRing(geo);
List<DataModel> dataList = new List<DataModel>();
int i = 0;
foreach (var item in geoList)
{
i++;
if (i == 1)
{
f.Shape = item;
f.Value[idxJCXZQTZLX] = "2";
f.Store();
}
else
{
IFeatureBuffer buffer = JCDLTB_Layer.FeatureClass.CreateFeatureBuffer();
buffer.Shape = item;
for (int j = 0; j < f.Fields.FieldCount; j++)
{
IField field = f.Fields.Field[j];
if (field.Editable == false || field.Name.ToUpper().Contains("SHAPE")) continue;
if (field.Name.ToUpper().Contains("TBMJ"))
{
buffer.Value[j] = kzmj;// itemXZDLTB.BGMJ;
continue;
}
buffer.Value[j] = f.Value[j];
}
buffer.Value[idxJCXZQTZLX] = "2";
cursorJCDLTB.InsertFeature(buffer);
cursorJCDLTB.Flush();
}
DataModel model = new DataModel();
dataList.Add(model);
model.TC = "DLTB";
model.Geo = item;
model.BGMJ = (item as IPolygon).GetEllipseArea();
model.IsOut = true;
model.BGZT = "划出";
model.DLTBOid = f.OID;
model.CJDCQInfo = f.Value[zlmcindex].ToTrim() + "-" + f.Value[zldmindex].ToTrim().Substring(0, 12);
model.XZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 9);
model.XJXZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 6);
}
IGeometry geo_out = FeatureAPI.Difference(jc_Geo, msGeo);
if (geo_out.IsEmpty) continue;
geoList = FeatureAPI.DissolveGeometryByRing(geo_out);
foreach (var item in geoList)
{
IFeatureBuffer buffer = JCDLTB_Layer.FeatureClass.CreateFeatureBuffer();
buffer.Shape = item;
for (int j = 0; j < f.Fields.FieldCount; j++)
{
IField field = f.Fields.Field[j];
if (field.Editable == false || field.Name.ToUpper().Contains("SHAPE")) continue;
if (field.Name.ToUpper().Contains("TBMJ"))
{
buffer.Value[j] = kzmj;// itemXZDLTB.BGMJ;
continue;
}
buffer.Value[j] = f.Value[j];
}
buffer.Value[idxJCXZQTZLX] = DBNull.Value;
cursorJCDLTB.InsertFeature(buffer);
cursorJCDLTB.Flush();
DataModel model = new DataModel();
dataList.Add(model);
model.TC = "DLTB";
model.Geo = item;
model.BGMJ = (item as IPolygon).GetEllipseArea();
model.DLTBOid = f.OID;
model.BGZT = "划出";
model.CJDCQInfo = f.Value[zlmcindex].ToTrim() + "-" + f.Value[zldmindex].ToTrim().Substring(0, 12);
model.XZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 9);
model.XJXZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 6);
}
JXTZBGHelper.AreaAdjustment(dataList, "BGMJ", kzmj);
splitSumMJ += dataList.Where(w => w.IsOut).Sum(s => s.BGMJ);
SaveDatas.AddRange(dataList);
}
}
}
/// <summary>
/// 标记城镇村图层数据划出
/// </summary>
/// <param name="msGeo"></param>
private void SetCZCDYDZT(IGeometry msGeo, string pXZQTZLX)
{
ITopologicalOperator topo = msGeo as ITopologicalOperator;
IGeometry tempGeo = msGeo;// topo.Buffer(-.01);
List<IFeature> features = FeatureAPI.Identify(tempGeo, JCCZC_Layer);
IGeometry tempGeo_B = msGeo;// topo.Buffer(0.01);
IRelationalOperator rele = tempGeo_B as IRelationalOperator;
int idxXZQTZLX = JCCZC_Layer.FeatureClass.FindField("XZQTZLX");
IFeatureCursor cursorJCDLTB = JCCZC_Layer.FeatureClass.Insert(true);
foreach (var f in features)
{
IGeometry jc_Geo = f.ShapeCopy;
if (idxXZQTZLX == -1) continue;
if (!rele.Contains(f.ShapeCopy))
{
IGeometry geo = FeatureAPI.InterSect(jc_Geo, msGeo);
if (!geo.IsEmpty)
{
List<IGeometry> geoList = FeatureAPI.DissolveGeometryByRing(geo);
int i = 0;
foreach (var item in geoList)
{
i++;
if (i == 1)
{
f.Shape = item;
f.Value[idxXZQTZLX] = pXZQTZLX;
f.Store();
}
else
{
IFeatureBuffer buffer = JCCZC_Layer.FeatureClass.CreateFeatureBuffer();
buffer.Shape = item;
for (int j = 0; j < f.Fields.FieldCount; j++)
{
IField field = f.Fields.Field[j];
if (field.Editable == false || field.Name.ToUpper().Contains("SHAPE")) continue;
buffer.Value[j] = f.Value[j];
}
buffer.Value[idxXZQTZLX] = pXZQTZLX;
cursorJCDLTB.InsertFeature(buffer);
cursorJCDLTB.Flush();
}
}
IGeometry geo_out = FeatureAPI.Difference(jc_Geo, msGeo);
if (geo_out.IsEmpty) continue;
geoList = FeatureAPI.DissolveGeometryByRing(geo_out);
foreach (var item in geoList)
{
IFeatureBuffer buffer = JCCZC_Layer.FeatureClass.CreateFeatureBuffer();
buffer.Shape = item;
for (int j = 0; j < f.Fields.FieldCount; j++)
{
IField field = f.Fields.Field[j];
if (field.Editable == false || field.Name.ToUpper().Contains("SHAPE")) continue;
//if (field.Name.ToUpper().Contains("TBMJ"))
//{
// buffer.Value[j] = kzmj;// itemXZDLTB.BGMJ;
// continue;
//}
buffer.Value[j] = f.Value[j];
}
buffer.Value[idxXZQTZLX] = DBNull.Value;
cursorJCDLTB.InsertFeature(buffer);
cursorJCDLTB.Flush();
}
}
}
else
{
f.Value[idxXZQTZLX] = pXZQTZLX;
f.Store();
}
}
}
/// <summary>
/// 海岛转陆地
/// </summary>
/// <param name="msGeo"></param>
private void ExtractHDZLDData(IGeometry msGeo)
{
IGeometry tempGeo = msGeo;
ITopologicalOperator topo = msGeo as ITopologicalOperator;
tempGeo = topo.Buffer(-.01);
//压盖的是海岛转陆地地类图斑
List<IFeature> features = FeatureAPI.Identify(tempGeo, JCDLTB_Layer);
IGeometry tempGeo_B = topo.Buffer(0.01);
IRelationalOperator rele = tempGeo_B as IRelationalOperator;
int zldmindex = JCDLTB_Layer.FeatureClass.FindField("ZLDWDM");
int zlmcindex = JCDLTB_Layer.FeatureClass.FindField("ZLDWMC");
int tbmjindex = JCDLTB_Layer.FeatureClass.FindField("TBMJ");
int mssmindex = JCDLTB_Layer.FeatureClass.FindField("MSSM");
int completeCount = 0;
double completeSumMJ = 0;
int splitCount = 0;
double splitSumMJ = 0;
foreach (var f in features)
{
DataModel modelItem = new DataModel
{
TC = "DLTB"
};
if (rele.Contains(f.ShapeCopy))
{
SaveDatas.Add(modelItem);
modelItem.IsCompleteOut = true;
modelItem.DLTBOid = f.OID;
modelItem.IsHDZLD = true;
if (zldmindex != -1)
{
string zldm = f.Value[zldmindex].ToTrim();
modelItem.CJDCQInfo = f.Value[zlmcindex].ToTrim() + "-" + (zldm.Length > 12 ? zldm.Substring(0, 12) : zldm);
modelItem.XZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 9);
modelItem.XJXZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 6);
}
modelItem.BGMJ = f.ShapeCopy.GetEllipseArea();// f.Value[tbmjindex].ToDouble();
modelItem.MSSM = "00";
modelItem.Geo = f.ShapeCopy;
modelItem.BGZT = "海岛转陆地";
completeCount++;
completeSumMJ += modelItem.BGMJ;
continue;
}
else
{
double kzmj = f.Value[tbmjindex].ToDouble();
splitCount++;
IGeometry geo = FeatureAPI.InterSect(f.ShapeCopy, msGeo);
List<IGeometry> geoList = FeatureAPI.DissolveGeometryByRing(geo);
List<DataModel> dataList = new List<DataModel>();
foreach (var item in geoList)
{
DataModel model = new DataModel();
dataList.Add(model);
model.TC = "DLTB";
model.Geo = item;
model.BGMJ = (item as IPolygon).GetEllipseArea();
model.DLTBOid = f.OID;
model.IsHDZLD = true;
model.CJDCQInfo = f.Value[zlmcindex].ToTrim() + "-" + f.Value[zldmindex].ToTrim().Substring(0, 12);
model.XZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 9);
model.XJXZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 6);
modelItem.MSSM = "00";
model.BGZT = "海岛转陆地";
}
IGeometry geo_out = FeatureAPI.Difference(f.ShapeCopy, msGeo);
geoList = FeatureAPI.DissolveGeometryByRing(geo_out);
foreach (var item in geoList)
{
DataModel model = new DataModel();
dataList.Add(model);
model.TC = "DLTB";
model.Geo = item;
model.BGMJ = (item as IPolygon).GetEllipseArea();
model.DLTBOid = f.OID;
model.CJDCQInfo = f.Value[zlmcindex].ToTrim() + "-" + f.Value[zldmindex].ToTrim().Substring(0, 12);
model.XZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 9);
model.XJXZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 6);
model.BGZT = "海岛转陆地";
modelItem.MSSM = "01";
}
JXTZBGHelper.AreaAdjustment<DataModel>(dataList, "BGMJ", kzmj);
splitSumMJ += dataList.Where(w => w.IsHDZLD).Sum(s => s.BGMJ);
SaveDatas.AddRange(dataList.FindAll(x => x.BGZT.Contains("海岛转陆地") && x.IsHDZLD));
}
}
}
/// <summary>
/// 新增数据存入SaveDatas
/// </summary>
/// <param name="msGeo"></param>
private void ExtractXZData(IGeometry msGeo)
{
IGeometry tempGeo = msGeo;
ITopologicalOperator topo = msGeo as ITopologicalOperator;
tempGeo = topo.Buffer(-.01);
//压盖的是新增地类图斑
List<IFeature> features = FeatureAPI.Identify(tempGeo, XZDLTB_Layer);
IGeometry tempGeo_B = topo.Buffer(0.01);
IRelationalOperator rele = tempGeo_B as IRelationalOperator;
int zldmindex = XZDLTB_Layer.FeatureClass.FindField("ZLDWDM");
int zlmcindex = XZDLTB_Layer.FeatureClass.FindField("ZLDWMC");
int tbmjindex = XZDLTB_Layer.FeatureClass.FindField("TBMJ");
int mssmindex = XZDLTB_Layer.FeatureClass.FindField("MSSM");
int completeCount = 0;
double completeSumMJ = 0;
int splitCount = 0;
double splitSumMJ = 0;
foreach (var f in features)
{
DataModel modelItem = new DataModel();
modelItem.TC = "DLTB";
if (rele.Contains(f.ShapeCopy))//rele灭失图斑
{
SaveDatas.Add(modelItem);
modelItem.IsCompleteOut = true;
modelItem.DLTBOid = f.OID;
modelItem.IsAdd = true;
if (zldmindex != -1)
{
string zldm = f.Value[zldmindex].ToTrim();
modelItem.CJDCQInfo = f.Value[zlmcindex].ToTrim() + "-" + (zldm.Length > 12 ? zldm.Substring(0, 12) : zldm);
modelItem.XZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 9);
modelItem.XJXZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 6);
}
modelItem.BGMJ = (f.ShapeCopy as IPolygon).GetEllipseArea();
if (mssmindex != -1)
modelItem.MSSM = f.Value[mssmindex].ToTrim();
modelItem.Geo = f.ShapeCopy;
modelItem.BGZT = "新增";
completeCount++;
completeSumMJ += modelItem.BGMJ;
continue;
}
else
{
double kzmj = f.Value[tbmjindex].ToDouble();
splitCount++;
IGeometry geo = FeatureAPI.InterSect(f.ShapeCopy, msGeo);
List<IGeometry> geoList = FeatureAPI.DissolveGeometryByRing(geo);
List<DataModel> dataList = new List<DataModel>();
foreach (var item in geoList)
{
DataModel model = new DataModel();
dataList.Add(model);
model.TC = "DLTB";
model.Geo = item;
model.BGMJ = (item as IPolygon).GetEllipseArea();
model.IsAdd = true;
model.DLTBOid = f.OID;
model.CJDCQInfo = f.Value[zlmcindex].ToTrim() + "-" + f.Value[zldmindex].ToTrim().Substring(0, 12);
model.XZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 9);
model.XJXZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 6);
if (mssmindex != -1)
modelItem.MSSM = f.Value[mssmindex].ToTrim();
model.BGZT = "新增";
}
IGeometry geo_out = FeatureAPI.Difference(f.ShapeCopy, msGeo);
geoList = FeatureAPI.DissolveGeometryByRing(geo_out);
foreach (var item in geoList)
{
DataModel model = new DataModel();
dataList.Add(model);
model.TC = "DLTB";
model.Geo = item;
model.IsOut = false;
model.BGMJ = (item as IPolygon).GetEllipseArea();
model.DLTBOid = f.OID;
model.CJDCQInfo = f.Value[zlmcindex].ToTrim() + "-" + f.Value[zldmindex].ToTrim().Substring(0, 12);
model.XZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 9);
model.XJXZQInfo = f.Value[zldmindex].ToTrim().Substring(0, 6);
model.BGZT = "新增";
if (mssmindex != -1)
modelItem.MSSM = f.Value[mssmindex].ToTrim();
}
JXTZBGHelper.AreaAdjustment<DataModel>(dataList, "BGMJ", kzmj);
splitSumMJ += dataList.Where(w => w.IsOut).Sum(s => s.BGMJ);
SaveDatas.AddRange(dataList.FindAll(x => x.BGZT.Contains("新增") && x.IsOut));
}
}
}
/// <summary>
/// 灭失数据存入SaveDatas
/// </summary>
/// <param name="msGeo"></param>
private void ExtractMSData(IGeometry msGeo)
{
try
{
IGeometry tempGeo = msGeo;
ITopologicalOperator topo = msGeo as ITopologicalOperator;
tempGeo = topo.Buffer(-.01);
List<IFeature> features = FeatureAPI.Identify(tempGeo, JCDLTB_Layer);
IGeometry tempGeo_B = topo.Buffer(0.01);
IRelationalOperator rele = tempGeo_B as IRelationalOperator;
int zldmindex = JCDLTB_Layer.FeatureClass.FindField("ZLDWDM");
int zlmcindex = JCDLTB_Layer.FeatureClass.FindField("ZLDWMC");
int tbmjindex = JCDLTB_Layer.FeatureClass.FindField("TBMJ");
int mssmindex = JCDLTB_Layer.FeatureClass.FindField("MSSM");
int completeCount = 0;
double completeSumMJ = 0;
int splitCount = 0;
double splitSumMJ = 0;
foreach (var JC_f in features)
{
DataModel modelItem = new DataModel();
modelItem.TC = "DLTB";
if (rele.Contains(JC_f.ShapeCopy))//灭失图斑是否包含当前压盖到的基础地类图斑;
{
modelItem.IsCompleteOut = true;
modelItem.DLTBOid = JC_f.OID;
modelItem.IsOut = true;
if (zldmindex != -1)
{
modelItem.CJDCQInfo = JC_f.Value[zlmcindex].ToTrim() + "-" + JC_f.Value[zldmindex].ToTrim().Substring(0, 12);
modelItem.XZQInfo = JC_f.Value[zldmindex].ToTrim().Substring(0, 9);
modelItem.XJXZQInfo = JC_f.Value[zldmindex].ToTrim().Substring(0, 6);
}
modelItem.BGMJ = JC_f.Value[tbmjindex].ToDouble();
modelItem.MSSM = JC_f.Value[mssmindex].ToTrim();
modelItem.Geo = JC_f.ShapeCopy;
modelItem.BGZT = "灭失";
completeCount++;
completeSumMJ += modelItem.BGMJ;
SaveDatas.Add(modelItem);
continue;
}
else
{
double kzmj = JC_f.Value[tbmjindex].ToDouble();
splitCount++;
IGeometry geo = FeatureAPI.InterSect(JC_f.ShapeCopy, msGeo);//取地类图斑与,灭失图斑相交的部分
List<IGeometry> geoList = FeatureAPI.DissolveGeometryByRing(geo);
List<DataModel> dataList = new List<DataModel>();
foreach (var item in geoList)
{
DataModel model = new DataModel();
model.TC = "DLTB";
model.Geo = item;
model.BGMJ = (item as IPolygon).GetEllipseArea();
model.IsOut = true;
model.DLTBOid = JC_f.OID;
model.CJDCQInfo = JC_f.Value[zlmcindex].ToTrim() + "-" + JC_f.Value[zldmindex].ToTrim().Substring(0, 12);
model.XZQInfo = JC_f.Value[zldmindex].ToTrim().Substring(0, 9);
model.XJXZQInfo = JC_f.Value[zldmindex].ToTrim().Substring(0, 6);
model.MSSM = JC_f.Value[mssmindex].ToTrim();
model.BGZT = "灭失";
dataList.Add(model);
}
IGeometry geo_out = FeatureAPI.Difference(JC_f.ShapeCopy, msGeo);//地类图斑擦除灭失图斑
geoList = FeatureAPI.DissolveGeometryByRing(geo_out);
foreach (var item in geoList)
{
DataModel model = new DataModel();
model.TC = "DLTB";
model.Geo = item;
model.BGMJ = (item as IPolygon).GetEllipseArea();
model.DLTBOid = JC_f.OID;
model.CJDCQInfo = JC_f.Value[zlmcindex].ToTrim() + "-" + JC_f.Value[zldmindex].ToTrim().Substring(0, 12);
model.XZQInfo = JC_f.Value[zldmindex].ToTrim().Substring(0, 9);
model.XJXZQInfo = JC_f.Value[zldmindex].ToTrim().Substring(0, 6);
model.MSSM = JC_f.Value[mssmindex].ToTrim();
model.BGZT = "灭失";
dataList.Add(model);
}
JXTZBGHelper.AreaAdjustment<DataModel>(dataList, "BGMJ", kzmj);
splitSumMJ += dataList.Where(w => w.IsOut && w.BGZT == "灭失").Sum(s => s.BGMJ);
SaveDatas.AddRange(dataList);
}
}
}
catch (Exception ex)
{
LogAPI.Debug(ex.Message);
throw;
}
}
/// <summary>
/// 选中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckBoxClick(object sender, RoutedEventArgs e)
{
try
{
if ((sender as CheckBox).IsChecked == true && !string.IsNullOrWhiteSpace((sender as CheckBox).Tag.ToTrim()))
{
string OIDTemp = (sender as CheckBox).Tag.ToTrim();
//IFeature feature = XJJXTQTB_Layer.FeatureClass.GetFeature(OIDTemp);
MapsManager.Instance.MapService.SelectFeature("XJJXTQTB", OIDTemp);
}
else
{
List<int> unSelectedRowsList = new List<int>() { Convert.ToInt32((sender as CheckBox).Tag.ToTrim()) };
ISelectionSet pSelectionSet = (XJJXTQTB_Layer as IFeatureSelection).SelectionSet;//获取图层要素已被选择的
pSelectionSet.RemoveList(unSelectedRowsList.Count, ref unSelectedRowsList.ToArray()[0]);
//视图部分刷新
MapsManager.Instance.MapService.getAxMapControl().ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, MapsManager.Instance.MapService.getAxMapControl().ActiveView.Extent);
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
/// <summary>
/// 坐落/权属批量赋值
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnSetZL_Click(object sender, RoutedEventArgs e)
{
IFeature feature = null;
IFeatureCursor pCursor = null;
try
{
if (!string.IsNullOrWhiteSpace(BGQZL.SelectedValue.ToTrim()))
{
if (!(BGQZL.ItemsSource is List<DataDicTionary> list)) return;
DataDicTionary dic = list.FirstOrDefault(f => f.CODE == BGQZL.SelectedValue.ToTrim());
if (dic == null) return;
string where = string.Format("(XZQTZLX='1' OR XZQTZLX='3')");
if (BGQZL.SelectedValue != null && !string.IsNullOrWhiteSpace(dic.NAME))
where += string.Format(" AND BGQZLDWDM='{0}' ", dic.CODE.ToTrim());
SetAttribute(where);
LoadData(true);
MessageHelper.ShowTips("坐落/权属批量赋值成功!");
return;
}
else if (!string.IsNullOrWhiteSpace(btnPath.Text) && External_FC != null && External_FC.FeatureCount(null) > 0)
{
this.ShowLoading("正在进行坐落/权属批量赋值......", 0, 0);
//FcAPI_DLTBHRGC与External_FC相交
var idxZLDWDM = External_FC.FindField("ZLDWDM");
var idxZLDWMC = External_FC.FindField("ZLDWMC");
if (idxZLDWDM == -1 || idxZLDWMC == -1)
{
MessageHelper.ShowTips($"当前选择矢量数据{btnPath.Text}中未找到ZLDWDM字段,请确认数据是否正确。");
return;
}
pCursor = External_FC.Search(null, true);
while ((feature = pCursor.NextFeature()) != null)
{
string strZLDWDM = feature.Value[idxZLDWDM].ToTrim();
string strZLDWMC = feature.Value[idxZLDWMC].ToTrim();
ISpatialFilter spatialFilter = new SpatialFilterClass()
{
Geometry = feature.ShapeCopy,
SpatialRel = esriSpatialRelEnum.esriSpatialRelContains,
};
SL_SetAttribute(spatialFilter, strZLDWDM, strZLDWMC);
}
LoadData(true);
this.CloseLoading();
//查询 变更后 是否存在 没有赋值的ZLDWDM
var count = FcAPI_DLTBHRGC.FeatureClass.FeatureCount(new QueryFilter() { WhereClause = "BGHZLDWDM='' or BGHZLDWDM is null or BGHZLDWMC='' or BGHZLDWMC is null or BGHQSDWDM='' or BGHQSDWDM is null or BGHQSDWMC='' or BGHQSDWMC is null " });
if (count > 0)
{
MessageHelper.ShowTips("新增/划入图斑数据与当前选择的矢量数据未完全套合,请检查数据是否正确。");
}
else
{
MessageHelper.ShowTips("坐落/权属批量赋值成功!");
}
return;
}
else
{
MessageHelper.ShowTips("请选择坐落单位!");
}
}
catch (Exception ex)
{
LogAPI.Debug("新增地类图斑坐落统赋:" + ex);
MessageHelper.ShowError("新增地类图斑坐落统赋:" + ex);
}
}
/// <summary>
/// 权属统赋
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SetQSDW_Click(object sender, RoutedEventArgs e)
{
try
{
DataRow[] drs = (dgInto2.ItemsSource as DataTable).Select("IsValid=True");
if (drs.Length == 0)
{
MessageHelper.Show("未选中需要权属统赋的新增图斑!!");
return;
}
string where = string.Format("XZQTZLX='3'");
object o = cobQSDWLX.EditValue;
switch (o.ToTrim())
{
case "随坐落变化":
SetAttribute("QSDWDM", "", where, "ZLDWDM");
SetAttribute("QSDWMC", "", where, "ZLDWMC");
SetAttribute("FRDBS", "0", where);
break;
case "随坐落变化(飞入地除外)":
where = string.Format("XZQTZLX='3' and FRDBS = '0'");
SetAttribute("QSDWDM", "", where, "ZLDWDM");
SetAttribute("QSDWMC", "", where, "ZLDWMC");
break;
case "继承原有权属":
SetAttribute("QSDWDM", "", where, "QSDWDM");
SetAttribute("QSDWMC", "", where, "QSDWMC");
break;
default:
break;
}
LoadData(true);
}
catch (Exception ex)
{
LogAPI.Debug("新增地类图斑权属统赋失败:" + ex);
MessageHelper.ShowError("新增地类图斑权属统赋失败:" + ex);
}
}
/// <summary>
/// 坐落统赋
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SetZLDW_Click(object sender, RoutedEventArgs e)
{
try
{
if (cobZLDW.SelectedItemValue != null)
{
DataRow[] drs = (dgInto2.ItemsSource as DataTable).Select("IsValid=True");
if (drs.Length == 0)
{
MessageHelper.Show("未选中需要坐落统赋的新增图斑!!");
return;
}
string where = string.Format("XZQTZLX='3'");
SetAttribute("ZLDWDM", (cobZLDW.SelectedItem as DataDicTionary).CODE, where);
SetAttribute("ZLDWMC", (cobZLDW.SelectedItem as DataDicTionary).NAME, where);
LoadData(true);
}
else
{
MessageHelper.ShowTips("请选择坐落单位!");
}
}
catch (Exception ex)
{
LogAPI.Debug("新增地类图斑坐落统赋:" + ex);
MessageHelper.ShowError("新增地类图斑坐落统赋:" + ex);
}
}
/// <summary>
/// 设置属性
/// </summary>
/// <param name="pFieldName">字段名称</param>
/// <param name="pValue">赋予值</param>
/// <param name="pWhere">赋值条件</param>
/// <param name="pJCFieldName">基础库字段名称</param>
private void SetAttribute(string pFieldName, string pValue, string pWhere = "", string pJCFieldName = "")
{
DataRow[] drs = (dgInto2.ItemsSource as DataTable).Select("IsValid=True");
IQueryFilter filter = null;
if (!string.IsNullOrWhiteSpace(pWhere))
filter = new QueryFilterClass() { WhereClause = pWhere };
IFeatureClass targetFc = FcAPI_DLTBBG.FeatureClass;
IFeatureCursor cursor = targetFc.Update(filter, true);
try
{
IFeature f = null;
int index = targetFc.Fields.FindField(pFieldName);
if (index == -1)
return;
while ((f = cursor.NextFeature()) != null)
{
drs = (dgInto.ItemsSource as DataTable).Select("OBJECTID=" + f.Value[targetFc.FindField("OBJECTID")]);
if (drs != null && drs.Length > 0 && drs[0]["IsValid"].ToString() != "True")
continue;
if (string.IsNullOrWhiteSpace(pValue) && !string.IsNullOrWhiteSpace(pJCFieldName))
{
int sIndex = targetFc.FindField(pJCFieldName);
if (sIndex != -1)
f.Value[index] = f.Value[sIndex];
}
else
{
f.Value[index] = pValue;
}
cursor.UpdateFeature(f);
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
/// <summary>
/// 权属/坐落批量设置属性
/// </summary>
private void SetAttribute(string pWhere)
{
IQueryFilter filter = null;
if (!string.IsNullOrWhiteSpace(pWhere))
filter = new QueryFilterClass() { WhereClause = pWhere };
IFeatureClass tDLTBHRGCFc = FcAPI_DLTBHRGC.FeatureClass;
IFeatureCursor DLTBHRGCcursor = tDLTBHRGCFc.Update(filter, true);
try
{
IFeature DLTBHRGCf = null;
int BGHQSDWDMindex = tDLTBHRGCFc.Fields.FindField("BGHQSDWDM");
int BGHQSDWMCindex = tDLTBHRGCFc.Fields.FindField("BGHQSDWMC");
int BGQQSDWDMindex = tDLTBHRGCFc.Fields.FindField("BGQQSDWDM");
int BGQQSDWMCindex = tDLTBHRGCFc.Fields.FindField("BGQQSDWMC");
int BGHZLDWMCindex = tDLTBHRGCFc.Fields.FindField("BGHZLDWMC");
int BGHZLDWDMindex = tDLTBHRGCFc.Fields.FindField("BGHZLDWDM");
int BGHFRDBSindex = tDLTBHRGCFc.Fields.FindField("BGHFRDBS");
if (BGHQSDWDMindex == -1 || BGHFRDBSindex == -1 || BGQQSDWDMindex == -1 || BGHZLDWDMindex == -1)
return;
List<DataDicTionary> list = BGHZL.ItemsSource as List<DataDicTionary>;
if (list == null) return;
DataDicTionary dic = list.FirstOrDefault(f => f.CODE == BGHZL.SelectedValue.ToTrim());
if (dic == null) return;
while ((DLTBHRGCf = DLTBHRGCcursor.NextFeature()) != null)
{
DLTBHRGCf.Value[BGHZLDWMCindex] = dic.NAME;
DLTBHRGCf.Value[BGHZLDWDMindex] = dic.CODE;
if (QSBB.IsChecked == true)
{
DLTBHRGCf.Value[BGHQSDWDMindex] = DLTBHRGCf.Value[BGQQSDWDMindex];
DLTBHRGCf.Value[BGHQSDWMCindex] = DLTBHRGCf.Value[BGQQSDWMCindex];
}
else if (QSByZL.IsChecked == true)
{
DLTBHRGCf.Value[BGHQSDWDMindex] = DLTBHRGCf.Value[BGHZLDWDMindex];
DLTBHRGCf.Value[BGHQSDWMCindex] = DLTBHRGCf.Value[BGHZLDWMCindex];
}
else if (QSByZLExitFRD.IsChecked == true && DLTBHRGCf.Value[BGHZLDWMCindex].ToTrim() != "1")
{ //权属随坐落变化(飞入地除外)
DLTBHRGCf.Value[BGHQSDWDMindex] = DLTBHRGCf.Value[BGHZLDWDMindex];
DLTBHRGCf.Value[BGHQSDWMCindex] = DLTBHRGCf.Value[BGHZLDWMCindex];
}
DLTBHRGCcursor.UpdateFeature(DLTBHRGCf);
}
DLTBHRGCcursor.Flush();
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
private void SL_SetAttribute(string pWhere, string ZLDWDM, string ZLDWMC)
{
IQueryFilter filter = null;
if (!string.IsNullOrWhiteSpace(pWhere))
filter = new QueryFilterClass() { WhereClause = pWhere };
IFeatureClass tDLTBHRGCFc = FcAPI_DLTBHRGC.FeatureClass;
IFeatureCursor DLTBHRGCcursor = tDLTBHRGCFc.Update(filter, true);
try
{
IFeature DLTBHRGCf = null;
int BGHQSDWDMindex = tDLTBHRGCFc.Fields.FindField("BGHQSDWDM");
int BGHQSDWMCindex = tDLTBHRGCFc.Fields.FindField("BGHQSDWMC");
int BGQQSDWDMindex = tDLTBHRGCFc.Fields.FindField("BGQQSDWDM");
int BGQQSDWMCindex = tDLTBHRGCFc.Fields.FindField("BGQQSDWMC");
int BGHZLDWMCindex = tDLTBHRGCFc.Fields.FindField("BGHZLDWMC");
int BGHZLDWDMindex = tDLTBHRGCFc.Fields.FindField("BGHZLDWDM");
int BGHFRDBSindex = tDLTBHRGCFc.Fields.FindField("BGHFRDBS");
if (BGHQSDWDMindex == -1 || BGHFRDBSindex == -1 || BGQQSDWDMindex == -1 || BGHZLDWDMindex == -1)
return;
while ((DLTBHRGCf = DLTBHRGCcursor.NextFeature()) != null)
{
DLTBHRGCf.Value[BGHZLDWMCindex] = ZLDWMC;
DLTBHRGCf.Value[BGHZLDWDMindex] = ZLDWDM;
if (QSBB.IsChecked == true)
{
DLTBHRGCf.Value[BGHQSDWDMindex] = DLTBHRGCf.Value[BGQQSDWDMindex];
DLTBHRGCf.Value[BGHQSDWMCindex] = DLTBHRGCf.Value[BGQQSDWMCindex];
}
else if (QSByZL.IsChecked == true)
{
DLTBHRGCf.Value[BGHQSDWDMindex] = DLTBHRGCf.Value[BGHZLDWDMindex];
DLTBHRGCf.Value[BGHQSDWMCindex] = DLTBHRGCf.Value[BGHZLDWMCindex];
}
else if (QSByZLExitFRD.IsChecked == true && DLTBHRGCf.Value[BGHZLDWMCindex].ToTrim() != "1")
{ //权属随坐落变化(飞入地除外)
DLTBHRGCf.Value[BGHQSDWDMindex] = DLTBHRGCf.Value[BGHZLDWDMindex];
DLTBHRGCf.Value[BGHQSDWMCindex] = DLTBHRGCf.Value[BGHZLDWMCindex];
}
DLTBHRGCcursor.UpdateFeature(DLTBHRGCf);
}
DLTBHRGCcursor.Flush();
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
private void SL_SetAttribute(ISpatialFilter pWhere, string ZLDWDM, string ZLDWMC)
{
IFeatureClass tDLTBHRGCFc = FcAPI_DLTBHRGC.FeatureClass;
IFeatureCursor DLTBHRGCcursor = tDLTBHRGCFc.Update(pWhere, true);
var xx = tDLTBHRGCFc.FeatureCount(pWhere);
try
{
IFeature DLTBHRGCf = null;
int BGHQSDWDMindex = tDLTBHRGCFc.Fields.FindField("BGHQSDWDM");
int BGHQSDWMCindex = tDLTBHRGCFc.Fields.FindField("BGHQSDWMC");
int BGQQSDWDMindex = tDLTBHRGCFc.Fields.FindField("BGQQSDWDM");
int BGQQSDWMCindex = tDLTBHRGCFc.Fields.FindField("BGQQSDWMC");
int BGHZLDWMCindex = tDLTBHRGCFc.Fields.FindField("BGHZLDWMC");
int BGHZLDWDMindex = tDLTBHRGCFc.Fields.FindField("BGHZLDWDM");
int BGHFRDBSindex = tDLTBHRGCFc.Fields.FindField("BGHFRDBS");
if (BGHQSDWDMindex == -1 || BGHFRDBSindex == -1 || BGQQSDWDMindex == -1 || BGHZLDWDMindex == -1)
return;
while ((DLTBHRGCf = DLTBHRGCcursor.NextFeature()) != null)
{
DLTBHRGCf.Value[BGHZLDWMCindex] = ZLDWMC;
DLTBHRGCf.Value[BGHZLDWDMindex] = ZLDWDM;
if (QSBB.IsChecked == true)
{
DLTBHRGCf.Value[BGHQSDWDMindex] = DLTBHRGCf.Value[BGQQSDWDMindex];
DLTBHRGCf.Value[BGHQSDWMCindex] = DLTBHRGCf.Value[BGQQSDWMCindex];
}
else if (QSByZL.IsChecked == true)
{
DLTBHRGCf.Value[BGHQSDWDMindex] = DLTBHRGCf.Value[BGHZLDWDMindex];
DLTBHRGCf.Value[BGHQSDWMCindex] = DLTBHRGCf.Value[BGHZLDWMCindex];
}
else if (QSByZLExitFRD.IsChecked == true && DLTBHRGCf.Value[BGHZLDWMCindex].ToTrim() != "1")
{ //权属随坐落变化(飞入地除外)
DLTBHRGCf.Value[BGHQSDWDMindex] = DLTBHRGCf.Value[BGHZLDWDMindex];
DLTBHRGCf.Value[BGHQSDWMCindex] = DLTBHRGCf.Value[BGHZLDWMCindex];
}
DLTBHRGCcursor.UpdateFeature(DLTBHRGCf);
}
DLTBHRGCcursor.Flush();
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
/// <summary>
/// 根据地类图斑划入过程构造列
/// </summary>
/// <param name="fields"></param>
private void ConstructColumn(IFields fields)
{
if (fields != null)
{
IntoData = new DataTable();
DataColumn col1 = new DataColumn();
col1.ColumnName = "IsValid";
col1.Caption = "选中";
col1.DataType = typeof(bool);
IntoData.Columns.Add(col1);
for (int i = 0; i < fields.FieldCount; i++)
{
IField field = fields.get_Field(i);
if (field.Name.ToUpper().StartsWith("SHAPE"))
continue;
DataColumn col = new DataColumn();
col.ExtendedProperties.Add("index", i);
col.ColumnName = field.Name;
col.Caption = field.AliasName;
switch (field.Type)
{
case esriFieldType.esriFieldTypeSmallInteger:
col.DataType = typeof(short);
break;
case esriFieldType.esriFieldTypeInteger:
col.DataType = typeof(int);
break;
case esriFieldType.esriFieldTypeSingle:
break;
case esriFieldType.esriFieldTypeDouble:
col.DataType = typeof(double);
break;
case esriFieldType.esriFieldTypeString:
col.DataType = typeof(string);
break;
case esriFieldType.esriFieldTypeDate:
col.DataType = typeof(DateTime);
break;
case esriFieldType.esriFieldTypeOID:
col.DataType = typeof(Int32);
break;
case esriFieldType.esriFieldTypeGeometry:
break;
case esriFieldType.esriFieldTypeBlob:
break;
case esriFieldType.esriFieldTypeRaster:
break;
case esriFieldType.esriFieldTypeGUID:
break;
case esriFieldType.esriFieldTypeGlobalID:
break;
case esriFieldType.esriFieldTypeXML:
break;
default:
break;
}
col.ReadOnly = !field.Editable;//编辑状态启用默认是否可以编辑
IntoData.Columns.Add(col);
Marshal.ReleaseComObject(field);
}
}
}
/// <summary>
/// 自定义构造列
/// </summary>
private void ConstructColumn()
{
IntoData = new DataTable();
DataColumn col1 = new DataColumn();
col1.ColumnName = "IsValid";
col1.Caption = "选中";
col1.DataType = typeof(bool);
IntoData.Columns.Add(col1);
DataColumn col = new DataColumn();
col.ExtendedProperties.Add("index", 1);
col.ColumnName = "OBJECTID";
col.Caption = "OID";
col.ReadOnly = true;
IntoData.Columns.Add(col);
col = new DataColumn();
col.ExtendedProperties.Add("index", 2);
col.ColumnName = "TBBGMJ";
col.Caption = "图斑变更面积";
col.ReadOnly = true;
IntoData.Columns.Add(col);
col = new DataColumn();
col.ExtendedProperties.Add("index", 3);
col.ColumnName = "BGQQS";
col.Caption = "变更前权属";
col.ReadOnly = true;
IntoData.Columns.Add(col);
col = new DataColumn();
col.ExtendedProperties.Add("index", 4);
col.ColumnName = "BGHQS";
col.Caption = "变更后权属";
col.ReadOnly = true;
IntoData.Columns.Add(col);
col = new DataColumn();
col.ExtendedProperties.Add("index", 5);
col.ColumnName = "BGQZL";
col.Caption = "变更前坐落";
col.ReadOnly = true;
IntoData.Columns.Add(col);
col = new DataColumn();
col.ExtendedProperties.Add("index", 6);
col.ColumnName = "BGHZL";
col.Caption = "变更后坐落";
col.ReadOnly = true;
IntoData.Columns.Add(col);
col = new DataColumn();
col.ExtendedProperties.Add("index", 7);
col.ColumnName = "XZQTZLX";
col.Caption = "行政区调整类型";
col.ReadOnly = true;
IntoData.Columns.Add(col);
col = new DataColumn();
col.ExtendedProperties.Add("index", 8);
col.ColumnName = "IsCompleteOut";
col.Caption = "是否整图斑划入";
col.ReadOnly = true;
IntoData.Columns.Add(col);
col = new DataColumn();
col.ExtendedProperties.Add("index", 9);
col.ColumnName = "JCTBBSM";
col.Caption = "基础图斑标识码";
col.ReadOnly = true;
IntoData.Columns.Add(col);
}
/// <summary>
/// 创建视图列
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DgInto_AutoGeneratedColumns(object sender, RoutedEventArgs e)
{
GridControl grid = sender as GridControl;
foreach (GridColumn column in grid.Columns)
{
if (IntoData.Columns.Contains(column.FieldName))
{
string caption = IntoData.Columns[column.FieldName].Caption;
if (caption != null)
{
column.EditSettings = new TextEditSettings() { HorizontalContentAlignment = EditSettingsHorizontalAlignment.Left };
column.Header = caption;
}
}
}
}
/// <summary>
/// 创建变更层数据
/// </summary>
/// <param name="jc_F"></param>
/// <param name="Geo"></param>
/// <param name="gxFc"></param>
/// <param name="IsTXBG"></param>
/// <param name="strXZQDM"></param>
/// <param name="bgztTemp"></param>
/// <returns></returns>
private IFeatureBuffer CreateXzqGxFeature(IFeature jc_F, IGeometry Geo, IFeatureClass gxFc, bool IsTXBG, string strXZQDM, string bgztTemp)
{
IFeatureBuffer buff = gxFc.CreateFeatureBuffer();
buff.Shape = Geo;
for (int i = 0; i < buff.Fields.FieldCount; i++)
{
IField field = buff.Fields.Field[i];
if (field.Name.ToUpper().Contains("SHAPE") || !field.Editable) continue;
int _Index = -1;
if (IsTXBG && field.Name == "BSM")
{
//图形变更标识码重新赋值
buff.Value[i] = JXTZBGHelper.GetNewBSM(new List<IFeatureClass>() { jc_F.Class as IFeatureClass, gxFc });
continue;
}
if (field.Name == "DCMJ")
{
_Index = jc_F.Fields.FindField(field.Name);
double bgqdcmj = jc_F.Value[_Index].ToDouble(2);
if (strXZQDM.Length == 9)
buff.Value[i] = (bgqdcmj - SaveDatas.Where(w => w.XZQInfo.Contains(strXZQDM) && w.IsOut && w.BGZT.Contains(bgztTemp)).Sum(s => s.BGMJ)).ToDouble(2);
else if (strXZQDM.Length >= 12)
buff.Value[i] = (bgqdcmj - SaveDatas.Where(w => w.CJDCQInfo.Contains(strXZQDM.Substring(0, 12)) && w.IsOut && w.BGZT.Contains(bgztTemp)).Sum(s => s.BGMJ)).ToDouble(2);
continue;
}
_Index = jc_F.Fields.FindField(field.Name);
if (_Index != -1)
{
buff.Value[i] = jc_F.Value[_Index];
}
}
return buff;
}
System.Windows.Forms.DialogResult dialogResultOut = new System.Windows.Forms.DialogResult();
System.Windows.Forms.DialogResult dialogResultAdd = new System.Windows.Forms.DialogResult();
/// <summary>
/// 选择(新增,划入,划出,灭失)状态
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SetTBZT_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
string OIDTemp = (sender as ComboBox).Tag.ToString();
if (!string.IsNullOrWhiteSpace(OIDTemp) && (e.Source as ComboBox).SelectedValue != null)
{
DataModel dataModel = Data.FirstOrDefault(x => x.DLTBOid == Convert.ToInt32(OIDTemp));
string TempZT = (e.Source as ComboBox).SelectedValue.ToString().Split(':')[1].ToTrim();
if (dataModel.IsOut && "划出,灭失".Contains(TempZT))
{
if (dialogResultOut == System.Windows.Forms.DialogResult.None)
dialogResultOut = MessageHelper.ShowYesNoAndTips("是否同类型(划出/灭失)数据根据当前选择状态批量赋值?");
if (dialogResultOut == System.Windows.Forms.DialogResult.Yes)
{
Data.FindAll(x => x.IsOut).ForEach(x => x.BGZT = TempZT);
dialogResultOut = System.Windows.Forms.DialogResult.Ignore;
}
else
Data.FirstOrDefault(x => x.DLTBOid == Convert.ToInt32(OIDTemp)).BGZT = TempZT;
}
else if (dataModel.IsAdd && "新增,划入".Contains(TempZT))
{
if (dialogResultAdd == System.Windows.Forms.DialogResult.None)
dialogResultAdd = MessageHelper.ShowYesNoAndTips("是否同类型(划入/新增)数据根据当前选择状态批量赋值?");
if (dialogResultAdd == System.Windows.Forms.DialogResult.Yes)
{
Data.FindAll(x => x.IsAdd).ForEach(x => x.BGZT = TempZT);
dialogResultAdd = System.Windows.Forms.DialogResult.Ignore;
}
else
Data.FirstOrDefault(x => x.DLTBOid == Convert.ToInt32(OIDTemp)).BGZT = TempZT;
}
else if (dataModel.IsHDZLD)
MessageHelper.ShowTips("属性变化无需标记状态!");
else
MessageHelper.ShowError("非期望状态值,请重新选择!");
dgInto.RefreshData();
(e.Source as ComboBox).SelectedValue = null;
if (Data.FirstOrDefault(x => x.BGZT == "新增" || x.BGZT == "划入") != null)
btnAddData.IsEnabled = true;
else
btnAddData.IsEnabled = false;
if (Data.FirstOrDefault(x => string.IsNullOrWhiteSpace(x.BGZT) && x.IsHDZLD == false) != null)
btn.IsEnabled = false;
else
btn.IsEnabled = true;
}
}
/// <summary>
/// 选择新增/划入的数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnSelData_Click(object sender, RoutedEventArgs e)
{
string xzdltbPaths = "";
IFeatureClass dltbFc = JXTZBGHelper.GetFeatureClass("请选择新增的地类图斑数据", ref xzdltbPaths);
if (dltbFc != null)
{
this.btnNewData.Text = xzdltbPaths;
XZDLTB_Layer = GeoDBAPI.CreateFeatureLayerInmemeory("XZDLTB", "新增地类图斑数据", (dltbFc as IGeoDataset).SpatialReference, dltbFc.ShapeType, dltbFc.Fields);
(XZDLTB_Layer.FeatureClass as ITable).DeleteSearchedRows(null);
JXTZBGHelper.InsertDataToMemeoryLayer(dltbFc, XZDLTB_Layer.FeatureClass, null);
}
}
/// <summary>
/// 坐落分组
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckBox_Click(object sender, RoutedEventArgs e)
{
dgInto2.ClearGrouping();
if (ckbBGQZLDWDMByGroup.IsChecked == false || ckbBGHZLDWDMByGroup.IsChecked == false)
ckbXZQTZLXByGroup.IsChecked = false;
if (ckbBGQZLDWDMByGroup.IsChecked == true && dgInto2.ItemsSource != null)
{
dgInto2.GroupBy("BGQZL", true);
}
if (ckbBGHZLDWDMByGroup.IsChecked == true && dgInto2.ItemsSource != null)
{
dgInto2.GroupBy("BGHZL", true);
}
}
private void ckbXZQTZLXByGroup_Click(object sender, RoutedEventArgs e)
{
dgInto2.ClearGrouping();
if (ckbXZQTZLXByGroup.IsChecked == true && dgInto2.ItemsSource != null)
{
dgInto2.GroupBy("XZQTZLX", true);
ckbBGQZLDWDMByGroup.IsChecked = false;
ckbBGHZLDWDMByGroup.IsChecked = false;
}
}
/// <summary>
/// 外部选择的区划调整数据
/// </summary>
private IFeatureClass External_FC = null;
private void btnSLPath_Click(object sender, RoutedEventArgs e)
{
try
{
KGIS.Framework.OpenData.Control.OpenDataDialog pDialog = new OpenDataDialog();
KGIS.Framework.OpenData.InterFace.ISpatialDataObjectFilter pOFilter;
pOFilter = new KGIS.Framework.OpenData.Filter.FilterDatasetsAndLayers();
pDialog.AddFilter(pOFilter, true);
pDialog.Title = "选择导入的数据";
pDialog.AllowMultiSelect = false;
pDialog.RestoreLocation = true;
pDialog.StartLocation = pDialog.FinalLocation;
System.Windows.Forms.DialogResult dialogResult = pDialog.ShowDialog();
if (dialogResult == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count != 0)
{
foreach (KGIS.Framework.OpenData.InterFace.ISpatialDataObject distObj in pDialog.Selection)
{
if (distObj.DatasetType == esriDatasetType.esriDTFeatureClass)
{
External_FC = (distObj.DatasetName as ESRI.ArcGIS.esriSystem.IName).Open() as IFeatureClass;
btnPath.Text = distObj.FullName;
break;
}
}
}
}
catch (Exception ex)
{
LogAPI.Debug("btnExternalData_Click异常:" + ex.Message);
LogAPI.Debug("btnExternalData_Click异常:" + ex.StackTrace);
}
}
}
}