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

93 lines
3.4 KiB

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using KGIS.Framework.AE;
using KGIS.Framework.Commands;
using KGIS.Framework.Maps;
using KGIS.Framework.Platform;
using KGIS.Framework.Utils.Helper;
using Kingo.PluginServiceInterface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kingo.Plugin.BGResultManager.Commands
{
/// <summary>
/// 创建年末库
/// </summary>
public class CreateNMKLayerCommand : BaseMenuCommand
{
private IDataCatalogService _DataCatalog = null;
private IHookHelper m_hookHelper = null;
public override void OnClick()
{
if (_DataCatalog == null)
_DataCatalog = UIShell.OSGi.BundleRuntime.Instance.GetFirstOrDefaultService<IDataCatalogService>();
if (_DataCatalog == null)
return;
if (!(MapsManager.Instance.MapService.GetProjectInfo() is PluginServiceInterface.ProjectInfo ProInfo))
return;
ILayer groupLayerNM = MapsManager.Instance.MapService.GetGroupLayer("NMSJ");
object GroupLayerInfoNM = _DataCatalog.GetNodeByLayer(groupLayerNM);
IWorkspaceAPI NmWsAPI = new WorkspaceAPI(ProInfo.NMDatabase, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.GDBFile);
IFeatureLayer JCdltb_Layer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("地类图斑");
IFeatureClassAPI DLTBNMKAPI = null;
if (NmWsAPI.ExistFeatureClass("DLTB_NMK"))
{
DLTBNMKAPI = NmWsAPI.OpenFeatureClass2("DLTB_NMK");
IFeatureLayer tempLayerNM = new FeatureLayer() { Name = "地类图斑年末库", FeatureClass = DLTBNMKAPI.FeatureClass };
_DataCatalog.AddLayer(tempLayerNM, GroupLayerInfoNM);
if (NmWsAPI != null)
NmWsAPI.CloseWorkspace();
_DataCatalog.UpdateTree();
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProject" });
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "InitProject" });
}
else
{
MessageHelper.ShowTips("是否已经进行增量图层数据提取操作!");
}
}
public override void OnCreate(object Hook)
{
try
{
if (m_hookHelper == null)
{
m_hookHelper = new HookHelperClass
{
Hook = Hook
};
}
}
catch
{
m_hookHelper = null;
return;
}
}
public override bool Enabled
{
get
{
ProjectInfo pTemp = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo);
if (pTemp == null)
{
return false;
}
else
{
IFeatureLayer NMK_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTB_NMK");
if (NMK_Layer == null)
return true;
else
return false;
}
}
}
}
}