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

353 lines
14 KiB

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
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.Helper;
using System;
using System.Collections.Generic;
using System.Windows;
using KUI.Windows;
using Kingo.PluginServiceInterface.Model;
using System.IO;
using Kingo.PluginServiceInterface;
using System.Windows.Controls;
namespace Kingo.Plugin.YJJK.View
{
/// <summary>
/// UCExtractDistrict.xaml 的交互逻辑
/// </summary>
public partial class ViewXZQ_TQ : UserControl, IWizardFramework
{
private Dictionary<string, int> jc_FieldsIndex;
private Dictionary<string, int> gx_FieldsIndex;
private Dictionary<string, int> gxgc_FieldsIndex;
private Dictionary<string, int> tzh_FieldsIndex;
IFeatureLayer jccjdcqLayer = null;
IFeatureLayer jcxzqLayer = null;
IFeatureClass drqCJDCQFc = null;
IFeatureClass drqXZQFc = null;
IFeatureLayer jcgddblayer = null;
public object Parameter
{
get;
set;
}
private string m_strDescription = "此步骤将会提取行政区/村级调查区更新层和更新过程层数据";
public string Description
{
get { return m_strDescription; }
set { m_strDescription = value; }
}
private string m_strCaption = "行政区/村级调查区数据提取";
public string Caption
{
get { return m_strCaption; }
set { m_strCaption = value; }
}
private bool m_bIsFinalSuccess = false;
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; }
}
public ViewXZQ_TQ()
{
InitializeComponent();
ProjectInfo prj = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
this.btnCJDCQ.Text = prj.DR_CJDCQPath;
this.btnXZQ.Text = prj.DR_XZQPath;
this.cb_XZQDMChange.IsChecked = prj.XZQDMChange;
this.cb_ZLDWMCChange.IsChecked = prj.ZLDWMCChange;
this.CheckBox_cjdcq.IsChecked = true;
this.CheckBox_xzq.IsChecked = true;
this.CheckBox_gddb.IsChecked = true;
}
/// <summary>
/// 单独图斑提取确定按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOK_Click(object sender, RoutedEventArgs e)
{
try
{
IFeatureClass GXGCFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGXGC"); //地类图斑更新过程
IFeatureClass GXFC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGX"); //地类图斑更新层
if (GXGCFC == null || GXFC == null || GXGCFC.FeatureCount(null) == 0 || GXFC.FeatureCount(null) == 0)
{
MessageHelper.Show("暂无地类图斑增量数据,请先进行地类图斑数据提取!");
return;
}
List<DataDicTionary> qsDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM);
if (qsDic == null)
{
MessageHelper.ShowError("请先生成权属单位代码表...");
return;
}
if (this.CheckBox_cjdcq.IsChecked == false && this.CheckBox_gddb.IsChecked == false && this.CheckBox_xzq.IsChecked == false)
{
MessageBox.Show("请最少选择一项内容进行分析");
return;
}
if (CheckBox_gddb.IsChecked == true)
{
jcgddblayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("耕地等别");
if (jcgddblayer == null)
{
MessageHelper.ShowError("未找到耕地等别图层,无法进行耕地等别数据提取...");
return;
}
}
if (CheckBox_cjdcq.IsChecked == true)
{
//村级调查区更新/村级调查区更新过程/基础村级调查区
jccjdcqLayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("村级调查区");
if (jccjdcqLayer == null)
{
MessageHelper.ShowError("未找到村级调查区图层,无法进行村级调查区数据提取...");
return;
}
}
if (CheckBox_xzq.IsChecked == true)
{
//行政区更新/行政区更新过程/基础行政区
jcxzqLayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("行政区");
if (jcxzqLayer == null)
{
MessageHelper.ShowError("未找到基础行政区图层,无法进行行政区数据提取...");
return;
}
}
//this.btnOK.IsEnabled = false;//功能按钮禁用
//this.btnCancel.IsEnabled = false;
//this.btnXZQPath.IsEnabled = false;
//this.btnCJDCQPath.IsEnabled = false;
this.ShowLoading("正在进行行政区数据提取,请稍候...", 0, 0);
//XZQ_IDGHelper xZQ_IDGHelper = new XZQ_IDGHelper();
//xZQ_IDGHelper.Implement(
// this.CheckBox_gddb.IsChecked == true,
// this.CheckBox_cjdcq.IsChecked == true,
// this.cb_ZLDWMCChange.IsChecked == true,
// this.CheckBox_xzq.IsChecked == true,
// this.cb_XZQDMChange.IsChecked == true,
// drqCJDCQFc,
// drqXZQFc
// );
//this.CloseLoading();
IDGParameter Parm = new IDGParameter();
//Parm.PrjInfo = MapsManager.Instance.CurrProjectInfo as ProjectInfo;
ProjectInfo prjInfo = MapsManager.Instance.CurrProjectInfo as ProjectInfo;
prjInfo.XZQDMChange = this.cb_XZQDMChange.IsChecked == true;
prjInfo.ZLDWMCChange = this.cb_ZLDWMCChange.IsChecked == true;
Parm.StrProjInfo = Path.Combine(prjInfo.ProjDir, prjInfo.ProjName + prjInfo.ProjSuffix);
Parm.ExeCJDCQ = CheckBox_cjdcq.IsChecked == true;
Parm.ExeXZQ = CheckBox_xzq.IsChecked == true;
Parm.ExeGDDB = CheckBox_gddb.IsChecked == 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("行政区数据提取提取完成!");
}
//this.Close();
}
catch (Exception ex)
{
//this.btnOK.IsEnabled = true;
//this.btnCancel.IsEnabled = true;
//this.btnXZQPath.IsEnabled = true;
//this.btnCJDCQPath.IsEnabled = true;
MessageHelper.ShowError($"行政区数据提取失败:{ex.Message}");
}
finally
{
this.CloseLoading();
}
}
/// <summary>
/// 关闭按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
//this.Close();
}
private void BtnXZQPath_Click(object sender, RoutedEventArgs e)
{
string FcPath = string.Empty;
drqXZQFc = GetSelectionFc(ref FcPath);
btnXZQ.EditValue = FcPath;
}
private void BtnCJDCQPath_Click(object sender, RoutedEventArgs e)
{
string FcPath = string.Empty;
drqCJDCQFc = GetSelectionFc(ref FcPath);
btnCJDCQ.EditValue = FcPath;
}
private IFeatureClass GetSelectionFc(ref string strFcPath)
{
IFeatureClass result = null;
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)
{
result = (obj.DatasetName as IName).Open() as IFeatureClass;
strFcPath = obj.FullName;
}
}
}
else
{
return result;
}
}
catch (Exception ex)
{
LogAPI.Debug("选择数据失败:" + ex.Message.ToString());
}
return result;
}
public bool Execute()
{
try
{
this.ShowLoading("正在进行行政区数据提取,请稍候...", 0, 0);
m_bIsFinalSuccess = true;
}
catch (Exception ex)
{
LogAPI.Debug("行政区数据提取失败:" + ex.Message);
MessageHelper.ShowError($"行政区数据提取失败:{ex.Message}");
return m_bIsFinalSuccess;
}
finally
{
this.CloseLoading();
}
return m_bIsFinalSuccess;
}
public void Intializing(bool IsSkip = false)
{
if (IsSkip)
{
m_IsSkip = IsSkip;
(Parameter as IDGParameter).ExeCJDCQ = false;
(Parameter as IDGParameter).ExeXZQ = false;
(Parameter as IDGParameter).ExeGDDB = false;
}
else
{
(Parameter as IDGParameter).ExeCJDCQ = CheckBox_cjdcq.IsChecked == true;
(Parameter as IDGParameter).ExeXZQ = CheckBox_xzq.IsChecked == true;
(Parameter as IDGParameter).ExeGDDB = CheckBox_gddb.IsChecked == true;
}
}
public bool Validating()
{
try
{
List<DataDicTionary> qsDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM);
if (qsDic == null)
{
MessageHelper.ShowError("请先生成权属单位代码表...");
return false;
}
if (this.CheckBox_cjdcq.IsChecked == false && this.CheckBox_gddb.IsChecked == false && this.CheckBox_xzq.IsChecked == false)
{
MessageBox.Show("请最少选择一项内容进行分析");
return false;
}
if (CheckBox_gddb.IsChecked == true)
{
jcgddblayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("耕地等别");
if (jcgddblayer == null)
{
MessageHelper.ShowError("未找到耕地等别图层,无法进行耕地等别数据提取...");
return false;
}
}
if (CheckBox_cjdcq.IsChecked == true)
{
//村级调查区更新/村级调查区更新过程/基础村级调查区
jccjdcqLayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("村级调查区");
if (jccjdcqLayer == null)
{
MessageHelper.ShowError("未找到村级调查区图层,无法进行村级调查区数据提取...");
return false;
}
}
if (CheckBox_xzq.IsChecked == true)
{
jcxzqLayer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("行政区");
if (jcxzqLayer == null)
{
MessageHelper.ShowError("未找到基础行政区图层,无法进行行政区数据提取...");
return false;
}
}
(Parameter as IDGParameter).ExeCJDCQ = CheckBox_cjdcq.IsChecked == true;
(Parameter as IDGParameter).ExeXZQ = CheckBox_xzq.IsChecked == true;
(Parameter as IDGParameter).ExeGDDB = CheckBox_gddb.IsChecked == true;
}
catch (Exception ex)
{
LogAPI.Debug("行政区数据提取失败:" + ex.Message);
MessageHelper.ShowError($"行政区数据提取失败:{ex.Message}");
return false;
}
return true;
}
public void Back()
{
}
}
}