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.
160 lines
8.0 KiB
160 lines
8.0 KiB
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.Controls; |
|
using ESRI.ArcGIS.esriSystem; |
|
using KGIS.Framework.Commands; |
|
using KGIS.Framework.Maps; |
|
using KGIS.Framework.Platform; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Utils.Helper; |
|
using Kingo.Framework.LayerStyleConvert.Common; |
|
using Kingo.Framework.LayerStyleConvert.XSDClass; |
|
using Kingo.PluginServiceInterface; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.IO; |
|
using System.Linq; |
|
using System.Text; |
|
using System.Windows.Forms; |
|
using UIShell.OSGi; |
|
using CommonHelper = Kingo.PluginServiceInterface.CommonHelper; |
|
|
|
namespace Kingo.Plugin.DTBJK.Commands |
|
{ |
|
/// <summary> |
|
/// 系统注销 |
|
/// </summary> |
|
public class CmdSigout : BaseMenuCommand |
|
{ |
|
public IHookHelper m_hookHelper { get; set; } |
|
|
|
private IEngineEditor m_Editor { get; set; } |
|
public override void OnClick() |
|
{ |
|
try |
|
{ |
|
if (m_Editor.EditState != esriEngineEditState.esriEngineStateNotEditing) |
|
{ |
|
MessageHelper.ShowTips("请先结束编辑操作!"); |
|
return; |
|
} |
|
if (MessageHelper.ShowYesNoAndTips("是否注销并退出系统,该操作会重置登录及当前工程等数据信息?") == DialogResult.Yes) |
|
{ |
|
CommonHelper.UpdateAppsettingValueByKey("UserName", "", "UserLoginConfig"); |
|
CommonHelper.UpdateAppsettingValueByKey("IsNeedLogin", "true", "SystemConfig"); |
|
|
|
#region 新疆需求 注销保存图层样式设置信息 |
|
string strMxdPath = SysAppPath.GetCurrentAppPath() + "工作空间DTBJK\\初始化工程模板\\LatersToXMLForDTBJK.xml"; |
|
LayerCfg allLayerInfo = SerializeAPI.DeserializeToObject2<LayerCfg>(strMxdPath); |
|
List<LayerCfg> allLayers = allLayerInfo.GetAllItem(); |
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProject" }); |
|
IDataCatalogService _DataCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IDataCatalogService>(); |
|
if (_DataCatalog.CurrentLayers as LayerCfg != null) |
|
{ |
|
List<LayerCfg> layers = (_DataCatalog.CurrentLayers as LayerCfg).GetAllItem(); |
|
|
|
#region 剔除非模板图层 |
|
List<LayerCfg> needDeleteLayers = new List<LayerCfg>(); |
|
foreach (LayerCfg currentLayer in layers) |
|
{ |
|
if (allLayers.FirstOrDefault(a => a.LayerName == currentLayer.LayerName) == null) |
|
needDeleteLayers.Add(currentLayer); |
|
} |
|
foreach (LayerCfg item in needDeleteLayers) |
|
{ |
|
bool remove = (_DataCatalog.CurrentLayers as LayerCfg).Layers.Remove(item); |
|
if(!remove) |
|
{ |
|
LayerCfg parentLayer = layers.FirstOrDefault(a => a.ID == item.PID); |
|
if ((_DataCatalog.CurrentLayers as LayerCfg).Layers.FirstOrDefault(a => a == parentLayer) != null) |
|
remove = (_DataCatalog.CurrentLayers as LayerCfg).Layers.FirstOrDefault(a => a == parentLayer).Layers.Remove(item); |
|
} |
|
} |
|
#endregion |
|
|
|
layers = (_DataCatalog.CurrentLayers as LayerCfg).GetAllItem(); |
|
foreach (LayerCfg currentLayer in layers) |
|
{ |
|
if (!string.IsNullOrEmpty(currentLayer.FcPath)) currentLayer.FcPath = null; |
|
|
|
if (currentLayer.Data != null) |
|
{ |
|
if (currentLayer.Data is ILayer layer) |
|
{ |
|
if (layer is IFeatureLayer) |
|
{ |
|
IGeoFeatureLayer pGeoFeatureLayer = layer as IGeoFeatureLayer; |
|
#region 标注信息保存 |
|
if (pGeoFeatureLayer.DisplayAnnotation == true) |
|
{ |
|
IAnnotateLayerPropertiesCollection m_AnnotateLayerPropertiesCollection = (layer as IGeoFeatureLayer).AnnotationProperties; |
|
IAnnotateLayerProperties annotateLayerProperties = null; |
|
IElementCollection elementCollection = null; |
|
IElementCollection elementCollection2 = null; |
|
#region 实体化 |
|
for (int i = 0; i < m_AnnotateLayerPropertiesCollection.Count; i++) |
|
{ |
|
m_AnnotateLayerPropertiesCollection.QueryItem(i, out annotateLayerProperties, out elementCollection2, out elementCollection); |
|
ILabelEngineLayerProperties labelEngineLayer = (annotateLayerProperties as IClone).Clone() as ILabelEngineLayerProperties; |
|
AdvancedAnnotationInfo annotationInfo = new AdvancedAnnotationInfo(); |
|
SimpleTextSymbol txtSymbol = AnnotationConvret.Instance().GetTextSymbol(labelEngineLayer.Symbol); |
|
if (txtSymbol != null) |
|
{ |
|
annotationInfo.AnnotationInfos.Symbol = txtSymbol; |
|
annotationInfo.AnnotationInfos.Expression = labelEngineLayer.Expression; |
|
annotationInfo.AnnotationInfos.DisplayAnnotation = true; |
|
currentLayer.Annotation = annotationInfo.ToJson(); |
|
} |
|
} |
|
#endregion |
|
} |
|
#endregion |
|
} |
|
} |
|
} |
|
|
|
} |
|
} |
|
string Str = SerializeAPI.SerializeToXML<LayerCfg>(_DataCatalog.CurrentLayers as LayerCfg); |
|
Byte[] bytearr = Encoding.Default.GetBytes(Str);//Encoding.UTF8.GetBytes(Str); |
|
using (Stream stream = new System.IO.FileStream(strMxdPath, FileMode.Create, FileAccess.Write, FileShare.None)) |
|
{ |
|
stream.Write(bytearr, 0, bytearr.Length); |
|
stream.Close(); |
|
} |
|
#endregion |
|
|
|
GC.Collect(); |
|
Application.Exit(); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug(ex); |
|
MessageHelper.ShowTips("系统注销失败!"); |
|
} |
|
} |
|
|
|
public override void OnCreate(object Hook) |
|
{ |
|
try |
|
{ |
|
if (m_hookHelper == null) |
|
{ |
|
m_hookHelper = new HookHelper |
|
{ |
|
Hook = Hook |
|
}; |
|
} |
|
if (m_Editor == null) |
|
m_Editor = new EngineEditorClass(); |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("初始化 系统注销 命令时异常,异常信息如下:"); |
|
LogAPI.Debug(ex); |
|
LogAPI.Debug("初始化 系统注销 命令时异常信息结束"); |
|
} |
|
} |
|
} |
|
}
|
|
|