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

914 lines
52 KiB

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using ExcelDataReader;
using KGIS.Framework.AE;
using KGIS.Framework.AE.Enum;
using KGIS.Framework.AE.GaussCalculate;
using KGIS.Framework.AE.GPHelper;
using KGIS.Framework.DBOperator;
using KGIS.Framework.Maps;
using KGIS.Framework.Platform;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.Helper;
using Kingo.Plugin.BGResultManager.Utility;
using Kingo.PluginServiceInterface;
using KUI.Windows;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Xml;
namespace Kingo.Plugin.BGResultManager.View
{
/// <summary>
/// FrmCreateVCTTemplate.xaml 的交互逻辑
/// </summary>
public partial class Exportcultivatedlandreport : BaseWindow
{
public Exportcultivatedlandreport()
{
InitializeComponent();
}
private void btnCreate_Click(object sender, RoutedEventArgs e)
{
string nc_gdxhExcelPath = string.Empty;
string nc_jkhfgchfExcelPath = string.Empty;
IRDBHelper rdbHelper = null;
DataTable dataTable = null;
List<string> ncsjExcels = new List<string>();
try
{
#region 判断表格数据是否存在
if (string.IsNullOrEmpty(txtNCData.Text))
{
MessageHelper.ShowTips("年初表格数据路径为空!");
return;
}
if (string.IsNullOrEmpty(txtsavePath.Text))
{
MessageHelper.ShowTips("请先选择输出路径!");
return;
}
IFeatureClass DLTBGXGC = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBGXGC");
if (DLTBGXGC == null || DLTBGXGC.FeatureCount(null) == 0)
{
MessageHelper.ShowTips("未找到更新过程层数据或更新过程层数据为空,无法导出!");
return;
}
this.ShowLoading("正在导出...", 0, 0);
DirectoryInfo dir = new DirectoryInfo(txtNCData.Text);
FileInfo[] fileSet = dir.GetFiles("(" + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE + ")耕地细化情况统计表.xlsx", SearchOption.AllDirectories);
if (fileSet != null && fileSet.Length > 0)
{
nc_gdxhExcelPath = fileSet[0].FullName;
}
else
{
fileSet = dir.GetFiles("(" + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE + ")耕地细化情况统计表.xls", SearchOption.AllDirectories);
if (fileSet != null && fileSet.Length > 0)
{
nc_gdxhExcelPath = fileSet[0].FullName;
}
}
fileSet = dir.GetFiles("(" + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE + ")即可恢复与工程恢复种植属性汇总统计表.xlsx", SearchOption.AllDirectories);
if (fileSet != null && fileSet.Length > 0)
{
nc_jkhfgchfExcelPath = fileSet[0].FullName;
}
else
{
fileSet = dir.GetFiles("(" + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE + ")即可恢复与工程恢复种植属性汇总统计表.xls", SearchOption.AllDirectories);
if (fileSet != null && fileSet.Length > 0)
{
nc_jkhfgchfExcelPath = fileSet[0].FullName;
}
}
if (string.IsNullOrEmpty(nc_gdxhExcelPath) || string.IsNullOrEmpty(nc_jkhfgchfExcelPath))
{
MessageHelper.ShowTips("未找到年初表格,请核对后在进行导出!");
return;
}
ncsjExcels.Add(nc_gdxhExcelPath);
ncsjExcels.Add(nc_jkhfgchfExcelPath);
#endregion
#region 数据处理
//1.读取年初数据
foreach (var item in ncsjExcels)
{
string dbPath = System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath()) + @"\BGTJ.sqlite";
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
var tableNames = item.Split('\\');
string tableName = tableNames[tableNames.Length - 1].Split('.')[0].ToString();
tableName = tableName.Substring(tableName.IndexOf(')') + 1);
rdbHelper.ExecuteSQL($" drop table {tableName} ");
using (var streamData = File.Open(item, FileMode.Open, FileAccess.Read))
{
using (var readerData = ExcelReaderFactory.CreateReader(streamData))
{
var result = readerData.AsDataSet();
dataTable = result.Tables[0];
Dictionary<string, string> dics = Get_Colunms(dataTable);
CreateTableSql(rdbHelper, tableName, dics);
if (dataTable != null && dataTable.Rows.Count > 0)
{
dataTable = DtSelectTop(10, dataTable);
Insert_sql(dataTable, dics, rdbHelper, tableName);
}
}
}
}
//2.地类图斑那更新过程层与相关专题图层联合
GetUnionResult(rdbHelper, DLTBGXGC);
//3.导出表格并赋值
#region 耕地细化调查情况变化统计表
string tempPath = AppDomain.CurrentDomain.BaseDirectory + "TempalateReports\\BGTJ\\耕地细化调查情况变化统计表.xlsx";
string code = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE;
string savePath = $"{this.txtsavePath.Text}\\({code})耕地细化调查情况变化统计表.xlsx";
File.Copy(tempPath, savePath, true);
DataTable resultdataTable = rdbHelper.ExecuteDatatable("tab", $@"
select '3' Cells_X ,'2'Cells_Y, round(column3,4) BGMJ,'河道湖区耕地'TYPE FROM 耕地细化情况统计表 WHERE column2='{code}'
union all
select '3' Cells_X ,'3'Cells_Y, round(column4,4) BGMJ,'林区耕地'TYPE FROM 耕地细化情况统计表 WHERE column2='{code}'
union all
select '3' Cells_X ,'4'Cells_Y, round(column5,4) BGMJ,'牧区耕地'TYPE FROM 耕地细化情况统计表 WHERE column2='{code}'
union all
select '3' Cells_X ,'5'Cells_Y, round(column6,4) BGMJ,'沙荒耕地'TYPE FROM 耕地细化情况统计表 WHERE column2='{code}'
union all
select '3' Cells_X ,'6'Cells_Y, round(column7,4) BGMJ,'石漠化耕地'TYPE FROM 耕地细化情况统计表 WHERE column2='{code}'
union all
select '3' Cells_X ,'7'Cells_Y, round(column8,4) BGMJ,'盐碱地耕地'TYPE FROM 耕地细化情况统计表 WHERE column2='{code}'
union all
select '7' Cells_X ,'3'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'林区耕地-年内增加' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGQTBXHDM<>'LQGD' or BGQTBXHMC ISNULL) and (BGHTBXHDM='LQGD' or BWLX='LQBW')
union all
select '8' Cells_X ,'3'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'林区耕地-年内减少' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGQTBXHDM='LQGD') and (BGHTBXHDM<>'LQGD' or BGHTBXHDM ISNULL) and BWLX<>'LQBW'
union all
select '7' Cells_X ,'4'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'牧区耕地-年内增加' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGQTBXHDM<>'MQGD' or BGQTBXHMC ISNULL) and (BGHTBXHDM='MQGD' or BWLX='CYBW')
union all
select '8' Cells_X ,'4'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'牧区耕地-年内减少' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGQTBXHDM='MQGD') and (BGHTBXHDM<>'MQGD' or BGHTBXHMC ISNULL) and BWLX<>'CYBW'
union all
select '7' Cells_X ,'5'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'沙荒耕地-年内增加' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL)and (BGHTBXHDM<>'LQGD' and BWLX<>'LQBW' and BGHTBXHDM<>'MQGD' and BWLX<>'CYBW') and (BGQTBXHDM<>'SHGD' or BGQTBXHMC ISNULL) and (BGHTBXHDM='SHGD')
union all
select '8' Cells_X ,'5'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'沙荒耕地-年内减少' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGHTBXHDM<>'LQGD' and BWLX<>'LQBW' and BGHTBXHDM<>'MQGD' and BWLX<>'CYBW') and (BGQTBXHDM='SHGD') and (BGHTBXHDM<>'SHGD')
union all
select '7' Cells_X ,'6'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'石漠化耕地-年内增加' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGHTBXHDM<>'LQGD' and BWLX<>'LQBW' and BGHTBXHDM<>'MQGD' and BWLX<>'CYBW') and (BGQTBXHDM<>'SMGD' or BGQTBXHMC ISNULL) and (BGHTBXHDM='SMGD')
union all
select '8' Cells_X ,'6'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'石漠化耕地-年内减少' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGHTBXHDM<>'LQGD' and BWLX<>'LQBW' and BGHTBXHDM<>'MQGD' and BWLX<>'CYBW') and (BGQTBXHDM='SMGD') and (BGHTBXHDM<>'SMGD' or BGHTBXHDM ISNULL)
union all
select '7' Cells_X ,'2'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'河道湖区耕地-年内增加' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGHTBXHDM<>'LQGD' and BWLX<>'LQBW' and BGHTBXHDM<>'MQGD' and BWLX<>'CYBW' and BGHTBXHDM<>'SMGD' and BGHTBXHDM<>'SHGD') and BGHTBXHDM='HDGD' and (BGQTBXHDM<>'HDGD' or BGQTBXHDM ISNULL )
union all
select '8' Cells_X ,'2'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'河道湖区耕地-年内减少' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGHTBXHDM<>'LQGD' and BWLX<>'LQBW' and BGHTBXHDM<>'MQGD' and BWLX<>'CYBW' and BGHTBXHDM<>'SMGD' and BGHTBXHDM<>'SHGD') and BGQTBXHDM='HDGD' and (BGHTBXHDM<>'HDGD' or BGHTBXHDM ISNULL )
union all
select '7' Cells_X ,'7'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'盐碱地耕地-年内增加' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGHTBXHDM<>'LQGD' and BWLX<>'LQBW' and BGHTBXHDM<>'MQGD' and BWLX<>'CYBW' and BGHTBXHDM<>'SMGD' and BGHTBXHDM<>'SHGD' and BGHTBXHDM<>'HDGD') and BGHTBXHDM='YJGD' and (BGQTBXHDM<>'YJGD' or BGQTBXHDM ISNULL)
union all
select '8' Cells_X ,'7'Cells_Y, round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ,'盐碱地耕地-年内减少' TYPE from BWGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGHTBXHDM<>'LQGD' and BWLX<>'LQBW' and BGHTBXHDM<>'MQGD' and BWLX<>'CYBW' and BGHTBXHDM<>'SMGD' and BGHTBXHDM<>'SHGD' and BGHTBXHDM<>'HDGD') and BGQTBXHDM='YJGD' and (BGHTBXHDM<>'YJGD' or BGHTBXHDM ISNULL) ", true);
CellHelper.SetFileToDisk(resultdataTable, savePath, 0);
CellHelper.Import(savePath);
#endregion
#region 即可恢复与工程恢复种植属性变化统计表
tempPath = AppDomain.CurrentDomain.BaseDirectory + "TempalateReports\\BGTJ\\即可恢复与工程恢复种植属性变化统计表.xlsx";
savePath = $"{this.txtsavePath.Text}\\({(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE})即可恢复与工程恢复种植属性变化统计表.xlsx";
File.Copy(tempPath, savePath, true);
resultdataTable = rdbHelper.ExecuteDatatable("tab", $@"
select '5' Cells_X ,'1'Cells_Y, round(column3,4) BGMJ,'合计'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'2'Cells_Y, round(column4,4) BGMJ,'即可恢复小计'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'3'Cells_Y, round(column5,4) BGMJ,'果园(0201)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'4'Cells_Y, round(column6,4) BGMJ,'可调整果园(0201K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'5'Cells_Y, round(column7,4) BGMJ,'茶园(0202)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'6'Cells_Y, round(column8,4) BGMJ,'可调整茶园(0202K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'7'Cells_Y, round(column9,4) BGMJ,'橡胶园(0203)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'8'Cells_Y, round(column10,4) BGMJ,'可调整橡胶园(0203K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'9'Cells_Y, round(column11,4) BGMJ,'其他园地(0204)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'10'Cells_Y, round(column12,4) BGMJ,'可调整其他园地(0204K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'11'Cells_Y, round(column13,4) BGMJ,'乔木林地(0301)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'12'Cells_Y, round(column14,4) BGMJ,'可调整乔木林地(0301K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'13'Cells_Y, round(column15,4) BGMJ,'竹林地(0302)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'14'Cells_Y, round(column16,4) BGMJ,'可调整竹林地(0302K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'15'Cells_Y, round(column17,4) BGMJ,'灌木林地(0305)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'16'Cells_Y, round(column18,4) BGMJ,'其他林地(0307)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'17'Cells_Y, round(column19,4) BGMJ,'可调整其他林地(0307K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'18'Cells_Y, round(column20,4) BGMJ,'可调整人工牧草地(0403K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'19'Cells_Y, round(column21,4) BGMJ,'其他草地(0404)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'20'Cells_Y, round(column22,4) BGMJ,'坑塘水面(1104)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'21'Cells_Y, round(column23,4) BGMJ,'可调整养殖坑塘(1104K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'22'Cells_Y, round(column24,4) BGMJ,'工程恢复小计'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'23'Cells_Y, round(column25,4) BGMJ,'果园(0201)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'24'Cells_Y, round(column26,4) BGMJ,'可调整果园(0201K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'25'Cells_Y, round(column27,4) BGMJ,'茶园(0202)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'26'Cells_Y, round(column28,4) BGMJ,'可调整茶园(0202K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'27'Cells_Y, round(column29,4) BGMJ,'橡胶园(0203)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'28'Cells_Y, round(column30,4) BGMJ,'可调整橡胶园(0203K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'29'Cells_Y, round(column31,4) BGMJ,'其他园地(0204)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'30'Cells_Y, round(column32,4) BGMJ,'可调整其他园地(0204K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'31'Cells_Y, round(column33,4) BGMJ,'乔木林地(0301)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'32'Cells_Y, round(column34,4) BGMJ,'可调整乔木林地(0301K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'33'Cells_Y, round(column35,4) BGMJ,'竹林地(0302)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'34'Cells_Y, round(column36,4) BGMJ,'可调整竹林地(0302K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'35'Cells_Y, round(column37,4) BGMJ,'灌木林地(0305)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'36'Cells_Y, round(column38,4) BGMJ,'其他林地(0307)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'37'Cells_Y, round(column39,4) BGMJ,'可调整其他林地(0307K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'38'Cells_Y, round(column40,4) BGMJ,'可调整人工牧草地(0403K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'39'Cells_Y, round(column41,4) BGMJ,'其他草地(0404)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'40'Cells_Y, round(column42,4) BGMJ,'坑塘水面(1104)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select '5' Cells_X ,'41'Cells_Y, round(column43,4) BGMJ,'可调整养殖坑塘(1104K)'TYPE FROM 即可恢复与工程恢复种植属性汇总统计表 WHERE column2='{code}'
union all
select Cells_X,Cells_Y, BGMJ,'即可恢复-年内减少' TYPE from
(
select BGQDLBM,round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ from LNGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGQZZSXDM='JKHF') and (BGHZZSXDM<>'JKHF' or BGHZZSXDM ISNULL) GROUP BY BGQDLBM
)a left join JKHFYGCHFZZSXHZTJB b on a.BGQDLBM=b.bgh WHERE b.bgq='年内减少' and TYPE='JKHF'
union all
select Cells_X,Cells_Y, BGMJ,'即可恢复-年内增加' TYPE from
(
select BGHDLBM,round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ from LNGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGHZZSXDM='JKHF') and (BGQZZSXDM<>'JKHF' or BGQZZSXDM ISNULL) GROUP BY BGHDLBM
)a left join JKHFYGCHFZZSXHZTJB b on a.BGHDLBM=b.bgh WHERE b.bgq='年内增加' and TYPE='JKHF'
union all
select Cells_X,Cells_Y, BGMJ,'工程恢复-年内减少' TYPE from
(
select BGQDLBM,round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ from LNGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGQZZSXDM='GCHF') and (BGHZZSXDM<>'GCHF' or BGHZZSXDM ISNULL) GROUP BY BGQDLBM
)a left join JKHFYGCHFZZSXHZTJB b on a.BGQDLBM=b.bgh WHERE b.bgq='年内减少' and TYPE='GCHF'
union all
select Cells_X,Cells_Y, BGMJ,'工程恢复-年内增加' TYPE from
(
select BGHDLBM,round(sum(ifnull(TBBGMJ/10000 + 0.0000001,0)),2) BGMJ from LNGD_Multipart WHERE SUBSTR(BGHDLBM,1,2)='01' and BGHGDPDJB<>'5' and (BGHCZCSXM not in ('201','202','203') or BGHCZCSXM ISNULL) and (BGHZZSXDM='GCHF') and (BGQZZSXDM<>'GCHF' or BGQZZSXDM ISNULL) GROUP BY BGHDLBM
)a left join JKHFYGCHFZZSXHZTJB b on a.BGHDLBM=b.bgh WHERE b.bgq='年内增加' and TYPE='GCHF'", true);
CellHelper.SetFileToDisk(resultdataTable, savePath, 0);
CellHelper.Import(savePath);
#endregion
#endregion
this.CloseLoading();
MessageHelper.ShowTips("导出完成!");
}
catch (Exception ex)
{
LogAPI.Debug(ex);
throw ex;
}
finally
{
this.CloseLoading();
this.Close();
}
}
#region Excel保存至db
public static Dictionary<string, string> Get_Colunms(DataTable dic)
{
Dictionary<string, string> dics = new Dictionary<string, string>();
foreach (DataColumn item in dic.Columns)
{
dics.Add(item.ColumnName, "Varchar");
}
return dics;
}
/// <summary>
/// 创建表
/// </summary>
/// <param name="rdbHelper"></param>
/// <param name="tableName"></param>
/// <param name="table"></param>
protected void CreateTableSql(IRDBHelper rdbHelper, string tableName, Dictionary<string, string> table)
{
string result = string.Empty;
try
{
string temp1 = "CREATE TABLE if not exists " + tableName + "(";
foreach (var item in table)
{
temp1 = temp1 + item.Key.Trim().ToLower() + " " + item.Value + ",";
}
result = temp1.TrimEnd(',') + ");";
rdbHelper.ExecuteNonQueryWithException($" DROP TABLE if exists {tableName}");
rdbHelper.ExecuteNonQueryWithException(result);
}
catch (Exception ex)
{
throw ex;
}
}
public void Insert_sql(DataTable dic, Dictionary<string, string> dics, IRDBHelper SqlHelper, string Table)
{
#region 获取所有字段
StringBuilder columns = new StringBuilder();
foreach (var item in dics)
{
columns.Append("," + item.Key);
}
#endregion
#region 数据入库
int CycleIndex = 0;
StringBuilder insertsql = new StringBuilder();
StringBuilder strsql = new StringBuilder();
StringBuilder stringBuilder = new StringBuilder();
var count = dic.Rows.Count;
foreach (DataRow item0 in dic.Rows)
{
CycleIndex++;
StringBuilder data = new StringBuilder();//insert语句插入字段
foreach (var item1 in dics)
{
if (item0[item1.Key].ToString().Trim() == "")
{
data.Append(",null");
}
else
{
data.Append((",'" + item0[item1.Key].ToString().Trim().Replace("'", "''").Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "") + "'"));
}
}
insertsql.Append(string.Format("insert into " + Table + "({0})values({1});", columns.ToString().Substring(1), data.ToString().Substring(1)));
#region 提交数据
if (count < 10000)
{
if (CycleIndex < count)
{
stringBuilder.Append(insertsql.ToString());
insertsql.Clear();
}
else if (CycleIndex == count)
{
stringBuilder.Append(insertsql.ToString());
var num = SqlHelper.ExecuteNonQuery(stringBuilder.ToString(), CommandType.Text);
if (num < 0 && stringBuilder.ToString() != "")
return;
}
}
else
{
strsql.Append(insertsql.ToString());
insertsql.Clear();
}
if (CycleIndex == 10000)
{
try
{
var num = SqlHelper.ExecuteNonQuery(strsql.ToString(), CommandType.Text);
if (num < 0 && strsql.ToString() != "")
return;
insertsql.Clear();
strsql.Clear();
count = count - CycleIndex;
CycleIndex = 0;
}
catch (Exception exc)
{
throw new Exception(exc.Message);
}
finally
{
GC.Collect();
}
}
#endregion
}
#endregion
}
public static DataTable DtSelectTop(int TopItem, DataTable oDT)
{
if (oDT.Rows.Count < TopItem) return oDT;
DataTable NewTable = oDT.Clone();
DataRow[] rows = oDT.Select("1=1");
for (int i = 0; i < TopItem; i++)
{
NewTable.ImportRow((DataRow)rows[i]);
}
return NewTable;
}
#endregion
#region 地类图斑那更新过程层与相关专题图层联合
private void GetUnionResult(IRDBHelper rdbHelper, IFeatureClass DLTBGXGC)
{
GPParamClass paramClass = null;
IFeatureLayer Temp_Union = null;
IFeatureLayer multipartToSingleFeatureLayer = null;
List<string> sqlList = new List<string>();
ProjectInfo ProjInfo = null;
IWorkspaceFactory pFtWsFct = null;
string TempfilePath = string.Empty;
IFeatureCursor pCursor = null;
try
{
string gdbFolder = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ProjDir + "\\Exportcultivatedlandreport";
if (!Directory.Exists(gdbFolder))
Directory.CreateDirectory(gdbFolder);
try
{ DelectDirect(gdbFolder); }
catch { }
pFtWsFct = new FileGDBWorkspaceFactory();
string gdbFileName = Guid.NewGuid().ToString();
string path = System.IO.Path.Combine(gdbFolder, gdbFileName);
pFtWsFct.Create(path, "Exportcultivatedlandreport", null, 0);
TempfilePath = $"{path}\\Exportcultivatedlandreport.gdb";
ProjInfo = MapsManager.Instance.CurrProjectInfo as ProjectInfo;
string dbPath = System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath()) + @"\BGTJ.sqlite";
IWorkspaceFactory pOutWorkFactory = null;
pOutWorkFactory = new SqlWorkspaceFactoryClass();
IFeature feature = null;
if (BWGDFeatureClass != null)
{
paramClass = new GPParamClass()
{
FirstFeatureLayer = new FeatureLayerClass() { FeatureClass = DLTBGXGC },
SecondFeatureLayer = new FeatureLayerClass() { FeatureClass = BWGDFeatureClass, Name = "BWGD" },
OutFeatureClassPath = $"{TempfilePath}\\BWGD_Union",
IsGetOutPutFeature = true,
PreserveAttributes = "ALL"
};
GeoprocessorHelper.UnionAnalysis(paramClass, ref Temp_Union, ProjInfo.XYResolution.ToString());
if (HHFWFeatureClass != null)
{
paramClass = new GPParamClass()
{
FirstFeatureLayer = Temp_Union,
SecondFeatureLayer = new FeatureLayerClass() { FeatureClass = HHFWFeatureClass },
OutFeatureClassPath = $"{TempfilePath}\\HHFW_Union",
IsGetOutPutFeature = true,
PreserveAttributes = "ALL"
};
}
GeoprocessorHelper.UnionAnalysis(paramClass, ref Temp_Union, ProjInfo.XYResolution.ToString());
paramClass = new GPParamClass();
paramClass.FirstFeatureLayer = Temp_Union;
paramClass.OutFeatureClassPath = $"{TempfilePath}\\BWGD_Multipart";
paramClass.IsGetOutPutFeature = true;
GeoprocessorHelper.MultipartToSinglePath(paramClass, ref multipartToSingleFeatureLayer);
IWorkspace pOutWork = pOutWorkFactory.OpenFromFile(dbPath, 0);
pCursor = multipartToSingleFeatureLayer.FeatureClass.Update(new QueryFilterClass() { SubFields = "OBJECTID,TBBGMJ,SHAPE", WhereClause = " (BGHDLBM='0101' or BGHDLBM='0102' or BGHDLBM='0103') and BGHGDPDJB<>'5' " }, true);
var _itbmj = multipartToSingleFeatureLayer.FeatureClass.FindField("TBBGMJ");
while ((feature = pCursor.NextFeature()) != null)
{
double area = GetEllipseArea(feature.ShapeCopy);
feature.Value[_itbmj] = area;
feature.Store();
}
rdbHelper.ExecuteSQL($" drop table BWGD_Multipart ");
TableToTable((multipartToSingleFeatureLayer.FeatureClass as FeatureClass).Workspace as IFeatureWorkspace, pOutWork, "BWGD_Multipart");
}
else if (HHFWFeatureClass != null)
{
paramClass = new GPParamClass()
{
FirstFeatureLayer = new FeatureLayerClass() { FeatureClass = DLTBGXGC },
SecondFeatureLayer = new FeatureLayerClass() { FeatureClass = HHFWFeatureClass },
OutFeatureClassPath = $"{TempfilePath}\\HHFW_Union",
IsGetOutPutFeature = true,
PreserveAttributes = "ALL"
};
GeoprocessorHelper.UnionAnalysis(paramClass, ref Temp_Union, ProjInfo.XYResolution.ToString());
paramClass = new GPParamClass();
paramClass.FirstFeatureLayer = Temp_Union;
paramClass.OutFeatureClassPath = $"{TempfilePath}\\BWGD_Multipart";
paramClass.IsGetOutPutFeature = true;
GeoprocessorHelper.MultipartToSinglePath(paramClass, ref multipartToSingleFeatureLayer);
IWorkspace pOutWork = pOutWorkFactory.OpenFromFile(dbPath, 0);
pCursor = multipartToSingleFeatureLayer.FeatureClass.Update(new QueryFilterClass() { SubFields = "OBJECTID,TBBGMJ,SHAPE", WhereClause = " (BGHDLBM='0101' or BGHDLBM='0102' or BGHDLBM='0103') and BGHGDPDJB<>'5' " }, true);
var _itbmj = multipartToSingleFeatureLayer.FeatureClass.FindField("TBBGMJ");
while ((feature = pCursor.NextFeature()) != null)
{
double area = GetEllipseArea(feature.ShapeCopy);
feature.Value[_itbmj] = area;
feature.Store();
}
rdbHelper.ExecuteSQL($" drop table BWGD_Multipart ");
TableToTable((multipartToSingleFeatureLayer.FeatureClass as FeatureClass).Workspace as IFeatureWorkspace, pOutWork, "BWGD_Multipart");
}
if (LNGDFeatureClass != null)
{
paramClass = new GPParamClass()
{
FirstFeatureLayer = new FeatureLayerClass() { FeatureClass = DLTBGXGC },
SecondFeatureLayer = new FeatureLayerClass() { FeatureClass = LNGDFeatureClass },
OutFeatureClassPath = $"{TempfilePath}\\LNGD_Union",
IsGetOutPutFeature = true,
PreserveAttributes = "ALL"
};
GeoprocessorHelper.UnionAnalysis(paramClass, ref Temp_Union, ProjInfo.XYResolution.ToString());
paramClass = new GPParamClass();
paramClass.FirstFeatureLayer = Temp_Union;
paramClass.OutFeatureClassPath = $"{TempfilePath}\\LNGD_Multipart";
paramClass.IsGetOutPutFeature = true;
GeoprocessorHelper.MultipartToSinglePath(paramClass, ref multipartToSingleFeatureLayer);
IWorkspace pOutWork = pOutWorkFactory.OpenFromFile(dbPath, 0);
pCursor = multipartToSingleFeatureLayer.FeatureClass.Update(new QueryFilterClass() { SubFields = "OBJECTID,TBBGMJ,SHAPE", WhereClause = " (BGHDLBM='0101' or BGHDLBM='0102' or BGHDLBM='0103') and BGHGDPDJB<>'5' " }, true);
var _itbmj = multipartToSingleFeatureLayer.FeatureClass.FindField("TBBGMJ");
while ((feature = pCursor.NextFeature()) != null)
{
double area = GetEllipseArea(feature.ShapeCopy);
feature.Value[_itbmj] = area;
feature.Store();
}
rdbHelper.ExecuteSQL($" drop table LNGD_Multipart ");
TableToTable((multipartToSingleFeatureLayer.FeatureClass as FeatureClass).Workspace as IFeatureWorkspace, pOutWork, "LNGD_Multipart");
}
}
catch (Exception ex)
{
LogAPI.Debug($"GetUnionResult执行错误:{ex.Message}");
LogAPI.Debug(ex);
}
finally
{
if (Temp_Union != null)
Marshal.ReleaseComObject(Temp_Union);
if (multipartToSingleFeatureLayer != null)
Marshal.ReleaseComObject(multipartToSingleFeatureLayer);
}
}
#endregion
#region DelectDirect
private static void DelectDirect(string srcPath)
{
try
{
DirectoryInfo dir = new DirectoryInfo(srcPath);
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录
foreach (FileSystemInfo i in fileinfo)
{
if (i is DirectoryInfo) //判断是否文件夹
{
DirectoryInfo subdir = new DirectoryInfo(i.FullName);
subdir.Delete(true); //删除子目录和文件
}
else
{
File.Delete(i.FullName); //删除指定文件
}
}
}
catch (Exception e)
{
throw;
}
}
#endregion
public bool TableToTable(IFeatureWorkspace pInWork, IWorkspace pOutWork, string tableName, IQueryFilter queryFilter = null)
{
try
{
if (pInWork == null || pOutWork == null || string.IsNullOrEmpty(tableName)) return false;
IWorkspace2 workspace2 = pInWork as IWorkspace2;
if (workspace2 != null)
{
if (!workspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, tableName))
{
return false;
}
}
ITable pInTable = pInWork.OpenTable(tableName);
if (pInTable == null) return false;
IDataset pIndataset = (IDataset)pInTable;
IDatasetName pInDatasetName = (IDatasetName)pIndataset.FullName;
IEnumDataset enumDataset = pOutWork.get_Datasets(esriDatasetType.esriDTTable);
IDataset dataset;
enumDataset.Reset();
while ((dataset = enumDataset.Next()) != null)
{
string[] names = dataset.Name.Split('.');
if (string.Equals(names[names.Length - 1], tableName, StringComparison.CurrentCultureIgnoreCase))
{
dataset.Delete();
break;
}
}
IDataset pOutDataset = (IDataset)pOutWork;
IDatasetName pOutDatasetName = new TableNameClass();
pOutDatasetName.WorkspaceName = (IWorkspaceName)pOutDataset.FullName;
pOutDatasetName.Name = tableName;
IFieldChecker fieldChecker = new FieldCheckerClass();
IFields targetFeatureClassFields = pInTable.Fields;
IFields sourceFeatureClassFields = pInTable.Fields;
IEnumFieldError enumFieldError;
fieldChecker.InputWorkspace = pInWork as IWorkspace;
fieldChecker.ValidateWorkspace = pOutWork;
fieldChecker.Validate(sourceFeatureClassFields, out enumFieldError, out targetFeatureClassFields);
IFeatureDataConverter one2another = new FeatureDataConverterClass();
try
{
one2another.ConvertTable(pInDatasetName, queryFilter, pOutDatasetName, targetFeatureClassFields, "", 1000, 0);
}
finally
{
Marshal.ReleaseComObject(one2another);
}
return true;
}
catch (Exception ex)
{
//LogAPI.Debug(ex);
throw ex;
}
}
public double GetEllipseArea(IGeometry polygon)
{
try
{
// 1、获得投影
String SphName = polygon.SpatialReference.Name.ToString().ToUpper();
// 2、获得椭球
ICoordinate coordinate = CoordinateFactory.CreateCoordinate();
if (SphName.Contains("XIAN_1980") || SphName.Contains("XIAN1980"))
{
coordinate = CoordinateFactory.CreateCoordinate(KGIS.Framework.AE.GaussCalculate.Spheroid.SphXian80);
}
else if (SphName.Contains("BEIJING_1954") || SphName.Contains("BEIJING1954"))
{
coordinate = CoordinateFactory.CreateCoordinate(KGIS.Framework.AE.GaussCalculate.Spheroid.SphBeijing54);
}
else if (SphName.Contains("WGS_1984") || SphName.Contains("WGS1984"))
{
coordinate = CoordinateFactory.CreateCoordinate(KGIS.Framework.AE.GaussCalculate.Spheroid.SphWGS84);
}
else if (SphName.Contains("CGCS_2000") || SphName.Contains("CGCS2000"))
{
coordinate = CoordinateFactory.CreateCoordinate(KGIS.Framework.AE.GaussCalculate.Spheroid.SphCGCS2000);
}
else
{
return -1;
}
// 3、计算面积
IGeometry pGeometry = polygon as IGeometry;
double PolygonArea = 0.0;
// 4、保留两位小数
PolygonArea = Math.Round(coordinate.CalculateTerranArea(pGeometry), 2, MidpointRounding.AwayFromZero);
return PolygonArea;
}
catch (Exception ex)
{
throw ex;
}
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
//不稳耕地
private IFeatureClass BWGDFeatureClass { get; set; }
//河湖范围
private IFeatureClass HHFWFeatureClass { get; set; }
//历年耕地
private IFeatureClass LNGDFeatureClass { get; set; }
private string BWGDName { get; set; }
private string HHFWName { get; set; }
private string LNGDName { get; set; }
private void btnSelectNCData_Click(object sender, RoutedEventArgs e)
{
try
{
MessageHelper.ShowTips("请选择基础数据汇总表格,如:.../基础数据包");
System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
folderBrowserDialog.Description = "请选择文件夹路径";
folderBrowserDialog.ShowNewFolderButton = true;
if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.LastSelectedFolder) && System.IO.Directory.Exists(Properties.Settings.Default.LastSelectedFolder))
{
folderBrowserDialog.SelectedPath = Properties.Settings.Default.LastSelectedFolder;
}
else
{
folderBrowserDialog.RootFolder = Environment.SpecialFolder.Desktop;
}
if (folderBrowserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
{
return;
}
Properties.Settings.Default.LastSelectedFolder = folderBrowserDialog.SelectedPath.ToString();
Properties.Settings.Default.Save();
if (string.IsNullOrWhiteSpace(folderBrowserDialog.SelectedPath))
{
return;
}
txtNCData.Text = folderBrowserDialog.SelectedPath;
}
catch (System.Exception ex)
{
LogAPI.Debug("选择年初数据表格时异常,异常原因: " + ex + " ; ");
}
}
private void btnSelectZTData_Click(object sender, RoutedEventArgs e)
{
IFeatureClass pFeatureClass = null;
try
{
this.txtBWGDData.Text = string.Empty;
KGIS.Framework.OpenData.Control.OpenDataDialog pDialog = null;
if (pDialog == null)
{
pDialog = new KGIS.Framework.OpenData.Control.OpenDataDialog();
}
KGIS.Framework.OpenData.InterFace.ISpatialDataObjectFilter pOFilter = new KGIS.Framework.OpenData.Filter.FilterShapefiles();
pDialog.AddFilter(pOFilter, true);
pOFilter = new KGIS.Framework.OpenData.Filter.FilterFeatureDatasetsAndFeatureClasses();
pDialog.AddFilter(pOFilter, true);
pDialog.Title = "选择数据源";
pDialog.RestoreLocation = true;
pDialog.StartLocation = pDialog.FinalLocation;
pDialog.AllowMultiSelect = true;
System.Windows.Forms.DialogResult dialogResult = pDialog.ShowDialog();
if (dialogResult == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count != 0)
{
foreach (KGIS.Framework.OpenData.InterFace.ISpatialDataObject distObj in pDialog.Selection)
{
if (distObj.DatasetType == ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureClass)
{
pFeatureClass = (distObj.DatasetName as ESRI.ArcGIS.esriSystem.IName).Open() as IFeatureClass;
if (pFeatureClass != null)
{
BWGDFeatureClass = pFeatureClass;
BWGDName = (pFeatureClass as FeatureClass).BrowseName;
this.txtBWGDData.Text = distObj.FullName;
break;
}
}
}
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
MessageHelper.ShowError("选择图层出现异常:" + ex.Message);
}
}
private void btnsavePath_Click(object sender, RoutedEventArgs e)
{
try
{
System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
folderBrowserDialog.Description = "请选择文件夹路径";
folderBrowserDialog.ShowNewFolderButton = true;
if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.LastSelectedFolder) && System.IO.Directory.Exists(Properties.Settings.Default.LastSelectedFolder))
{
folderBrowserDialog.SelectedPath = Properties.Settings.Default.LastSelectedFolder;
}
else
{
folderBrowserDialog.RootFolder = Environment.SpecialFolder.Desktop;
}
if (folderBrowserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
{
return;
}
Properties.Settings.Default.LastSelectedFolder = folderBrowserDialog.SelectedPath.ToString();
Properties.Settings.Default.Save();
if (string.IsNullOrWhiteSpace(folderBrowserDialog.SelectedPath))
{
return;
}
txtsavePath.Text = folderBrowserDialog.SelectedPath;
}
catch (System.Exception ex)
{
LogAPI.Debug("选择导出路径异常,异常原因: " + ex + " ; ");
}
}
private void btnSelectHHFWData_Click(object sender, RoutedEventArgs e)
{
IFeatureClass pFeatureClass = null;
try
{
this.txtHHFWData.Text = string.Empty;
KGIS.Framework.OpenData.Control.OpenDataDialog pDialog = null;
if (pDialog == null)
{
pDialog = new KGIS.Framework.OpenData.Control.OpenDataDialog();
}
KGIS.Framework.OpenData.InterFace.ISpatialDataObjectFilter pOFilter = new KGIS.Framework.OpenData.Filter.FilterShapefiles();
pDialog.AddFilter(pOFilter, true);
pOFilter = new KGIS.Framework.OpenData.Filter.FilterFeatureDatasetsAndFeatureClasses();
pDialog.AddFilter(pOFilter, true);
pDialog.Title = "选择数据源";
pDialog.RestoreLocation = true;
pDialog.StartLocation = pDialog.FinalLocation;
pDialog.AllowMultiSelect = true;
System.Windows.Forms.DialogResult dialogResult = pDialog.ShowDialog();
if (dialogResult == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count != 0)
{
foreach (KGIS.Framework.OpenData.InterFace.ISpatialDataObject distObj in pDialog.Selection)
{
if (distObj.DatasetType == ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureClass)
{
pFeatureClass = (distObj.DatasetName as ESRI.ArcGIS.esriSystem.IName).Open() as IFeatureClass;
if (pFeatureClass != null)
{
HHFWFeatureClass = pFeatureClass;
HHFWName = (pFeatureClass as FeatureClass).BrowseName;
this.txtHHFWData.Text = distObj.FullName;
break;
}
}
}
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
MessageHelper.ShowError("选择图层出现异常:" + ex.Message);
}
}
private void btnSelectLNGDData_Click(object sender, RoutedEventArgs e)
{
IFeatureClass pFeatureClass = null;
try
{
this.txtLNGDData.Text = string.Empty;
KGIS.Framework.OpenData.Control.OpenDataDialog pDialog = null;
if (pDialog == null)
{
pDialog = new KGIS.Framework.OpenData.Control.OpenDataDialog();
}
KGIS.Framework.OpenData.InterFace.ISpatialDataObjectFilter pOFilter = new KGIS.Framework.OpenData.Filter.FilterShapefiles();
pDialog.AddFilter(pOFilter, true);
pOFilter = new KGIS.Framework.OpenData.Filter.FilterFeatureDatasetsAndFeatureClasses();
pDialog.AddFilter(pOFilter, true);
pDialog.Title = "选择数据源";
pDialog.RestoreLocation = true;
pDialog.StartLocation = pDialog.FinalLocation;
pDialog.AllowMultiSelect = true;
System.Windows.Forms.DialogResult dialogResult = pDialog.ShowDialog();
if (dialogResult == System.Windows.Forms.DialogResult.OK && pDialog.Selection.Count != 0)
{
foreach (KGIS.Framework.OpenData.InterFace.ISpatialDataObject distObj in pDialog.Selection)
{
if (distObj.DatasetType == ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureClass)
{
pFeatureClass = (distObj.DatasetName as ESRI.ArcGIS.esriSystem.IName).Open() as IFeatureClass;
if (pFeatureClass != null)
{
LNGDFeatureClass = pFeatureClass;
LNGDName = (pFeatureClass as FeatureClass).BrowseName;
this.txtLNGDData.Text = distObj.FullName;
break;
}
}
}
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
MessageHelper.ShowError("选择图层出现异常:" + ex.Message);
}
}
}
}