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.
303 lines
16 KiB
303 lines
16 KiB
using ESRI.ArcGIS.Geodatabase; |
|
using KGIS.Framework.Maps; |
|
using KGIS.Framework.Utils; |
|
using Kingo.PluginServiceInterface.Model; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.IO; |
|
using System.Linq; |
|
using System.Text; |
|
using System.Threading.Tasks; |
|
using System.Xml.Linq; |
|
|
|
namespace Kingo.Plugin.DataLoad.Helper |
|
{ |
|
public class SetKCDLXSHelper |
|
{ |
|
private static List<GDEntity> GDEntitys; |
|
private static XDocument xDoc; |
|
private static IQueryFilter pQueryFilterTT1 = new QueryFilter(); |
|
private static IFeatureCursor pTT1FeatureCursor; |
|
private static IFeature pTT1Feature; |
|
private static string BG_GDLXConfigPath; |
|
private static string GDLX = null; |
|
private static string GDPDJB = null; |
|
private static object obj = null; |
|
/// <summary> |
|
/// 设置扣除系数 |
|
/// </summary> |
|
public static void SetKCDLXS() |
|
{ |
|
try |
|
{ |
|
InitGD(); |
|
|
|
IFeatureClass pFeatureClass = MapsManager.Instance.MapService.GetFeatureClassByName("DLTB"); |
|
if (pFeatureClass != null && pFeatureClass.FeatureCount(null) > 0) |
|
{ |
|
ITable pTable = pFeatureClass as ITable; |
|
#region 梯田扣除地类系数 |
|
string TempFH = "%"; |
|
if (Path.GetExtension((pFeatureClass as FeatureClass).Workspace.PathName).ToLower().Contains(".mdb")) |
|
TempFH = "*"; |
|
for (int i = 0; i < pTable.Fields.FieldCount; i++) |
|
{ |
|
IField pField = pFeatureClass.Fields.get_Field(i); |
|
|
|
if (pField.AliasName == "扣除地类系数" || pField.AliasName == "KCXS") |
|
{ |
|
for (int j = 1; j < 6; j++) |
|
{ |
|
if (j == 1) |
|
{ |
|
pQueryFilterTT1.WhereClause = string.Format(" KCXS >= 0 AND GDLX = 'TT' AND DLBM LIKE '01{1}' AND GDPDJB = '{0}' ", j, TempFH); |
|
pTT1FeatureCursor = pFeatureClass.Search(pQueryFilterTT1, true); |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
while (pTT1Feature != null) |
|
{ |
|
obj = pTT1Feature.get_Value(i); |
|
GDLX = "TT"; |
|
GDPDJB = "1"; |
|
Save(); |
|
if (!string.IsNullOrWhiteSpace(obj?.ToString() ?? "")) |
|
break; |
|
else |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
} |
|
} |
|
else if (j == 2) |
|
{ |
|
pQueryFilterTT1.WhereClause = string.Format(" KCXS >= 0 AND GDLX = 'TT' AND DLBM LIKE '01{1}' AND GDPDJB = '{0}' ", j, TempFH); |
|
pTT1FeatureCursor = pFeatureClass.Search(pQueryFilterTT1, true); |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
while (pTT1Feature != null) |
|
{ |
|
obj = pTT1Feature.get_Value(i); |
|
GDLX = "TT"; |
|
GDPDJB = "2"; |
|
Save(); |
|
if (!string.IsNullOrWhiteSpace(obj?.ToString() ?? "")) |
|
break; |
|
else |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
} |
|
} |
|
else if (j == 3) |
|
{ |
|
pQueryFilterTT1.WhereClause = string.Format(" KCXS >= 0 AND GDLX = 'TT' AND DLBM LIKE '01{1}' AND GDPDJB = '{0}' ", j, TempFH); |
|
pTT1FeatureCursor = pFeatureClass.Search(pQueryFilterTT1, true); |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
while (pTT1Feature != null) |
|
{ |
|
obj = pTT1Feature.get_Value(i); |
|
GDLX = "TT"; |
|
GDPDJB = "3"; |
|
Save(); |
|
if (!string.IsNullOrWhiteSpace(obj?.ToString() ?? "")) |
|
break; |
|
else |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
} |
|
} |
|
else if (j == 4) |
|
{ |
|
pQueryFilterTT1.WhereClause = string.Format(" KCXS >= 0 AND GDLX = 'TT' AND DLBM LIKE '01{1}' AND GDPDJB = '{0}' ", j, TempFH); |
|
pTT1FeatureCursor = pFeatureClass.Search(pQueryFilterTT1, true); |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
while (pTT1Feature != null) |
|
{ |
|
obj = pTT1Feature.get_Value(i); |
|
GDLX = "TT"; |
|
GDPDJB = "4"; |
|
Save(); |
|
if (!string.IsNullOrWhiteSpace(obj?.ToString() ?? "")) |
|
break; |
|
else |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
} |
|
} |
|
else if (j == 5) |
|
{ |
|
pQueryFilterTT1.WhereClause = string.Format(" KCXS >= 0 AND GDLX = 'TT' AND DLBM LIKE '01{1}' AND GDPDJB = '{0}' ", j, TempFH); |
|
pTT1FeatureCursor = pFeatureClass.Search(pQueryFilterTT1, true); |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
while (pTT1Feature != null) |
|
{ |
|
obj = pTT1Feature.get_Value(i); |
|
GDLX = "TT"; |
|
GDPDJB = "5"; |
|
Save(); |
|
if (!string.IsNullOrWhiteSpace(obj?.ToString() ?? "")) |
|
break; |
|
else |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
} |
|
} |
|
} |
|
break; |
|
} |
|
} |
|
#endregion |
|
#region 坡地扣除地类系数 |
|
for (int k = 0; k < pTable.Fields.FieldCount; k++) |
|
{ |
|
IField pField = pFeatureClass.Fields.get_Field(k); |
|
|
|
if (pField.AliasName == "扣除地类系数" || pField.AliasName == "KCXS") |
|
{ |
|
for (int j = 1; j < 6; j++) |
|
{ |
|
if (j == 1) |
|
{ |
|
pQueryFilterTT1.WhereClause = string.Format(" KCXS >= 0 AND GDLX = 'TT' AND DLBM LIKE '01{1}' AND GDPDJB = '{0}' ", j, TempFH); |
|
pTT1FeatureCursor = pFeatureClass.Search(pQueryFilterTT1, true); |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
while (pTT1Feature != null) |
|
{ |
|
obj = pTT1Feature.get_Value(k); |
|
GDLX = "PD"; |
|
GDPDJB = "1"; |
|
Save(); |
|
if (!string.IsNullOrWhiteSpace(obj?.ToString() ?? "")) |
|
break; |
|
else |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
} |
|
} |
|
else if (j == 2) |
|
{ |
|
pQueryFilterTT1.WhereClause = string.Format(" KCXS >= 0 AND GDLX = 'PD' AND DLBM LIKE '01{1}' AND GDPDJB = '{0}' ", j, TempFH); |
|
pTT1FeatureCursor = pFeatureClass.Search(pQueryFilterTT1, true); |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
while (pTT1Feature != null) |
|
{ |
|
obj = pTT1Feature.get_Value(k); |
|
GDLX = "PD"; |
|
GDPDJB = "2"; |
|
Save(); |
|
if (!string.IsNullOrWhiteSpace(obj?.ToString() ?? "")) |
|
break; |
|
else |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
} |
|
} |
|
else if (j == 3) |
|
{ |
|
pQueryFilterTT1.WhereClause = string.Format(" KCXS >= 0 AND GDLX = 'PD' AND DLBM LIKE '01{1}' AND GDPDJB = '{0}' ", j, TempFH); |
|
pTT1FeatureCursor = pFeatureClass.Search(pQueryFilterTT1, true); |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
while (pTT1Feature != null) |
|
{ |
|
obj = pTT1Feature.get_Value(k); |
|
GDLX = "PD"; |
|
GDPDJB = "3"; |
|
Save(); |
|
if (!string.IsNullOrWhiteSpace(obj?.ToString() ?? "")) |
|
break; |
|
else |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
} |
|
} |
|
else if (j == 4) |
|
{ |
|
pQueryFilterTT1.WhereClause = string.Format(" KCXS >= 0 AND GDLX = 'PD' AND DLBM LIKE '01{1}' AND GDPDJB = '{0}' ", j, TempFH); |
|
pTT1FeatureCursor = pFeatureClass.Search(pQueryFilterTT1, true); |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
while (pTT1Feature != null) |
|
{ |
|
obj = pTT1Feature.get_Value(k); |
|
GDLX = "PD"; |
|
GDPDJB = "4"; |
|
Save(); |
|
if (!string.IsNullOrWhiteSpace(obj?.ToString() ?? "")) |
|
break; |
|
else |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
} |
|
} |
|
else if (j == 5) |
|
{ |
|
pQueryFilterTT1.WhereClause = string.Format(" KCXS >= 0 AND GDLX = 'PD' AND DLBM LIKE '01{1}' AND GDPDJB = '{0}' ", j, TempFH); |
|
pTT1FeatureCursor = pFeatureClass.Search(pQueryFilterTT1, true); |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
while (pTT1Feature != null) |
|
{ |
|
obj = pTT1Feature.get_Value(k); |
|
GDLX = "PD"; |
|
GDPDJB = "5"; |
|
Save(); |
|
if (!string.IsNullOrWhiteSpace(obj?.ToString() ?? "")) |
|
break; |
|
else |
|
pTT1Feature = pTT1FeatureCursor.NextFeature(); |
|
} |
|
} |
|
} |
|
break; |
|
} |
|
} |
|
#endregion |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("设置扣除系数发生异常:" + ex); |
|
} |
|
|
|
} |
|
|
|
private static void InitGD() |
|
{ |
|
try |
|
{ |
|
GDEntitys = new List<GDEntity>(); |
|
BG_GDLXConfigPath = (MapsManager.Instance.CurrProjectInfo as PluginServiceInterface.ProjectInfo).ProjDir + "\\BG_GDLXConfig.xml"; |
|
if (string.IsNullOrWhiteSpace(BG_GDLXConfigPath) || !File.Exists(BG_GDLXConfigPath)) |
|
BG_GDLXConfigPath = SysAppPath.GetBGGDLXConfigPath(); |
|
xDoc = XDocument.Load(BG_GDLXConfigPath); |
|
foreach (XElement xElement in xDoc.Descendants("Item")) |
|
{ |
|
GDEntity model = new GDEntity(); |
|
model.GDLX = xElement.Attributes("GDLX").Single().Value; |
|
model.GDPDJB = xElement.Attributes("GDPDJB").Single().Value; |
|
model.GDPDJBMC = xElement.Attributes("GDPDJBMC").Single().Value; |
|
decimal kcdlxs = 0; |
|
if (decimal.TryParse(xElement.Attributes("KCDLXS").Single().Value, out kcdlxs)) |
|
{ |
|
model.KCDLXS = kcdlxs; |
|
} |
|
else |
|
{ |
|
model.KCDLXS = 0; |
|
} |
|
GDEntitys.Add(model); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
|
|
private static void Save() |
|
{ |
|
try |
|
{ |
|
List<GDEntity> Entitys = GDEntitys.ToList(); |
|
foreach (GDEntity model1 in Entitys) |
|
{ |
|
if (model1.GDLX == GDLX && model1.GDPDJB == GDPDJB) |
|
{ |
|
xDoc.Descendants("Item").Where(p => p.Attribute("GDLX").Value.Equals(model1.GDLX) && p.Attribute("GDPDJB").Value.Equals(model1.GDPDJB)).Single().Attribute("KCDLXS").SetValue(obj.ToString()); |
|
} |
|
} |
|
xDoc.Save(BG_GDLXConfigPath); |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
|
|
} |
|
}
|
|
|