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.
263 lines
12 KiB
263 lines
12 KiB
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.Controls; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using KGIS.Framework.AE; |
|
using KGIS.Framework.AE.Enum; |
|
using KGIS.Framework.DBOperator; |
|
using KGIS.Framework.Maps; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Utils.Helper; |
|
using KGIS.Framework.Views; |
|
using Kingo.PluginServiceInterface; |
|
using Kingo.PluginServiceInterface.Enums; |
|
using Kingo.PluginServiceInterface.Model; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.ComponentModel; |
|
using System.Data; |
|
using System.Linq; |
|
using System.Windows; |
|
using System.Windows.Controls; |
|
|
|
namespace Kingo.Plugin.General.View |
|
{ |
|
/// <summary> |
|
/// 图斑基本信息 |
|
/// </summary> |
|
public partial class UCTBBasicInformation : UserControl, IElementInfo, INotifyPropertyChanged |
|
{ |
|
public bool showDetail { get; set; } |
|
private int m_DataIndex { get; set; } |
|
private int m_DataCount { get; set; } |
|
|
|
#region 接口实现 |
|
|
|
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; } |
|
public bool IsShowInMap { get; set; } |
|
public bool IsShow { get; set; } |
|
public int ShowIndex { get; set; } |
|
public bool ResetSize { get; set; } |
|
public bool AllowEdit { get; set; } |
|
#endregion |
|
public UCTBBasicInformation() |
|
{ |
|
InitializeComponent(); |
|
DevExpress.Xpf.Core.ThemeManager.SetTheme(this, DevExpress.Xpf.Core.Theme.Office2013LightGray); |
|
this.Title = "图斑基本信息"; |
|
} |
|
private void TxtYPSM_GotFocus(object sender, RoutedEventArgs e) |
|
{ |
|
if ((MapsManager.Instance.CurrProjectInfo as ProjectInfo) != null) |
|
{ |
|
(MapsManager.Instance.CurrProjectInfo as ProjectInfo).EnableShortcut = false; |
|
} |
|
} |
|
private void TxtYPSM_LostFocus(object sender, RoutedEventArgs e) |
|
{ |
|
if ((MapsManager.Instance.CurrProjectInfo as ProjectInfo) != null) |
|
{ |
|
(MapsManager.Instance.CurrProjectInfo as ProjectInfo).EnableShortcut = true; |
|
} |
|
} |
|
private NYYSInfo NYYSInfo { get; set; } |
|
private TaskPackage taskPackage { get; set; } |
|
private IEngineEditor engineEditor = new EngineEditorClass(); |
|
|
|
public event PropertyChangedEventHandler PropertyChanged; |
|
|
|
public void BindData(object obj) |
|
{ |
|
try |
|
{ |
|
NYYSInfo nYYSInfo = obj as NYYSInfo; |
|
if (nYYSInfo == null) |
|
{ |
|
this.DataContext = null; |
|
return; |
|
} |
|
this.NYYSInfo = nYYSInfo; |
|
this.taskPackage = nYYSInfo.TaskPackages; |
|
this.DataContext = null; |
|
switch (nYYSInfo.BingDataType) |
|
{ |
|
case DTBDataTypeEnum.DTBJK: |
|
nYYSInfo.IsReadOnly = true; |
|
break; |
|
case DTBDataTypeEnum.DTBSL: |
|
nYYSInfo.IsReadOnly = true; |
|
break; |
|
case DTBDataTypeEnum.NYYCL: |
|
nYYSInfo.IsReadOnly = true; |
|
break; |
|
} |
|
this.DataContext = NYYSInfo; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug($"{ex.Message}"); |
|
LogAPI.Debug($"{ex.Source}"); |
|
} |
|
} |
|
|
|
public void SaveEdit() |
|
{ |
|
//IRDBHelper rdbHelper = null; |
|
IWorkspaceAPI workspaceAPI = null; |
|
try |
|
{ |
|
if (taskPackage == null) return; |
|
NYYSInfo = this.DataContext as NYYSInfo; |
|
if (NYYSInfo.BingDataType != DTBDataTypeEnum.NYYCL) return; |
|
//if (engineEditor == null) |
|
//{ |
|
// engineEditor = new EngineEditorClass(); |
|
//} |
|
//if (engineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing) |
|
//{ |
|
// if (engineEditor.HasEdits()) |
|
// { |
|
// engineEditor.StopEditing(true); |
|
// } |
|
//} |
|
//if (string.IsNullOrWhiteSpace((MapsManager.Instance.CurrProjectInfo as ProjectInfo).UserName)) |
|
//{ |
|
// throw new Exception("未获取到当前用户信息,请先进行用户信息设置!"); |
|
//} |
|
if (this.NYYSInfo.WYRWTB == null || string.IsNullOrWhiteSpace(this.NYYSInfo.WYRWTB.XZQDM) || this.NYYSInfo.WYRWTB.XZQDM.Length != 6) |
|
{ |
|
if (this.NYYSInfo.WYRWTB != null && string.IsNullOrWhiteSpace(this.NYYSInfo.WYRWTB.XZQDM)) |
|
this.NYYSInfo.WYRWTB.XZQDM = GetCJDM(6); |
|
|
|
if (this.NYYSInfo.WYRWTB == null || string.IsNullOrWhiteSpace(this.NYYSInfo.WYRWTB.XZQDM) || this.NYYSInfo.WYRWTB.XZQDM.Length != 6) |
|
{ |
|
throw new Exception("行政区代码为为空或不正确(行政区代码为6位)!"); |
|
} |
|
} |
|
//if (string.IsNullOrWhiteSpace(this.NYYSInfo.WYRWTB.XZDM) || this.NYYSInfo.WYRWTB.XZDM.Length != 9) |
|
//{ |
|
// if (string.IsNullOrWhiteSpace(this.NYYSInfo.WYRWTB.XZDM)) |
|
// this.NYYSInfo.WYRWTB.XZDM = GetCJDM(9); |
|
|
|
// if (string.IsNullOrWhiteSpace(this.NYYSInfo.WYRWTB.XZDM) || this.NYYSInfo.WYRWTB.XZDM.Length != 9) |
|
// throw new Exception("乡镇代码为空或不正确(乡镇代码为9位)!"); |
|
//} |
|
//if (string.IsNullOrWhiteSpace(this.NYYSInfo.WYRWTB.CJDM) || this.NYYSInfo.WYRWTB.CJDM.Length != 12) |
|
//{ |
|
// if (string.IsNullOrWhiteSpace(this.NYYSInfo.WYRWTB.CJDM)) |
|
// this.NYYSInfo.WYRWTB.CJDM = GetCJDM(12); |
|
|
|
// if (string.IsNullOrWhiteSpace(this.NYYSInfo.WYRWTB.CJDM) || this.NYYSInfo.WYRWTB.CJDM.Length != 12) |
|
// throw new Exception("村代码为空或不正确(村代码为12位)!"); |
|
//} |
|
workspaceAPI = new WorkspaceAPI(taskPackage.SchemeGDBPath, WorkspaceTypeEnum.GDBFile, true); |
|
//rdbHelper = RDBFactory.CreateDbHelper($"{taskPackage.PackageTempPath}{(MapsManager.Instance.CurrProjectInfo as ProjectInfo).Pathpassword}", DatabaseType.SQLite); |
|
//rdbHelper.BeginTransaction(); |
|
#region 自主变更图斑保存 |
|
try |
|
{ |
|
if (this.NYYSInfo.WYRWTB != null && this.NYYSInfo.WYRWTB.SJLY.Equals("ZZBG")) |
|
{ |
|
string updateSQL = string.Format("update ZZTB set xzqdm='{1}', xzdm='{2}', cjdm='{3}', jcbh='{4}', tblx='{5}', sjly='{6}', jcmj={7}, tbmj={8} where TBBSM='{0}'", this.NYYSInfo.WYRWTB.TBBSM, this.NYYSInfo.WYRWTB.XZQDM, this.NYYSInfo.WYRWTB.XZDM, this.NYYSInfo.WYRWTB.CJDM, this.NYYSInfo.WYRWTB.JCBH, this.NYYSInfo.WYRWTB.TBLX, "ZZBG", this.NYYSInfo.WYRWTB.JCMJ, this.NYYSInfo.WYRWTB.TBMJ); |
|
workspaceAPI.CurrentWorkspace.ExecuteSQL(updateSQL); |
|
//updateSQL = string.Format("update WYRW set xzqdm='{1}', xzdm='{2}', cjdm='{3}', jcbh='{4}', tblx='{5}', sjly='{6}', jcmj={7}, tbmj={8} where TBBSM='{0}'", this.NYYSInfo.WYRWTB.TBBSM, this.NYYSInfo.WYRWTB.XZQDM, this.NYYSInfo.WYRWTB.XZDM, this.NYYSInfo.WYRWTB.CJDM, this.NYYSInfo.WYRWTB.JCBH, this.NYYSInfo.WYRWTB.TBLX, "ZZBG", this.NYYSInfo.WYRWTB.JCMJ, this.NYYSInfo.WYRWTB.TBMJ); |
|
//rdbHelper.ExecuteNonQueryWithException(updateSQL, CommandType.Text); |
|
//rdbHelper.Commit(); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw new Exception("保存失败:" + ex.Message); |
|
} |
|
#endregion |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("自主变更图斑保存异常:" + ex); |
|
LogAPI.Debug("自主变更图斑保存异常:" + ex.StackTrace); |
|
throw ex; |
|
} |
|
//finally |
|
//{ |
|
// if (rdbHelper != null) |
|
// rdbHelper.DisConnect(); |
|
//} |
|
} |
|
|
|
/// <summary> |
|
/// 获取基础库行政区代码、乡镇代码及村代码 |
|
/// </summary> |
|
/// <param name="subDMLength"></param> |
|
/// <returns></returns> |
|
private string GetCJDM(int subDMLength) |
|
{ |
|
//村级调查区 坐落单位代码 |
|
try |
|
{ |
|
if (this.NYYSInfo == null || this.NYYSInfo.WYRWTB == null) return null; |
|
IFeatureLayer JCKFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTB"); |
|
IFeatureLayer zztbFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("ZZTB"); |
|
if (zztbFeatureLayer == null || JCKFeatureLayer == null) return null; |
|
|
|
//var gx_CZCMJ = JCKFeatureLayer.FeatureClass.FindField("TBMJ");//TBDLMJ SHAPE_Area |
|
int index = JCKFeatureLayer.FeatureClass.Fields.FindField("ZLDWDM"); |
|
IQueryFilter queryFilter = new QueryFilterClass() |
|
{ |
|
WhereClause = "TBBSM='" + this.NYYSInfo.WYRWTB.TBBSM + "'", |
|
}; |
|
IFeatureCursor featureCursor = zztbFeatureLayer.FeatureClass.Search(queryFilter, true); |
|
IFeature feature = featureCursor.NextFeature(); |
|
if (feature == null) return null; |
|
IFeature featureInterArea = null; |
|
List<IFeature> features = FeatureAPI.Identify(feature.ShapeCopy, JCKFeatureLayer); |
|
if (features != null && features.Count > 0) |
|
{ |
|
//feature = features.OrderByDescending(x => x.Value[gx_CZCMJ]).FirstOrDefault(); |
|
|
|
if (features.Count == 1) |
|
{ |
|
featureInterArea = features[0]; |
|
} |
|
else if (features.Count > 1) |
|
{ |
|
double _area = -1; |
|
foreach (IFeature item in features) |
|
{ |
|
double interArea = FeatureAPI.GetInterArea(feature.ShapeCopy, item.ShapeCopy); |
|
if (_area < interArea) |
|
{ |
|
_area = interArea; |
|
featureInterArea = item; |
|
} |
|
} |
|
} |
|
if (featureInterArea != null && index > -1) |
|
{ |
|
string zldwdm = featureInterArea.get_Value(index).ToString(); |
|
if (!string.IsNullOrEmpty(zldwdm) && zldwdm.Length > subDMLength) |
|
{ |
|
return zldwdm.Substring(0, subDMLength); |
|
} |
|
} |
|
} |
|
return null; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("UCTBBasicInformation.GetCJDM 异常:" + ex.Message); |
|
LogAPI.Debug("UCTBBasicInformation.GetCJDM 异常:" + ex.StackTrace); |
|
return null; |
|
} |
|
} |
|
|
|
|
|
|
|
} |
|
}
|
|
|