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.
1789 lines
72 KiB
1789 lines
72 KiB
using KGIS.Framework.Common; |
|
using KGIS.Framework.DBOperator; |
|
using KGIS.Framework.Maps; |
|
using KGIS.Framework.Platform; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Utils.Helper; |
|
using Kingo.PluginServiceInterface; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.Data; |
|
using System.IO; |
|
using System.Xml; |
|
|
|
namespace Kingo.Plugin.BGResultManager.Utility |
|
{ |
|
public class BGReportBasicOperate |
|
{ |
|
#region 公用SQL语句 |
|
|
|
public string sSQL_GroupBySelect_BGYLB = @" |
|
select |
|
BGQDLBM, |
|
BGQQSXZ, |
|
BGQZLDWDM, |
|
BGQGDLX, |
|
BGQGDPDJB, |
|
BGQTBXHDM, |
|
BGQZZSXDM, |
|
BGQCZCSXM, |
|
BGQMSSM, |
|
|
|
BGHDLBM, |
|
BGHQSXZ, |
|
BGHZLDWDM, |
|
BGHGDLX, |
|
BGHGDPDJB, |
|
BGHTBXHDM, |
|
BGHZZSXDM, |
|
BGHCZCSXM, |
|
BGHMSSM, |
|
|
|
Sum(BGMJ) as 'BGMJ' |
|
from '{0}' |
|
group by |
|
BGQDLBM,BGHDLBM, |
|
BGQQSXZ,BGHQSXZ, |
|
substr(BGQZLDWDM,1,12),substr(BGHZLDWDM,1,12), |
|
BGQGDLX,BGHGDLX, |
|
BGQGDPDJB,BGHGDPDJB, |
|
BGQTBXHDM,BGHTBXHDM, |
|
BGQZZSXDM,BGHZZSXDM, |
|
BGQCZCSXM,BGHCZCSXM, |
|
BGQMSSM,BGHMSSM |
|
"; |
|
|
|
public string sSQL_GroupBySelect_BGYLB2 = @" |
|
select |
|
BGQDLBM, |
|
BGQQSXZ, |
|
BGQZLDWDM, |
|
BGQGDLX, |
|
BGQGDPDJB, |
|
BGQTBXHDM, |
|
BGQZZSXDM, |
|
BGQCZCSXM, |
|
BGQMSSM, |
|
|
|
BGHDLBM, |
|
BGHQSXZ, |
|
BGHZLDWDM, |
|
BGHGDLX, |
|
BGHGDPDJB, |
|
BGHTBXHDM, |
|
BGHZZSXDM, |
|
BGHCZCSXM, |
|
BGHMSSM, |
|
|
|
Sum(BGMJ) as 'BGMJ',BGQ_YJDL,BGH_YJDL |
|
from '{0}' |
|
group by |
|
BGQDLBM,BGHDLBM, |
|
BGQQSXZ,BGHQSXZ, |
|
substr(BGQZLDWDM,1,12),substr(BGHZLDWDM,1,12), |
|
BGQGDLX,BGHGDLX, |
|
BGQGDPDJB,BGHGDPDJB, |
|
BGQTBXHDM,BGHTBXHDM, |
|
BGQZZSXDM,BGHZZSXDM, |
|
BGQCZCSXM,BGHCZCSXM, |
|
BGQMSSM,BGHMSSM |
|
"; |
|
|
|
public string sSQL_Create_BGJCTJB = @" Create TABLE '{0}' ( |
|
BGQDLBM text(255),BGQQSXZ text(255),BGQZLDWDM text(255),BGQGDLX text(255),BGQGDPDJB text(255), |
|
BGQTBXHDM text(255),BGQZZSXDM text(255),BGQCZCSXM text(255),BGQMSSM text(255), |
|
|
|
BGHDLBM text(255),BGHQSXZ text(255),BGHZLDWDM text(255),BGHGDLX text(255),BGHGDPDJB text(255), |
|
BGHTBXHDM text(255),BGHZZSXDM text(255),BGHCZCSXM text(255),BGHMSSM text(255), |
|
BGMJ text(255) ) "; |
|
|
|
public string sSQL_Create_BGJCTJB2 = @" Create TABLE '{0}' ( |
|
BGQDLBM text(255),BGQQSXZ text(255),BGQZLDWDM text(255),BGQGDLX text(255),BGQGDPDJB text(255), |
|
BGQTBXHDM text(255),BGQZZSXDM text(255),BGQCZCSXM text(255),BGQMSSM text(255), |
|
|
|
BGHDLBM text(255),BGHQSXZ text(255),BGHZLDWDM text(255),BGHGDLX text(255),BGHGDPDJB text(255), |
|
BGHTBXHDM text(255),BGHZZSXDM text(255),BGHCZCSXM text(255),BGHMSSM text(255), |
|
BGMJ text(255),BGQ_YJDL text(255),BGH_YJDL text(255) ) "; |
|
|
|
|
|
|
|
|
|
public string sSQL_Insert_BGJCTJB = @" |
|
Insert into '{0}' ( |
|
BGQDLBM,BGQQSXZ,BGQZLDWDM, |
|
BGQGDLX,BGQGDPDJB,BGQTBXHDM, |
|
BGQZZSXDM,BGQCZCSXM,BGQMSSM, |
|
|
|
BGHDLBM,BGHQSXZ,BGHZLDWDM, |
|
BGHGDLX,BGHGDPDJB,BGHTBXHDM, |
|
BGHZZSXDM,BGHCZCSXM,BGHMSSM, |
|
BGMJ) |
|
values ( |
|
'{1}','{2}','{3}', |
|
'{4}','{5}','{6}', |
|
'{7}','{8}','{9}', |
|
|
|
'{10}','{11}','{12}', |
|
'{13}','{14}','{15}', |
|
'{16}','{17}','{18}', |
|
'{19}' |
|
) "; |
|
|
|
public string sSQL_Insert_BGJCTJB2 = @" |
|
Insert into '{0}' ( |
|
BGQDLBM,BGQQSXZ,BGQZLDWDM, |
|
BGQGDLX,BGQGDPDJB,BGQTBXHDM, |
|
BGQZZSXDM,BGQCZCSXM,BGQMSSM, |
|
|
|
BGHDLBM,BGHQSXZ,BGHZLDWDM, |
|
BGHGDLX,BGHGDPDJB,BGHTBXHDM, |
|
BGHZZSXDM,BGHCZCSXM,BGHMSSM, |
|
BGMJ,BGQ_YJDL,BGH_YJDL) |
|
values ( |
|
'{1}','{2}','{3}', |
|
'{4}','{5}','{6}', |
|
'{7}','{8}','{9}', |
|
|
|
'{10}','{11}','{12}', |
|
'{13}','{14}','{15}', |
|
'{16}','{17}','{18}', |
|
'{19}','{20}','{21}' |
|
) "; |
|
|
|
public string sNeedDealWithFields_NullOrEmpty = |
|
"BGQDLBM,BGHDLBM," + |
|
"BGQQSXZ,BGHQSXZ," + |
|
"BGQZLDWDM,BGHZLDWDM," + |
|
"BGQGDLX,BGHGDLX," + |
|
"BGQGDPDJB,BGHGDPDJB," + |
|
"BGQTBXHDM,BGHTBXHDM," + |
|
"BGQZZSXDM,BGHZZSXDM," + |
|
"BGQCZCSXM,BGHCZCSXM," + |
|
"BGQMSSM,BGHMSSM"; |
|
|
|
#endregion |
|
|
|
public DataTable GetBGBasicStatisticsMsg() |
|
{ |
|
IRDBHelper rdbHelper = null; |
|
try |
|
{ |
|
ProjectInfo ProInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; |
|
if (ProInfo == null) |
|
{ |
|
MessageHelper.Show("请先打开要统计的工程"); |
|
return null; |
|
} |
|
|
|
string sProjDBPath = ProInfo.BGDatabase; |
|
if (string.IsNullOrWhiteSpace(sProjDBPath) == true) |
|
{ |
|
MessageHelper.Show("工程信息地址获取失败,无法输出报表!"); |
|
return null; |
|
} |
|
|
|
string dbPath = System.IO.Path.GetDirectoryName(sProjDBPath) + "\\BGTJ.sqlite"; |
|
if (File.Exists(dbPath) == false) |
|
{ |
|
MessageHelper.Show("变更信息未能记录成功,故信息生成失败"); |
|
return null; |
|
} |
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite); |
|
|
|
if (Judge_SQLiteTable_IsExist(rdbHelper, "BGJCTJB_Gq") == false) |
|
{ |
|
CreateBGBasicStatisticsTable createBGBasicStatisticsTable = new CreateBGBasicStatisticsTable(); |
|
createBGBasicStatisticsTable.ToCreateBGBasicStatisticsTable(); |
|
} |
|
|
|
if (Judge_SQLiteTable_IsExist(rdbHelper, "BGJCTJB_Gq") == false) |
|
{ |
|
return null; |
|
} |
|
|
|
DataTable dtGet_BGJCTJB_Gq = rdbHelper.ExecuteDatatable("Get_BGJCTJB_Gq", " select * from BGJCTJB_Gq ", true); |
|
if (dtGet_BGJCTJB_Gq == null || dtGet_BGJCTJB_Gq.Rows.Count <= 0) |
|
{ |
|
LogAPI.Debug("变更基础统计表(公顷级) 信息获取 失败 ; "); |
|
return null; |
|
} |
|
else |
|
{ |
|
return dtGet_BGJCTJB_Gq; |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("获取 变更基础统计表(公顷级) 信息时失败,异常原因: " + ex + " ; "); |
|
return null; |
|
} |
|
finally |
|
{ |
|
if (rdbHelper != null) |
|
{ |
|
rdbHelper = null; |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 获取地类所属的二级地类(09无二级地类) |
|
/// </summary> |
|
/// <param name="sDLBMTypeTwo"></param> |
|
/// <param name="sTheTableNameNow"></param> |
|
/// <returns></returns> |
|
public string DealWithDLBMTypeTwo(string sDLBMTypeTwo, string sTheTableNameNow) |
|
{ |
|
try |
|
{ |
|
if (string.IsNullOrWhiteSpace(sDLBMTypeTwo) == true) |
|
{ |
|
return ""; |
|
} |
|
|
|
if (sDLBMTypeTwo.Length == 5) |
|
{ |
|
if (sDLBMTypeTwo.EndsWith("A") == true || |
|
sDLBMTypeTwo.EndsWith("K") == true) |
|
{ |
|
sDLBMTypeTwo = sDLBMTypeTwo.Substring(0, 4); |
|
} |
|
|
|
return sDLBMTypeTwo; |
|
} |
|
else if (sDLBMTypeTwo.Length == 4) |
|
{ |
|
return sDLBMTypeTwo; |
|
} |
|
else |
|
{ |
|
return ""; |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug(sTheTableNameNow + " 中 处理二级地类所属 信息时失败!异常原因: " + ex + " ; "); |
|
return ""; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 依据地类编码判断所属二级地类是不是耕地类型 |
|
/// </summary> |
|
/// <param name="sDLBM"></param> |
|
/// <returns></returns> |
|
public bool JudgeDLBMIsGDByDLBM(string sDLBM) |
|
{ |
|
try |
|
{ |
|
/*地类编码一共就三种情况,且每条数据必有,即不为空。 |
|
情况1:两位,即 09 特殊用地; |
|
情况2:四位,即 所有的二级地类的类型编码; |
|
情况3:五位,即 所有的二级地类的类型编码+"A"或者"K"; |
|
*/ |
|
string sDLBMs_GD = ",0101,0102,0103,";//PS:耕地没有"A"和"K"一说; |
|
|
|
if (string.IsNullOrWhiteSpace(sDLBM) == true) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
sDLBM = sDLBM.TrimStart(',').TrimEnd(','); |
|
sDLBM = "," + sDLBM + ","; |
|
if (sDLBMs_GD.Contains(sDLBM) == true) |
|
{ |
|
return true; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("在 依据地类编码判断所属一级地类是不是耕地类型 时失败,异常原因:" + ex + " ; "); |
|
return false; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 依据地类编码判断所属二级地类是不是 林区范围内种植园用地 的统计类型 |
|
/// </summary> |
|
/// <param name="sDLBM"></param> |
|
/// <returns></returns> |
|
public bool JudgeDLBM_IsLDTJFW_ByDLBM(string sDLBM) |
|
{ |
|
try |
|
{ |
|
/*地类编码一共就三种情况,且每条数据必有,即不为空。 |
|
情况1:两位,即 09 特殊用地; |
|
情况2:四位,即 所有的二级地类的类型编码; |
|
情况3:五位,即 所有的二级地类的类型编码+"A"或者"K"; |
|
*/ |
|
string sDLBMs_LDFW = ",0201,0202,0203,0204,0201A,0202A,0203A,0204A,0201K,0202K,0203K,0204K,"; |
|
|
|
if (string.IsNullOrWhiteSpace(sDLBM) == true) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
sDLBM = sDLBM.TrimStart(',').TrimEnd(','); |
|
sDLBM = "," + sDLBM + ","; |
|
if (sDLBMs_LDFW.Contains(sDLBM) == true) |
|
{ |
|
return true; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("在 依据地类编码判断所属二级地类是不是 林区范围内种植园用地 的统计类型 时失败,异常原因:" + ex + " ; "); |
|
return false; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 依据地类编码判断所属二级地类是不是 灌丛草地 的统计类型 |
|
/// </summary> |
|
/// <param name="sDLBM"></param> |
|
/// <returns></returns> |
|
public bool JudgeDLBM_IsGCCDTJFW_ByDLBM(string sDLBM) |
|
{ |
|
try |
|
{ |
|
/*地类编码一共就三种情况,且每条数据必有,即不为空。 |
|
情况1:两位,即 09 特殊用地; |
|
情况2:四位,即 所有的二级地类的类型编码; |
|
情况3:五位,即 所有的二级地类的类型编码+"A"或者"K"; |
|
*/ |
|
string sDLBMs_GCCDFW = ",0401,0402,0403,0404,0401A,0402A,0403A,0404A,0401K,0402K,0403K,0404K,"; |
|
|
|
if (string.IsNullOrWhiteSpace(sDLBM) == true) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
sDLBM = sDLBM.TrimStart(',').TrimEnd(','); |
|
sDLBM = "," + sDLBM + ","; |
|
if (sDLBMs_GCCDFW.Contains(sDLBM) == true) |
|
{ |
|
return true; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("在 依据地类编码判断所属二级地类是不是 灌丛草地 的统计类型 时失败,异常原因:" + ex + " ; "); |
|
return false; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 依据地类编码判断所属二级地类是不是 工业用地 的统计类型 |
|
/// </summary> |
|
/// <param name="sDLBM"></param> |
|
/// <returns></returns> |
|
public bool JudgeDLBM_IsGYYDTJFW_ByDLBM(string sDLBM) |
|
{ |
|
try |
|
{ |
|
/*地类编码一共就三种情况,且每条数据必有,即不为空。 |
|
情况1:两位,即 09 特殊用地; |
|
情况2:四位,即 所有的二级地类的类型编码; |
|
情况3:五位,即 所有的二级地类的类型编码+"A"或者"K"; |
|
*/ |
|
string sDLBMs_GYYDFW = ",0601,0601A,0601K,"; |
|
|
|
if (string.IsNullOrWhiteSpace(sDLBM) == true) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
sDLBM = sDLBM.TrimStart(',').TrimEnd(','); |
|
sDLBM = "," + sDLBM + ","; |
|
if (sDLBMs_GYYDFW.Contains(sDLBM) == true) |
|
{ |
|
return true; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("在 依据地类编码判断所属二级地类是不是 工业用地 的统计类型 时失败,异常原因:" + ex + " ; "); |
|
return false; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 依据地类编码判断所属二级地类是不是 可调整地类 的统计类型 |
|
/// </summary> |
|
/// <param name="sDLBM"></param> |
|
/// <returns></returns> |
|
public bool JudgeDLBM_IsKTZDLTJFW_ByDLBM(string sDLBM) |
|
{ |
|
try |
|
{ |
|
/*地类编码一共就三种情况,且每条数据必有,即不为空。 |
|
情况1:两位,即 09 特殊用地; |
|
情况2:四位,即 所有的二级地类的类型编码; |
|
情况3:五位,即 所有的二级地类的类型编码+"A"或者"K"; |
|
*/ |
|
string sDLBMs_KTZDLFW = ",0201K,0202K,0203K,0204K,0301K,0302K,0307K,0403K,1104K,"; |
|
|
|
if (string.IsNullOrWhiteSpace(sDLBM) == true) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
sDLBM = sDLBM.TrimStart(',').TrimEnd(','); |
|
sDLBM = "," + sDLBM + ","; |
|
if (sDLBMs_KTZDLFW.Contains(sDLBM) == true) |
|
{ |
|
return true; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("在 依据地类编码判断所属二级地类是不是 可调整地类 的统计类型 时失败,异常原因:" + ex + " ; "); |
|
return false; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 依据地类编码判断 数据记录 是不是 部分细化地类 中的 非城镇村及工矿用地 中的地类 统计类型 |
|
/// </summary> |
|
/// <param name="sDLBM"></param> |
|
/// <returns></returns> |
|
public bool Judge_IsDLBM_Of_BFXHDLTJFW_ByDLBM(string sDLBM) |
|
{ |
|
try |
|
{ |
|
/*地类编码一共就三种情况,且每条数据必有,即不为空。 |
|
情况1:两位,即 09 特殊用地; |
|
情况2:四位,即 所有的二级地类的类型编码; |
|
情况3:五位,即 所有的二级地类的类型编码+"A"或者"K"; |
|
*/ |
|
//string sDLBMs_BFXHDLFW = ",08H2,08H2A,0810,0810A,1104,1104A,1107,1107A,"; |
|
string sDLBMs_BFXHDLFW = ",08H2A,0810A,1104A,1107A,"; |
|
|
|
if (string.IsNullOrWhiteSpace(sDLBM) == true) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
sDLBM = sDLBM.TrimStart(',').TrimEnd(','); |
|
sDLBM = "," + sDLBM + ","; |
|
if (sDLBMs_BFXHDLFW.Contains(sDLBM) == true) |
|
{ |
|
return true; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("在 依据地类编码判断 数据记录 是不是 部分细化地类 中的 非城镇村及工矿用地 中的地类 统计类型 时失败,异常原因:" + ex + " ; "); |
|
return false; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 依据城镇村属性码判断 数据记录 是不是 部分细化地类 中的 城镇村及工矿用地 的统计部分 |
|
/// </summary> |
|
/// <param name="sCZCSXM"></param> |
|
/// <returns></returns> |
|
public bool Judge_IsCZCSXM_Of_BFXHDLTJFW_ByCZCSXM(string sCZCSXM) |
|
{ |
|
try |
|
{ |
|
/*变更前城镇村属性码和变更后城镇村属性码: |
|
* 按照“201、201A、202、202A、203、203A、204、205、空”九种类型进行分类; |
|
*/ |
|
string sCZCSXMs_BFXHDLFW = ",201A,202A,203A,"; |
|
|
|
if (string.IsNullOrWhiteSpace(sCZCSXM) == true) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
sCZCSXM = sCZCSXM.TrimStart(',').TrimEnd(','); |
|
sCZCSXM = "," + sCZCSXM + ","; |
|
if (sCZCSXMs_BFXHDLFW.Contains(sCZCSXM) == true) |
|
{ |
|
return true; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("在 依据城镇村属性码判断 数据记录 是不是 部分细化地类 中的 城镇村及工矿用地 的统计部分 时失败,异常原因:" + ex + " ; "); |
|
return false; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 依据地类编码判断所属二级地类是不是 废弃与垃圾填埋 的 废弃地类 的统计类型 |
|
/// </summary> |
|
/// <param name="sDLBM"></param> |
|
/// <returns></returns> |
|
public bool JudgeDLBM_IsFQ_Of_FQYLJTMTJFW_ByDLBM(string sDLBM) |
|
{ |
|
try |
|
{ |
|
/*地类编码一共就三种情况,且每条数据必有,即不为空。 |
|
情况1:两位,即 09 特殊用地; |
|
情况2:四位,即 所有的二级地类的类型编码; |
|
情况3:五位,即 所有的二级地类的类型编码+"A"或者"K"; |
|
*/ |
|
string sDLBMs_FQYLJTMTJFW = ",0602,0602A,0602K,1001,1001A,1001K,1003,1003A,1003K,"; |
|
|
|
if (string.IsNullOrWhiteSpace(sDLBM) == true) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
sDLBM = sDLBM.TrimStart(',').TrimEnd(','); |
|
sDLBM = "," + sDLBM + ","; |
|
if (sDLBMs_FQYLJTMTJFW.Contains(sDLBM) == true) |
|
{ |
|
return true; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("在 依据地类编码判断所属二级地类是不是 废弃与垃圾填埋 的 废弃地类 的统计类型 时失败,异常原因:" + ex + " ; "); |
|
return false; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 依据地类编码判断所属二级地类是不是 废弃与垃圾填埋 的 垃圾填埋地类 的统计类型 |
|
/// </summary> |
|
/// <param name="sDLBM"></param> |
|
/// <returns></returns> |
|
public bool JudgeDLBM_IsLJTM_Of_FQYLJTMTJFW_ByDLBM(string sDLBM) |
|
{ |
|
try |
|
{ |
|
/*地类编码一共就三种情况,且每条数据必有,即不为空。 |
|
情况1:两位,即 09 特殊用地; |
|
情况2:四位,即 所有的二级地类的类型编码; |
|
情况3:五位,即 所有的二级地类的类型编码+"A"或者"K"; |
|
*/ |
|
string sDLBMs_FQYLJTMTJFW = ",0301,0301A,0301K,0302,0302A,0302K,0305,0305A,0305K,0307,0307A,0307K,0404,0404A,0404K,"; |
|
|
|
if (string.IsNullOrWhiteSpace(sDLBM) == true) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
sDLBM = sDLBM.TrimStart(',').TrimEnd(','); |
|
sDLBM = "," + sDLBM + ","; |
|
if (sDLBMs_FQYLJTMTJFW.Contains(sDLBM) == true) |
|
{ |
|
return true; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("在 依据地类编码判断所属二级地类是不是 废弃与垃圾填埋 的 垃圾填埋地类 的统计类型 时失败,异常原因:" + ex + " ; "); |
|
return false; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 依据 图斑细化代码 判断是否需要被 耕地细化调查统计 |
|
/// </summary> |
|
/// <param name="sTBXHDM"></param> |
|
/// <returns></returns> |
|
public bool JudgeTBXHDMIsNeedGDXHDC(string sTBXHDM) |
|
{ |
|
try |
|
{ |
|
string sTBXHDMs_GD = ",HDGD,HQGD,LQGD,MQGD,SHGD,SMGD,YJGD,"; |
|
|
|
if (string.IsNullOrWhiteSpace(sTBXHDM) == true) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
sTBXHDM = sTBXHDM.TrimStart(',').TrimEnd(','); |
|
sTBXHDM = "," + sTBXHDM + ","; |
|
if (sTBXHDMs_GD.Contains(sTBXHDM) == true) |
|
{ |
|
return true; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("在 依据 图斑细化代码 判断是否需要被 耕地细化调查统计 时失败,异常原因:" + ex + " ; "); |
|
return false; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 验证SQLite中是否存在某表 |
|
/// </summary> |
|
/// <param name="rdbHelper"></param> |
|
/// <param name="sTableName"></param> |
|
/// <returns></returns> |
|
public bool Judge_SQLiteTable_IsExist(IRDBHelper rdbHelper, string sTableName) |
|
{ |
|
try |
|
{ |
|
//PS: if (rdbHelper.TableIsExist(dtName) == true) 判断方法无效。 |
|
DataTable dtJudge_Result = rdbHelper.ExecuteDatatable( |
|
"Judge_" + sTableName + "_IsExist", |
|
"SELECT COUNT(*) FROM sqlite_master where type='table' and name='" + sTableName + "';", |
|
true); |
|
|
|
if (dtJudge_Result == null || dtJudge_Result.Rows.Count <= 0) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
int iResultTemp1 = Convert.ToInt32(dtJudge_Result.Rows[0]["COUNT(*)"].ToString()); |
|
if (iResultTemp1 <= 0) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
return true; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("验证 " + sTableName + " 表是否存在时 失败,异常原因: " + ex + " ; "); |
|
return false; |
|
} |
|
} |
|
|
|
public string GetTheProjectXZQDM() |
|
{ |
|
try |
|
{ |
|
ProjectInfo ProInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; |
|
if (ProInfo == null) |
|
{ |
|
MessageHelper.Show("请先打开要统计的工程"); |
|
return ""; |
|
} |
|
|
|
if (ProInfo.CODE == null) |
|
{ |
|
MessageHelper.Show("工程信息中区划代码未配置,故获取行政区编码失败!"); |
|
return ""; |
|
} |
|
|
|
return ProInfo.CODE; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("在获取 项目所属行政区编码 时失败!异常原因: " + ex + " ; "); |
|
return ""; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 获取当前工程唯一标识码 |
|
/// </summary> |
|
/// <returns></returns> |
|
public string GetProjectUniqueID() |
|
{ |
|
string sThePrjUniqueID_Now = ""; |
|
|
|
string strRecentOpenProjectRecordXmlPath = ""; |
|
string sPrjPath_Now = ""; |
|
try |
|
{ |
|
SysConfigsOprator configOp = new SysConfigsOprator(); |
|
|
|
//获取当前工程唯一码 |
|
strRecentOpenProjectRecordXmlPath = KGIS.Framework.Utils.SysAppPath.GetRecentOpenProjectRecordConfigPath(); |
|
if (File.Exists(strRecentOpenProjectRecordXmlPath) == false) |
|
{ |
|
//MessageHelper.Show("工程信息记录信息获取失败!"); |
|
return ""; |
|
} |
|
if (MapsManager.Instance.MapService == null) |
|
{ |
|
MessageHelper.Show("工程信息获取失败"); |
|
return ""; |
|
} |
|
|
|
if (MapsManager.Instance.MapService.GetProjectInfo() == null) |
|
{ |
|
MessageHelper.Show("工程信息获取失败"); |
|
return ""; |
|
} |
|
ProjectInfo iProInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; |
|
if (iProInfo == null) |
|
{ |
|
MessageHelper.Show("工程信息获取失败"); |
|
return ""; |
|
} |
|
|
|
if (iProInfo.ProjDir == null) |
|
{ |
|
MessageHelper.Show("工程信息 获取失败"); |
|
return ""; |
|
} |
|
|
|
if (iProInfo.ProjName == null) |
|
{ |
|
MessageHelper.Show("工程信息 获取失败"); |
|
return ""; |
|
} |
|
|
|
sPrjPath_Now = iProInfo.ProjDir + "\\" + iProInfo.ProjName + ".KBG"; |
|
if (string.IsNullOrWhiteSpace(sPrjPath_Now) == true) |
|
{ |
|
MessageHelper.Show("项目工程信息 获取失败!"); |
|
return ""; |
|
} |
|
|
|
sThePrjUniqueID_Now = configOp.GetProjectUniqueIDInRecentOpenProjectRecordXmlMsg(strRecentOpenProjectRecordXmlPath, sPrjPath_Now); |
|
return sThePrjUniqueID_Now; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("获取当前项目唯一码时 失败,异常原因: " + ex + " ; "); |
|
return ""; |
|
} |
|
} |
|
|
|
public string GetShowExcelPath(EnumReportType rtEnum) |
|
{ |
|
//方便统一维护 |
|
try |
|
{ |
|
string sPath = ""; |
|
string sProjectXZQDM_1 = GetTheProjectXZQDM(); |
|
if (string.IsNullOrWhiteSpace(sProjectXZQDM_1) == true) |
|
{ |
|
MessageHelper.Show("项目工程 信息 获取失败!"); |
|
return ""; |
|
} |
|
|
|
string sShowExcelDirectoryPath = AppDomain.CurrentDomain.BaseDirectory + "TempalateReports\\统一时点更新统计表\\展示导出\\"; |
|
//变更报表展示地址增加工程名字文件夹区分-2020-6-12 |
|
string sPrjUniqueID_Now = GetProjectUniqueID(); |
|
if (string.IsNullOrWhiteSpace(sPrjUniqueID_Now) == true) |
|
{ |
|
MessageHelper.Show("项目工程信息 获取失败!"); |
|
return ""; |
|
} |
|
|
|
sShowExcelDirectoryPath += sPrjUniqueID_Now + "BG\\(" + sProjectXZQDM_1 + ") "; |
|
|
|
#region 获取地址 |
|
switch (rtEnum) |
|
{ |
|
case EnumReportType.变更一览表: |
|
sPath = sShowExcelDirectoryPath + "变更一览表.xlsx"; |
|
break; |
|
case EnumReportType.土地利用现状变化平衡统计表: |
|
sPath = sShowExcelDirectoryPath + "土地利用现状变化平衡统计表.xlsx"; |
|
break; |
|
case EnumReportType.土地利用现状一级分类面积按权属性质变化统计表: |
|
sPath = sShowExcelDirectoryPath + "土地利用现状一级分类面积按权属性质变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.城镇村及工矿用地面积变化统计表: |
|
sPath = sShowExcelDirectoryPath + "城镇村及工矿用地面积变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.耕地坡度分级面积变化统计表: |
|
sPath = sShowExcelDirectoryPath + "耕地坡度分级面积变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.耕地种植类型面积变化统计表: |
|
sPath = sShowExcelDirectoryPath + "耕地种植类型面积变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.即可恢复与工程恢复种植属性变化统计表: |
|
sPath = sShowExcelDirectoryPath + "即可恢复与工程恢复种植属性变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.林区范围内种植园用地变化统计表: |
|
sPath = sShowExcelDirectoryPath + "林区范围内种植园用地变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.灌丛草地汇总情况变化统计表: |
|
sPath = sShowExcelDirectoryPath + "灌丛草地汇总情况变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.工业用地按类型汇总变化统计表: |
|
sPath = sShowExcelDirectoryPath + "工业用地按类型汇总变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.可调整地类面积变化统计表: |
|
sPath = sShowExcelDirectoryPath + "可调整地类面积变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.部分细化地类面积变化统计表: |
|
sPath = sShowExcelDirectoryPath + "部分细化地类面积变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.废弃与垃圾填埋细化标注变化统计表: |
|
sPath = sShowExcelDirectoryPath + "废弃与垃圾填埋细化标注变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.耕地细化调查情况变化统计表: |
|
sPath = sShowExcelDirectoryPath + "耕地细化调查情况变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.海岛土地利用现状变化平衡统计表: |
|
sPath = sShowExcelDirectoryPath + "海岛土地利用现状变化平衡统计表.xlsx"; |
|
break; |
|
case EnumReportType.三大类土地利用现状变化平衡统计表: |
|
sPath = sShowExcelDirectoryPath + "三大类土地利用现状变化平衡统计表.xlsx"; |
|
break; |
|
default: |
|
sPath = ""; |
|
break; |
|
} |
|
#endregion |
|
|
|
return sPath; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("依据报表类型获取文档最终所在Excel地址 失败!异常原因: " + ex + " ; "); |
|
return ""; |
|
} |
|
} |
|
|
|
public string GetExcelModelNameByBGReportType(EnumReportType rtEnum) |
|
{ |
|
try |
|
{ |
|
string sExcelModelName = ""; |
|
|
|
switch (rtEnum) |
|
{ |
|
#region 获取地址 |
|
case EnumReportType.变更一览表: |
|
sExcelModelName = ""; |
|
break; |
|
case EnumReportType.土地利用现状变化平衡统计表: |
|
sExcelModelName = "表 2-土地利用现状变化平衡统计表.xlsx"; |
|
break; |
|
case EnumReportType.土地利用现状一级分类面积按权属性质变化统计表: |
|
sExcelModelName = "表 3-土地利用现状一级分类面积按权属性质变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.城镇村及工矿用地面积变化统计表: |
|
sExcelModelName = "表 4-城镇村及工矿用地面积变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.耕地坡度分级面积变化统计表: |
|
sExcelModelName = "表 5-耕地坡度分级面积变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.耕地种植类型面积变化统计表: |
|
sExcelModelName = "表 6-耕地种植类型面积变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.即可恢复与工程恢复种植属性变化统计表: |
|
sExcelModelName = "表 7-即可恢复与工程恢复种植属性变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.林区范围内种植园用地变化统计表: |
|
sExcelModelName = "表 8-林区范围内种植园用地变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.灌丛草地汇总情况变化统计表: |
|
sExcelModelName = "表 9-灌丛草地汇总情况变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.工业用地按类型汇总变化统计表: |
|
sExcelModelName = "表 10-工业用地按类型汇总变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.可调整地类面积变化统计表: |
|
sExcelModelName = "表 11-可调整地类面积变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.部分细化地类面积变化统计表: |
|
sExcelModelName = "表 12-部分细化地类面积变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.废弃与垃圾填埋细化标注变化统计表: |
|
sExcelModelName = "表 13-废弃与垃圾填埋细化标注变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.耕地细化调查情况变化统计表: |
|
sExcelModelName = "表 14-耕地细化调查情况变化统计表.xlsx"; |
|
break; |
|
case EnumReportType.海岛土地利用现状变化平衡统计表: |
|
sExcelModelName = "表 15-海岛土地利用现状变化平衡统计表.xlsx"; |
|
break; |
|
case EnumReportType.三大类土地利用现状变化平衡统计表: |
|
sExcelModelName = "表 16-三大类土地利用现状变化平衡统计表.xlsx"; |
|
break; |
|
default: |
|
break; |
|
#endregion |
|
} |
|
|
|
return sExcelModelName; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("依据 变更报表类型 获取原文档所在Excel地址 失败!异常原因: " + ex + " ; "); |
|
return ""; |
|
} |
|
} |
|
|
|
|
|
|
|
#region 处理XPS的记录操作 |
|
|
|
|
|
public string GetReportTableRecordNameByEnum(EnumReportType rtEnum) |
|
{ |
|
try |
|
{ |
|
string sReportTableRecordName = ""; |
|
|
|
#region 获取地址 |
|
switch (rtEnum) |
|
{ |
|
case EnumReportType.变更一览表: |
|
sReportTableRecordName = "BGYLB"; |
|
break; |
|
case EnumReportType.土地利用现状变化平衡统计表: |
|
sReportTableRecordName = "TDLYXZBHPHTJB"; |
|
break; |
|
case EnumReportType.土地利用现状一级分类面积按权属性质变化统计表: |
|
sReportTableRecordName = "TDLYXZYJFLMJAQSXZBHTJB"; |
|
break; |
|
case EnumReportType.城镇村及工矿用地面积变化统计表: |
|
sReportTableRecordName = "CZCJGKYDMJBHTJB"; |
|
break; |
|
case EnumReportType.耕地坡度分级面积变化统计表: |
|
sReportTableRecordName = "GDPDFJMJBHTJB"; |
|
break; |
|
case EnumReportType.耕地种植类型面积变化统计表: |
|
sReportTableRecordName = "GDZZLXMJBHTJB"; |
|
break; |
|
case EnumReportType.即可恢复与工程恢复种植属性变化统计表: |
|
sReportTableRecordName = "JKHFYGCHFZZSXBHTJB"; |
|
break; |
|
case EnumReportType.林区范围内种植园用地变化统计表: |
|
sReportTableRecordName = "LQFWNZZYYDBHTJB"; |
|
break; |
|
case EnumReportType.灌丛草地汇总情况变化统计表: |
|
sReportTableRecordName = "GCCDHZQKBHTJB"; |
|
break; |
|
case EnumReportType.工业用地按类型汇总变化统计表: |
|
sReportTableRecordName = "GYYDALXHZBHTJB"; |
|
break; |
|
case EnumReportType.可调整地类面积变化统计表: |
|
sReportTableRecordName = "KTZDLMJBHTJB"; |
|
break; |
|
case EnumReportType.部分细化地类面积变化统计表: |
|
sReportTableRecordName = "BFXHDLMJBHTJB"; |
|
break; |
|
case EnumReportType.废弃与垃圾填埋细化标注变化统计表: |
|
sReportTableRecordName = "FQYLJTMXHBZBHTJB"; |
|
break; |
|
case EnumReportType.耕地细化调查情况变化统计表: |
|
sReportTableRecordName = "GDXHDCQKBHTJB"; |
|
break; |
|
case EnumReportType.海岛土地利用现状变化平衡统计表: |
|
sReportTableRecordName = "HDTDLYXZBHPHTJB"; |
|
break; |
|
case EnumReportType.三大类土地利用现状变化平衡统计表: |
|
sReportTableRecordName = "SDLTDLYXZBHPHTJB"; |
|
break; |
|
default: |
|
sReportTableRecordName = ""; |
|
break; |
|
} |
|
#endregion |
|
|
|
return sReportTableRecordName; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("依据 报表枚举类型获取Xml记录用报表名称时 失败,异常原因: " + ex + " ; "); |
|
return ""; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 将 变更报表展示的XPS地址 置为空 |
|
/// </summary> |
|
/// <param name="rtEnum"></param> |
|
/// <param name="sXZQDM"></param> |
|
/// <param name="sTableName"></param> |
|
/// <param name="sProjFilePath"></param> |
|
public void Set_BGReport_ShowXPSPath_Empty(EnumReportType rtEnum, string sXZQDM, string sTableName, string sProjFilePath) |
|
{ |
|
try |
|
{ |
|
string sTheProjFilePath = ""; |
|
string sTheReportTableRecordName = ""; |
|
string sXmlPath = ""; |
|
|
|
sTheReportTableRecordName = GetReportTableRecordNameByEnum(rtEnum); |
|
if (string.IsNullOrWhiteSpace(sTheReportTableRecordName) == true) |
|
{ |
|
LogAPI.Debug("依据 报表枚举类型获取Xml记录用报表名称 时失败, 故未能将 " + sTableName + " XPS信息置空 ; "); |
|
return; |
|
} |
|
|
|
if (string.IsNullOrWhiteSpace(sXZQDM) == true) |
|
{ |
|
LogAPI.Debug("将 变更报表展示的XPS地址 置为空 期间 工程所属行政区编码为空, 故未能将 " + sTableName + " XPS信息置空 ; "); |
|
return; |
|
} |
|
|
|
sTheProjFilePath = sProjFilePath; |
|
if (string.IsNullOrWhiteSpace(sTheProjFilePath) == true) |
|
{ |
|
LogAPI.Debug("将 变更报表展示的XPS地址 置为空 期间 工程地址为空, 故未能将 " + sTableName + " XPS信息置空 ; "); |
|
return; |
|
} |
|
|
|
sXmlPath = KGIS.Framework.Utils.SysAppPath.GetBGReportXPSRecordConfigPath(); |
|
|
|
#region 处理“XPS存储”记录 |
|
|
|
XmlDocument doc = new XmlDocument(); |
|
if (File.Exists(sXmlPath) == false) |
|
{ |
|
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null); |
|
doc.AppendChild(dec); |
|
XmlElement xpsmessage = doc.CreateElement("bgreport_showxpspath_message"); |
|
doc.AppendChild(xpsmessage); |
|
doc.Save(sXmlPath); |
|
} |
|
|
|
if (Judge_BGReport_ShowXPSPath_RecordXmlMsgIsExist(sXmlPath, sTheProjFilePath, sXZQDM, sTheReportTableRecordName) == false) |
|
{ |
|
#region 记录不存在,就创建记录,且地址为空 |
|
doc.Load(sXmlPath); |
|
XmlElement projectrecord = doc.DocumentElement; |
|
XmlElement xpsrecord = doc.CreateElement("xpsrecord"); |
|
|
|
xpsrecord.SetAttribute("ProjectPath", sTheProjFilePath); |
|
projectrecord.AppendChild(xpsrecord); |
|
|
|
xpsrecord.SetAttribute("BelongXZQ", sXZQDM); |
|
projectrecord.AppendChild(xpsrecord); |
|
|
|
xpsrecord.SetAttribute("ReportTable", sTheReportTableRecordName); |
|
projectrecord.AppendChild(xpsrecord); |
|
|
|
xpsrecord.SetAttribute("XPSPath", ""); |
|
projectrecord.AppendChild(xpsrecord); |
|
|
|
doc.Save(sXmlPath); |
|
//MessageHelper.Show(sTableName + " 展示的XPS地址 保存成功"); |
|
#endregion |
|
} |
|
else//存在,将记录地址置为空 |
|
{ |
|
#region 更新打开记录的时间 |
|
//思路1:删除再添加 |
|
//思路2::找到后修改 |
|
doc.Load(sXmlPath); |
|
|
|
UpdateBGReport_ShowXPSPath_Record(sXmlPath, sTheProjFilePath, sXZQDM, sTheReportTableRecordName, ""); |
|
//MessageHelper.Show(sTableName + "展示的XPS地址 更新成功"); |
|
#endregion |
|
} |
|
#endregion |
|
} |
|
catch (Exception ex) |
|
{ |
|
string sErrorMsg = "将 变更报表展示的XPS地址 置为空 时失败,"; |
|
sErrorMsg += "项目地址为: " + sProjFilePath + " ; "; |
|
sErrorMsg += "所属行政区为: " + sXZQDM + " ; "; |
|
sErrorMsg += "变更报表名称为: " + sTableName + " ; "; |
|
sErrorMsg += "异常原因:" + ex + " ; "; |
|
|
|
LogAPI.Debug(sErrorMsg); |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 增加 变更报表展示的XPS地址 信息 |
|
/// </summary> |
|
/// <param name="rtEnum"></param> |
|
/// <param name="sXZQDM"></param> |
|
/// <param name="sTableName"></param> |
|
/// <param name="sProjFilePath"></param> |
|
public void Add_BGReport_ShowXPSPath(EnumReportType rtEnum, string sXZQDM, string sTableName, string sProjFilePath, string sXPSPath) |
|
{ |
|
try |
|
{ |
|
string sTheProjFilePath = ""; |
|
string sTheReportTableRecordName = ""; |
|
string sXmlPath = ""; |
|
|
|
sTheReportTableRecordName = GetReportTableRecordNameByEnum(rtEnum); |
|
if (string.IsNullOrWhiteSpace(sTheReportTableRecordName) == true) |
|
{ |
|
LogAPI.Debug("依据 报表枚举类型获取Xml记录用报表名称 时失败, 故未能增加 " + sTableName + " XPS信息 ; "); |
|
return; |
|
} |
|
|
|
if (string.IsNullOrWhiteSpace(sXZQDM) == true) |
|
{ |
|
LogAPI.Debug("将 变更报表展示的XPS地址 置为空 期间 工程所属行政区编码为空, 故未能增加 " + sTableName + " XPS信息 ; "); |
|
return; |
|
} |
|
|
|
sTheProjFilePath = sProjFilePath; |
|
if (string.IsNullOrWhiteSpace(sTheProjFilePath) == true) |
|
{ |
|
LogAPI.Debug("将 变更报表展示的XPS地址 置为空 期间 工程地址为空, 故未能增加 " + sTableName + " XPS信息 ; "); |
|
return; |
|
} |
|
|
|
sXmlPath = KGIS.Framework.Utils.SysAppPath.GetBGReportXPSRecordConfigPath(); |
|
|
|
#region 处理“XPS存储”记录 |
|
|
|
XmlDocument doc = new XmlDocument(); |
|
if (File.Exists(sXmlPath) == false) |
|
{ |
|
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null); |
|
doc.AppendChild(dec); |
|
XmlElement xpsmessage = doc.CreateElement("bgreport_showxpspath_message"); |
|
doc.AppendChild(xpsmessage); |
|
doc.Save(sXmlPath); |
|
} |
|
|
|
if (Judge_BGReport_ShowXPSPath_RecordXmlMsgIsExist(sXmlPath, sTheProjFilePath, sXZQDM, sTheReportTableRecordName) == false) |
|
{ |
|
#region 记录不存在,就创建记录,且地址为空 |
|
doc.Load(sXmlPath); |
|
XmlElement projectrecord = doc.DocumentElement; |
|
XmlElement xpsrecord = doc.CreateElement("xpsrecord"); |
|
|
|
xpsrecord.SetAttribute("ProjectPath", sTheProjFilePath); |
|
projectrecord.AppendChild(xpsrecord); |
|
|
|
xpsrecord.SetAttribute("BelongXZQ", sXZQDM); |
|
projectrecord.AppendChild(xpsrecord); |
|
|
|
xpsrecord.SetAttribute("ReportTable", sTheReportTableRecordName); |
|
projectrecord.AppendChild(xpsrecord); |
|
|
|
xpsrecord.SetAttribute("XPSPath", sXPSPath); |
|
projectrecord.AppendChild(xpsrecord); |
|
|
|
doc.Save(sXmlPath); |
|
MessageHelper.Show(sTableName + "展示的XPS地址 保存成功");//待注销 |
|
#endregion |
|
} |
|
else//存在,将记录地址置为空 |
|
{ |
|
#region 更新打开记录的时间 |
|
//思路1:删除再添加 |
|
//思路2::找到后修改 |
|
doc.Load(sXmlPath); |
|
|
|
UpdateBGReport_ShowXPSPath_Record(sXmlPath, sTheProjFilePath, sXZQDM, sTheReportTableRecordName, sXPSPath); |
|
MessageHelper.Show("变更报表展示的XPS地址 更新成功");//待注销 |
|
#endregion |
|
} |
|
#endregion |
|
} |
|
catch (Exception ex) |
|
{ |
|
string sErrorMsg = "增加 变更报表展示的XPS地址 时失败,"; |
|
sErrorMsg += "项目地址为: " + sProjFilePath + " ; "; |
|
sErrorMsg += "所属行政区为: " + sXZQDM + " ; "; |
|
sErrorMsg += "变更报表名称为: " + sTableName + " ; "; |
|
sErrorMsg += "展示的XPS地址为: " + sXPSPath + " ; \r "; |
|
sErrorMsg += "异常原因:" + ex + " ; "; |
|
LogAPI.Debug(sErrorMsg); |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 验证变更报表展示用XPS地址记录中是否存在此项目此行政区此变更报表的XPS记录信息 |
|
/// </summary> |
|
/// <param name="sXmlPath">记录表地址</param> |
|
/// <param name="sPrjPath">此次打开工程所在地址</param> |
|
/// <param name="sXZQDM"></param> |
|
/// <param name="sTheReportTableRecordNameNow"></param> |
|
/// <returns></returns> |
|
public bool Judge_BGReport_ShowXPSPath_RecordXmlMsgIsExist(string sXmlPath, string sPrjPath, string sXZQDM, string sTheReportTableRecordNameNow) |
|
{ |
|
string sThePrjName_Now = ""; |
|
XmlDocument doc = new XmlDocument(); |
|
XmlElement orderElement = null; |
|
XmlNodeList orderChildr = null; |
|
try |
|
{ |
|
#region 判断是否存在此工程打开记录 |
|
if (string.IsNullOrWhiteSpace(sXmlPath) == true || |
|
string.IsNullOrWhiteSpace(sPrjPath) == true || |
|
string.IsNullOrWhiteSpace(sXZQDM) == true || |
|
string.IsNullOrWhiteSpace(sTheReportTableRecordNameNow) == true) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
if (File.Exists(sXmlPath) == false)//逻辑上不可能 |
|
{ |
|
//MessageHelper.ShowError("工程文件不存在!"); |
|
return false; |
|
} |
|
else |
|
{ |
|
sThePrjName_Now = ToGetProjectNameByPath(sPrjPath); |
|
if (string.IsNullOrWhiteSpace(sThePrjName_Now) == true) |
|
{ |
|
//MessageHelper.ShowError("文件名字无效!"); |
|
return false; |
|
} |
|
else |
|
{ |
|
doc.Load(sXmlPath); |
|
orderElement = doc.DocumentElement;//获取根节点 |
|
if (orderElement == null) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
if (orderElement.ChildNodes == null || orderElement.ChildNodes.Count <= 0) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
orderChildr = orderElement.ChildNodes; |
|
if (orderChildr == null || orderChildr.Count <= 0) |
|
{ |
|
return false; |
|
} |
|
else |
|
{ |
|
bool bTemp = false; |
|
foreach (XmlNode item in orderChildr) |
|
{ |
|
//LogAPI.Debug("项目地址:" + item.Attributes["ProjectPath"].Value + " \r; "); |
|
//LogAPI.Debug("所属行政区:" + item.Attributes["BelongXZQ"].Value + " \r; "); |
|
//LogAPI.Debug("报表名称:" + item.Attributes["ReportTable"].Value + " \r; "); |
|
|
|
if (item.Attributes["ProjectPath"].Value == sPrjPath && |
|
ToGetProjectNameByPath(item.Attributes["ProjectPath"].Value) == sThePrjName_Now && |
|
item.Attributes["BelongXZQ"].Value == sXZQDM && |
|
item.Attributes["ReportTable"].Value == sTheReportTableRecordNameNow |
|
) |
|
{ |
|
bTemp = true; |
|
break; |
|
} |
|
else |
|
{ |
|
continue; |
|
} |
|
} |
|
return bTemp; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
#endregion |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("验证变更报表展示用XPS地址记录中是否存在此项目此行政区此变更报表的XPS记录信息 时异常:" + ex); |
|
return false; |
|
} |
|
finally |
|
{ |
|
if (doc != null) |
|
{ |
|
doc = null; |
|
} |
|
if (string.IsNullOrWhiteSpace(sThePrjName_Now) == false) |
|
{ |
|
sThePrjName_Now = ""; |
|
} |
|
if (orderElement != null) |
|
{ |
|
orderElement = null; |
|
} |
|
if (orderChildr != null && orderChildr.Count > 0) |
|
{ |
|
orderChildr = null; |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 依据工程目录文件所在地址获取工程文件名称 |
|
/// </summary> |
|
/// <param name="sPath"></param> |
|
/// <returns></returns> |
|
public string ToGetProjectNameByPath(string sPath) |
|
{ |
|
FileInfo fileInfo = null; |
|
try |
|
{ |
|
if (string.IsNullOrWhiteSpace(sPath) == true) |
|
{ |
|
return ""; |
|
} |
|
//if (File.Exists(sPath) == false) |
|
//{ |
|
// return ""; |
|
//} |
|
fileInfo = new FileInfo(sPath); |
|
if (fileInfo == null) |
|
{ |
|
return ""; |
|
} |
|
//if (fileInfo.Extension != ".KBG") |
|
//{ |
|
// return ""; |
|
//} |
|
return fileInfo.Name; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("依据工程所在目录获取工程名称异常:" + ex); |
|
return ""; |
|
} |
|
finally |
|
{ |
|
if (fileInfo != null) |
|
{ |
|
fileInfo = null; |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 更新 变更报表展示的XPS地址 |
|
/// </summary> |
|
/// <param name="sXmlPath">记录表地址</param> |
|
/// <param name="sPrjPath">此次打开工程所在地址</param> |
|
/// <param name="sXZQDM">所属行政区代码</param> |
|
/// <param name="sTheReportTableRecordNameNow">变更表记录用名称</param> |
|
/// <param name="sXPSPath">设置的XPS地址</param> |
|
public void UpdateBGReport_ShowXPSPath_Record(string sXmlPath, string sPrjPath, string sXZQDM, string sTheReportTableRecordNameNow, string sXPSPath) |
|
{ |
|
string sThePrjName_Now = ""; |
|
XmlDocument doc = new XmlDocument(); |
|
XmlElement orderElement = null; |
|
XmlNodeList orderChildr = null; |
|
try |
|
{ |
|
#region 判断是否存在此工程打开记录 |
|
if (string.IsNullOrWhiteSpace(sXmlPath) == true || |
|
string.IsNullOrWhiteSpace(sPrjPath) == true || |
|
string.IsNullOrWhiteSpace(sXZQDM) == true || |
|
string.IsNullOrWhiteSpace(sTheReportTableRecordNameNow) == true) |
|
{ |
|
return; |
|
} |
|
else |
|
{ |
|
if (File.Exists(sXmlPath) == false)//逻辑上不可能 |
|
{ |
|
//MessageHelper.ShowError("工程文件不存在!"); |
|
return; |
|
} |
|
else |
|
{ |
|
sThePrjName_Now = ToGetProjectNameByPath(sPrjPath); |
|
if (string.IsNullOrWhiteSpace(sThePrjName_Now) == true) |
|
{ |
|
//MessageHelper.ShowError("文件名字无效!"); |
|
return; |
|
} |
|
else |
|
{ |
|
doc.Load(sXmlPath); |
|
orderElement = doc.DocumentElement;// 获取根节点 |
|
if (orderElement == null) |
|
{ |
|
return; |
|
} |
|
else |
|
{ |
|
if (orderElement.ChildNodes == null || orderElement.ChildNodes.Count <= 0) |
|
{ |
|
return; |
|
} |
|
else |
|
{ |
|
orderChildr = orderElement.ChildNodes; |
|
if (orderChildr == null || orderChildr.Count <= 0) |
|
{ |
|
return; |
|
} |
|
else |
|
{ |
|
foreach (XmlNode item in orderChildr) |
|
{ |
|
//LogAPI.Debug("项目地址:" + item.Attributes["ProjectPath"].Value + " \r; "); |
|
//LogAPI.Debug("所属行政区:" + item.Attributes["BelongXZQ"].Value + " \r; "); |
|
//LogAPI.Debug("报表名称:" + item.Attributes["ReportTable"].Value + " \r; "); |
|
//LogAPI.Debug("XPS地址:" + sXPSPath + " \r; "); |
|
if (item.Attributes["ProjectPath"].Value == sPrjPath && |
|
ToGetProjectNameByPath(item.Attributes["ProjectPath"].Value) == sThePrjName_Now && |
|
item.Attributes["BelongXZQ"].Value == sXZQDM && |
|
item.Attributes["ReportTable"].Value == sTheReportTableRecordNameNow |
|
) |
|
{ |
|
item.Attributes["XPSPath"].Value = sXPSPath;//修改 |
|
//break; |
|
} |
|
else |
|
{ |
|
continue; |
|
} |
|
} |
|
doc.Save(sXmlPath); |
|
return; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
#endregion |
|
} |
|
catch (Exception ex) |
|
{ |
|
string sErrorMsg = "更新 变更报表展示的XPS地址 时失败,"; |
|
sErrorMsg += "项目地址为: " + sPrjPath + " ; "; |
|
sErrorMsg += "所属行政区为: " + sXZQDM + " ; "; |
|
sErrorMsg += "变更报表名称为: " + sTheReportTableRecordNameNow + " ; "; |
|
sErrorMsg += "展示的XPS地址为: " + sXPSPath + " ; \r "; |
|
sErrorMsg += "异常原因:" + ex + " ; "; |
|
LogAPI.Debug(sErrorMsg); |
|
return; |
|
} |
|
finally |
|
{ |
|
if (doc != null) |
|
{ |
|
doc = null; |
|
} |
|
if (orderElement != null) |
|
{ |
|
orderElement = null; |
|
} |
|
if (orderChildr != null && orderChildr.Count > 0) |
|
{ |
|
orderChildr = null; |
|
} |
|
if (string.IsNullOrWhiteSpace(sXmlPath) == false) |
|
{ |
|
sXmlPath = ""; |
|
} |
|
if (string.IsNullOrWhiteSpace(sPrjPath) == false) |
|
{ |
|
sPrjPath = ""; |
|
} |
|
if (string.IsNullOrWhiteSpace(sThePrjName_Now) == false) |
|
{ |
|
sThePrjName_Now = ""; |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 获取 变更报表展示的XPS地址 |
|
/// </summary> |
|
/// <param name="rtEnum"></param> |
|
/// <param name="sXZQDM"></param> |
|
/// <param name="sTableName"></param> |
|
/// <param name="sProjFilePath"></param> |
|
/// <returns></returns> |
|
public string GetBGReport_ShowXPSPath(EnumReportType rtEnum, string sXZQDM, string sTableName, string sProjFilePath) |
|
{ |
|
string sTheXPSPath = ""; |
|
|
|
string s_TheProjFilePath = ""; |
|
string s_TheReportTableRecordName = ""; |
|
string s_XmlPath = ""; |
|
string sThePrjName_Now = ""; |
|
|
|
s_TheReportTableRecordName = GetReportTableRecordNameByEnum(rtEnum); |
|
if (string.IsNullOrWhiteSpace(s_TheReportTableRecordName) == true) |
|
{ |
|
LogAPI.Debug("依据 报表枚举类型获取Xml记录用报表名称 时失败, 故未能获取 " + sTableName + " 的 XPS信息 ; "); |
|
return ""; |
|
} |
|
|
|
if (string.IsNullOrWhiteSpace(sXZQDM) == true) |
|
{ |
|
LogAPI.Debug("获取 变更报表展示的XPS地址 期间 工程所属行政区编码为空, 故未能获取 " + sTableName + " 的 XPS信息 ; "); |
|
return ""; |
|
} |
|
|
|
s_TheProjFilePath = sProjFilePath; |
|
if (string.IsNullOrWhiteSpace(s_TheProjFilePath) == true) |
|
{ |
|
LogAPI.Debug("获取 变更报表展示的XPS地址 期间 工程地址为空, 故未能获取 " + sTableName + " 的 XPS信息 ; "); |
|
return ""; |
|
} |
|
|
|
s_XmlPath = KGIS.Framework.Utils.SysAppPath.GetBGReportXPSRecordConfigPath(); |
|
|
|
XmlDocument doc = new XmlDocument(); |
|
XmlElement orderElement = null; |
|
XmlNodeList orderChildr = null; |
|
try |
|
{ |
|
#region 判断是否存在此工程打开记录 |
|
if (string.IsNullOrWhiteSpace(s_XmlPath) == true || |
|
string.IsNullOrWhiteSpace(s_TheProjFilePath) == true || |
|
string.IsNullOrWhiteSpace(sXZQDM) == true || |
|
string.IsNullOrWhiteSpace(s_TheReportTableRecordName) == true) |
|
{ |
|
return ""; |
|
} |
|
else |
|
{ |
|
if (File.Exists(s_XmlPath) == false)//逻辑上不可能 |
|
{ |
|
//MessageHelper.ShowError("工程文件不存在!"); |
|
return ""; |
|
} |
|
else |
|
{ |
|
sThePrjName_Now = ToGetProjectNameByPath(s_TheProjFilePath); |
|
if (string.IsNullOrWhiteSpace(sThePrjName_Now) == true) |
|
{ |
|
//MessageHelper.ShowError("文件名字无效!"); |
|
return ""; |
|
} |
|
else |
|
{ |
|
doc.Load(s_XmlPath); |
|
orderElement = doc.DocumentElement;// 获取根节点 |
|
if (orderElement == null) |
|
{ |
|
return ""; |
|
} |
|
else |
|
{ |
|
if (orderElement.ChildNodes == null || orderElement.ChildNodes.Count <= 0) |
|
{ |
|
return ""; |
|
} |
|
else |
|
{ |
|
orderChildr = orderElement.ChildNodes; |
|
if (orderChildr == null || orderChildr.Count <= 0) |
|
{ |
|
return ""; |
|
} |
|
else |
|
{ |
|
foreach (XmlNode item in orderChildr) |
|
{ |
|
//LogAPI.Debug("项目地址:" + item.Attributes["ProjectPath"].Value + " \r; "); |
|
//LogAPI.Debug("所属行政区:" + item.Attributes["BelongXZQ"].Value + " \r; "); |
|
//LogAPI.Debug("报表名称:" + item.Attributes["ReportTable"].Value + " \r; "); |
|
//LogAPI.Debug("XPS地址:" + item.Attributes["XPSPath"].Value + " \r; "); |
|
if (item.Attributes["ProjectPath"].Value == s_TheProjFilePath && |
|
ToGetProjectNameByPath(item.Attributes["ProjectPath"].Value) == sThePrjName_Now && |
|
item.Attributes["BelongXZQ"].Value == sXZQDM && |
|
item.Attributes["ReportTable"].Value == s_TheReportTableRecordName |
|
) |
|
{ |
|
|
|
sTheXPSPath = item.Attributes["XPSPath"].Value; |
|
break; |
|
} |
|
else |
|
{ |
|
continue; |
|
} |
|
} |
|
//doc.Save(s_XmlPath); |
|
return sTheXPSPath; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
#endregion |
|
} |
|
catch (Exception ex) |
|
{ |
|
string sErrorMsg = "获取 变更报表展示的XPS地址 时失败,"; |
|
sErrorMsg += "所属行政区为: " + sXZQDM + " ; "; |
|
sErrorMsg += "变更报表名称为: " + sTableName + " ; "; |
|
sErrorMsg += "项目所在地址为: " + sProjFilePath + " ; \r "; |
|
sErrorMsg += "异常原因:" + ex + " ; "; |
|
LogAPI.Debug(sErrorMsg); |
|
return ""; |
|
} |
|
finally |
|
{ |
|
if (doc != null) |
|
{ |
|
doc = null; |
|
} |
|
if (orderElement != null) |
|
{ |
|
orderElement = null; |
|
} |
|
if (orderChildr != null && orderChildr.Count > 0) |
|
{ |
|
orderChildr = null; |
|
} |
|
if (string.IsNullOrWhiteSpace(s_XmlPath) == false) |
|
{ |
|
s_XmlPath = ""; |
|
} |
|
if (string.IsNullOrWhiteSpace(s_TheReportTableRecordName) == false) |
|
{ |
|
s_TheReportTableRecordName = ""; |
|
} |
|
if (string.IsNullOrWhiteSpace(s_TheProjFilePath) == false) |
|
{ |
|
s_TheProjFilePath = ""; |
|
} |
|
if (string.IsNullOrWhiteSpace(sThePrjName_Now) == false) |
|
{ |
|
sThePrjName_Now = ""; |
|
} |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 获取变更报表展示用XPS地址记录信息 |
|
/// </summary> |
|
/// <param name="sXmlPath">记录表地址</param> |
|
/// <returns></returns> |
|
public List<string> Get_BGReport_ShowXPSPath_RecordXmlMsg(string sXmlPath) |
|
{ |
|
List<string> sXPSPathList = new List<string>(); |
|
|
|
XmlDocument doc = new XmlDocument(); |
|
XmlElement orderElement = null; |
|
XmlNodeList orderChildr = null; |
|
try |
|
{ |
|
#region 判断是否存在此工程打开记录 |
|
if (string.IsNullOrWhiteSpace(sXmlPath) == true) |
|
{ |
|
return null; |
|
} |
|
else |
|
{ |
|
if (File.Exists(sXmlPath) == false)//逻辑上不可能 |
|
{ |
|
//MessageHelper.ShowError("工程文件不存在!"); |
|
return null; |
|
} |
|
else |
|
{ |
|
doc.Load(sXmlPath); |
|
orderElement = doc.DocumentElement;//获取根节点 |
|
if (orderElement == null) |
|
{ |
|
return null; |
|
} |
|
else |
|
{ |
|
if (orderElement.ChildNodes == null || orderElement.ChildNodes.Count <= 0) |
|
{ |
|
return null; |
|
} |
|
else |
|
{ |
|
orderChildr = orderElement.ChildNodes; |
|
if (orderChildr == null || orderChildr.Count <= 0) |
|
{ |
|
return null; |
|
} |
|
else |
|
{ |
|
foreach (XmlNode item in orderChildr) |
|
{ |
|
if (string.IsNullOrWhiteSpace(item.Attributes["XPSPath"].Value) == false) |
|
{ |
|
sXPSPathList.Add(item.Attributes["XPSPath"].Value); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
return sXPSPathList; |
|
} |
|
#endregion |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("获取变更报表展示用XPS地址记录列表信息 时异常:" + ex); |
|
return null; |
|
} |
|
finally |
|
{ |
|
if (doc != null) |
|
{ |
|
doc = null; |
|
} |
|
if (orderElement != null) |
|
{ |
|
orderElement = null; |
|
} |
|
if (orderChildr != null && orderChildr.Count > 0) |
|
{ |
|
orderChildr = null; |
|
} |
|
} |
|
} |
|
|
|
#endregion |
|
|
|
} |
|
|
|
}
|
|
|