|
|
|
|
using DevExpress.Xpf.Editors.Settings;
|
|
|
|
|
using DevExpress.Xpf.Grid;
|
|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.esriSystem;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
using KGIS.Framework.AE.Enum;
|
|
|
|
|
using KGIS.Framework.AE.GPHelper;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.OpenData.Control;
|
|
|
|
|
using KGIS.Framework.OpenData.Filter;
|
|
|
|
|
using KGIS.Framework.OpenData.InterFace;
|
|
|
|
|
using KGIS.Framework.Platform;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using KGIS.Framework.Views;
|
|
|
|
|
using Kingo.Plugin.DLTB_IDG.Helper;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using KUI.Windows;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.AttributeMaintain.View
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性维护 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class FrmCZC_TR : UserControl, IDockPanel2
|
|
|
|
|
{
|
|
|
|
|
List<TestData> list = new List<TestData>();
|
|
|
|
|
private ProjectInfo projectInfo = null;
|
|
|
|
|
IFeatureClass drqCZCFc = null;
|
|
|
|
|
public event EventHandler CloseViewHandler;
|
|
|
|
|
private static int SHAPE_Area = 50;
|
|
|
|
|
private string WhereClause = string.Empty;
|
|
|
|
|
private IFeatureClass dltbBG = null;
|
|
|
|
|
private DataTable IntoData { get; set; }
|
|
|
|
|
public bool IsShowInMap { get; set; }
|
|
|
|
|
public Guid ID { get; set; }
|
|
|
|
|
public DockStyle DockAreas { get; set; }
|
|
|
|
|
public System.Drawing.Size FloatSize { get; set; }
|
|
|
|
|
public int DockWidth { get; set; }
|
|
|
|
|
public int DockHeight { get; set; }
|
|
|
|
|
public DockStyle DefaultArea { get; set; }
|
|
|
|
|
public bool ShowCloseButton { get; set; }
|
|
|
|
|
public bool ShowAutoHideButton { get; set; }
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
private IWorkspaceAPI BgWsAPI = null;
|
|
|
|
|
public FrmCZC_TR()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
DevExpress.Xpf.Core.ThemeManager.SetTheme(this, DevExpress.Xpf.Core.Theme.Office2013LightGray);
|
|
|
|
|
_MapService = MapsManager.Instance.MapService;
|
|
|
|
|
IsShowInMap = true;
|
|
|
|
|
DockAreas = DockStyle.DockBottom;
|
|
|
|
|
DockHeight = 380;
|
|
|
|
|
DefaultArea = DockStyle.DockBottom;
|
|
|
|
|
ShowCloseButton = true;
|
|
|
|
|
ShowAutoHideButton = false;
|
|
|
|
|
Title = "20范围拆分(调入)";
|
|
|
|
|
InitData();
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitData()
|
|
|
|
|
{
|
|
|
|
|
projectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
|
|
|
|
|
if (projectInfo != null && !string.IsNullOrWhiteSpace(projectInfo.DR_CZCPath))
|
|
|
|
|
{
|
|
|
|
|
btnczcPath.Text = projectInfo.DR_CZCPath;
|
|
|
|
|
if (string.IsNullOrWhiteSpace(projectInfo.DR_CZCPath)) return;
|
|
|
|
|
string HRXZQ = projectInfo.DR_CZCPath;
|
|
|
|
|
if (projectInfo.DR_CZCPath.ToUpper().Contains(".GDB"))
|
|
|
|
|
{
|
|
|
|
|
string hr_dbPath = HRXZQ.Substring(0, HRXZQ.ToLower().IndexOf(".gdb"));
|
|
|
|
|
hr_dbPath = Path.Combine(hr_dbPath + ".gdb");
|
|
|
|
|
BgWsAPI = new WorkspaceAPI(hr_dbPath, WorkspaceTypeEnum.GDBFile, true);
|
|
|
|
|
if (BgWsAPI.CurrentWorkspace == null) return;
|
|
|
|
|
}
|
|
|
|
|
else if (projectInfo.DR_CZCPath.ToUpper().Contains(".MDB"))
|
|
|
|
|
{
|
|
|
|
|
string hr_dbPath = HRXZQ.Substring(0, HRXZQ.ToLower().IndexOf(".mdb"));
|
|
|
|
|
hr_dbPath = hr_dbPath + ".mdb";
|
|
|
|
|
BgWsAPI = new WorkspaceAPI(hr_dbPath, WorkspaceTypeEnum.MDBFile);
|
|
|
|
|
if (BgWsAPI.CurrentWorkspace == null) return;
|
|
|
|
|
}
|
|
|
|
|
FileInfo fInfo = new FileInfo(HRXZQ);
|
|
|
|
|
IFeatureClassAPI hrFcAPI = BgWsAPI.OpenFeatureClass(fInfo.Name);
|
|
|
|
|
if (hrFcAPI != null) drqCZCFc = hrFcAPI.FeatureClass;
|
|
|
|
|
if (hrFcAPI != null) hrFcAPI.CloseFeatureClass();
|
|
|
|
|
if (BgWsAPI != null) BgWsAPI.CloseWorkspace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadData()
|
|
|
|
|
{
|
|
|
|
|
dltbBG = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBBG");
|
|
|
|
|
if (dltbBG == null) return;
|
|
|
|
|
IntoData = new DataTable();
|
|
|
|
|
if (!string.IsNullOrEmpty(SArea.Text))
|
|
|
|
|
{
|
|
|
|
|
if (SArea.Text.ToTrim().ToInt() > 0)
|
|
|
|
|
SHAPE_Area = SArea.Text.ToTrim().ToInt();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SHAPE_Area = 50;
|
|
|
|
|
}
|
|
|
|
|
WhereClause = $" SHAPE_Area<{SHAPE_Area} ";
|
|
|
|
|
IFeatureCursor cursor = dltbBG.Search(new QueryFilter() { WhereClause = WhereClause }, true);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ConstructColumn(dltbBG.Fields);
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
while ((f = cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
DataRow dr = IntoData.NewRow();
|
|
|
|
|
bool IsInto = true;
|
|
|
|
|
for (int i = 0; i < IntoData.Columns.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
object obj = f.get_Value((int)IntoData.Columns[i].ExtendedProperties["index"]);
|
|
|
|
|
if (obj == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ((obj.ToString()).Contains("1899/12/30 0:00:00"))
|
|
|
|
|
{
|
|
|
|
|
obj = System.DBNull.Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (obj is string)
|
|
|
|
|
{
|
|
|
|
|
obj = obj.ToString().Trim();//字符串时,去空格
|
|
|
|
|
}
|
|
|
|
|
dr[i] = obj;
|
|
|
|
|
}
|
|
|
|
|
if (IsInto)
|
|
|
|
|
IntoData.Rows.Add(dr);
|
|
|
|
|
}
|
|
|
|
|
this.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
dgInto.ItemsSource = null;
|
|
|
|
|
dgInto.ItemsSource = IntoData;
|
|
|
|
|
dgInto.Columns[0].AllowEditing = DevExpress.Utils.DefaultBoolean.True;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (cursor != null) Marshal.ReleaseComObject(cursor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造列获取记录条数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fields"></param>
|
|
|
|
|
private void ConstructColumn(IFields fields)
|
|
|
|
|
{
|
|
|
|
|
if (fields != null)
|
|
|
|
|
{
|
|
|
|
|
IntoData = new DataTable();
|
|
|
|
|
for (int i = 0; i < fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = fields.get_Field(i);
|
|
|
|
|
if (field.Name.ToUpper().EndsWith("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 = true; //!field.Editable;//编辑状态启用默认是否可以编辑
|
|
|
|
|
IntoData.Columns.Add(col);
|
|
|
|
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(field);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 拷贝模板gdb文件夹
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="SourcePath"></param>
|
|
|
|
|
/// <param name="DestinationPath"></param>
|
|
|
|
|
/// <param name="overwriteexisting"></param>
|
|
|
|
|
public static void CopyDirectory(string SourcePath, string DestinationPath, bool overwriteexisting)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
SourcePath = SourcePath.EndsWith(@"\") ? SourcePath : SourcePath + @"\";
|
|
|
|
|
DestinationPath = DestinationPath.EndsWith(@"\") ? DestinationPath : DestinationPath + @"\";
|
|
|
|
|
|
|
|
|
|
if (Directory.Exists(SourcePath))
|
|
|
|
|
{
|
|
|
|
|
if (Directory.Exists(DestinationPath) == false)
|
|
|
|
|
Directory.CreateDirectory(DestinationPath);
|
|
|
|
|
|
|
|
|
|
foreach (string fls in Directory.GetFiles(SourcePath))
|
|
|
|
|
{
|
|
|
|
|
FileInfo flinfo = new FileInfo(fls);
|
|
|
|
|
flinfo.CopyTo(DestinationPath + flinfo.Name, overwriteexisting);
|
|
|
|
|
}
|
|
|
|
|
foreach (string drs in Directory.GetDirectories(SourcePath))
|
|
|
|
|
{
|
|
|
|
|
DirectoryInfo drinfo = new DirectoryInfo(drs);
|
|
|
|
|
CopyDirectory(drs, DestinationPath + drinfo.Name, overwriteexisting);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnSelectedCZCPath_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
#region GetSelectionFc
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 获取源数据
|
|
|
|
|
OpenDataDialog pDialog = new OpenDataDialog();
|
|
|
|
|
ISpatialDataObjectFilter pOFilter;
|
|
|
|
|
pOFilter = new FilterFeatureDatasetsAndFeatureClasses();
|
|
|
|
|
pDialog.AddFilter(pOFilter, true);
|
|
|
|
|
pDialog.Title = "选择划调整范围数据";
|
|
|
|
|
pDialog.AllowMultiSelect = false;
|
|
|
|
|
pDialog.RestoreLocation = true;
|
|
|
|
|
pDialog.StartLocation = pDialog.FinalLocation;
|
|
|
|
|
if (pDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
List<ISpatialDataObject> distObj = pDialog.Selection;
|
|
|
|
|
foreach (var obj in distObj)
|
|
|
|
|
{
|
|
|
|
|
if (obj.DatasetType == esriDatasetType.esriDTFeatureClass)
|
|
|
|
|
{
|
|
|
|
|
drqCZCFc = (obj.DatasetName as IName).Open() as IFeatureClass;
|
|
|
|
|
btnczcPath.Text = obj.FullName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("btnSelectedCZCPath_Click失败:" + ex.Message.ToString());
|
|
|
|
|
LogAPI.Debug("btnSelectedCZCPath_Click失败:" + ex.StackTrace.ToString());
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnRefreshData_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShowPanel()
|
|
|
|
|
{
|
|
|
|
|
Platform.Instance.OpenView(this, false);
|
|
|
|
|
MapsManager.Instance.MapService.ProjectClosed += (s, e) =>
|
|
|
|
|
{
|
|
|
|
|
this.ClosePanel();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClosePanel()
|
|
|
|
|
{
|
|
|
|
|
if (BgWsAPI != null) BgWsAPI.CloseWorkspace();
|
|
|
|
|
Platform.Instance.CloseView(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClosePanelInvoke()
|
|
|
|
|
{
|
|
|
|
|
CloseViewHandler?.Invoke(null, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DgInto_CustomColumnGroup(object sender, CustomColumnSortEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private IMapService _MapService { get; set; }
|
|
|
|
|
private void TvAttr2_RowDoubleClick(object sender, RowDoubleClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DataRowView obj = e.Source.FocusedRowData.Row as DataRowView;
|
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
_MapService.SelectFeature("DLTBBG", obj["OBJECTID"].ToTrim(), true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show("定位失败!" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnsplitdltbbg_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
IFeatureCursor cursor = null;
|
|
|
|
|
IFeature feature = null;
|
|
|
|
|
IFeatureLayer CZC_DLTBBGLayer = null;
|
|
|
|
|
IFeatureLayer multipartToSingleFeatureLayer = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(btnczcPath.Text) || drqCZCFc == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("请选择城镇村范围(调入)");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string tableName = "result" + DateTime.Now.ToString("HHmmss");
|
|
|
|
|
string dbName = "result" + DateTime.Now.ToString("HHmmss");
|
|
|
|
|
string currentAppPath = SysAppPath.GetCurrentAppPath();
|
|
|
|
|
string templeteGDBPath = Path.Combine(currentAppPath, "Template", "TempGDB.gdb");
|
|
|
|
|
string resultPath = Path.Combine(currentAppPath, "Temp\\Union_DLTBBG_CZCHR");
|
|
|
|
|
if (!Directory.Exists(resultPath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(resultPath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DelectDir(resultPath);
|
|
|
|
|
}
|
|
|
|
|
string savePath = Path.Combine(resultPath, dbName + ".gdb");
|
|
|
|
|
CopyDirectory(templeteGDBPath, savePath, true);
|
|
|
|
|
string outPath = Path.Combine(savePath, "Union_DLTBBG_CZCHR");
|
|
|
|
|
GPParamClass gPParamClass = new GPParamClass
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureLayer = new FeatureLayer() { FeatureClass = dltbBG },
|
|
|
|
|
SecondFeatureLayer = new FeatureLayer() { FeatureClass = drqCZCFc },
|
|
|
|
|
OutFeatureClassPath = outPath,
|
|
|
|
|
IsGetOutPutFeature = true
|
|
|
|
|
};
|
|
|
|
|
this.ShowLoading($"正在进行数据处理...", 0, 0);
|
|
|
|
|
GeoprocessorHelper.UnionAnalysis(gPParamClass, ref CZC_DLTBBGLayer);
|
|
|
|
|
gPParamClass = new GPParamClass
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureLayer = CZC_DLTBBGLayer,
|
|
|
|
|
OutFeatureClassPath = $"{savePath}\\Multipart",
|
|
|
|
|
IsGetOutPutFeature = true,
|
|
|
|
|
};
|
|
|
|
|
GeoprocessorHelper.MultipartToSinglePath(gPParamClass, ref multipartToSingleFeatureLayer);
|
|
|
|
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(savePath, WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
IFeatureClassAPI Temp = wsAPI.CreateFeatureClass("DLTBBGTemp", (multipartToSingleFeatureLayer.FeatureClass as IGeoDataset).SpatialReference, multipartToSingleFeatureLayer.FeatureClass.Fields);
|
|
|
|
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(multipartToSingleFeatureLayer.FeatureClass);
|
|
|
|
|
fcAPI.FcToFc(Temp.FeatureClass, null, false);
|
|
|
|
|
cursor = Temp.FeatureClass.Search(new QueryFilterClass() { WhereClause = "SHAPE_Area<50" }, true);
|
|
|
|
|
(multipartToSingleFeatureLayer.FeatureClass as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "SHAPE_Area<50" });
|
|
|
|
|
var izldwdm = multipartToSingleFeatureLayer.FeatureClass.FindField("ZLDWDM");
|
|
|
|
|
var izldwmc = multipartToSingleFeatureLayer.FeatureClass.FindField("ZLDWMC");
|
|
|
|
|
var ifid_czcdyd = multipartToSingleFeatureLayer.FeatureClass.FindField("FID_CZCDYD");
|
|
|
|
|
var ifid_dltbbg = multipartToSingleFeatureLayer.FeatureClass.FindField("FID_DLTBBG");
|
|
|
|
|
var iczclx = multipartToSingleFeatureLayer.FeatureClass.FindField("CZCLX");
|
|
|
|
|
while ((feature = cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
var identity = FeatureAPI.Identify(feature.ShapeCopy, multipartToSingleFeatureLayer);
|
|
|
|
|
if (identity.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var thisczcdm = feature.Value[izldwdm].ToString();
|
|
|
|
|
var thisczcmc = feature.Value[izldwmc].ToString();
|
|
|
|
|
var thisczclx = feature.Value[iczclx].ToString();
|
|
|
|
|
var Unionlength = 0.00;
|
|
|
|
|
IFeature feature1 = null;
|
|
|
|
|
foreach (var ifeature in identity)
|
|
|
|
|
{
|
|
|
|
|
var gxczcdm = ifeature.Value[izldwdm].ToString();
|
|
|
|
|
var gxczcmc = ifeature.Value[izldwmc].ToString();
|
|
|
|
|
var czclx = ifeature.Value[iczclx].ToString();
|
|
|
|
|
if (thisczcdm == gxczcdm && thisczcmc == gxczcmc && thisczclx == czclx)
|
|
|
|
|
{
|
|
|
|
|
var length = FeatureAPI.LengthOfSide(feature.ShapeCopy, ifeature.ShapeCopy);
|
|
|
|
|
if (length > Unionlength)
|
|
|
|
|
{
|
|
|
|
|
Unionlength = length;
|
|
|
|
|
feature1 = ifeature;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (feature1 != null)
|
|
|
|
|
{
|
|
|
|
|
feature1.Shape = FeatureAPI.Union(feature.ShapeCopy, feature1.ShapeCopy);
|
|
|
|
|
feature1.Store();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fcAPI.AddFeature(feature);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
(dltbBG as FeatureClass).Workspace.ExecuteSQL("Delete From DLTBBG Where 1=1");
|
|
|
|
|
InsertDLTBBG(multipartToSingleFeatureLayer.FeatureClass, dltbBG);
|
|
|
|
|
#region
|
|
|
|
|
if (wsAPI != null) wsAPI.CloseWorkspace();
|
|
|
|
|
if (fcAPI != null) fcAPI.CloseFeatureClass();
|
|
|
|
|
if (Temp != null) Temp.CloseFeatureClass();
|
|
|
|
|
if (cursor != null) Marshal.ReleaseComObject(cursor);
|
|
|
|
|
GC.Collect();
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
MessageHelper.Show("拆分变更图斑完成!");
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
LogAPI.Debug($"20范围拆分(调入)错误:{ex.Message}");
|
|
|
|
|
LogAPI.Debug($"20范围拆分(调入)错误:{ex.StackTrace}");
|
|
|
|
|
MessageHelper.ShowTips("拆分变更图斑错误:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (multipartToSingleFeatureLayer != null)
|
|
|
|
|
Marshal.ReleaseComObject(multipartToSingleFeatureLayer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool InsertDLTBBG(IFeatureClass sfeatureClass, IFeatureClass tfeatureClass)
|
|
|
|
|
{
|
|
|
|
|
IFeatureCursor S_Cursor = null;
|
|
|
|
|
IFeatureCursor T_Cursor = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (sfeatureClass == null || tfeatureClass == null) return false;
|
|
|
|
|
Dictionary<int, int> dicField = new Dictionary<int, int>();
|
|
|
|
|
int index = -1;
|
|
|
|
|
for (int i = 0; i < tfeatureClass.Fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = tfeatureClass.Fields.Field[i];
|
|
|
|
|
if (field.Name == tfeatureClass.ShapeFieldName || field.Name.Contains(tfeatureClass.ShapeFieldName) || field.Name == tfeatureClass.OIDFieldName || !field.Editable) continue;
|
|
|
|
|
index = sfeatureClass.Fields.FindField(field.Name);
|
|
|
|
|
if (index == -1) continue;
|
|
|
|
|
dicField.Add(i, index);
|
|
|
|
|
}
|
|
|
|
|
IFeatureClassLoad pFclsLoad = tfeatureClass as IFeatureClassLoad;
|
|
|
|
|
if (pFclsLoad != null)
|
|
|
|
|
pFclsLoad.LoadOnlyMode = true;
|
|
|
|
|
//此处写编辑的代码
|
|
|
|
|
S_Cursor = sfeatureClass.Search(null, true);
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
T_Cursor = tfeatureClass.Insert(true);
|
|
|
|
|
var iczcsxm = tfeatureClass.FindField("CZCSXM");
|
|
|
|
|
var iczclx = sfeatureClass.FindField("CZCLX");
|
|
|
|
|
IFeatureBuffer buffer = tfeatureClass.CreateFeatureBuffer();
|
|
|
|
|
while ((f = S_Cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
buffer.Shape = f.ShapeCopy;
|
|
|
|
|
foreach (int item in dicField.Keys)
|
|
|
|
|
{
|
|
|
|
|
buffer.Value[item] = f.Value[dicField[item]];
|
|
|
|
|
}
|
|
|
|
|
if (iczcsxm != -1 && iczclx != -1)
|
|
|
|
|
{
|
|
|
|
|
string czcsxm = buffer.Value[iczcsxm].ToTrim();
|
|
|
|
|
if (string.IsNullOrWhiteSpace(czcsxm))
|
|
|
|
|
buffer.Value[iczcsxm] = f.Value[iczclx];
|
|
|
|
|
}
|
|
|
|
|
T_Cursor.InsertFeature(buffer);
|
|
|
|
|
}
|
|
|
|
|
T_Cursor.Flush();
|
|
|
|
|
if (pFclsLoad != null)
|
|
|
|
|
pFclsLoad.LoadOnlyMode = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("20属性拆分数据导入到变更层执行失败!");
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Marshal.ReleaseComObject(S_Cursor);
|
|
|
|
|
Marshal.ReleaseComObject(T_Cursor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除文件夹以及子文件夹与子文件-
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="srcPath"></param>
|
|
|
|
|
public static void DelectDir(string srcPath)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DirectoryInfo dir = new DirectoryInfo(srcPath);
|
|
|
|
|
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录
|
|
|
|
|
foreach (FileSystemInfo i in fileinfo)
|
|
|
|
|
{
|
|
|
|
|
if (i is DirectoryInfo) //判断是否文件夹
|
|
|
|
|
{
|
|
|
|
|
DirectoryInfo subdir = new DirectoryInfo(i.FullName);
|
|
|
|
|
subdir.Delete(true); //删除子目录和文件
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
File.Delete(i.FullName); //删除指定文件
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("20范围拆分,删除缓存文件报错,不处理!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|