|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Controls;
|
|
|
|
|
using ESRI.ArcGIS.esriSystem;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using ESRI.ArcGIS.Geometry;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
using KGIS.Framework.Core.Services;
|
|
|
|
|
using KGIS.Framework.DBOperator;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.OpenData.Control;
|
|
|
|
|
using KGIS.Framework.OpenData.Filter;
|
|
|
|
|
using KGIS.Framework.OpenData.InterFace;
|
|
|
|
|
using KGIS.Framework.Platform;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.Dialog;
|
|
|
|
|
using KGIS.Framework.Utils.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using KGIS.Framework.Utils.Model;
|
|
|
|
|
using KGIS.Framework.Utils.Utility;
|
|
|
|
|
using Kingo.Core.Authorize;
|
|
|
|
|
using Kingo.Framework.LayerStyleConvert.Common;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
using UIShell.OSGi;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.MapView.Views.AppMenuView
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UCCreateProjectView_WPF.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class UCCreateProjectView_WPF : BaseWindow
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ViewManager服务接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
private KGIS.Framework.Views.IViewManager m_ViewManager;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作目录服务接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
IWorkCatalog _workCatalog = null;
|
|
|
|
|
private ISystemCfg SystemCfg = null;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 行政区代码集合
|
|
|
|
|
/// </summary>
|
|
|
|
|
List<DataDicTionary> xzqCoderesult = new List<DataDicTionary>();
|
|
|
|
|
private string Setworkapacepath { get; set; }
|
|
|
|
|
|
|
|
|
|
private string PrjFileStr;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 授权加密-区划代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string getCodes = "";
|
|
|
|
|
private List<string> Codes = new List<string>();
|
|
|
|
|
ObservableCollection<ZLXXInfo> ListZLXXInfo = null;//坐落信息变化数据
|
|
|
|
|
public UCCreateProjectView_WPF()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
DevExpress.Xpf.Core.ThemeManager.SetTheme(this, DevExpress.Xpf.Core.Theme.Office2013LightGray);
|
|
|
|
|
//工作目录接口
|
|
|
|
|
_workCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IWorkCatalog>();
|
|
|
|
|
//系统配置接口
|
|
|
|
|
SystemCfg = BundleRuntime.Instance.GetFirstOrDefaultService<ISystemCfg>();
|
|
|
|
|
Codes = RunIDService2.Instance.Codes;
|
|
|
|
|
ListZLXXInfo = new ObservableCollection<ZLXXInfo>();
|
|
|
|
|
ListZLXXInfo.Add(new ZLXXInfo() { ID = 0 });
|
|
|
|
|
gvCtrl.ItemsSource = ListZLXXInfo;
|
|
|
|
|
//从工作目录中选择工程目录
|
|
|
|
|
ProjectInfo ProInfo = new ProjectInfo();
|
|
|
|
|
Init(ProInfo);
|
|
|
|
|
AutoCompluteTxt_Box();
|
|
|
|
|
string tempCode = string.Empty;
|
|
|
|
|
if (Codes != null && Codes.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
tempCode = Codes[0];
|
|
|
|
|
}
|
|
|
|
|
GetXZQDic();
|
|
|
|
|
if (!tempCode.EndsWith("00") && !string.IsNullOrWhiteSpace(tempCode))
|
|
|
|
|
{
|
|
|
|
|
ProInfo.CODE = tempCode;
|
|
|
|
|
txt_Box.SelectedValue = tempCode;
|
|
|
|
|
txt_Box.IsReadOnly = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//给下拉框绑定行政区代码集合
|
|
|
|
|
txt_Box.ItemsSource = GetXZQDic();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//按类型显示默认工程类型 类型判定待修改
|
|
|
|
|
SystemTypeEnum systemTypeEnum = Platform.Instance.SystemType;
|
|
|
|
|
if (systemTypeEnum == SystemTypeEnum.RCBGJK)
|
|
|
|
|
{
|
|
|
|
|
projectType.SelectedIndex = -1;
|
|
|
|
|
projectType.SelectedIndex = 0;
|
|
|
|
|
projType.Opacity = 0;
|
|
|
|
|
hideProjType.Visibility = Visibility.Visible;
|
|
|
|
|
TbXZQInfo.Visibility = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
else if (systemTypeEnum == SystemTypeEnum.BGFWCG)
|
|
|
|
|
{
|
|
|
|
|
projType.Content = "变化图斑提取";
|
|
|
|
|
projType.Tag = "BHTBTQ";
|
|
|
|
|
}
|
|
|
|
|
else if (systemTypeEnum == SystemTypeEnum.NDBGJK)
|
|
|
|
|
{
|
|
|
|
|
projType.Content = "年度变更建库";
|
|
|
|
|
projType.Tag = "NDBG";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 区划代码自动过滤参数获取getCodes
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void AutoCompluteTxt_Box()
|
|
|
|
|
{
|
|
|
|
|
//获取当前授权类型
|
|
|
|
|
Attribute guid_attr = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(GuidAttribute));
|
|
|
|
|
string guid = ((GuidAttribute)guid_attr).Value;
|
|
|
|
|
var type = "";//ConfigurationManager.AppSettings.Get("LicenseType");
|
|
|
|
|
//RunIDService2.Instance.Codes
|
|
|
|
|
if (type == "F")//加密文件
|
|
|
|
|
{
|
|
|
|
|
getCodes = RunIDService.GetCode();
|
|
|
|
|
}
|
|
|
|
|
else if (type == "D")//加密狗EmptyValue
|
|
|
|
|
{
|
|
|
|
|
AuthorizeHelper authorizeHelper = new AuthorizeHelper(AuthorizeType.单机授权, "MobileDataMake", "2x", "");
|
|
|
|
|
getCodes = authorizeHelper.GetAreaCode(); //GetCode("dlgtz2021", "2x", GetVersion(Assembly.GetExecutingAssembly().Location), TokenLibrary.VendorCode.Code);
|
|
|
|
|
if (getCodes == "EmptyValue" || getCodes == null) getCodes = "";
|
|
|
|
|
}
|
|
|
|
|
if (getCodes != null && getCodes.IndexOf("0000") == 2)
|
|
|
|
|
{
|
|
|
|
|
getCodes = getCodes.Substring(0, 2);
|
|
|
|
|
}
|
|
|
|
|
else if (getCodes != null && getCodes.IndexOf("00") == 4)
|
|
|
|
|
{
|
|
|
|
|
getCodes = getCodes.Substring(0, 4);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetVersion(string fileName)
|
|
|
|
|
{
|
|
|
|
|
FileVersionInfo file1 = System.Diagnostics.FileVersionInfo.GetVersionInfo(fileName);
|
|
|
|
|
return String.Format("{0}{1}{2}", file1.ProductMajorPart, file1.ProductMinorPart, file1.ProductBuildPart);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 区划代码集(330110-余杭区)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<DataDicTionary> GetXZQDic()
|
|
|
|
|
{
|
|
|
|
|
KGIS.Framework.DBOperator.IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string systemPath = SysAppPath.GetDataBasePath() + "System.mdb";
|
|
|
|
|
if (File.Exists(systemPath))
|
|
|
|
|
{
|
|
|
|
|
string connStr = SysConfigsOprator.GetDBConnectionByName("MDBOledbConnection");
|
|
|
|
|
connStr = string.Format(connStr, systemPath);
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper(connStr, DatabaseType.MSAccess);
|
|
|
|
|
string strPrWhere = "1=2";
|
|
|
|
|
string strWhere = string.Empty;
|
|
|
|
|
if (Codes != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in Codes)
|
|
|
|
|
{
|
|
|
|
|
string likeVal = item;
|
|
|
|
|
if (item.EndsWith("0000"))
|
|
|
|
|
{
|
|
|
|
|
likeVal = item.Substring(0, 2);
|
|
|
|
|
strWhere += string.Format(" or XZQ LIKE '{0}%'", likeVal);
|
|
|
|
|
}
|
|
|
|
|
else if (item.EndsWith("00"))
|
|
|
|
|
{
|
|
|
|
|
likeVal = item.Substring(0, 4);
|
|
|
|
|
strWhere += string.Format(" or XZQ LIKE '{0}%'", likeVal);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strWhere += string.Format(" or XZQ LIKE '{0}%'", likeVal);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(strWhere))
|
|
|
|
|
strWhere = strPrWhere + strWhere;
|
|
|
|
|
else
|
|
|
|
|
strWhere = "1=1";
|
|
|
|
|
string strSQL = "select OBJECTID AS ID, XZQ AS CODE,XZQMC AS NAME from XZQ Where " + strWhere + "";
|
|
|
|
|
LogAPI.Debug(strWhere);
|
|
|
|
|
DataTable dt = rdbHelper.ExecuteDatatable("Dic", strSQL, true);
|
|
|
|
|
if (dt != null)
|
|
|
|
|
{
|
|
|
|
|
xzqCoderesult = TBToList.ToList<DataDicTionary>(dt);
|
|
|
|
|
foreach (var item in xzqCoderesult)
|
|
|
|
|
{
|
|
|
|
|
item.DisplayName = item.CODE + "-" + item.NAME;
|
|
|
|
|
if (dt.Rows.Count == 1) txt_Box.DisplayMemberPath = item.DisplayName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
return xzqCoderesult;
|
|
|
|
|
}
|
|
|
|
|
void Init(ProjectInfo pPrj)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<ScaleCodeTable> listScale = new List<ScaleCodeTable>();
|
|
|
|
|
listScale.Add(new ScaleCodeTable() { Scale = "1:2000", ScaleCode = "I" });
|
|
|
|
|
listScale.Add(new ScaleCodeTable() { Scale = "1:5000", ScaleCode = "H" });
|
|
|
|
|
listScale.Add(new ScaleCodeTable() { Scale = "1:10000", ScaleCode = "G" });
|
|
|
|
|
listScale.Add(new ScaleCodeTable() { Scale = "1:25000", ScaleCode = "F" });
|
|
|
|
|
listScale.Add(new ScaleCodeTable() { Scale = "1:50000", ScaleCode = "E" });
|
|
|
|
|
listScale.Add(new ScaleCodeTable() { Scale = "1:100000", ScaleCode = "D" });
|
|
|
|
|
listScale.Add(new ScaleCodeTable() { Scale = "1:250000", ScaleCode = "C" });
|
|
|
|
|
listScale.Add(new ScaleCodeTable() { Scale = "1:500000", ScaleCode = "B" });
|
|
|
|
|
combScale.ItemsSource = listScale;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(pPrj.ScaleCode))
|
|
|
|
|
{
|
|
|
|
|
combScale.SelectedItem = listScale.FirstOrDefault(x => x.ScaleCode == pPrj.ScaleCode);
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrWhiteSpace(pPrj.ScaleCode))
|
|
|
|
|
{
|
|
|
|
|
combScale.SelectedItem = listScale.FirstOrDefault(x => x.Scale == pPrj.Scale);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
combScale.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<ScaleCodeTable> listResolution = new List<ScaleCodeTable>();
|
|
|
|
|
listResolution.Add(new ScaleCodeTable() { Scale = "万分之一", ScaleCode = "0.0001" });
|
|
|
|
|
listResolution.Add(new ScaleCodeTable() { Scale = "十万分之一", ScaleCode = "0.00001" });
|
|
|
|
|
combXYResolution.ItemsSource = listResolution;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(pPrj.XYResolution.ToTrim()) && pPrj.XYResolution != 0)
|
|
|
|
|
{
|
|
|
|
|
combXYResolution.SelectedItem = listResolution.FirstOrDefault(x => x.ScaleCode == pPrj.XYResolution.ToTrim());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
combXYResolution.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.PrjFileStr = pPrj.PrjFileStr;
|
|
|
|
|
btnPrjFile.Text = pPrj.GetPRJName();
|
|
|
|
|
if (_workCatalog != null && _workCatalog.SaveWorkSapcePath != "")
|
|
|
|
|
pPrj.ProjDir = _workCatalog.SaveWorkSapcePath;
|
|
|
|
|
this.DataContext = pPrj;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("加载新建工程页面数据时失败,异常原因: " + ex.Message + " ; ");
|
|
|
|
|
MessageHelper.ShowTips(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Validate(object sender, DevExpress.Xpf.Editors.ValidationEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Value != null)
|
|
|
|
|
{
|
|
|
|
|
if (e.Value is string)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(e.Value as string))
|
|
|
|
|
{
|
|
|
|
|
e.IsValid = false;
|
|
|
|
|
e.ErrorContent = "值不能为空";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (e.Value is float || e.Value is double || e.Value is Int32 || e.Value is decimal)
|
|
|
|
|
{
|
|
|
|
|
double db = Convert.ToDouble(e.Value);
|
|
|
|
|
if (db == 0)
|
|
|
|
|
{
|
|
|
|
|
e.IsValid = false;
|
|
|
|
|
e.ErrorContent = "值不能为0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
e.IsValid = false;
|
|
|
|
|
e.ErrorContent = "值不能为空";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选择工程目录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btnSelectedPrjDir_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FolderBrowserDialog m_Dialog = new FolderBrowserDialog();
|
|
|
|
|
System.Windows.Forms.DialogResult result = m_Dialog.ShowDialog();
|
|
|
|
|
if (result == System.Windows.Forms.DialogResult.Cancel) return;
|
|
|
|
|
string m_Dir = m_Dialog.SelectedPath.Trim();
|
|
|
|
|
this.btnPrjDir.Text = m_Dir;//工程路径
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新建工程页面中-选择工程目录时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
MessageHelper.ShowTips("操作异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作目录文件夹复制
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sourceDir">原文件夹</param>
|
|
|
|
|
/// <param name="targetDirPath">目标目录</param>
|
|
|
|
|
/// <returns>是否成功复制</returns>
|
|
|
|
|
private void DirectoryCopys(string targetDirPath, string xzqCode_Name)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string targetDir = targetDirPath + "\\" + xzqCode_Name;
|
|
|
|
|
//创建工程目录文件
|
|
|
|
|
if (!Directory.Exists(targetDir)) Directory.CreateDirectory(targetDir);
|
|
|
|
|
string folderName = string.Empty;
|
|
|
|
|
Directory.CreateDirectory(targetDir + "\\举证成果");
|
|
|
|
|
Directory.CreateDirectory(targetDir + "\\参考数据");
|
|
|
|
|
Directory.CreateDirectory(targetDir + "\\工程目录");
|
|
|
|
|
Directory.CreateDirectory(targetDir + "\\年初数据");
|
|
|
|
|
Directory.CreateDirectory(targetDir + "\\变更成果");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("创建工程目录页面中,文件夹复制时失败,异常原因: " + ex.Message + " ; ");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void btnPrjFilePath_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
|
|
|
openFileDialog.InitialDirectory = System.IO.Path.Combine(SysAppPath.GetCurrentAppPath(), @"CGCS2000");
|
|
|
|
|
openFileDialog.Filter = "prj Files(*.prj)|*.prj";
|
|
|
|
|
openFileDialog.Multiselect = false;
|
|
|
|
|
if (openFileDialog.ShowDialog())
|
|
|
|
|
{
|
|
|
|
|
ISpatialReference spatialReference = GetSpatialReference(openFileDialog.FileName);
|
|
|
|
|
SetPRJBySp(spatialReference);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新建工程 页面 中 选择坐标系 时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
MessageHelper.ShowTips("选择坐标参考异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnPrjFilePath_Click2(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IGeoDataset s = GetGisFileSource();
|
|
|
|
|
if (s == null || s.SpatialReference == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SetPRJBySp(s.SpatialReference);
|
|
|
|
|
if (s != null)
|
|
|
|
|
Marshal.ReleaseComObject(s);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新建工程 页面 中 导入坐标系 时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
MessageHelper.ShowTips("导入坐标参考系异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ISpatialReference GetSpatialReference(string prjFile)
|
|
|
|
|
{
|
|
|
|
|
//创建一个要素集创建一个投影
|
|
|
|
|
ISpatialReferenceFactory pSpatialRefFac = new SpatialReferenceEnvironmentClass();
|
|
|
|
|
ISpatialReference spatialReference = pSpatialRefFac.CreateESRISpatialReferenceFromPRJFile(prjFile);
|
|
|
|
|
return spatialReference;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetPRJBySp(ISpatialReference spatialReference)
|
|
|
|
|
{
|
|
|
|
|
int t;
|
|
|
|
|
string spatialrefstr = string.Empty;
|
|
|
|
|
IESRISpatialReferenceGEN2 prjsr = spatialReference as IESRISpatialReferenceGEN2;
|
|
|
|
|
prjsr.ExportToESRISpatialReference2(out spatialrefstr, out t);
|
|
|
|
|
PrjFileStr = spatialrefstr;
|
|
|
|
|
string beginstr = "[";
|
|
|
|
|
int leftindex = spatialrefstr.IndexOf(beginstr) + beginstr.Length;
|
|
|
|
|
string spatialrefrightstr = spatialrefstr.Substring(leftindex);
|
|
|
|
|
int length = spatialrefrightstr.IndexOf(",");
|
|
|
|
|
|
|
|
|
|
btnPrjFile.Text = spatialrefrightstr.Substring(0, length).Replace("\"", "");
|
|
|
|
|
|
|
|
|
|
if (btnPrjFile.Text.ToTrim().ToLower().Contains("3_degree"))
|
|
|
|
|
{
|
|
|
|
|
this.txtFDD.Text = "3";
|
|
|
|
|
//3度分带
|
|
|
|
|
//combFD.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (btnPrjFile.Text.ToTrim().ToLower().Contains("6_degree"))
|
|
|
|
|
{
|
|
|
|
|
this.txtFDD.Text = "6";
|
|
|
|
|
//6度分带
|
|
|
|
|
//combFD.SelectedIndex = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.txtFDD.Text = "0";
|
|
|
|
|
}
|
|
|
|
|
//获取中央经线
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
txtZYJD.Text = "0";
|
|
|
|
|
beginstr = "Central_Meridian";
|
|
|
|
|
leftindex = spatialrefstr.IndexOf(beginstr) + beginstr.Length;
|
|
|
|
|
if (leftindex > beginstr.Length)
|
|
|
|
|
{
|
|
|
|
|
spatialrefrightstr = spatialrefstr.Substring(leftindex);
|
|
|
|
|
length = spatialrefrightstr.IndexOf("]");
|
|
|
|
|
double p1 = double.Parse(spatialrefrightstr.Substring(0, length).Split(',')[1]);
|
|
|
|
|
txtZYJD.Text = p1.ToTrim();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex1)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新建工程 页面 中 设置项目坐标系 过程中 获取中央经线 时失败,异常原因: " + ex1 + " ; ");
|
|
|
|
|
}
|
|
|
|
|
//获取图形带号
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string str_spTXDH = "0";
|
|
|
|
|
spTXDH.Text = "0";
|
|
|
|
|
beginstr = "False_Easting";
|
|
|
|
|
leftindex = spatialrefstr.IndexOf(beginstr) + beginstr.Length;
|
|
|
|
|
if (leftindex > beginstr.Length)
|
|
|
|
|
{
|
|
|
|
|
spatialrefrightstr = spatialrefstr.Substring(leftindex);
|
|
|
|
|
length = spatialrefrightstr.IndexOf("]");
|
|
|
|
|
string p7 = spatialrefrightstr.Substring(0, length).Split(',')[1];
|
|
|
|
|
//原方法强行转化有问题
|
|
|
|
|
//spTXDH.Text = int.Parse(p7.Replace("500000.0", "")).ToString();
|
|
|
|
|
string sTemp_1 = p7.Replace("500000.0", "");
|
|
|
|
|
int iTemp_1;
|
|
|
|
|
if (ExtendMethd.JudgeIsCouldConversionInt(sTemp_1) == true)
|
|
|
|
|
{
|
|
|
|
|
iTemp_1 = int.Parse(sTemp_1);
|
|
|
|
|
str_spTXDH = iTemp_1.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str_spTXDH = "0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str_spTXDH = "0";
|
|
|
|
|
}
|
|
|
|
|
spTXDH.Text = str_spTXDH;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex2)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新建工程 页面 中 设置项目坐标系 过程中 获取图形带号 时失败,异常原因: " + ex2 + " ; ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IGeoDataset GetGisFileSource()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OpenDataDialog pDialog = new OpenDataDialog();
|
|
|
|
|
ISpatialDataObjectFilter pOFilter;
|
|
|
|
|
pOFilter = new FilterDatasetsAndLayers();
|
|
|
|
|
pDialog.AddFilter(pOFilter, true);
|
|
|
|
|
pDialog.Title = "选择矢量图层数据";
|
|
|
|
|
pDialog.AllowMultiSelect = false;
|
|
|
|
|
pDialog.RestoreLocation = true;
|
|
|
|
|
pDialog.StartLocation = pDialog.FinalLocation;
|
|
|
|
|
if (pDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (ISpatialDataObject distObj in pDialog.Selection)
|
|
|
|
|
{
|
|
|
|
|
if (distObj.DatasetType == esriDatasetType.esriDTFeatureClass)
|
|
|
|
|
{
|
|
|
|
|
return (distObj.DatasetName as ESRI.ArcGIS.esriSystem.IName).Open() as IGeoDataset;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新建工程页面中获取GIS文件源时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建新工程
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void BtnOK_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
btnOK.IsEnabled = false;
|
|
|
|
|
btnCanel.IsEnabled = false;
|
|
|
|
|
//关闭前关闭所有的未关闭的窗体
|
|
|
|
|
m_ViewManager = Platform.Instance.ViewManager;
|
|
|
|
|
//m_ViewManager.CloseAllDocument();
|
|
|
|
|
//m_ViewManager.CloseAllPanel();
|
|
|
|
|
ProjectInfo ProInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
|
|
|
|
|
if (ProInfo != null && ProInfo.ProjType == EnumProjType.BHTBTQ && Platform.Instance.SystemType == SystemTypeEnum.BGFWCG)
|
|
|
|
|
{
|
|
|
|
|
IUcZYQMagrHelper ucZYQMagrHelper = BundleRuntime.Instance.GetFirstOrDefaultService<IUcZYQMagrHelper>();
|
|
|
|
|
if (ucZYQMagrHelper != null)
|
|
|
|
|
{
|
|
|
|
|
ucZYQMagrHelper.ClearData();
|
|
|
|
|
}
|
|
|
|
|
IUcMulitMapControlHelper ucMulitMapControlHelper = BundleRuntime.Instance.GetFirstOrDefaultService<IUcMulitMapControlHelper>();
|
|
|
|
|
if (ucMulitMapControlHelper != null)
|
|
|
|
|
{
|
|
|
|
|
ucMulitMapControlHelper.ClearData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MapsManager.Instance.MapService.CloseProject();
|
|
|
|
|
KGIS.Framework.Platform.Helper.ProgressHelper.ShowProcessBar("工程创建中……");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(PrjFileStr))
|
|
|
|
|
{
|
|
|
|
|
KGIS.Framework.Platform.Helper.ProgressHelper.CloseProcessBar();
|
|
|
|
|
MessageHelper.ShowTips("请指定坐标系!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((combScale.SelectedItem as ScaleCodeTable) == null)
|
|
|
|
|
{
|
|
|
|
|
KGIS.Framework.Platform.Helper.ProgressHelper.CloseProcessBar();
|
|
|
|
|
MessageHelper.ShowTips("请选择比例尺!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (xzqCoderesult.FirstOrDefault(x => x.CODE == txt_Box.SelectedValue.ToTrim()) == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("请选择正确的区县代码");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ProjectInfo pro = this.DataContext as ProjectInfo;
|
|
|
|
|
pro.CODE = txt_Box.SelectedValue.ToTrim();
|
|
|
|
|
pro.FDD = txtFDD.Text;
|
|
|
|
|
pro.Scale = (combScale.SelectedItem as ScaleCodeTable).Scale;
|
|
|
|
|
pro.ScaleCode = (combScale.SelectedItem as ScaleCodeTable).ScaleCode;
|
|
|
|
|
pro.XYResolution = (combXYResolution.SelectedItem as ScaleCodeTable).ScaleCode.ToDouble();
|
|
|
|
|
//pro.CurrentScheme = pro.DefaultScheme;
|
|
|
|
|
//if (pro.SchemeList == null)
|
|
|
|
|
// pro.SchemeList = new List<string>();
|
|
|
|
|
//pro.SchemeList.Add(pro.DefaultScheme);
|
|
|
|
|
pro.ProjSuffix = ".KBG";
|
|
|
|
|
pro.PrjFileStr = PrjFileStr;
|
|
|
|
|
pro.TXDH = Convert.ToInt16(spTXDH.Text);
|
|
|
|
|
pro.ZYJD = Convert.ToInt16(txtZYJD.Text);
|
|
|
|
|
//设置工作目录下的工程目录
|
|
|
|
|
string dispalyName = xzqCoderesult.FirstOrDefault(x => x.CODE == txt_Box.SelectedValue.ToTrim()).NAME;
|
|
|
|
|
string itemType = string.Format("{0}({1})", dispalyName, txt_Box.SelectedValue.ToTrim());//作为工作目录次级目录文件夹
|
|
|
|
|
pro.ProWorkDir = itemType;// btnPrjDir.Text.ToString();//工作目录工程文件夹
|
|
|
|
|
pro.ProjDir = System.IO.Path.Combine(btnPrjDir.Text.ToString(), itemType + "\\工程目录\\" + pro.ProjName);
|
|
|
|
|
//存放年初数据文件夹路径
|
|
|
|
|
//pro.JCKPath = System.IO.Path.Combine(btnPrjDir.Text.ToString(), itemType + "\\年初数据");
|
|
|
|
|
//设置举证成果的文件夹路径
|
|
|
|
|
pro.DBPath = System.IO.Path.Combine(btnPrjDir.Text.ToString(), itemType + "\\举证成果");
|
|
|
|
|
pro.BGResultPath = System.IO.Path.Combine(btnPrjDir.Text.ToString(), itemType + "\\变更成果");
|
|
|
|
|
#region 工程信息增加
|
|
|
|
|
string s = projType.Tag.ToTrim();// (projectType.SelectedItem as ComboBoxItem).Tag.ToTrim();
|
|
|
|
|
pro.ProjType = (EnumProjType)System.Enum.Parse(typeof(EnumProjType), s);
|
|
|
|
|
if (ListZLXXInfo.Count == 1 && ListZLXXInfo.FirstOrDefault().ID == 0)
|
|
|
|
|
ListZLXXInfo.Clear();
|
|
|
|
|
pro.ListZLXXInfo = ListZLXXInfo;
|
|
|
|
|
pro.DR_CJDCQPath = btnCJDCQPath.Text;
|
|
|
|
|
pro.DR_XZQPath = btnXZQPath.Text;
|
|
|
|
|
pro.DR_CZCPath = btnczcPath.Text;
|
|
|
|
|
pro.XZQDMChange = cb_XZQDMChange.IsChecked == true;
|
|
|
|
|
pro.ZLDWMCChange = cb_ZLDWMCChange.IsChecked == true;
|
|
|
|
|
#endregion
|
|
|
|
|
Setworkapacepath = btnPrjDir.Text.ToString();
|
|
|
|
|
DirectoryCopys(Setworkapacepath, itemType);
|
|
|
|
|
ClearKCDLSXData();
|
|
|
|
|
#region 验证:依据配置记录中的地址遍历去验证发现如果工程文件不在的就把记录删掉
|
|
|
|
|
SysConfigsOprator configOp = new SysConfigsOprator();
|
|
|
|
|
int iDelFailCount_Temp = 0;
|
|
|
|
|
string strRecentOpenProjectRecordXmlPath = Setworkapacepath + "\\RecentWorkCatalogRecord.xml";
|
|
|
|
|
if (File.Exists(strRecentOpenProjectRecordXmlPath) == true)
|
|
|
|
|
{
|
|
|
|
|
List<string> iInvalidPathXMLList = configOp.GetExcludeInvalidRecentOpenProjectRecordXmlMsg(strRecentOpenProjectRecordXmlPath);
|
|
|
|
|
if (iInvalidPathXMLList != null && iInvalidPathXMLList.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
bool bDelTemp = false;
|
|
|
|
|
for (int ut = 0; ut < iInvalidPathXMLList.Count(); ut++)
|
|
|
|
|
{
|
|
|
|
|
bDelTemp = configOp.DeleteProjectFileOpenTime(strRecentOpenProjectRecordXmlPath, iInvalidPathXMLList[ut]);
|
|
|
|
|
if (bDelTemp == false)
|
|
|
|
|
{
|
|
|
|
|
iDelFailCount_Temp += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (iDelFailCount_Temp > 0)
|
|
|
|
|
LogAPI.Debug("依据配置记录中的地址遍历去验证发现如果KBG文件不在的就把记录删掉 时失败,请排查 ; ");
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//验证同名工程是否存在
|
|
|
|
|
if (!Directory.Exists(pro.ProjDir))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(pro.ProjDir);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
KGIS.Framework.Platform.Helper.ProgressHelper.CloseProcessBar();
|
|
|
|
|
MessageHelper.ShowTips("当前目录下已存在同名工程!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string strMxdPath = string.Empty;
|
|
|
|
|
if (pro.ProjSuffix == ".KBG")
|
|
|
|
|
{
|
|
|
|
|
//strMxdPath = SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\KBG.MOD";
|
|
|
|
|
if (pro.ProjType == EnumProjType.BHTBTQ)
|
|
|
|
|
{
|
|
|
|
|
DirectoryCopy(SysAppPath.GetCurrentAppPath() + string.Format("工作空间\\模板\\新建变更工程\\{0}\\BHDB.gdb", (int)Math.Floor(Math.Round(10 / pro.XYResolution))), pro.ProjDir);
|
|
|
|
|
strMxdPath = SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\LatersToXMLForBHTBTQ.xml";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strMxdPath = SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\LatersToXML.xml";
|
|
|
|
|
//DirectoryCopy(SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\成果导出", pro.ProjDir);
|
|
|
|
|
DirectoryCopy(SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\变更成果模板", pro.ProjDir + "\\变更成果模板", true);
|
|
|
|
|
File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\ReportData.db", pro.ProjDir + "\\ReportData.db");
|
|
|
|
|
File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\dic.mdb", pro.ProjDir + "\\dic.mdb");
|
|
|
|
|
File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\DataCheckrResult.db", pro.ProjDir + "\\DataCheckrResult.db");
|
|
|
|
|
File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\BGTJ.sqlite", pro.ProjDir + "\\BGTJ.sqlite");
|
|
|
|
|
File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\变更成果检查.xls", pro.ProjDir + "\\变更成果检查.xls");
|
|
|
|
|
File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\检查数据.xls", pro.ProjDir + "\\检查数据.xls");
|
|
|
|
|
File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\新建变更工程\\土地变更一览表.xls", pro.ProjDir + "\\土地变更一览表.xls");
|
|
|
|
|
pro.DataBaseName = "PrjDB.gdb";
|
|
|
|
|
}
|
|
|
|
|
//FileInfo file = new FileInfo(strMxdPath);
|
|
|
|
|
//FileStream fileStream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None);
|
|
|
|
|
//byte[] bytes = new byte[fileStream.Length];
|
|
|
|
|
//fileStream.Read(bytes, 0, bytes.Length);
|
|
|
|
|
//fileStream.Close();
|
|
|
|
|
|
|
|
|
|
LayerCfg StrLayerInfo = SerializeAPI.DeserializeToObject2<LayerCfg>(strMxdPath);
|
|
|
|
|
StrLayerInfo.LayerName = pro.ProjName;
|
|
|
|
|
Byte[] bytearr = System.Text.Encoding.Default.GetBytes(SerializeAPI.SerializeToXML<LayerCfg>(StrLayerInfo));
|
|
|
|
|
string strBase64 = Convert.ToBase64String(bytearr);
|
|
|
|
|
pro.TempData = strBase64;
|
|
|
|
|
Platform.Instance.Progress.SetWorkPath(System.IO.Path.GetDirectoryName(pro.ProjDir));
|
|
|
|
|
//设置坐标系
|
|
|
|
|
if (pro.ProjType == EnumProjType.BHTBTQ)
|
|
|
|
|
{
|
|
|
|
|
string BhDatabase = System.IO.Path.Combine(pro.ProjDir, "BHDB.gdb");
|
|
|
|
|
IWorkspaceAPI wsAPI = new WorkspaceAPI(BhDatabase, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
//GeoDBAPI.SetGeoDatasetSpatialReference(wsAPI.CurrentWorkspace, MapsManager.Instance.MapService.getAxMapControl().SpatialReference, pro.XYResolution);
|
|
|
|
|
ISpatialReference reference = GetCurentProjectedCoordinate();
|
|
|
|
|
GeoDBAPI.SetGeoDatasetSpatialReference(wsAPI.CurrentWorkspace, reference, pro.XYResolution);
|
|
|
|
|
wsAPI.CloseWorkspace();
|
|
|
|
|
}
|
|
|
|
|
if (pro.Save())
|
|
|
|
|
{
|
|
|
|
|
#region 设置坐标系
|
|
|
|
|
//string PrjDBPath = pro.GetProjDBPath();
|
|
|
|
|
//string SchemeDBPath = pro.GetSchemeDBPath();
|
|
|
|
|
//List<string> dbPaths = new List<string>() { PrjDBPath, SchemeDBPath };
|
|
|
|
|
//foreach (var dbPath in dbPaths)
|
|
|
|
|
//{
|
|
|
|
|
// if (!string.IsNullOrWhiteSpace(dbPath) && (File.Exists(dbPath) || Directory.Exists(dbPath)))
|
|
|
|
|
// {
|
|
|
|
|
// if (dbPath.EndsWith(".gdb"))
|
|
|
|
|
// {
|
|
|
|
|
// wsAPI = new WorkspaceAPI(dbPath, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.GDBFile);
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// wsAPI = new WorkspaceAPI(dbPath, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.MDBFile);
|
|
|
|
|
// }
|
|
|
|
|
// if (wsAPI != null)
|
|
|
|
|
// {
|
|
|
|
|
// ISpatialReference reference = GetCurentProjectedCoordinate();
|
|
|
|
|
// double Tolerance = 0.0001;
|
|
|
|
|
// string ToleranceCfg = "";
|
|
|
|
|
// if (!string.IsNullOrWhiteSpace(ToleranceCfg))
|
|
|
|
|
// {
|
|
|
|
|
// if (!double.TryParse(ToleranceCfg, out Tolerance))
|
|
|
|
|
// {
|
|
|
|
|
// Tolerance = 0.0001;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// GeoDBAPI.SetGeoDatasetSpatialReference(wsAPI.CurrentWorkspace, reference, Tolerance);
|
|
|
|
|
// //设置坐标参考精度XYUnits 为二万分之一
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// wsAPI.CurrentWorkspace.ExecuteSQL(string.Format("UPDATE GDB_SpatialRefs SET XYUnits = 20000 ,XYTolerance = {0}", Tolerance));
|
|
|
|
|
// }
|
|
|
|
|
// catch (Exception ex)
|
|
|
|
|
// {
|
|
|
|
|
// LogAPI.Debug("新建工程页面中,设置坐标参考坐标精度和容差异常时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
// throw new Exception("设置坐标参考坐标精度和容差异常:" + ex.Message);
|
|
|
|
|
// }
|
|
|
|
|
// wsAPI.CloseWorkspace();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
IMapService mapService = MapsManager.Instance.MapService;
|
|
|
|
|
|
|
|
|
|
//设置工作目录时同时会加载
|
|
|
|
|
mapService.LoadProject(pro.ProjDir + "\\" + pro.ProjName + pro.ProjSuffix);
|
|
|
|
|
mapService.SetFolderPath(pro.ProjDir);//获取工程目录路径
|
|
|
|
|
Platform.Instance.ViewManager.SetFilePath(pro.ProjDir);
|
|
|
|
|
Platform.Instance.AppMenuManager.HideAppMenu();
|
|
|
|
|
|
|
|
|
|
#region 创建系统配置文件
|
|
|
|
|
//if (SystemCfg != null)
|
|
|
|
|
//{
|
|
|
|
|
// string layerConfigsPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "LoadLayersConfig.xml");
|
|
|
|
|
// if (File.Exists(layerConfigsPath))
|
|
|
|
|
// {
|
|
|
|
|
// SystemCfg.BaseLoadCfg = new JCSJLayers();
|
|
|
|
|
// XDocument xDoc = XDocument.Load(layerConfigsPath);
|
|
|
|
|
// XElement configElement = xDoc.Element("LayersConfig");
|
|
|
|
|
// XElement jcsjLayersElment = configElement.Element("JCSJLayers");
|
|
|
|
|
// if (jcsjLayersElment != null)
|
|
|
|
|
// {
|
|
|
|
|
// foreach (XElement item in jcsjLayersElment.Elements("Layer"))
|
|
|
|
|
// {
|
|
|
|
|
// LayerCfg layer = new LayerCfg();
|
|
|
|
|
// layer.LayerName = item.Attribute("Name").Value;
|
|
|
|
|
// //layer.LayerAliasName = item.Attribute("AliasName").Value;
|
|
|
|
|
// //layer.Order = Convert.ToInt32(item.Attribute("Order").Value);
|
|
|
|
|
// layer.Required = item.Attribute("Required").Value.ToLower() == "true" ? true : false;
|
|
|
|
|
// SystemCfg.BaseLoadCfg.LayerInfo.Add(layer);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// SystemCfg.Save();
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
//if (pro.ProjType == EnumProjType.BHTBTQ)
|
|
|
|
|
// CreateBHTBTQ();
|
|
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProject" });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("新建工程失败:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("新建工程时发生异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("异常信息结束。");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
btnOK.IsEnabled = true;
|
|
|
|
|
btnCanel.IsEnabled = true;
|
|
|
|
|
KGIS.Framework.Platform.Helper.ProgressHelper.CloseProcessBar();
|
|
|
|
|
_workCatalog.IsLoadProject = false;
|
|
|
|
|
//重新加载工作目录列表
|
|
|
|
|
_workCatalog.SetWorksapce(Setworkapacepath);
|
|
|
|
|
_workCatalog.IsLoadProject = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建投影坐标系
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pcType">esriSRProjCS4Type</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public ISpatialReference GetCurentProjectedCoordinate()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(PrjFileStr))
|
|
|
|
|
{
|
|
|
|
|
//创建一个要素集创建一个投影
|
|
|
|
|
ISpatialReferenceFactory pSpatialRefFac = new SpatialReferenceEnvironmentClass();
|
|
|
|
|
ISpatialReference pSpatialReference;
|
|
|
|
|
PrjFileStr = PrjFileStr.Replace("'", "\"");
|
|
|
|
|
pSpatialRefFac.CreateESRISpatialReference(PrjFileStr, out pSpatialReference, out int s);
|
|
|
|
|
return pSpatialReference;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("创建投影坐标系失败:" + ex.Message);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 文件夹复制
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sourceDir">原文件夹</param>
|
|
|
|
|
/// <param name="targetDirPath">目标目录</param>
|
|
|
|
|
/// <returns>是否成功复制</returns>
|
|
|
|
|
public bool DirectoryCopy(string sourceDir, string targetDirPath)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(sourceDir)) return false;
|
|
|
|
|
string targetDir = targetDirPath + "\\" + System.IO.Path.GetFileName(sourceDir);
|
|
|
|
|
if (!Directory.Exists(targetDir)) Directory.CreateDirectory(targetDir);
|
|
|
|
|
// 文件及文件夹名称数组
|
|
|
|
|
string[] dirColl = Directory.GetDirectories(sourceDir);
|
|
|
|
|
string[] fileColl = Directory.GetFiles(sourceDir);
|
|
|
|
|
// 便利所有文件
|
|
|
|
|
if (fileColl.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
string fileName;
|
|
|
|
|
foreach (string fileDir in fileColl)
|
|
|
|
|
{
|
|
|
|
|
fileName = System.IO.Path.GetFileName(fileDir);
|
|
|
|
|
File.Copy(sourceDir + "\\" + fileName, targetDir + "\\" + fileName, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 遍历所有文件夹
|
|
|
|
|
if (dirColl.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
string folderName;
|
|
|
|
|
foreach (string dir in dirColl)
|
|
|
|
|
{
|
|
|
|
|
folderName = System.IO.Path.GetFileName(dir);
|
|
|
|
|
// 递归调用
|
|
|
|
|
Directory.CreateDirectory(targetDir + "\\" + folderName);
|
|
|
|
|
DirectoryCopy(dir, targetDir + "\\" + folderName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新建工程页面中,文件夹复制时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
return false;
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 文件夹复制
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sourceDir">原文件夹</param>
|
|
|
|
|
/// <param name="targetDirPath">目标目录</param>
|
|
|
|
|
/// <returns>是否成功复制</returns>
|
|
|
|
|
public bool DirectoryCopy(string sourceDir, string targetDirPath, bool Isfa)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!Directory.Exists(sourceDir)) return false;
|
|
|
|
|
string targetDir = targetDirPath;//+ "\\" + System.IO.Path.GetFileName(sourceDir);
|
|
|
|
|
if (!Directory.Exists(targetDir)) Directory.CreateDirectory(targetDir);
|
|
|
|
|
// 文件及文件夹名称数组
|
|
|
|
|
string[] dirColl = Directory.GetDirectories(sourceDir);
|
|
|
|
|
string[] fileColl = Directory.GetFiles(sourceDir);
|
|
|
|
|
// 便利所有文件
|
|
|
|
|
if (fileColl.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
string fileName;
|
|
|
|
|
foreach (string fileDir in fileColl)
|
|
|
|
|
{
|
|
|
|
|
fileName = System.IO.Path.GetFileName(fileDir);
|
|
|
|
|
File.Copy(sourceDir + "\\" + fileName, targetDir + "\\" + fileName, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 遍历所有文件夹
|
|
|
|
|
if (dirColl.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
string folderName;
|
|
|
|
|
foreach (string dir in dirColl)
|
|
|
|
|
{
|
|
|
|
|
folderName = System.IO.Path.GetFileName(dir);
|
|
|
|
|
// 递归调用
|
|
|
|
|
Directory.CreateDirectory(targetDir + "\\" + folderName);
|
|
|
|
|
DirectoryCopy(dir, targetDir + "\\" + folderName, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新建工程页面中,文件夹复制时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
return false;
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnCanel_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 行政区
|
|
|
|
|
IFeatureClass drqXZQFc = null;
|
|
|
|
|
private void BtnSelectedXZQPath_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string FcPath = string.Empty;
|
|
|
|
|
drqXZQFc = GetSelectionFc(ref FcPath);
|
|
|
|
|
btnXZQPath.Text = FcPath;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 调入村级调查区
|
|
|
|
|
IFeatureClass drqCJDCQFc = null;
|
|
|
|
|
private void BtnSelectedCJDCQPath_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string FcPath = string.Empty;
|
|
|
|
|
drqCJDCQFc = GetSelectionFc(ref FcPath);
|
|
|
|
|
btnCJDCQPath.Text = FcPath;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region GetSelectionFc
|
|
|
|
|
private IFeatureClass GetSelectionFc(ref string strFcPath)
|
|
|
|
|
{
|
|
|
|
|
IFeatureClass result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 获取源数据
|
|
|
|
|
OpenDataDialog pDialog = new OpenDataDialog();
|
|
|
|
|
ISpatialDataObjectFilter pOFilter;
|
|
|
|
|
pOFilter = new FilterFeatureDatasetsAndFeatureClasses();
|
|
|
|
|
pDialog.AddFilter(pOFilter, true);
|
|
|
|
|
pDialog.Title = "选择划调整范围数据";
|
|
|
|
|
pDialog.AllowMultiSelect = false;
|
|
|
|
|
pDialog.RestoreLocation = true;
|
|
|
|
|
pDialog.StartLocation = pDialog.FinalLocation;
|
|
|
|
|
if (pDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
List<ISpatialDataObject> distObj = pDialog.Selection;
|
|
|
|
|
foreach (var obj in distObj)
|
|
|
|
|
{
|
|
|
|
|
if (obj.DatasetType == esriDatasetType.esriDTFeatureClass)
|
|
|
|
|
{
|
|
|
|
|
result = (obj.DatasetName as IName).Open() as IFeatureClass;
|
|
|
|
|
|
|
|
|
|
strFcPath = obj.FullName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("选择数据失败:" + ex.Message.ToString());
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 清空扣除地类系数
|
|
|
|
|
private void ClearKCDLSXData()
|
|
|
|
|
{
|
|
|
|
|
string strPath = SysAppPath.GetBGGDLXConfigPath();
|
|
|
|
|
XDocument xDoc = XDocument.Load(strPath);
|
|
|
|
|
foreach (XElement xElement in xDoc.Descendants("Item"))
|
|
|
|
|
{
|
|
|
|
|
xElement.Attributes("KCDLXS").Single().Value = "0";
|
|
|
|
|
}
|
|
|
|
|
xDoc.Save(strPath);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 删除坐落变更信息
|
|
|
|
|
private void Txt_Delete_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var TextBlock = sender as System.Windows.Controls.TextBlock;
|
|
|
|
|
if (TextBlock != null)
|
|
|
|
|
{
|
|
|
|
|
var Info = ListZLXXInfo.FirstOrDefault(f => f.ID == TextBlock.Tag.ToInt());
|
|
|
|
|
ListZLXXInfo.Remove(Info);
|
|
|
|
|
if (ListZLXXInfo.Count == 0)
|
|
|
|
|
ListZLXXInfo.Add(new ZLXXInfo() { ID = 0 });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("删除坐落信息失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ComboBox_SelectionChanged
|
|
|
|
|
private void ComboBox_SelectionChanged(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
KUI.ComboBox.AutoCompleteBox sender1 = sender as KUI.ComboBox.AutoCompleteBox;
|
|
|
|
|
if (sender1 != null && !string.IsNullOrEmpty(sender1.Text) && sender1.Text.Contains("-"))
|
|
|
|
|
{
|
|
|
|
|
var Default = ListZLXXInfo.Where(x => x.ID == sender1.Tag.ToInt()).FirstOrDefault();
|
|
|
|
|
if (Default != null)
|
|
|
|
|
{
|
|
|
|
|
Default.BGHMC = sender1.Text.Split('-')[1];
|
|
|
|
|
Default.BGHDM = sender1.Text.Split('-')[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("ComboBox_SelectionChanged失败:" + ex.Message.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 添加坐落变更信息
|
|
|
|
|
private void Txt_Add_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ListZLXXInfo.Add(new ZLXXInfo()
|
|
|
|
|
{
|
|
|
|
|
ID = ListZLXXInfo.OrderByDescending(x => x.ID).FirstOrDefault() == null ? 0 : ListZLXXInfo.OrderByDescending(x => x.ID).FirstOrDefault().ID + 1,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
IFeatureClass drqCZCFc = null;
|
|
|
|
|
private void btnSelectedCZCPath_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string FcPath = string.Empty;
|
|
|
|
|
drqCZCFc = GetSelectionFc(ref FcPath);
|
|
|
|
|
btnczcPath.Text = FcPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void projectType_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.AddedItems.Count <= 0) return;
|
|
|
|
|
if (DRCJDCQ == null) return;
|
|
|
|
|
if ((e.AddedItems[0] as ComboBoxItem).Content.ToString() == "变化图斑提取类型")
|
|
|
|
|
{
|
|
|
|
|
DRCJDCQ.Visibility = Visibility.Collapsed;
|
|
|
|
|
DRXZQ.Visibility = Visibility.Collapsed;
|
|
|
|
|
DRCZC.Visibility = Visibility.Collapsed;
|
|
|
|
|
ZLBHXX.Visibility = Visibility.Collapsed;
|
|
|
|
|
this.Height = 350;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DRCJDCQ.Visibility = Visibility.Visible;
|
|
|
|
|
DRXZQ.Visibility = Visibility.Visible;
|
|
|
|
|
DRCZC.Visibility = Visibility.Visible;
|
|
|
|
|
ZLBHXX.Visibility = Visibility.Visible;
|
|
|
|
|
this.Height = 660;
|
|
|
|
|
}
|
|
|
|
|
projType.Content = (e.AddedItems[0] as ComboBoxItem).Content;
|
|
|
|
|
projType.Tag = (projectType.SelectedItem as ComboBoxItem).Tag;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|