using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.Geometry; using KGIS.Framework.AE; using KGIS.Framework.AE.Enum; using KGIS.Framework.AE.GPHelper; using KGIS.Framework.Common.Interface; using KGIS.Framework.DBOperator; using KGIS.Framework.Maps; using KGIS.Framework.Platform; using KGIS.Framework.Platform.Helper; using KGIS.Framework.Utils; using KGIS.Framework.Utils.ExtensionMethod; using KGIS.Framework.Utils.Helper; using KGIS.Framework.Utils.Model; using kingo.Plugin.BGResultManager.Interface; using kingo.Plugin.BGResultManager.Utility; using kingo.Plugin.BGResultManager.Utility.Dic; using kingo.Plugin.BGResultManager.Utility.GDB; using kingo.Plugin.BGResultManager.Utility.MDB; using kingo.Plugin.BGResultManager.Utility.Metadata; using Kingo.PluginServiceInterface; using ReactiveUI; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Xml; using UIShell.OSGi; namespace Kingo.Plugin.BGResultManager.ViewModel { public class ExportBGNMKViewModel : ReactiveObject, IScreen { private string _OutDir; public string OutDir { get { return _OutDir; } set { this.RaiseAndSetIfChanged(ref _OutDir, value); } } private string _NMKDir; /// /// 指定的年末库mdb所在地址 /// public string NMKDir { get { return _NMKDir; } set { this.RaiseAndSetIfChanged(ref _NMKDir, value); } } private bool _hasPdt; public bool HasPDT { get { return _hasPdt; } set { this.RaiseAndSetIfChanged(ref _hasPdt, value); } } private bool _IsBL;//是否补充0至19位 public bool IsBL { get { return _IsBL; } set { this.RaiseAndSetIfChanged(ref _IsBL, value); } } private bool _IsHZPC;//是否汇总平差 public bool IsHZPC { get { return _IsHZPC; } set { this.RaiseAndSetIfChanged(ref _IsHZPC, value); } } public List Items { get; set; } /// /// 输出成果根目录 /// public string OutDataRootDir { get; set; } public RoutingState Router { get; } public bool bHasHZPC; public ReactiveCommand ExportClick { get; protected set; } public ExportBGNMKViewModel() { HasPDT = false; IsBL = false; Items = GetResultsCatalog(); ExportClick = ReactiveCommand.Create(); ExportClick.Subscribe(x => { try { if (Items == null) return; NMKDir = string.Empty; IsHZPC = true; if (string.IsNullOrWhiteSpace(OutDir)) { MessageHelper.Show("请选择输出目录!"); return; } ProgressHelper.ShowProcessBar("正在导出......"); OutDataRootDir = Items[0].Name; CreateCatalogDir(Items); ProgressHelper.CloseProcessBar(); MessageHelper.ShowTips("导出完成!"); } catch (Exception ex) { ProgressHelper.CloseProcessBar(); MessageHelper.ShowError("导出失败:" + ex.Message); LogAPI.Debug(ex); } }); } IReportService _ReportService = null; private void CreateCatalogDir(List pCatalog) { try { bHasHZPC = false; if (pCatalog == null) return; List qsDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM); foreach (ResultsCatalog item in pCatalog) { item.Path = item.Path.Replace("县行政区划代码6位", (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE); //白明雅 2019-03-05 比例尺不写死 item.Name = item.Name.Replace("县行政区划代码6位", (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE).Replace("年代代码4位", DateTime.Now.Year.ToString()).Replace("比例尺代码1位", (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ScaleCode); if (item.IsChecked == false) continue; string sPath = string.Empty; switch (item.Type) { case "Directory": ProgressHelper.ShowProcessBar(string.Format("正在创建目录:{0}", item.Name)); sPath = System.IO.Path.Combine(OutDir, item.Path); if (!System.IO.Directory.Exists(sPath)) System.IO.Directory.CreateDirectory(sPath); if (item.SubCatalog != null) CreateCatalogDir(item.SubCatalog); break; case "MetadataFile": sPath = System.IO.Path.Combine(OutDir, item.Path); ProgressHelper.ShowProcessBar(string.Format("正在生成元数据【{0}】", item.Name)); ExportMetadata exportMetadata = new ExportMetadata(); exportMetadata.OutPath = System.IO.Path.GetDirectoryName(sPath); exportMetadata.Scale = new ScaleCodeTable() { Scale = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).Scale, ScaleCode = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ScaleCode }; exportMetadata.Export(); break; case "MDBFile": sPath = System.IO.Path.Combine(OutDir, item.Path); ProgressHelper.ShowProcessBar(string.Format("正在导出【{0}】", item.Name)); ExportMDB exportMDB = new ExportMDB(); exportMDB.OutPath = sPath; exportMDB.Export(true, NMKDir); break; case "CopyMDBFile": try { sPath = System.IO.Path.Combine(OutDir, item.Path); ProgressHelper.ShowProcessBar(string.Format("正在导出【{0}】", item.Name)); //导出年末库MDB NMKDir = sPath; ExportMDB(sPath); } catch (Exception ex) { throw ex; } break; case "CopyGDBFile": try { if (!System.IO.File.Exists(NMKDir)) { throw new Exception("请勾选生成原格式数据!"); } sPath = System.IO.Path.Combine(OutDir, item.Path); ProgressHelper.ShowProcessBar(string.Format("正在导出【{0}】", item.Name)); string sFilePath = System.IO.Path.Combine(OutDir, OutDataRootDir, item.CopyFile, System.IO.Path.GetFileName(sPath)); ExportGDB exportGDB2 = new ExportGDB(); exportGDB2.OutPath = sPath; exportGDB2.Export_PDT(NMKDir);//生成坡度图gdb } catch (Exception ex) { throw ex; } break; case "VCTFile": if (!System.IO.File.Exists(NMKDir)) { throw new Exception("请勾选生成原格式数据!"); } ProgressHelper.ShowProcessBar(string.Format("正在导出【{0}】", item.Name)); sPath = System.IO.Path.Combine(OutDir, item.Path); IVCTExport vctExport = new MDBToVCTWindow(); vctExport.OutPath = System.IO.Path.GetDirectoryName(sPath); vctExport.Scale = new ScaleCodeTable() { Scale = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).Scale, ScaleCode = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ScaleCode }; vctExport.ExportVCT(HasPDT, NMKDir); break; case "OwnerUnitCodeFile": sPath = System.IO.Path.Combine(OutDir, item.Path); ProgressHelper.ShowProcessBar(string.Format("正在导出【{0}】", item.Name)); ExportOwnerUnitCode exportOwnerUnitCode = new ExportOwnerUnitCode(); exportOwnerUnitCode.OutPath = sPath + ".xlsx"; exportOwnerUnitCode.Export(IsBL); break; case "ReportExcel": if (!System.IO.File.Exists(NMKDir)) { throw new Exception("请勾选生成原格式数据!"); } if (bHasHZPC == false) { if (File.Exists(NMKDir)) { sPath = System.IO.Path.Combine(OutDir, Guid.NewGuid().ToTrim() + ".mdb"); File.Copy(NMKDir, sPath); NMKDir = sPath; NMKPC(); bHasHZPC = true; } } ProgressHelper.ShowProcessBar(string.Format("正在导出【{0}】", item.Name)); sPath = System.IO.Path.Combine(OutDir, item.Path); if (_ReportService == null) _ReportService = BundleRuntime.Instance.GetFirstOrDefaultService(); if (_ReportService != null) { _ReportService.ExportBGNMKReport(item.FileType, System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath()) + @"\BGTJ.sqlite", sPath); } else { LogAPI.Debug("未能获取到报表输出服务,无法进行报表输出!"); } break; case "ReportWord": ProgressHelper.ShowProcessBar(string.Format("正在导出【{0}】", item.Name)); sPath = System.IO.Path.Combine(OutDir, item.Path); if (_ReportService == null) _ReportService = BundleRuntime.Instance.GetFirstOrDefaultService(); if (_ReportService != null) { _ReportService.ExportWordReport(item.FileType, sPath); } else { LogAPI.Debug("未能获取到报表输出服务,无法进行报表输出!"); } break; case "ReportShap": sPath = System.IO.Path.Combine(OutDir, item.Path); IWorkspaceAPI wsAPI_1 = new WorkspaceAPI(NMKDir, WorkspaceTypeEnum.MDBFile); IFeatureClassAPI ifeatureClassApi = wsAPI_1.OpenFeatureClass("YJGD"); int index = sPath.LastIndexOf("\\"); var str = sPath.Substring(0, index); FeatureOperator.ExportFeaturesToShp2(ifeatureClassApi.FeatureClass, null, str, "YJGD"); break; default: break; } } bHasHZPC = false; } catch (Exception ex) { throw ex; } } private void ExportMDB(string t_targetPath) { WorkspaceAPI t_WsAPI = null; WorkspaceAPI s_WsAPI = null; IEnumDataset pEnumDataset = null; try { if (File.Exists(t_targetPath)) { File.Delete(t_targetPath); } s_WsAPI = new WorkspaceAPI((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath(), KGIS.Framework.AE.Enum.WorkspaceTypeEnum.GDBFile); //创建mdb CreateFileMDB(t_targetPath, System.IO.Path.GetFileName(t_targetPath)); t_WsAPI = new WorkspaceAPI(t_targetPath, KGIS.Framework.AE.Enum.WorkspaceTypeEnum.MDBFile); pEnumDataset = s_WsAPI.CurrentWorkspace.Datasets[esriDatasetType.esriDTFeatureDataset]; if (pEnumDataset != null) { pEnumDataset.Reset(); IDataset pDataset = null; //如果数据集是IFeatureDataset,则遍历它下面的子类 while ((pDataset = pEnumDataset.Next()) != null) { if (pDataset.BrowseName != "变更成果库") { continue; } IDataset newDataset = null; newDataset = CreateFeatureDataset(pDataset, t_WsAPI); if (newDataset == null) { continue; } List listFeatureClass = new List(); List listFeatureClassNameList = new List(); IEnumDataset ed = pDataset.Subsets; if (ed != null) { IDataset dataset = ed.Next(); while (dataset != null) { if ((dataset as IFeatureClass) != null) { string featureClassName = dataset.BrowseName; if (!string.IsNullOrWhiteSpace(featureClassName) && !listFeatureClass.Contains(featureClassName)) { listFeatureClass.Add(System.IO.Path.Combine(pDataset.Workspace.PathName.ToString(), pDataset.BrowseName, featureClassName)); listFeatureClassNameList.Add(featureClassName); } } System.Runtime.InteropServices.Marshal.FinalReleaseComObject(dataset); dataset = ed.Next(); } } if (listFeatureClass.Count > 0) { //KGIS.Framework.AE.GPHelper.GeoprocessorHelper.FeatureClassToGeodatabase(listFeatureClass, t_targetPath + "\\" + newDataset.BrowseName); //因为原先这个 FeatureClassToGeodatabase 方法不稳定所以采用如下新的处理方式-2020-6-1 沈超 GeoprocessorHelper iGeoprocessorHelper = new GeoprocessorHelper(); //iGeoprocessorHelper.InsertMDBFeatureClassFromGDBFeatureClass((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath(), listFeatureClassNameList, t_targetPath, newDataset.BrowseName, null); } if (newDataset != null) System.Runtime.InteropServices.Marshal.FinalReleaseComObject(newDataset); } } } catch (Exception ex) { throw; } finally { if (t_WsAPI != null) { t_WsAPI.CloseWorkspace(); } if (s_WsAPI != null) { s_WsAPI.CloseWorkspace(); } if (pEnumDataset != null) { Marshal.ReleaseComObject(pEnumDataset); } } } public void ExportFeature(IFeatureClass pInFeatureClass, string pPath) { IWorkspaceFactory pWorkspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass(); string parentPath = pPath.Substring(0, pPath.LastIndexOf('\\')); string fileName = pPath.Substring(pPath.LastIndexOf('\\') + 1, pPath.Length - pPath.LastIndexOf('\\') - 1); //AE.WorkspaceAPI workspaceApi = new WorkspaceAPI(parentPath, AE.Enum.WorkspaceTypeEnum.ShapeFile); //IWorkspaceName pWorkspaceName = workspaceApi.CurrentWorkspace as IWorkspaceName; IWorkspaceName pWorkspaceName = pWorkspaceFactory.Create(parentPath, fileName, null, 0); ESRI.ArcGIS.esriSystem.IName name = (ESRI.ArcGIS.esriSystem.IName)pWorkspaceName; IWorkspace pOutWorkspace = (IWorkspace)name.Open(); IDataset pInDataset = pInFeatureClass as IDataset; IFeatureClassName pInFCName = pInDataset.FullName as IFeatureClassName; IWorkspace pInWorkspace = pInDataset.Workspace; IDataset pOutDataset = pOutWorkspace as IDataset; IWorkspaceName pOutWorkspaceName = pOutDataset.FullName as IWorkspaceName; IFeatureClassName pOutFCName = new FeatureClassNameClass(); IDatasetName pDatasetName = pOutFCName as IDatasetName; pDatasetName.WorkspaceName = pOutWorkspaceName; pDatasetName.Name = "YJGD"; IFieldChecker pFieldChecker = new FieldCheckerClass(); pFieldChecker.InputWorkspace = pInWorkspace; pFieldChecker.ValidateWorkspace = pOutWorkspace; IFields pFields = pInFeatureClass.Fields; IFields pOutFields; IEnumFieldError pEnumFieldError; pFieldChecker.Validate(pFields, out pEnumFieldError, out pOutFields); IFeatureDataConverter pFeatureDataConverter = new FeatureDataConverterClass(); pFeatureDataConverter.ConvertFeatureClass(pInFCName, null, null, pOutFCName, null, pOutFields, "", 100, 0); } #region 年末库平差 /// /// 年末库平差 /// public void NMKPC() { string sNMK_MDBPath = NMKDir; string dbpath = System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath()) + @"\BGTJ.sqlite"; IRDBHelper dbHelper = null; try { dbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbpath, DatabaseType.SQLite); if (IsHZPC == true && !System.IO.File.Exists(sNMK_MDBPath) && !dbHelper.TableIsExist("MJHZJCTJB")) { MessageHelper.ShowTips("请勾选生成原格式数据!"); return; } if (IsHZPC == true || !dbHelper.TableIsExist("MJHZJCTJB")) { dbHelper.DisConnect(); #region 汇总平差 var HZHDLD = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).DCMJ + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).DCMJHD; string connStr = SysConfigsOprator.GetDBConnectionByName("MDBOledbConnection"); string SourcePath = string.Format(connStr, sNMK_MDBPath); //创建数据库连接 dbHelper = RDBFactory.CreateDbHelper(SourcePath, DatabaseType.MSAccess); decimal xjkzmj = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).DCMJ.ToDecimal(2); System.Data.DataTable dt = dbHelper.ExecuteDatatable("cjzmj", "SELECT sum(TBMJ) as TBMJ,sum(KCMJ) as KCMJ,sum(tbdlmj) as TBDLMJ FROM dltb ", true); decimal tbmj = dt.Rows[0]["TBMJ"].ToDecimal(2); decimal kcmj = dt.Rows[0]["KCMJ"].ToDecimal(2); decimal tbdlmj = dt.Rows[0]["TBDLMJ"].ToDecimal(2); if ((kcmj + tbdlmj).ToDecimal(2) != tbmj) { MessageHelper.ShowTips("图斑地类面积与田坎面积之和不等于图斑总面积,不能进行汇总平差!"); return; } if (HZHDLD.ToDecimal(2) != tbmj) { MessageHelper.ShowTips("控制面积平差失败,不能进行汇总平差!"); return; } ProgressHelper.ShowProcessBar("正在汇总平差..."); dbHelper.DisConnect(); GeoDBAPI.CompactAccessDataBaseByWorkspace(null, sNMK_MDBPath); string dir = System.IO.Path.Combine(SysAppPath.GetCurrentAppPath(), "TempCache"); var path = System.IO.Path.Combine(dir, Guid.NewGuid().ToString().Split('-')[0] + ".mdb"); if (!System.IO.Directory.Exists(dir)) { System.IO.Directory.CreateDirectory(dir); } if (!System.IO.File.Exists(path)) { System.IO.File.Copy(SysAppPath.GetCurrentAppPath() + "工作空间\\模板\\临时文件\\TempMDB.mdb", path, true); } if (_ReportService == null) _ReportService = BundleRuntime.Instance.GetFirstOrDefaultService(); if (_ReportService != null) { _ReportService.InitMJHZJCTJBData(sNMK_MDBPath, path); } else { LogAPI.Debug("未能获取到报表输出服务,无法进行报表输出!"); } } ProgressHelper.CloseProcessBar(); try { GeoDBAPI.CompactAccessDataBaseByWorkspace(null, sNMK_MDBPath); } catch (Exception ex_1) { } #endregion } catch (Exception ex) { LogAPI.Debug("年末库平差失败,异常原因: " + ex + " ; "); ProgressHelper.CloseProcessBar(); MessageHelper.ShowError("汇总平差错误:" + ex.Message); return; } finally { ProgressHelper.CloseProcessBar(); if (dbHelper != null) { dbHelper.DisConnect(); } } } #endregion #region public static List GetResultsCatalog() { List result = new List(); try { XmlDocument doc = new XmlDocument(); string strPath = SysAppPath.GetResultsCataCfgForBGNMKPath(); doc.Load(strPath); XmlNode nodeDataCatalog = doc.SelectSingleNode("ResultsCatalog"); if (nodeDataCatalog == null) return result; List qsDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM); foreach (XmlNode item in nodeDataCatalog.ChildNodes) { if (item.Name == "DataCatalog") { ResultsCatalog rootCatalog = new ResultsCatalog(); rootCatalog.Name = item.Attributes["Name"] == null ? "" : item.Attributes["Name"].Value; rootCatalog.Path = rootCatalog.Name; rootCatalog.Type = "Directory"; if (item.ChildNodes != null) { List tree = GetSubCatalog(item, rootCatalog); if (rootCatalog.SubCatalog == null) rootCatalog.SubCatalog = new List(); rootCatalog.SubCatalog.AddRange(tree); } if (qsDic != null) { DataDicTionary dic = qsDic.FirstOrDefault(f => f.CODE.Length == 2); if (dic != null) { rootCatalog.Path = rootCatalog.Path.Replace("*省", dic.NAME); rootCatalog.Name = rootCatalog.Name.Replace("*省", dic.NAME); } dic = qsDic.FirstOrDefault(f => f.CODE.Length == 4); if (dic != null) { rootCatalog.Path = rootCatalog.Path.Replace("*市", dic.NAME); rootCatalog.Name = rootCatalog.Name.Replace("*市", dic.NAME); } dic = qsDic.FirstOrDefault(f => f.CODE == (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE); //dic = qsDic.FindLast(f => == (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE); if (dic != null) { rootCatalog.Path = rootCatalog.Path.Replace("*县", dic.NAME); rootCatalog.Name = rootCatalog.Name.Replace("*县", dic.NAME); } } rootCatalog.Path = rootCatalog.Path.Replace("县行政区划代码6位", (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE); rootCatalog.Name = rootCatalog.Name.Replace("县行政区划代码6位", (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE).Replace("年代代码4位", DateTime.Now.Year.ToString()).Replace("比例尺代码1位", (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ScaleCode); result.Add(rootCatalog); } } return result; } catch (Exception ex) { LogAPI.Debug(ex); throw; } } public static List GetSubCatalog(XmlNode pNode, ResultsCatalog pCatalog) { List result = new List(); if (pNode != null && pNode.ChildNodes != null) { string sPName = pNode.Attributes["Name"] == null ? "" : pNode.Attributes["Name"].Value.ToString(); sPName = sPName.Replace("县行政区划代码6位", (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE).Replace("年代代码4位", DateTime.Now.Year.ToString()).Replace("比例尺代码1位", (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ScaleCode); List qsDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM); if (qsDic != null) { DataDicTionary dic = qsDic.FirstOrDefault(f => f.CODE.Length == 2); if (dic != null) { sPName = sPName.Replace("*省", dic.NAME); } dic = qsDic.FirstOrDefault(f => f.CODE.Length == 4); if (dic != null) { sPName = sPName.Replace("*市", dic.NAME); } dic = qsDic.FirstOrDefault(f => f.CODE == (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE); if (dic != null) { sPName = sPName.Replace("*县", dic.NAME); } } foreach (XmlNode item in pNode.ChildNodes) { ResultsCatalog catalog = new ResultsCatalog(); try { if (item.Attributes != null && item.Attributes["ShowFilter"] != null) { string[] showFilter = item.Attributes["ShowFilter"].Value.ToString().Split('_'); if (!(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE.StartsWith(showFilter[0]) && !sPName.StartsWith(showFilter[1])) { continue; } } catalog.Name = item.Attributes["Name"] == null ? "" : item.Attributes["Name"].Value; catalog.Path = System.IO.Path.Combine(pCatalog.Path, catalog.Name); catalog.CopyFile = item.Attributes["CopyFile"] == null ? "" : item.Attributes["CopyFile"].Value; catalog.Type = item.Name; catalog.Parent = pCatalog; if (qsDic != null) { DataDicTionary dic = qsDic.FirstOrDefault(f => f.CODE.Length == 2); if (dic != null) { catalog.Path = catalog.Path.Replace("*省", dic.NAME); catalog.Name = catalog.Name.Replace("*省", dic.NAME); } dic = qsDic.FirstOrDefault(f => f.CODE.Length == 4); if (dic != null) { catalog.Path = catalog.Path.Replace("*市", dic.NAME); catalog.Name = catalog.Name.Replace("*市", dic.NAME); } dic = qsDic.FirstOrDefault(f => f.CODE == (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE); if (dic != null) { catalog.Path = catalog.Path.Replace("*县", dic.NAME); catalog.Name = catalog.Name.Replace("*县", dic.NAME); } } catalog.Path = catalog.Path.Replace("县行政区划代码6位", (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE); catalog.Name = catalog.Name.Replace("县行政区划代码6位", (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE).Replace("年代代码4位", DateTime.Now.Year.ToString()).Replace("比例尺代码1位", (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ScaleCode); result.Add(catalog); } catch (Exception ex) { } if (item.ChildNodes != null) { if ("ReportExcel,ReportWord".Contains(item.Name)) { ReadAttribute(item, catalog); } else { catalog.SubCatalog = GetSubCatalog(item, catalog); } } } } return result; } private static void ReadAttribute(XmlNode pNode, ResultsCatalog pCatalog) { if (pNode != null && pNode.ChildNodes != null) { foreach (XmlNode item in pNode.ChildNodes) { switch (item.Name) { case "ReportType": pCatalog.FileType = item.InnerText; break; case "TempalateFileName": pCatalog.FileTempalate = item.InnerText; break; default: break; } } } } #endregion /// /// 创建FileMDB /// /// 路径名 public static void CreateFileMDB(string fullPath, string gdbName) { string temp = SysAppPath.GetTemplatePath() + "Temp.mdb"; if (File.Exists(temp)) { File.Copy(temp, fullPath); } } private IFeatureDataset CreateFeatureDataset(IDataset pDataset, KGIS.Framework.AE.WorkspaceAPI workspaceAPI) { try { IFeatureWorkspace targetWorkspac = workspaceAPI.CurrentWorkspace as IFeatureWorkspace; ISpatialReference SpatialReference = new UnknownCoordinateSystemClass(); IControlPrecision2 pCP = SpatialReference as IControlPrecision2; //要素分辨率 ISpatialReferenceResolution spatialReferenceResolution = SpatialReference as ISpatialReferenceResolution; spatialReferenceResolution.set_XYResolution(false, 0.000005); spatialReferenceResolution.set_ZResolution(false, 0.000005); //要素数据集容差 ISpatialReferenceTolerance spatialReferenceTolerance = SpatialReference as ISpatialReferenceTolerance; double tolerance = 0; if (double.TryParse(KGIS.Framework.Utils.SysConfigsOprator.GetAppsetingValueByKey("Tolerance"), out tolerance)) { spatialReferenceTolerance.XYTolerance = tolerance; spatialReferenceTolerance.ZTolerance = tolerance; spatialReferenceTolerance.MTolerance = tolerance; } else { spatialReferenceTolerance.XYTolerance = 0.0001; spatialReferenceTolerance.ZTolerance = 0.0001; spatialReferenceTolerance.MTolerance = 0.0001; } SpatialReference.SetDomain(0, 45035996273.705, 0, 45035996273.705); return targetWorkspac.CreateFeatureDataset("土地调查标准数据集", SpatialReference); } catch (Exception ex) { LogAPI.Debug("异常原因: " + ex + " ; "); throw ex; } } } }