|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
using KGIS.Framework.AE.Enum;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.Platform;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using Kingo.Plugin.YJJK.ModelEntity;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using Kingo.PluginServiceInterface.Model;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.YJJK.View
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// FrmResultsExportForBG.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ViewCGDC_TC : UserControl, IWizardFramework
|
|
|
|
|
{
|
|
|
|
|
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; }
|
|
|
|
|
}
|
|
|
|
|
ExportBGViewModel exportBGViewModel = null;
|
|
|
|
|
public ViewCGDC_TC()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
if ((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ProjSuffix == ".KBG")
|
|
|
|
|
{
|
|
|
|
|
exportBGViewModel = new ExportBGViewModel();
|
|
|
|
|
DataContext = exportBGViewModel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (System.Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("一键成果导出 异常: " + ex + " ; ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Execute()
|
|
|
|
|
{
|
|
|
|
|
IWorkspaceAPI s_WsAPI = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string currentGDBPath = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ZLDatabase;
|
|
|
|
|
s_WsAPI = new WorkspaceAPI(currentGDBPath, WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
List<BGVCTEntity> TableMappingList = new List<BGVCTEntity>();
|
|
|
|
|
//string sDir = System.IO.Path.Combine(SysAppPath.GetCurrentAppPath(), "工作空间", "模板", "变更成果模板", "成果导出");
|
|
|
|
|
string sDir = Path.Combine((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ProjDir, "变更成果模板", "成果导出");
|
|
|
|
|
List<BGVCTEntity> list = exportBGViewModel.GXVCTEntity.SubEntities.FindAll(x => x.IsChecked == true && (x.FeatureClassName.EndsWith("GX") || x.FeatureClassName == "GXZJ"));
|
|
|
|
|
list.AddRange((exportBGViewModel.LayerSource as List<BGVCTEntity>)[0].SubEntities.FindAll(x => x.IsChecked == true));
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string sPath = System.IO.Path.Combine(sDir, "VCTTemplate3ForBG.VCT");
|
|
|
|
|
FileStream fs = new FileStream(sPath, FileMode.Create);
|
|
|
|
|
StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("GB18030"));
|
|
|
|
|
exportBGViewModel.GenerateVCTHead(sw);
|
|
|
|
|
foreach (BGVCTEntity item in list)
|
|
|
|
|
{
|
|
|
|
|
TableMappingList.Add(item);
|
|
|
|
|
}
|
|
|
|
|
exportBGViewModel.GenerateVCTFeatureCode(sw, list, s_WsAPI);
|
|
|
|
|
sw.WriteLine("TableStructureBegin");
|
|
|
|
|
foreach (BGVCTEntity entity in list)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClassAPI fcSourceAPI = s_WsAPI.OpenFeatureClass(entity.FeatureClassName);
|
|
|
|
|
IFeatureClass fcSource = fcSourceAPI.FeatureClass;
|
|
|
|
|
IFields fields = fcSource.Fields;
|
|
|
|
|
int FieldCount = 0;
|
|
|
|
|
for (int i = 0; i < fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = fields.Field[i];
|
|
|
|
|
if (field.Name == "OBJECTID" || field.Name == "JCTBBSM" || field.Name == "Element" || field.Name == "SHAPE" || field.Name == "SHAPE_Length" || field.Name == "SHAPE_Area")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (entity.FeatureClassName == "DLTBGX" && (field.Name == "XZQTZLX" || field.Name == "ONLYZLBG"))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
FieldCount++;
|
|
|
|
|
}
|
|
|
|
|
sw.WriteLine(string.Format("{0},{1}", entity.FeatureClassName, FieldCount));
|
|
|
|
|
for (int i = 0; i < fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = fields.Field[i];
|
|
|
|
|
if (field.Name == "OBJECTID" || field.Name == "JCTBBSM" || field.Name == "Element" || field.Name == "SHAPE" || field.Name == "SHAPE_Length" || field.Name == "SHAPE_Area")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (entity.FeatureClassName == "DLTBGX" && (field.Name == "XZQTZLX" || field.Name == "ONLYZLBG"))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
string strFieldType = exportBGViewModel.GetVCTFieldType(field);
|
|
|
|
|
if (strFieldType == "Float")
|
|
|
|
|
{
|
|
|
|
|
sw.WriteLine(string.Format("{0},{1},{2},2", field.Name, strFieldType, field.Length <= 255 ? field.Length : 255));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sw.WriteLine(string.Format("{0},{1},{2}", field.Name, strFieldType, field.Length <= 255 ? field.Length : 255));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
sw.WriteLine("0");
|
|
|
|
|
}
|
|
|
|
|
sw.Write("TableStructureEnd");
|
|
|
|
|
sw.Close();
|
|
|
|
|
sw.Dispose();
|
|
|
|
|
fs.Close();
|
|
|
|
|
fs.Dispose();
|
|
|
|
|
}
|
|
|
|
|
#region 一键成果导出的VCT中不包含PDTGX图层及其相关表结构信息 2020-7-29 沈超
|
|
|
|
|
|
|
|
|
|
list = exportBGViewModel.GXVCTEntity.SubEntities.FindAll(x => x.IsChecked == true && x.FeatureClassName == "PDTGX");
|
|
|
|
|
if (list.Count > 0)//创建没有PDTGCX的VCT
|
|
|
|
|
{
|
|
|
|
|
list = exportBGViewModel.GXVCTEntity.SubEntities.FindAll(x => x.IsChecked == true && (x.FeatureClassName.EndsWith("GX") || x.FeatureClassName == "GXZJ") && x.FeatureClassName != "PDTGX");
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string sPath = System.IO.Path.Combine(sDir, "VCTTemplate3ForBG_WithOutPDXGX.VCT");
|
|
|
|
|
FileStream fs = new FileStream(sPath, FileMode.Create);
|
|
|
|
|
StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("GB18030"));
|
|
|
|
|
exportBGViewModel.GenerateVCTHead(sw);
|
|
|
|
|
exportBGViewModel.GenerateVCTFeatureCode(sw, list, s_WsAPI);
|
|
|
|
|
sw.WriteLine("TableStructureBegin");
|
|
|
|
|
foreach (BGVCTEntity entity in list)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClassAPI fcSourceAPI = s_WsAPI.OpenFeatureClass(entity.FeatureClassName);
|
|
|
|
|
IFeatureClass fcSource = fcSourceAPI.FeatureClass;
|
|
|
|
|
IFields fields = fcSource.Fields;
|
|
|
|
|
int FieldCount = 0;
|
|
|
|
|
for (int i = 0; i < fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = fields.Field[i];
|
|
|
|
|
if (entity.FeatureClassName == "DLTBGX" && field.Name.ToUpper() == "XHMARK")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (field.Name == "OBJECTID" || field.Name == "JCTBBSM" || field.Name == "Element" ||
|
|
|
|
|
field.Name.ToUpper() == "SHAPE" || field.Name.ToUpper() == "SHAPE_LENGTH" || field.Name.ToUpper() == "SHAPE_AREA" ||
|
|
|
|
|
field.Name == "BGTBOID")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
FieldCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sw.WriteLine(string.Format("{0},{1}", entity.FeatureClassName, FieldCount));
|
|
|
|
|
for (int i = 0; i < fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = fields.Field[i];
|
|
|
|
|
if (entity.FeatureClassName == "DLTBGX" && field.Name.ToUpper() == "XHMARK")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (field.Name == "OBJECTID" || field.Name == "JCTBBSM" || field.Name == "Element" ||
|
|
|
|
|
field.Name.ToUpper() == "SHAPE" || field.Name.ToUpper() == "SHAPE_LENGTH" || field.Name.ToUpper() == "SHAPE_AREA" ||
|
|
|
|
|
field.Name == "BGTBOID")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
string strFieldType = exportBGViewModel.GetVCTFieldType(field);
|
|
|
|
|
if (strFieldType == "Float")
|
|
|
|
|
{
|
|
|
|
|
sw.WriteLine(string.Format("{0},{1},{2},2", field.Name, strFieldType, field.Length <= 255 ? field.Length : 255));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sw.WriteLine(string.Format("{0},{1},{2}", field.Name, strFieldType, field.Length <= 255 ? field.Length : 255));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sw.WriteLine("0");
|
|
|
|
|
}
|
|
|
|
|
sw.Write("TableStructureEnd");
|
|
|
|
|
sw.Close();
|
|
|
|
|
sw.Dispose();
|
|
|
|
|
fs.Close();
|
|
|
|
|
fs.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
list = exportBGViewModel.GXVCTEntity.SubEntities.FindAll(x => x.IsChecked == true && x.FeatureClassName.EndsWith("GXGC"));
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string sPath = System.IO.Path.Combine(sDir, "VCTTemplate3ForBG2.VCT");
|
|
|
|
|
FileStream fs = new FileStream(sPath, FileMode.Create);
|
|
|
|
|
StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("GB18030"));
|
|
|
|
|
exportBGViewModel.GenerateVCTHead(sw);
|
|
|
|
|
foreach (BGVCTEntity item in list)
|
|
|
|
|
{
|
|
|
|
|
TableMappingList.Add(item);
|
|
|
|
|
}
|
|
|
|
|
exportBGViewModel.GenerateVCTFeatureCode(sw, list, s_WsAPI);
|
|
|
|
|
sw.WriteLine("TableStructureBegin");
|
|
|
|
|
foreach (BGVCTEntity entity in list)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClassAPI fcSourceAPI = s_WsAPI.OpenFeatureClass(entity.FeatureClassName);
|
|
|
|
|
IFeatureClass fcSource = fcSourceAPI.FeatureClass;
|
|
|
|
|
IFields fields = fcSource.Fields;
|
|
|
|
|
int FieldCount = 0;
|
|
|
|
|
for (int i = 0; i < fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = fields.Field[i];
|
|
|
|
|
if (field.Name == "OBJECTID" || field.Name == "JCTBBSM" || field.Name == "SHAPE" || field.Name == "SHAPE_Length" || field.Name == "SHAPE_Area")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (entity.FeatureClassName == "DLTBGXGC" && (field.Name == "JCZT" || field.Name == "JCJG" || field.Name == "ONLYZLBG" || field.Name == "XMMC" || field.Name == "XMBH" || field.Name == "DKMC"))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
FieldCount++;
|
|
|
|
|
}
|
|
|
|
|
sw.WriteLine(string.Format("{0},{1}", entity.FeatureClassName, FieldCount));
|
|
|
|
|
for (int i = 0; i < fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = fields.Field[i];
|
|
|
|
|
if (field.Name == "OBJECTID" || field.Name == "JCTBBSM" || field.Name == "SHAPE" || field.Name == "SHAPE_Length" || field.Name == "SHAPE_Area")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (entity.FeatureClassName == "DLTBGXGC" && (field.Name == "JCZT" || field.Name == "JCJG" || field.Name == "ONLYZLBG" || field.Name == "XMMC" || field.Name == "XMBH" || field.Name == "DKMC"))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
string strFieldType = exportBGViewModel.GetVCTFieldType(field);
|
|
|
|
|
if (strFieldType == "Float")
|
|
|
|
|
{
|
|
|
|
|
sw.WriteLine(string.Format("{0},{1},{2},2", field.Name, strFieldType, field.Length <= 255 ? field.Length : 255));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sw.WriteLine(string.Format("{0},{1},{2}", field.Name, strFieldType, field.Length <= 255 ? field.Length : 255));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sw.WriteLine("0");
|
|
|
|
|
}
|
|
|
|
|
sw.Write("TableStructureEnd");
|
|
|
|
|
sw.Close();
|
|
|
|
|
sw.Dispose();
|
|
|
|
|
fs.Close();
|
|
|
|
|
fs.Dispose();
|
|
|
|
|
}
|
|
|
|
|
string TMConfigPath = System.IO.Path.Combine(SysAppPath.GetCurrentAppPath(), "Configs", "BGCheckTableMappingConfig.xml");
|
|
|
|
|
exportBGViewModel.CreateBGCheckTableMappingConfig(TMConfigPath, TableMappingList);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (s_WsAPI != null)
|
|
|
|
|
{
|
|
|
|
|
s_WsAPI.CloseWorkspace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Intializing(bool IsSkip = false)
|
|
|
|
|
{
|
|
|
|
|
if (IsSkip)
|
|
|
|
|
{
|
|
|
|
|
m_IsSkip = IsSkip;
|
|
|
|
|
if (Parameter is IDGParameter)
|
|
|
|
|
{
|
|
|
|
|
if ((Parameter as IDGParameter).ExtParam.Contains(this))
|
|
|
|
|
(Parameter as IDGParameter).ExtParam.Remove(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Parameter is IDGParameter)
|
|
|
|
|
{
|
|
|
|
|
if (!(Parameter as IDGParameter).ExtParam.Contains(this))
|
|
|
|
|
(Parameter as IDGParameter).ExtParam.Add(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Validating()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Back()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|