|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.DataManagementTools;
|
|
|
|
|
using ESRI.ArcGIS.esriSystem;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using ESRI.ArcGIS.Geoprocessor;
|
|
|
|
|
using ExcelDataReader;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
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 Kingo.PluginServiceInterface;
|
|
|
|
|
using Kingo.PluginServiceInterface.Model;
|
|
|
|
|
using KUI.Windows;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using OpenFileDialog = KGIS.Framework.Utils.Dialog.OpenFileDialog;
|
|
|
|
|
using UserControl = System.Windows.Controls.UserControl;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.YJJK.View
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ViewDLTB_TQ.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ViewDLTB_TQ : UserControl, IWizardFramework
|
|
|
|
|
{
|
|
|
|
|
private IFeatureLayer SelLocation_Layer = null;
|
|
|
|
|
List<DataDicTionary> Dics_QS = null;//权属字典
|
|
|
|
|
ObservableCollection<ZLXXInfo> ListZLXXInfo = null;//坐落信息变化数据
|
|
|
|
|
ProjectInfo projInfo = MapsManager.Instance.CurrProjectInfo as ProjectInfo;
|
|
|
|
|
|
|
|
|
|
#region IWizardFramework接口属性
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 向导步骤间的参数传递
|
|
|
|
|
/// </summary>
|
|
|
|
|
public object Parameter
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string m_strDescription = "此步骤将会提取地类图斑更新层和更新过程层数据";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 描述
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Description
|
|
|
|
|
{
|
|
|
|
|
get { return m_strDescription; }
|
|
|
|
|
set { m_strDescription = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string m_strCaption = "地类图斑数据提取";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 标题
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Caption
|
|
|
|
|
{
|
|
|
|
|
get { return m_strCaption; }
|
|
|
|
|
set { m_strCaption = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool m_bIsFinalSuccess = false;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 标识是否是最后一步
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsFinalSuccess
|
|
|
|
|
{
|
|
|
|
|
get { return m_bIsFinalSuccess; }
|
|
|
|
|
set { m_bIsFinalSuccess = value; }
|
|
|
|
|
}
|
|
|
|
|
private bool m_IsSkip = false;
|
|
|
|
|
public bool IsSkip
|
|
|
|
|
{
|
|
|
|
|
get { return m_IsSkip; }
|
|
|
|
|
set { m_IsSkip = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
public ViewDLTB_TQ()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
Dics_QS = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM).ToLookup(x => x.CODE).ToDictionary(x => x.Key, x => x.First()).Values.ToList();
|
|
|
|
|
if (projInfo.ListZLXXInfo != null && projInfo.ListZLXXInfo.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ListZLXXInfo = projInfo.ListZLXXInfo;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ListZLXXInfo = new ObservableCollection<ZLXXInfo>();
|
|
|
|
|
}
|
|
|
|
|
gvCtrl.ItemsSource = ListZLXXInfo;
|
|
|
|
|
System.Windows.Controls.ComboBoxItem comboBoxItem = new System.Windows.Controls.ComboBoxItem();
|
|
|
|
|
comboBoxItem.Tag = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBBG");
|
|
|
|
|
comboBoxItem.Content = "变更图斑";
|
|
|
|
|
combBGTB.Items.Add(comboBoxItem);
|
|
|
|
|
combBGTB.SelectedItem = comboBoxItem;
|
|
|
|
|
comboBoxItem = new System.Windows.Controls.ComboBoxItem();
|
|
|
|
|
comboBoxItem.Tag = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("地类图斑");
|
|
|
|
|
comboBoxItem.Content = "地类图斑";
|
|
|
|
|
combJCDLTB.Items.Add(comboBoxItem);
|
|
|
|
|
combJCDLTB.SelectedItem = comboBoxItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btn_oK_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass BGFeatureClass = null;
|
|
|
|
|
IFeatureLayer JCFeatureLayer = null;
|
|
|
|
|
IFeatureClass GXGCFC = null;//更新过程层
|
|
|
|
|
IFeatureClass GXFC = null;//更新层
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var combBGTBItem = combBGTB.SelectedItem as System.Windows.Controls.ComboBoxItem;
|
|
|
|
|
if (combBGTBItem != null)
|
|
|
|
|
BGFeatureClass = combBGTBItem.Tag as IFeatureClass;
|
|
|
|
|
var combDLTBItem = combJCDLTB.SelectedItem as System.Windows.Controls.ComboBoxItem;
|
|
|
|
|
if (combDLTBItem != null)
|
|
|
|
|
JCFeatureLayer = combDLTBItem.Tag as IFeatureLayer;
|
|
|
|
|
|
|
|
|
|
if (JCFeatureLayer != null && JCFeatureLayer.FeatureClass.FindField("XZQTZLX") == -1)
|
|
|
|
|
{
|
|
|
|
|
//添加字段
|
|
|
|
|
IFieldEdit _field = new FieldClass();
|
|
|
|
|
_field.Name_2 = "XZQTZLX";
|
|
|
|
|
_field.AliasName_2 = "行政区调整类型";
|
|
|
|
|
_field.Type_2 = esriFieldType.esriFieldTypeString;
|
|
|
|
|
_field.Length_2 = 1;
|
|
|
|
|
JCFeatureLayer.FeatureClass.AddField(_field as IField);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BGFeatureClass == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("变更图斑图层读取失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (JCFeatureLayer == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("基础地类图斑图层读取失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
GXGCFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGXGC"); //地类图斑更新过程
|
|
|
|
|
GXFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGX"); //地类图斑更新层
|
|
|
|
|
if (GXFC == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("地类图斑更新层读取失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (GXGCFC == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("地类图斑更新过程层读取失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#region 查询数据中是否存在未填写必要属性的数据 DLBM/ZLDWDM/QSDWDM
|
|
|
|
|
ITable bgtbTb = BGFeatureClass as ITable;
|
|
|
|
|
var count = bgtbTb.RowCount(new QueryFilterClass() { WhereClause = "DLBM='' or ZLDWDM='' or QSDWDM='' " });
|
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (MessageHelper.ShowYesNoAndTips($"检测到变更图斑存在{count}条数据中地类编码,坐落单位代码,坐落单位名称等必要信息未赋值,是否继续提取?") == System.Windows.Forms.DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
//this.ShowLoading("正在生成地类图斑更新层/更新过程层,请稍后...", 0, 0);
|
|
|
|
|
//btn_oK.IsEnabled = false;
|
|
|
|
|
//btn_nO.IsEnabled = false;
|
|
|
|
|
IFeatureLayer jcDLTBLayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("地类图斑");
|
|
|
|
|
if (jcDLTBLayer == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("未找到基础库地类图斑图层");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
IDGParameter Parm = new IDGParameter();
|
|
|
|
|
ProjectInfo prjInfo = MapsManager.Instance.CurrProjectInfo as ProjectInfo;
|
|
|
|
|
Parm.StrProjInfo = System.IO.Path.Combine(prjInfo.ProjDir, prjInfo.ProjName + prjInfo.ProjSuffix);
|
|
|
|
|
Parm.ExeDLTB = true;
|
|
|
|
|
//ProcesHelper.Instance.ProgressHandle = (o) =>
|
|
|
|
|
//{
|
|
|
|
|
// this.UpdateMsg(o.ToString());
|
|
|
|
|
//};
|
|
|
|
|
string result = ProcesHelper.Instance.ExeGPForProces(Parm);
|
|
|
|
|
|
|
|
|
|
//this.CloseLoading();
|
|
|
|
|
if (result.Contains("Err"))
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("地类图斑数据提取失败,失败信息请查看系统日志!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("地类图斑数据提取完成!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//this.CloseLoading();
|
|
|
|
|
MessageHelper.ShowError($"地类图斑数据提取失败:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
//btn_oK.IsEnabled = true;
|
|
|
|
|
//btn_nO.IsEnabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void BtnSelTB_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass BGFeatureClass = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string xzdltbPaths = "";
|
|
|
|
|
IFeatureClass dltbFc = GetFeatureClass("请选择新增的地类图斑数据", ref xzdltbPaths);
|
|
|
|
|
if (dltbFc != null)
|
|
|
|
|
{
|
|
|
|
|
btnNewData.Text = xzdltbPaths;
|
|
|
|
|
SelLocation_Layer = GeoDBAPI.CreateFeatureLayerInmemeory("SelLocation", "选择范围图斑数据", (dltbFc as IGeoDataset).SpatialReference, dltbFc.ShapeType, dltbFc.Fields);
|
|
|
|
|
(SelLocation_Layer.FeatureClass as ITable).DeleteSearchedRows(null);
|
|
|
|
|
InsertDataToMemeoryLayer(dltbFc, SelLocation_Layer.FeatureClass, null);
|
|
|
|
|
#region 选择的图斑与基础数据库相交,获取图形 并赋 QSDWDM 与 ZLDWDM
|
|
|
|
|
if (SelLocation_Layer != null && SelLocation_Layer.FeatureClass.FeatureCount(null) > 0)
|
|
|
|
|
{
|
|
|
|
|
this.ShowLoading("正在根据矢量数据范围提取变更图斑,请稍后...", 0, 0);
|
|
|
|
|
IFeatureLayer JClayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("地类图斑");
|
|
|
|
|
BGFeatureClass = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBBG");
|
|
|
|
|
IFeatureLayer JCDLTB_DLTBBGLayer = null;
|
|
|
|
|
IFeatureLayer TempErase = null;
|
|
|
|
|
string resultPath = Path.Combine(SysAppPath.GetCurrentAppPath(), "Temp\\ZLBG_DLTB");
|
|
|
|
|
if (!Directory.Exists(resultPath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(resultPath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DelectDirect(resultPath);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) { }
|
|
|
|
|
}
|
|
|
|
|
string savePath = Path.Combine(resultPath, "TempGDB.gdb");
|
|
|
|
|
string templeteGDBPath = Path.Combine(SysAppPath.GetCurrentAppPath(), "Template", "TempGDB.gdb");
|
|
|
|
|
CopyDirectory(templeteGDBPath, savePath, true);
|
|
|
|
|
string outPath = Path.Combine(savePath, "ZLBG_DLTB");
|
|
|
|
|
GPParamClass gPParamClass = new GPParamClass()
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureLayer = SelLocation_Layer,
|
|
|
|
|
SecondFeatureLayer = new FeatureLayerClass() { FeatureClass = BGFeatureClass },
|
|
|
|
|
OutFeatureClassPath = $"{savePath}\\erase",
|
|
|
|
|
IsGetOutPutFeature = true,
|
|
|
|
|
PreserveAttributes = "ALL"
|
|
|
|
|
};
|
|
|
|
|
GeoprocessorHelper.EraseAnalysis(gPParamClass, ref TempErase);
|
|
|
|
|
gPParamClass = new KGIS.Framework.AE.GPHelper.GPParamClass
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureLayer = TempErase,
|
|
|
|
|
SecondFeatureLayer = JClayer,
|
|
|
|
|
OutFeatureClassPath = outPath,
|
|
|
|
|
IsGetOutPutFeature = true
|
|
|
|
|
};
|
|
|
|
|
GeoprocessorHelper.IntersectAnalysis(gPParamClass, ref JCDLTB_DLTBBGLayer);
|
|
|
|
|
if (JCDLTB_DLTBBGLayer != null)
|
|
|
|
|
{
|
|
|
|
|
//#region 字段计算器 权属单位代码的前9位等于坐落单位代码的前9位
|
|
|
|
|
//Geoprocessor gp = new Geoprocessor();
|
|
|
|
|
//gp.OverwriteOutput = true;
|
|
|
|
|
//CalculateField calc = new CalculateField();
|
|
|
|
|
//calc.in_table = JCDLTB_DLTBBGLayer.FeatureClass;
|
|
|
|
|
//calc.field = "QSDWDM";
|
|
|
|
|
//calc.expression = "\"{0}{1}\".format(!ZLDWDM![0:9],!QSDWDM![10:19])";
|
|
|
|
|
//calc.expression_type = "PYTHON";
|
|
|
|
|
//gp.Execute(calc, null);
|
|
|
|
|
//#endregion
|
|
|
|
|
//修改坐落单位代码
|
|
|
|
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(JCDLTB_DLTBBGLayer.FeatureClass);
|
|
|
|
|
fcAPI.FcToFc(BGFeatureClass, null, true);
|
|
|
|
|
if (fcAPI != null)
|
|
|
|
|
fcAPI.CloseFeatureClass();
|
|
|
|
|
if (BGFeatureClass != null)
|
|
|
|
|
Marshal.ReleaseComObject(BGFeatureClass);
|
|
|
|
|
BGFeatureClass = null;
|
|
|
|
|
}
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
MessageHelper.ShowTips("提取完成!");
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
LogAPI.Debug("选择范围图斑异常:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("选择范围图斑异常:" + ex.StackTrace);
|
|
|
|
|
MessageHelper.ShowError("选择范围图斑异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void DelectDirect(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 e)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void InsertDataToMemeoryLayer(IFeatureClass pSource, IFeatureClass pTarget, IQueryFilter pFilter = null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (pSource == null || pTarget == null) return;
|
|
|
|
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(pSource);
|
|
|
|
|
if (pTarget != null)
|
|
|
|
|
fcAPI.FcToFc(pTarget, pFilter, false);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("插入数据失败:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static IFeatureClass GetFeatureClass(string title, ref string paths)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 获取源数据
|
|
|
|
|
OpenDataDialog pDialog = new OpenDataDialog();
|
|
|
|
|
ISpatialDataObjectFilter pOFilter;
|
|
|
|
|
pOFilter = new FilterFeatureDatasetsAndFeatureClasses();
|
|
|
|
|
pDialog.AddFilter(pOFilter, true);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(title))
|
|
|
|
|
pDialog.Title = title;
|
|
|
|
|
else
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass featureclass = (obj.DatasetName as IName).Open() as IFeatureClass;
|
|
|
|
|
result = featureclass;
|
|
|
|
|
paths += obj.FullName;//展示完整路径
|
|
|
|
|
//paths = featureclass.AliasName;//展示文件名
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("选择数据失败:" + ex.Message.ToString());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void BtnOpenFile_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (MessageHelper.ShowYesNoAndTips("是否要先获取当前坐落变更表格模板?") == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
string savepaths = string.Empty;
|
|
|
|
|
SaveFileDialog dialogCopy = new SaveFileDialog
|
|
|
|
|
{
|
|
|
|
|
DefaultExt = "xlsx",
|
|
|
|
|
Filter = "Excel Files(*.xlsx)|*.xlsx",
|
|
|
|
|
FileName = "变更坐落" + DateTime.Now.ToString("yyyyMMddHHmmssfff")
|
|
|
|
|
};
|
|
|
|
|
if (dialogCopy.ShowDialog() == DialogResult.OK)
|
|
|
|
|
savepaths = dialogCopy.FileName;
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
if (string.IsNullOrWhiteSpace(savepaths))
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show("未获取到文件路径!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (File.Exists(savepaths))
|
|
|
|
|
{
|
|
|
|
|
var result = MessageHelper.ShowYesNoAndTips("文件已存在,是否覆盖?");
|
|
|
|
|
if (result == DialogResult.No) return;
|
|
|
|
|
}
|
|
|
|
|
string strPath = AppDomain.CurrentDomain.BaseDirectory + @"工作空间\模板\坐落变更模板\坐落变更模板.xlsx";
|
|
|
|
|
File.Copy(strPath, savepaths, true);
|
|
|
|
|
if (MessageHelper.ShowYesNoAndTips("模板下载已完成,是否打开?") == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Process.Start("explorer.exe", savepaths);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string filePath = string.Empty;
|
|
|
|
|
OpenFileDialog dialog = new OpenFileDialog
|
|
|
|
|
{
|
|
|
|
|
DefaultExt = "xls",
|
|
|
|
|
Filter = "Excel文件|*.xls;*.xlsx"
|
|
|
|
|
};
|
|
|
|
|
if (dialog.ShowDialog())
|
|
|
|
|
{
|
|
|
|
|
filePath = dialog.FileName;
|
|
|
|
|
if (Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM) == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("请先进行字典设置!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
using (var streamData = File.Open(filePath, FileMode.Open, FileAccess.Read))
|
|
|
|
|
{
|
|
|
|
|
using (var readerData = ExcelReaderFactory.CreateReader(streamData))
|
|
|
|
|
{
|
|
|
|
|
var result = readerData.AsDataSet();
|
|
|
|
|
DataTable tempDT = result.Tables[0];
|
|
|
|
|
if (tempDT.Columns == null || tempDT.Columns.Count != 5)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("导入模板错误!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
tempDT.Columns[0].ColumnName = "变更前代码";
|
|
|
|
|
tempDT.Columns[1].ColumnName = "变更前名称";
|
|
|
|
|
tempDT.Columns[2].ColumnName = "变更后代码";
|
|
|
|
|
tempDT.Columns[3].ColumnName = "变更后名称";
|
|
|
|
|
tempDT.Columns[4].ColumnName = "是否仅权属变化";
|
|
|
|
|
tempDT.Rows.RemoveAt(0);
|
|
|
|
|
if (tempDT != null && tempDT.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var Index = -1;
|
|
|
|
|
ListZLXXInfo = new ObservableCollection<ZLXXInfo>();
|
|
|
|
|
foreach (DataRow row in tempDT.Rows)
|
|
|
|
|
{
|
|
|
|
|
var QS = Dics_QS.Where(x => x.CODE == row["变更后代码"].ToString()).FirstOrDefault();
|
|
|
|
|
if (QS != null)
|
|
|
|
|
Index = Dics_QS.IndexOf(QS);
|
|
|
|
|
if (Index > 0)
|
|
|
|
|
ListZLXXInfo.Add(new ZLXXInfo()
|
|
|
|
|
{
|
|
|
|
|
ID = ListZLXXInfo.OrderByDescending(x => x.ID).FirstOrDefault() == null ? 0 : ListZLXXInfo.OrderByDescending(x => x.ID).FirstOrDefault().ID + 1,
|
|
|
|
|
BGQDM = row["变更前代码"].ToString(),
|
|
|
|
|
BGQMC = row["变更前名称"].ToString(),
|
|
|
|
|
BGHDM = row["变更后代码"].ToString(),
|
|
|
|
|
BGHMC = row["变更后名称"].ToString(),
|
|
|
|
|
IsQS = row["是否仅权属变化"].ToString(),
|
|
|
|
|
Data = Dics_QS,
|
|
|
|
|
DataDicTionary = QS
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
projInfo.ListZLXXInfo = ListZLXXInfo;
|
|
|
|
|
gvCtrl.ItemsSource = null;
|
|
|
|
|
gvCtrl.ItemsSource = ListZLXXInfo;
|
|
|
|
|
projInfo.Save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Txt_Delete_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var TextBlock = sender as System.Windows.Controls.TextBlock;
|
|
|
|
|
if (TextBlock != null)
|
|
|
|
|
{
|
|
|
|
|
var Info = ListZLXXInfo.FirstOrDefault(f => f.ID == TextBlock.Tag.ToInt());//.Where(x => x.ID == TextBlock.Tag.ToInt()).FindFirst();
|
|
|
|
|
ListZLXXInfo.Remove(Info);
|
|
|
|
|
}
|
|
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProject" });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("删除坐落信息失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Txt_Add_MouseLeftButtonDown(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ListZLXXInfo.Add(new ZLXXInfo()
|
|
|
|
|
{
|
|
|
|
|
ID = ListZLXXInfo.OrderByDescending(x => x.ID).FirstOrDefault() == null ? 0 : ListZLXXInfo.OrderByDescending(x => x.ID).FirstOrDefault().ID + 1,
|
|
|
|
|
Data = Dics_QS,
|
|
|
|
|
});
|
|
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProject" });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
System.Windows.Controls.ComboBox sender1 = sender as System.Windows.Controls.ComboBox;
|
|
|
|
|
if (sender1 != null)
|
|
|
|
|
{
|
|
|
|
|
var SelectedItem = sender1.SelectedItem as DataDicTionary;
|
|
|
|
|
if (SelectedItem == null)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(sender1.Text))
|
|
|
|
|
{
|
|
|
|
|
sender1.ItemsSource = Dics_QS.Where(x => x.DisplayName.Contains(sender1.Text)).ToList();
|
|
|
|
|
sender1.IsDropDownOpen = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int[] rows = gvCtrl.GetSelectedRowHandles();
|
|
|
|
|
if (rows.Length == 1)
|
|
|
|
|
{
|
|
|
|
|
var Default = ListZLXXInfo.Where(x => x.ID == rows[0]).FirstOrDefault();
|
|
|
|
|
if (Default != null)
|
|
|
|
|
{
|
|
|
|
|
Default.BGHMC = SelectedItem.NAME;
|
|
|
|
|
Default.DataDicTionary = SelectedItem;
|
|
|
|
|
Default.BGHDM = SelectedItem.CODE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SelectBGTB_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string bgPaths = "";
|
|
|
|
|
IFeatureClass dltbFc = GetFeatureClass("请选择变更图斑数据", ref bgPaths);
|
|
|
|
|
if (dltbFc != null)
|
|
|
|
|
{
|
|
|
|
|
System.Windows.Controls.ComboBoxItem comboBoxItem = new System.Windows.Controls.ComboBoxItem();
|
|
|
|
|
comboBoxItem.Content = bgPaths;
|
|
|
|
|
comboBoxItem.Tag = dltbFc;
|
|
|
|
|
combBGTB.Items.Add(comboBoxItem);
|
|
|
|
|
combBGTB.SelectedItem = comboBoxItem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SelectDLTB_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string jcPaths = "";
|
|
|
|
|
IFeatureClass dltbFc = GetFeatureClass("请选择变更图斑数据", ref jcPaths);
|
|
|
|
|
if (dltbFc != null)
|
|
|
|
|
{
|
|
|
|
|
System.Windows.Controls.ComboBoxItem comboBoxItem = new System.Windows.Controls.ComboBoxItem();
|
|
|
|
|
comboBoxItem.Content = jcPaths;
|
|
|
|
|
comboBoxItem.Tag = new FeatureLayer() { FeatureClass = dltbFc, Name = dltbFc.AliasName };
|
|
|
|
|
combJCDLTB.Items.Add(comboBoxItem);
|
|
|
|
|
combJCDLTB.SelectedItem = comboBoxItem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ComboBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
System.Windows.Controls.ComboBox sender1 = sender as System.Windows.Controls.ComboBox;
|
|
|
|
|
if (sender1 != null && e.Text.Length > 6)
|
|
|
|
|
{
|
|
|
|
|
sender1.ItemsSource = Dics_QS.Where(x => x.DisplayName.Contains(e.Text)).ToList();
|
|
|
|
|
sender1.IsDropDownOpen = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ComboBox_SelectionChanged(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
KUI.ComboBox.AutoCompleteBox sender1 = sender as KUI.ComboBox.AutoCompleteBox;
|
|
|
|
|
if (sender1 != null && !string.IsNullOrEmpty(sender1.Text) && sender1.Text.Contains("-"))
|
|
|
|
|
{
|
|
|
|
|
var Default = ListZLXXInfo.Where(x => x.ID == sender1.Tag.ToInt()).FirstOrDefault();
|
|
|
|
|
if (Default != null)
|
|
|
|
|
{
|
|
|
|
|
Default.BGHMC = sender1.Text.Split('-')[1];
|
|
|
|
|
Default.BGHDM = sender1.Text.Split('-')[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("ComboBox_SelectionChanged失败:" + ex.Message.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region IWizardFramework接口函数
|
|
|
|
|
public bool Execute()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.ShowLoading("正在生成地类图斑更新层/更新过程层,请稍后...", 0, 0);
|
|
|
|
|
m_bIsFinalSuccess = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
MessageHelper.ShowError($"地类图斑数据提取失败:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
}
|
|
|
|
|
return m_bIsFinalSuccess;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Validating()
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass BGFeatureClass = null;
|
|
|
|
|
IFeatureLayer JCFeatureLayer = null;
|
|
|
|
|
IFeatureClass GXGCFC = null;//更新过程层
|
|
|
|
|
IFeatureClass GXFC = null;//更新层
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var combBGTBItem = combBGTB.SelectedItem as System.Windows.Controls.ComboBoxItem;
|
|
|
|
|
if (combBGTBItem != null)
|
|
|
|
|
BGFeatureClass = combBGTBItem.Tag as IFeatureClass;
|
|
|
|
|
var combDLTBItem = combJCDLTB.SelectedItem as System.Windows.Controls.ComboBoxItem;
|
|
|
|
|
if (combDLTBItem != null)
|
|
|
|
|
JCFeatureLayer = combDLTBItem.Tag as IFeatureLayer;
|
|
|
|
|
if (BGFeatureClass == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("变更图斑图层读取失败!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (JCFeatureLayer == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("基础地类图斑图层读取失败!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (JCFeatureLayer != null && JCFeatureLayer.FeatureClass.FindField("XZQTZLX") == -1)
|
|
|
|
|
{
|
|
|
|
|
//添加字段
|
|
|
|
|
IFieldEdit _field = new FieldClass();
|
|
|
|
|
_field.Name_2 = "XZQTZLX";
|
|
|
|
|
_field.AliasName_2 = "行政区调整类型";
|
|
|
|
|
_field.Type_2 = esriFieldType.esriFieldTypeString;
|
|
|
|
|
_field.Length_2 = 1;
|
|
|
|
|
JCFeatureLayer.FeatureClass.AddField(_field as IField);
|
|
|
|
|
}
|
|
|
|
|
GXGCFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGXGC"); //地类图斑更新过程
|
|
|
|
|
GXFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGX"); //地类图斑更新层
|
|
|
|
|
if (GXFC == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("地类图斑更新层读取失败!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (GXGCFC == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("地类图斑更新过程层读取失败!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#region 查询数据中是否存在未填写必要属性的数据 DLBM/ZLDWDM/QSDWDM
|
|
|
|
|
ITable bgtbTb = BGFeatureClass as ITable;
|
|
|
|
|
var count = bgtbTb.RowCount(new QueryFilterClass() { WhereClause = "DLBM='' or ZLDWDM='' or QSDWDM='' " });
|
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (MessageHelper.ShowYesNoAndTips($"检测到变更图斑存在{count}条数据中地类编码,坐落单位代码,坐落单位名称等必要信息未赋值,是否继续提取?") == System.Windows.Forms.DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
IFeatureLayer jcDLTBLayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("地类图斑");
|
|
|
|
|
if (jcDLTBLayer == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("未找到基础库地类图斑图层");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
(Parameter as IDGParameter).AllowPDFZ = cbAllowGDPD.IsChecked == true;
|
|
|
|
|
(Parameter as IDGParameter).AllowUnion = cbAllowUnion.IsChecked == true;
|
|
|
|
|
(Parameter as IDGParameter).AutoCalcGDKCSX = cbAutoCalcGDKCSX.IsChecked == true;
|
|
|
|
|
(Parameter as IDGParameter).AutoSetGDLX = cbAutoSetGDLX.IsChecked == true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError($"地类图斑数据提取失败:{ex.Message}");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Back()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Intializing(bool IsSkip = false)
|
|
|
|
|
{
|
|
|
|
|
if (IsSkip)
|
|
|
|
|
{
|
|
|
|
|
m_IsSkip = IsSkip;
|
|
|
|
|
(Parameter as IDGParameter).ExeDLTB = false;
|
|
|
|
|
(Parameter as IDGParameter).AllowPDFZ = false;
|
|
|
|
|
(Parameter as IDGParameter).AllowUnion = false;
|
|
|
|
|
(Parameter as IDGParameter).AutoCalcGDKCSX = false;
|
|
|
|
|
(Parameter as IDGParameter).AutoSetGDLX = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
(Parameter as IDGParameter).ExeDLTB = true;
|
|
|
|
|
(Parameter as IDGParameter).AllowPDFZ = cbAllowGDPD.IsChecked == true;
|
|
|
|
|
(Parameter as IDGParameter).AllowUnion = cbAllowUnion.IsChecked == true;
|
|
|
|
|
(Parameter as IDGParameter).AutoCalcGDKCSX = cbAutoCalcGDKCSX.IsChecked == true;
|
|
|
|
|
(Parameter as IDGParameter).AutoSetGDLX = cbAutoSetGDLX.IsChecked == true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|