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.
404 lines
17 KiB
404 lines
17 KiB
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.Controls; |
|
using ESRI.ArcGIS.esriSystem; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using ESRI.ArcGIS.Geometry; |
|
using KGIS.Framework.Maps; |
|
using KGIS.Framework.Platform; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Utils.Helper; |
|
using KGIS.Framework.Views; |
|
using Kingo.Plugin.General.Helper; |
|
using Kingo.PluginServiceInterface; |
|
using Kingo.RuleCheck; |
|
using KUI.Windows; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Windows; |
|
using System.Windows.Controls; |
|
using UIShell.OSGi; |
|
|
|
namespace Kingo.Plugin.General.ViewDTBResultCheck |
|
{ |
|
/// <summary> |
|
/// UCCheckResults.xaml 的交互逻辑 |
|
/// </summary> |
|
public partial class UCCheckResults : UserControl, IDockPanel3 |
|
{ |
|
private IHookHelper hookHelper { get; set; } |
|
private IFeatureLayer BgfeatureLayer = null; |
|
private IFeatureLayer DtbfeatureLayer = null; |
|
public UCCheckResults(IHookHelper _hookHelper = null, IFeatureLayer _featureLayer = null, IFeatureLayer _DfeatureLayer = null) |
|
{ |
|
DevExpress.Xpf.Core.ThemeManager.SetTheme(this, DevExpress.Xpf.Core.Theme.Office2013LightGray); |
|
InitializeComponent(); |
|
ID = new Guid("A947BF3F-B0BE-4895-A061-5981C34CAA53");//继承与IDockPanel1属性 |
|
this.DockAreas = DockStyle.DockBottom | DockStyle.Float; |
|
this.FloatSize = new System.Drawing.Size(600, 670); |
|
this.DockHeight = 200; |
|
this.DefaultArea = DockStyle.DockBottom; |
|
this.ShowCloseButton = true; |
|
this.ShowAutoHideButton = true; |
|
this.IsShowInMap = true; |
|
this.Title = "质检检查结果"; |
|
this.ShowCloseButton = true; |
|
this.Loaded += (s, e) => |
|
{ |
|
hookHelper = _hookHelper; |
|
BgfeatureLayer = _featureLayer; |
|
DtbfeatureLayer = _DfeatureLayer; |
|
}; |
|
} |
|
|
|
public void InitData(List<RuleCheck.RuleEntity> lstResult) |
|
{ |
|
try |
|
{ |
|
int i = 1; |
|
if (lstResult != null) |
|
{ |
|
//lstResult.OrderBy(x => x.XH).ThenBy(x => x.ErrorId).ThenBy(x => x.RuleCode).ToList().ForEach(x => x.XH = i++); |
|
lstResult.OrderBy(x => x.XH).ThenBy(x => x.ErrorId).ToList().ForEach(x => x.XH = i++); |
|
} |
|
this.Dispatcher.Invoke(new Action(delegate |
|
{ |
|
gridPackage.ItemsSource = null; |
|
gridPackage.ItemsSource = lstResult; |
|
})); |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug(ex); |
|
} |
|
} |
|
private void gcAttr_SelectionChanged(object sender, DevExpress.Xpf.Grid.GridSelectionChangedEventArgs e) |
|
{ |
|
try |
|
{ |
|
if (!gridPackage.IsMouseOver) |
|
{ |
|
return; |
|
} |
|
if (gridPackage.SelectedItems == null || gridPackage.SelectedItems.Count <= 0) |
|
{ |
|
return; |
|
} |
|
if (gridPackage.SelectedItems.Count > 1) |
|
{ |
|
MessageHelper.Show("请选择单条数据查看!"); |
|
return; |
|
} |
|
RuleEntity ruleEntity = gridPackage.SelectedItems[0] as RuleEntity; |
|
if (ruleEntity == null) |
|
{ |
|
return; |
|
} |
|
if (ruleEntity.RuleCode == "TX003") |
|
{ |
|
Repair.Visibility = Visibility.Visible; |
|
} |
|
else |
|
{ |
|
Repair.Visibility = Visibility.Collapsed; |
|
} |
|
Guid guid = new Guid(); |
|
int oid = 0; |
|
if (!Guid.TryParse(ruleEntity.ErrorId, out guid) && int.TryParse(ruleEntity.ErrorId, out oid)) |
|
{ |
|
IFeatureLayer featureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("N"); |
|
if (featureLayer != null && featureLayer.FeatureClass != null) |
|
{ |
|
IFeature feature = null; |
|
try |
|
{ |
|
if (!featureLayer.Visible) |
|
{ |
|
featureLayer.Visible = true; |
|
} |
|
feature = featureLayer.FeatureClass.GetFeature(oid);//选中并居中 |
|
MapsManager.Instance.MapService.SelectFeature(featureLayer.Name, oid.ToString()); |
|
Location(ruleEntity); |
|
return; |
|
} |
|
catch |
|
{ |
|
} |
|
finally |
|
{ |
|
if (feature != null) |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(feature); |
|
} |
|
} |
|
} |
|
} |
|
if (!string.IsNullOrWhiteSpace(ruleEntity.ErrorId)) |
|
{ |
|
//通知主任务树定位图斑 |
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "CheckResultLocation", Content = ruleEntity.ErrorId }); |
|
Location(ruleEntity); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
MessageHelper.ShowError(ex.Message); |
|
} |
|
} |
|
IMapService _mapService = null; |
|
private void Location(RuleEntity ruleEntity) |
|
{ |
|
IPointCollection poly2 = new PolygonClass(); |
|
IGeometry tempgeometry = null; |
|
try |
|
{ |
|
if (_mapService == null) |
|
_mapService = MapsManager.Instance.MapService; |
|
_mapService.ClearFeatureSelection(this.hookHelper.Hook as IMapControlDefault); |
|
if (ruleEntity.Geometry != null && !string.IsNullOrWhiteSpace(ruleEntity.Geometry.ToString())) |
|
{ |
|
ESRI.ArcGIS.Geometry.IGeometry geometry = null; |
|
switch (ruleEntity.GeometryType) |
|
{ |
|
case 1: |
|
geometry = GeometryConvertHelper.ConverJsonToIGeoemtry(ruleEntity.Geometry.ToString(), ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint); |
|
geometry.Project(this.hookHelper.FocusMap.SpatialReference); |
|
_mapService.DrawGraph(geometry, true); |
|
//IArray geoArray = new ArrayClass();//声明一个几何的集合 |
|
//geoArray.Add(geometry);//向几何集合中添加几何对象 |
|
//IHookActions hookActions = (IHookActions)hookHelper;//通过IHookActions闪烁要素集合 |
|
//hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsZoom); |
|
//System.Windows.Forms.Application.DoEvents(); |
|
//hookHelper.ActiveView.ScreenDisplay.UpdateWindow(); |
|
//((hookHelper.Hook) as IMapControl2).CenterAt((IPoint)geometry); |
|
//hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsFlash); |
|
|
|
//为了实现地图界面放大效果 |
|
poly2.AddPoint(new PointClass() { X = geometry.Envelope.XMin - 10, Y = geometry.Envelope.YMax + 10 }); |
|
poly2.AddPoint(new PointClass() { X = geometry.Envelope.XMax + 10, Y = geometry.Envelope.YMax + 10 }); |
|
poly2.AddPoint(new PointClass() { X = geometry.Envelope.XMax + 10, Y = geometry.Envelope.YMin - 10 }); |
|
poly2.AddPoint(new PointClass() { X = geometry.Envelope.XMin - 10, Y = geometry.Envelope.YMin - 10 }); |
|
poly2.AddPoint(new PointClass() { X = geometry.Envelope.XMin - 10, Y = geometry.Envelope.YMax + 10 }); |
|
tempgeometry = poly2 as IGeometry; |
|
_mapService.Zoom(tempgeometry); |
|
|
|
//MapsManager.Instance.MapService.Zoom(geometry.Envelope); |
|
//this.hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphicSelection, null, geometry.Envelope); |
|
break; |
|
case 2: |
|
geometry = GeometryConvertHelper.ConverJsonToIGeoemtry(ruleEntity.Geometry.ToString(), ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline); |
|
geometry.Project(this.hookHelper.FocusMap.SpatialReference); |
|
//MapsManager.Instance.MapService.ClearFeatureSelection(this.hookHelper.Hook as IMapControlDefault); |
|
//MapsManager.Instance.MapService.Zoom(geometry); |
|
break; |
|
case 3: |
|
geometry = GeometryConvertHelper.ConverJsonToIGeoemtry(ruleEntity.Geometry.ToString()); |
|
geometry.Project(this.hookHelper.FocusMap.SpatialReference); |
|
//MapsManager.Instance.MapService.ClearFeatureSelection(this.hookHelper.Hook as IMapControlDefault); |
|
//MapsManager.Instance.MapService.Zoom(geometry); |
|
break; |
|
} |
|
if (ruleEntity.GeometryType != 1) |
|
{ |
|
_mapService.DrawGraph(geometry, true); |
|
_mapService.Zoom(geometry); |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
finally |
|
{ |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(poly2); |
|
if (tempgeometry != null) |
|
System.Runtime.InteropServices.Marshal.ReleaseComObject(tempgeometry); |
|
} |
|
} |
|
|
|
#region IDockPanel3 |
|
public KGIS.Framework.Views.DockStyle DockAreas { get; set; } |
|
public System.Drawing.Size FloatSize { get; set; } |
|
public int DockWidth { get; set; } |
|
public int DockHeight { get; set; } |
|
public KGIS.Framework.Views.DockStyle DefaultArea { get; set; } |
|
public bool ShowCloseButton { get; set; } |
|
public bool ShowAutoHideButton { get; set; } |
|
public string Title { get; set; } |
|
private Grid currentheadergrid { get; set; } |
|
|
|
public bool IsShowInMap { get; set; } |
|
public bool IsDockToPanel { get; set; } |
|
public DockStyle DockToPanelStyle { get; set; } |
|
public Guid ID { get; set; } |
|
public bool IsShow { get; set; } |
|
|
|
public event EventHandler CloseViewHandler; |
|
|
|
public void Close() |
|
{ |
|
//Env.Instance.KMap.LoadProjectCompleteEvent -= Platform_LoadProjectEvent; |
|
//Env.Instance.KMap.CloseProjectCompleteEvent -= Platform_CloseProjectEvent; |
|
this.ClosePanel(); |
|
} |
|
|
|
private void Platform_CloseProjectEvent(object sender, object e) |
|
{ |
|
try |
|
{ |
|
this.Close(); |
|
} |
|
catch (Exception ex) |
|
{ |
|
MessageHelper.ShowError(ex.Message); |
|
} |
|
} |
|
|
|
public void ShowPanel() |
|
{ |
|
Platform.Instance.OpenView(this, false); |
|
} |
|
|
|
public void ClosePanel() |
|
{ |
|
Platform.Instance.CloseView(this); |
|
} |
|
|
|
public void ClosePanelInvoke() |
|
{ |
|
CloseViewHandler?.Invoke(this, null); |
|
} |
|
#endregion |
|
|
|
/// <summary> |
|
/// 导出质检结果 |
|
/// </summary> |
|
/// <param name="sender"></param> |
|
/// <param name="e"></param> |
|
private void BtnExprotResult_Click(object sender, RoutedEventArgs e) |
|
{ |
|
System.Windows.Forms.SaveFileDialog saveFileDialog = null; |
|
try |
|
{ |
|
saveFileDialog = new System.Windows.Forms.SaveFileDialog(); |
|
saveFileDialog.Title = "导出Excel"; |
|
saveFileDialog.Filter = "Excel文件(*.xlsx)|*.xlsx"; |
|
saveFileDialog.FileName = "变更检查结果-" + DateTime.Now.ToString("yyyyMMddHHmmss"); |
|
if (saveFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) |
|
{ |
|
return; |
|
} |
|
this.ShowLoading("正在导出......", 0, 0); |
|
//KGIS.Framework.Platform.Helper.ProgressHelper.ShowProcessBar("正在导出......"); |
|
DevExpress.XtraPrinting.XlsxExportOptionsEx op = new DevExpress.XtraPrinting.XlsxExportOptionsEx(); |
|
this.viewPackage.ExportToXlsx(saveFileDialog.FileName, op); |
|
KGIS.Framework.Platform.Helper.ProgressHelper.CloseProcessBar(); |
|
if (MessageHelper.ShowYesNoAndTips("导出成功!是否查看文件?") != System.Windows.Forms.DialogResult.Yes) |
|
{ |
|
return; |
|
} |
|
System.Diagnostics.Process.Start("explorer.exe", System.IO.Path.GetDirectoryName(saveFileDialog.FileName)); |
|
} |
|
catch (Exception ex) |
|
{ |
|
this.CloseLoading(); |
|
//KGIS.Framework.Platform.Helper.ProgressHelper.CloseProcessBar(); |
|
LogAPI.Debug(ex); |
|
MessageHelper.ShowError("导出质检结果异常:" + ex.Message); |
|
} |
|
finally |
|
{ |
|
this.CloseLoading(); |
|
//KGIS.Framework.Platform.Helper.ProgressHelper.CloseProcessBar(); |
|
if (saveFileDialog != null) |
|
{ |
|
saveFileDialog.Dispose(); |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 例外 |
|
/// </summary> |
|
/// <param name="sender"></param> |
|
/// <param name="e"></param> |
|
private void MenuItem_Click(object sender, RoutedEventArgs e) |
|
{ |
|
try |
|
{ |
|
if (!gridPackage.IsMouseOver) |
|
{ |
|
return; |
|
} |
|
if (gridPackage.SelectedItems == null || gridPackage.SelectedItems.Count <= 0) |
|
{ |
|
return; |
|
} |
|
if (gridPackage.SelectedItems.Count > 1) |
|
{ |
|
MessageHelper.Show("请选择单条数据!"); |
|
return; |
|
} |
|
RuleEntity ruleEntity = gridPackage.SelectedItems[0] as RuleEntity; |
|
if (!ruleEntity.ErrorType.Equals("二类错误")) |
|
{ |
|
MessageHelper.Show("例外只适用于二类错误!"); |
|
return; |
|
} |
|
//通知主任务树定位图斑 |
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "CheckResultLW", Content = ruleEntity }); |
|
} |
|
catch (Exception ex) |
|
{ |
|
MessageHelper.Show(ex.Message); |
|
} |
|
} |
|
|
|
//修复 |
|
private void Repair_Click(object sender, RoutedEventArgs e) |
|
{ |
|
try |
|
{ |
|
if (!gridPackage.IsMouseOver) |
|
{ |
|
return; |
|
} |
|
if (gridPackage.SelectedItems == null || gridPackage.SelectedItems.Count <= 0) |
|
{ |
|
return; |
|
} |
|
if (gridPackage.SelectedItems.Count > 1) |
|
{ |
|
MessageHelper.Show("请选择单条数据!"); |
|
return; |
|
} |
|
RuleEntity ruleEntity = gridPackage.SelectedItems[0] as RuleEntity; |
|
if (ruleEntity == null || !ruleEntity.ErrorType.Equals("一类错误") && ruleEntity.RuleCode != "TX003") |
|
{ |
|
MessageHelper.Show("修复只适用于TX003类型的错误!"); |
|
return; |
|
} |
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "RefreshGeometry", Content = ruleEntity }); |
|
|
|
|
|
} |
|
catch (Exception ex) |
|
{ |
|
this.CloseLoading(); |
|
LogAPI.Debug("质检图形节点密度修复 异常:" + ex.Message); |
|
LogAPI.Debug("质检图形节点密度修复 异常:" + ex.StackTrace); |
|
MessageHelper.Show(ex.Message); |
|
} |
|
finally |
|
{ |
|
this.CloseLoading(); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
}
|
|
|