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.
1948 lines
96 KiB
1948 lines
96 KiB
//using ESRI.ArcGIS.AnalysisTools; |
|
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.DataSourcesGDB; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using ESRI.ArcGIS.Geometry; |
|
using ESRI.ArcGIS.Geoprocessing; |
|
using ESRI.ArcGIS.Geoprocessor; |
|
using KGIS.Framework.AE; |
|
using KGIS.Framework.AE.Enum; |
|
//using KGIS.Framework.AE.GPHelper; |
|
using KGIS.Framework.AE.ExtensionMethod; |
|
using KGIS.Framework.AE.GPHelper; |
|
using KGIS.Framework.DBOperator; |
|
using KGIS.Framework.Platform; |
|
using KGIS.Framework.ThreadManager; |
|
//using KGIS.Framework.Maps; |
|
using KGIS.Framework.Utils; |
|
using Kingo.PluginServiceInterface; |
|
using Kingo.PluginServiceInterface.Model; |
|
//using KUI.Windows; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.Data; |
|
using System.IO; |
|
using System.Linq; |
|
using System.Runtime.InteropServices; |
|
//using IDEParameter; |
|
|
|
namespace IDGForNDBG |
|
{ |
|
public class CJDCQ_IDGHelper2 : BaseIDG |
|
{ |
|
public string IDataChangeName { get => "XZQ_IDGHelper"; } |
|
private string TempGDBPath = string.Empty; |
|
private string TempDBPath = string.Empty; |
|
private string TempDir = string.Empty; |
|
|
|
IDGParameter IDGParm = null; |
|
|
|
public void Execute(IDGParameter pParm) |
|
{ |
|
ThreadManager.Instance.QueueUserWorkItem(new System.Threading.WaitCallback(ExeCJDCQ), pParm, new System.Threading.WaitCallback(ComplateCallBack)); |
|
//ExeCJDCQ(pParm); |
|
} |
|
public void ComplateCallBack(object obj) |
|
{ |
|
Console.WriteLine("Log:村级调查区数据提取完成。"); |
|
} |
|
|
|
public void ExeCJDCQ(object obj) |
|
{ |
|
IDGParameter Parm = obj as IDGParameter; |
|
IDGParm = Parm; |
|
|
|
Console.WriteLine("Log:正在进行村级调查区数据提取,请稍候..."); |
|
IFeatureLayer TempGXLayer = null; |
|
try |
|
{ |
|
GPParamClass paramClass = new GPParamClass(); |
|
TempDir = CreateTempDB("CJDCQ"); |
|
TempGDBPath = System.IO.Path.Combine(TempDir, "TempGDB.gdb"); |
|
TempDBPath = TempDir + @"\Temp" + ".sqlite"; |
|
|
|
//CJDCQ_Param bgParm = new CJDCQ_Param(); |
|
OpenDB(Parm); |
|
IRDBHelper rdbHelper = null; |
|
List<DataDicTionary> qsDic = null; |
|
try |
|
{ |
|
rdbHelper = RDBFactory.CreateDbHelper(System.IO.Path.Combine(Parm.PrjInfo.ProjDir, "BGTJ.sqlite"), DatabaseType.SQLite); |
|
DataTable dicDt = rdbHelper.ExecuteDatatable("Dic", string.Format("SELECT * from Sys_Dicdetail where OWNERDIC=1"), true); |
|
|
|
//jccjdcqLayer = Parm.JC_CJDCQLay as IFeatureLayer; |
|
qsDic = KGIS.Framework.Utils.Utility.TBToList.ToList<DataDicTionary>(dicDt);// Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.QSDM); |
|
|
|
} |
|
catch (Exception ex) |
|
{ |
|
Console.WriteLine("Err:获取权属字典失败!" + ex.Message); |
|
LogAPI.Debug(ex); |
|
} |
|
finally |
|
{ |
|
if (rdbHelper != null) |
|
rdbHelper.DisConnect(); |
|
} |
|
//string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\NMK"; |
|
//if (!System.IO.Directory.Exists(gdbFolder)) |
|
//{ |
|
// System.IO.Directory.CreateDirectory(gdbFolder); |
|
//} |
|
//try |
|
//{ DelectDir(gdbFolder); } |
|
//catch |
|
//{ } |
|
//string gdbFileName = Guid.NewGuid().ToString() + ".gdb"; |
|
//string path = System.IO.Path.Combine(gdbFolder, gdbFileName); |
|
//IWorkspaceFactory pFtWsFct = new FileGDBWorkspaceFactory(); |
|
//IWorkspaceName workspaceName = pFtWsFct.Create(gdbFolder, gdbFileName, null, 0); |
|
|
|
List<string> columns = new List<string>() { "ZLDWDM", "MSSM", "HDMC" };//, "ZLDWMC", "XZQTZLX" |
|
//if (cb_ZLDWMCChange == true) |
|
//{ |
|
// columns = new List<string>() { "ZLDWDM", "ZLDWMC", "MSSM", "HDMC" }; |
|
//} |
|
//GeoprocessorHelper gpHelper = new GeoprocessorHelper(); |
|
|
|
GPParamClass gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = NmTbLayer; |
|
//gPParamClass.FirstFeatureClassPath = Parm.NmDbPath + "\\DLTB_NMK"; |
|
gPParamClass.OutFeatureClassPath = TempGDBPath + "\\" + "TempCJDCQGX"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
gPParamClass.ListDissolveFiledName = columns; |
|
gPParamClass.GPType = EnumGPType.Dissolve; |
|
//gpHelper.DissolveAnalysis(gPParamClass, ref TempGXLayer); |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref TempGXLayer); |
|
//Parm.GX_CJDCQLay = cjdcqgxFeatureLayer; |
|
|
|
IFeatureLayer jcLayer = null; |
|
gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = JcCjdcqLayer; |
|
//gPParamClass.FirstFeatureClassPath = Parm.JcDbPath + "\\CJDCQ"; |
|
//gPParamClass.SecondFeatureClassPath = "JC_CJDCQ"; |
|
gPParamClass.OutFeatureClassPath = TempGDBPath; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
gPParamClass.ListDissolveFiledName = new List<string>(); |
|
gPParamClass.FcName = "JC_CJDCQ"; |
|
gPParamClass.GPType = EnumGPType.FcToFc; |
|
//gpHelper.FeatureClassToFeatureClass(gPParamClass, "JC_CJDCQ", ref jcLayer); |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref jcLayer); |
|
JcCjdcqLayer = jcLayer; |
|
//Parm.JC_CJDCQLay = JCCJDCQLayer; |
|
//if (drqCJDCQFc != null) |
|
//{ |
|
// fcAPI = new FeatureClassAPI(drqCJDCQFc); |
|
// fcAPI.FcToFc(jccjdcqLayer.FeatureClass, null, false); |
|
//} |
|
|
|
IFeatureCursor cursor = null; |
|
int zldwdmIdx = TempGXLayer.FeatureClass.FindField("ZLDWDM"); |
|
int zldwmcIdx = TempGXLayer.FeatureClass.FindField("ZLDWMC"); |
|
int mssmIdx = TempGXLayer.FeatureClass.FindField("MSSM"); |
|
int hdmcIdx = TempGXLayer.FeatureClass.FindField("HDMC"); |
|
int areaIdx = TempGXLayer.FeatureClass.FindField("SHAPE_AREA"); |
|
int lengthIdx = TempGXLayer.FeatureClass.FindField("SHAPE_LENGTH"); |
|
int jc_zldwdmIdx = JcCjdcqLayer.FeatureClass.FindField("ZLDWDM"); |
|
int jc_zldwmcIdx = JcCjdcqLayer.FeatureClass.FindField("ZLDWMC"); |
|
int jc_mssmIdx = JcCjdcqLayer.FeatureClass.FindField("MSSM"); |
|
int jc_hdmcIdx = JcCjdcqLayer.FeatureClass.FindField("HDMC"); |
|
int jc_areaIdx = JcCjdcqLayer.FeatureClass.FindField("SHAPE_AREA"); |
|
int jc_lengthIdx = JcCjdcqLayer.FeatureClass.FindField("SHAPE_LENGTH"); |
|
int xzqtzlxIndex = TempGXLayer.FeatureClass.FindField("XZQTZLX"); |
|
string zldwdm = string.Empty; |
|
string zldwmc = string.Empty; |
|
string mssm = string.Empty; |
|
string hdmc = string.Empty; |
|
IFeature f = null; |
|
ITable cjdcqgxTb = GxCjdcqLayer.FeatureClass as ITable; |
|
cjdcqgxTb.DeleteSearchedRows(null); |
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(TempGXLayer.FeatureClass); |
|
//if (cb_ZLDWMCChange == false) |
|
//{ |
|
// fcAPI.AddField("ZLDWMC", esriFieldType.esriFieldTypeString, "坐落单位名称"); |
|
//} |
|
fcAPI.AddField("BSM", esriFieldType.esriFieldTypeString, "标识码"); |
|
fcAPI.AddField("GXSJ", esriFieldType.esriFieldTypeDate, "更新时间"); |
|
fcAPI.AddField("DCMJ", esriFieldType.esriFieldTypeDouble, "调查面积"); |
|
//if (cb_ZLDWMCChange == false) |
|
//{ |
|
zldwmcIdx = TempGXLayer.FeatureClass.FindField("ZLDWMC"); |
|
cursor = TempGXLayer.FeatureClass.Update(null, false); |
|
while ((f = cursor.NextFeature()) != null) |
|
{ |
|
if (zldwdmIdx != -1) |
|
zldwdm = f.Value[zldwdmIdx].ToTrim(); |
|
if (zldwmcIdx != -1 && qsDic != null) |
|
{ |
|
var qs = qsDic.FirstOrDefault(dic => dic.CODE == zldwdm); |
|
if (qs != null) |
|
{ |
|
f.Value[zldwmcIdx] = qs.NAME; |
|
cursor.UpdateFeature(f); |
|
} |
|
} |
|
} |
|
cursor.Flush(); |
|
fcAPI.FcToFc(GxCjdcqLayer.FeatureClass, null, false); |
|
//} |
|
GenerateGxgcData(Parm); |
|
int gcNum = GxgcCjdcqLayer.FeatureClass.FeatureCount(null); |
|
if (gcNum == 0) |
|
{ |
|
(GxCjdcqLayer.FeatureClass as ITable).DeleteSearchedRows(null); |
|
} |
|
else |
|
{ |
|
//fcAPI.FcToFc(bgParm.GXLayer.FeatureClass, null, false); |
|
CJDCQExtractExe(Parm);//村级调查区界线 |
|
} |
|
Console.WriteLine("Log:村级调查区数据提取完成。"); |
|
} |
|
catch (Exception ex) |
|
{ |
|
Console.WriteLine("Err:村级调查区数据提取失败。"); |
|
//LogAPI.Debug("Err:提取村级调查区错误:" + ex.Message.ToString()); |
|
//LogAPI.Debug(ex); |
|
throw ex; |
|
} |
|
} |
|
public void OpenDB(IDGParameter parm) |
|
{ |
|
try |
|
{ |
|
LayerCfg layerInfo = null; |
|
if (parm.PrjInfo != null && !string.IsNullOrWhiteSpace(parm.PrjInfo.TempData)) |
|
{ |
|
byte[] contentArray = Convert.FromBase64String(parm.PrjInfo.TempData); |
|
string LayerCfg = System.Text.Encoding.Default.GetString(contentArray); |
|
layerInfo = KGIS.Framework.Utils.SerializeAPI.DeserializeToObject<LayerCfg>(LayerCfg); |
|
} |
|
if (layerInfo == null) |
|
{ |
|
throw new Exception("Err:获取图层信息失败!"); |
|
} |
|
//FileInfo fileInfo = new FileInfo(parm.PrjInfo.BGDatabase); |
|
string PathBgDB = parm.PrjInfo.BGDatabase;// Path.Combine(, "BGDB" + ".gdb"); |
|
string PathZLDB = parm.PrjInfo.ZLDatabase; |
|
string PathNMDB = parm.PrjInfo.NMDatabase;// System.IO.Path.Combine(fileInfo.DirectoryName, "NMDB" + ".gdb"); |
|
BgWsAPI = new WorkspaceAPI(PathBgDB, WorkspaceTypeEnum.GDBFile); |
|
if (BgWsAPI.CurrentWorkspace == null) |
|
{ |
|
Console.WriteLine("打开变更数据库失败!"); |
|
return; |
|
} |
|
ZlWsAPI = new WorkspaceAPI(PathZLDB, WorkspaceTypeEnum.GDBFile); |
|
if (ZlWsAPI.CurrentWorkspace == null) |
|
{ |
|
Console.WriteLine("打开增量数据库失败!"); |
|
return; |
|
} |
|
NmWsAPI = new WorkspaceAPI(PathNMDB, WorkspaceTypeEnum.GDBFile); |
|
|
|
|
|
LayerCfg JCLayerInfo = layerInfo.Layers.FirstOrDefault(f => f.LayerName == "年初数据"); |
|
if (JCLayerInfo == null) |
|
{ |
|
throw new Exception("Err:获取年初数据库失败!"); |
|
} |
|
List<LayerCfg> NcList = JCLayerInfo.GetAllItem(); |
|
if (parm.ExeDLTB) |
|
{ |
|
LayerCfg _JcTBLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "地类图斑"); |
|
|
|
_jcTbLayer = OpenLayer(_JcTBLayerInfo); |
|
if (_jcTbLayer == null) |
|
{ |
|
throw new Exception("Err:获取年初地类图斑数据失败!"); |
|
} |
|
|
|
} |
|
if (parm.ExeCJDCQ) |
|
{ |
|
LayerCfg _JcCjdcqLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "村级调查区"); |
|
_jcCjdcqLayer = OpenLayer(_JcCjdcqLayerInfo); |
|
if (_jcCjdcqLayer == null) |
|
throw new Exception("Err:获取年初村级调查区数据失败!"); |
|
LayerCfg _JcCjdcqJxLayerInfo = NcList.FirstOrDefault(f => f.LayerName == "村级调查区界线"); |
|
_jcCjdcqJxLayer = OpenLayer(_JcCjdcqJxLayerInfo); |
|
if (_JcCjdcqJxLayerInfo == null) |
|
throw new Exception("Err:获取年初村级调查区界线数据失败!"); |
|
_gxCjdcqLayer = OpenLayer(ZlWsAPI, "CJDCQGX"); |
|
_gxgcCjdcqLayer = OpenLayer(ZlWsAPI, "CJDCQGXGC"); |
|
_gxCjdcqJxLayer = OpenLayer(ZlWsAPI, "CJDCQJXGX"); |
|
_gxgcTBLayer = OpenLayer(ZlWsAPI, "DLTBGXGC"); |
|
if (_nmTbLayer == null) |
|
_nmTbLayer = OpenLayer(NmWsAPI, "DLTB_NMK"); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
|
|
|
|
|
|
#region 提取行政区界线 |
|
|
|
public void InsertXZQGXFeature(IFeature pGXJX, int BGXW, string JXLX, string JXXZ, IFeatureClass JC_XZQJX, IFeatureClass XZQJXGX) |
|
{ |
|
IFeatureCursor gx_cursor = null; |
|
IFeatureBuffer gx_buffer = null; |
|
try |
|
{ |
|
bool IsInsert = true; |
|
var Identify = FeatureAPI.Identify2(pGXJX.Shape, new FeatureLayer() { FeatureClass = XZQJXGX }); |
|
if (Identify.Count > 0) |
|
{ |
|
foreach (var item in Identify) |
|
{ |
|
if (FeatureAPI.GetEqual(item.ShapeCopy, pGXJX.Shape) && FeatureAPI.GetEqual(pGXJX.Shape, item.ShapeCopy) && BGXW != 3) |
|
{ |
|
IsInsert = false; |
|
break; |
|
} |
|
} |
|
} |
|
if (IsInsert) |
|
{ |
|
if (string.IsNullOrWhiteSpace(strXZQJXMaxBSM)) |
|
{ |
|
strXZQJXMaxBSM = SetMaxBSM(JC_XZQJX, XZQJXGX); |
|
if (!strXZQJXMaxBSM.StartsWith(IDGParm.PrjInfo.CODE)) |
|
strXZQJXMaxBSM = IDGParm.PrjInfo.CODE + "1220" + "1".PadLeft(8, '0'); |
|
} |
|
else |
|
{ |
|
string bsmPrefix = IDGParm.PrjInfo.CODE + strXZQJXMaxBSM.Substring(6, 4); |
|
int MaxNum = Convert.ToInt32(strXZQJXMaxBSM.Substring(9)); |
|
strXZQJXMaxBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); |
|
} |
|
gx_cursor = XZQJXGX.Insert(true); |
|
gx_buffer = XZQJXGX.CreateFeatureBuffer(); |
|
gx_buffer.Shape = pGXJX.Shape; |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("BSM"), BGXW == 3 ? strXZQJXMaxBSM : pGXJX.Value[pGXJX.Fields.FindField("BSM")]); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("JXLX"), JXLX); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("JXXZ"), JXXZ); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("JXSM"), BGXW == 3 ? string.Empty : pGXJX.Value[pGXJX.Fields.FindField("JXSM")]); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("BZ"), BGXW == 3 ? string.Empty : pGXJX.Value[pGXJX.Fields.FindField("BZ")]); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("BGXW"), BGXW); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("GXSJ"), DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31)); |
|
gx_cursor.InsertFeature(gx_buffer); |
|
gx_cursor.Flush(); |
|
Marshal.ReleaseComObject(gx_buffer); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("写入村级调查区界线更新层数据时发生异常,异常信息如下:"); |
|
LogAPI.Debug(ex); |
|
LogAPI.Debug("异常信息结束"); |
|
} |
|
finally |
|
{ |
|
if (gx_cursor != null) |
|
Marshal.ReleaseComObject(gx_cursor); |
|
if (gx_buffer != null) |
|
Marshal.ReleaseComObject(gx_buffer); |
|
} |
|
} |
|
|
|
private string strXZQJXMaxBSM = string.Empty; |
|
|
|
private string SetMaxBSM(IFeatureClass JC_XZQJX, IFeatureClass XZQJXGC) |
|
{ |
|
var MaxBSM = GetMaxBSM(new List<IFeatureClass>() { JC_XZQJX, XZQJXGC }); |
|
string bsmPrefix = IDGParm.PrjInfo.CODE + MaxBSM.Substring(6, 4); |
|
int MaxNum = Convert.ToInt32(MaxBSM.Substring(9)); |
|
MaxBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); |
|
return MaxBSM; |
|
} |
|
private string GetMaxBSM(List<IFeatureClass> fcList) |
|
{ |
|
int xh = 0; |
|
string MaxBSM = ""; |
|
string leftStr = string.Empty; |
|
foreach (var fc in fcList) |
|
{ |
|
string BSM = string.Empty; |
|
int BSMIndex = fc.FindField("BSM"); |
|
if (BSMIndex == -1) return BSM; |
|
|
|
ITable table = (ITable)fc; |
|
// 创建一个ITableSort接口对象 |
|
ITableSort tableSort = new TableSortClass(); |
|
tableSort.Table = table; |
|
tableSort.Fields = "BSM"; |
|
tableSort.set_Ascending("BSM", false); |
|
tableSort.Sort(null); |
|
ICursor cursor = tableSort.Rows; |
|
IRow row = cursor.NextRow(); |
|
if (row != null) |
|
{ |
|
int maxBSM = 0; |
|
int currBSM = 0; |
|
string BSMStr = row.Value[BSMIndex].ToString(); |
|
if (BSMStr.Length != 18) return BSM; |
|
string subBSMStr = BSMStr.Substring(9); |
|
try |
|
{ |
|
currBSM = Convert.ToInt32(subBSMStr); |
|
} |
|
catch (Exception) |
|
{ |
|
return BSM; |
|
} |
|
if (currBSM > maxBSM) maxBSM = currBSM; |
|
|
|
if (BSMStr.Length != 18) return BSM; |
|
string maxStr = maxBSM.ToString(); |
|
int zeroNum = 9 - maxStr.Length; |
|
for (int i = 0; i < zeroNum; i++) |
|
{ |
|
maxStr = 0 + maxStr; |
|
} |
|
BSM = BSMStr.Substring(0, 9) + maxStr; |
|
} |
|
if (BSM.Length != 18) |
|
continue; |
|
int xh2 = Convert.ToInt32(BSM.Substring(10)); |
|
leftStr = BSM.Substring(0, 10); |
|
if (xh < xh2) |
|
{ |
|
xh = xh2; |
|
MaxBSM = BSM; |
|
} |
|
} |
|
return MaxBSM; |
|
} |
|
|
|
#endregion |
|
|
|
#region 提取村级调查区界界线 |
|
public void CJDCQExtractExe(IDGParameter pParm) |
|
{ |
|
bool cb_XZQDMChange = false; |
|
IFeatureClass CJDCQGXFeatureClass = null; |
|
IFeatureClass CJDCQGXGCFeatureClass = null; |
|
IFeatureLayer JCCJDCQFeatureLayer = null; |
|
IFeatureLayer JCCJDCQJXFeatureLayer = null; |
|
IFeatureClassAPI cjdcqgxgcfcAPI = null; |
|
IFeatureLayer gx_cjdcqLayer = null; |
|
IFeatureLayer gxgc_cjdcqLayer = null; |
|
IFeatureLayer gx_cjdcqjxLayer = null; |
|
try |
|
{ |
|
//if (_MapService == null) |
|
// _MapService = MapsManager.Instance.MapService; |
|
gx_cjdcqLayer = GxCjdcqLayer; |
|
gxgc_cjdcqLayer = GxgcCjdcqLayer; |
|
gx_cjdcqjxLayer = GxCjdcqJxLayer; |
|
CJDCQGXFeatureClass = gx_cjdcqLayer.FeatureClass;// _MapService.GetFeatureClassByName("CJDCQGX");//村级调查区更新层 |
|
CJDCQGXGCFeatureClass = gxgc_cjdcqLayer.FeatureClass;// _MapService.GetFeatureClassByName("CJDCQGXGC");//村级调查区更新过程层 |
|
JCCJDCQFeatureLayer = JcCjdcqLayer;// _MapService.GetFeatureLayerByLayerName("村级调查区");//基础村级调查区 |
|
JCCJDCQJXFeatureLayer = JcCjdcqJxLayer;// _MapService.GetFeatureLayerByLayerName("村级调查区界线");//基础村级调查区界线 |
|
if (CJDCQGXGCFeatureClass.FeatureCount(null) == 0) return; |
|
cjdcqgxgcfcAPI = new FeatureClassAPI(CJDCQGXGCFeatureClass); |
|
List<IFeature> cjdcqgxgcList = cjdcqgxgcfcAPI.QueryFeatures(null); |
|
IFeature cjdcqGXGC = FeatureAPI.MergeFeature(cjdcqgxgcList); |
|
List<IFeature> features = FeatureAPI.Identify(cjdcqGXGC.ShapeCopy, JCCJDCQFeatureLayer); |
|
string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\CJDCQJXGX"; |
|
if (!System.IO.Directory.Exists(gdbFolder)) |
|
{ |
|
System.IO.Directory.CreateDirectory(gdbFolder); |
|
} |
|
try |
|
{ |
|
DelectDir(gdbFolder);//能删除就删除 删除报错不处理 |
|
} |
|
catch |
|
{ } |
|
string gdbFileName = Guid.NewGuid().ToString() + ".gdb"; |
|
string path = System.IO.Path.Combine(gdbFolder, gdbFileName); |
|
IWorkspaceFactory pFtWsFct = new FileGDBWorkspaceFactory(); |
|
IWorkspaceName workspaceName = pFtWsFct.Create(gdbFolder, gdbFileName, null, 0); |
|
IWorkspaceAPI psTempWorkspaceAPI = new WorkspaceAPI(path, WorkspaceTypeEnum.GDBFile); |
|
IFeatureClassAPI tempcjdcqgxFeatureclassAPI = psTempWorkspaceAPI.CreateFeatureClass("CJDCQGX_TEMP", (CJDCQGXFeatureClass as IGeoDataset).SpatialReference, CJDCQGXFeatureClass.Fields); |
|
tempcjdcqgxFeatureclassAPI.AddField("IsJCTB", esriFieldType.esriFieldTypeString, "基础图斑"); |
|
JCCJDCQInsertGX(features, tempcjdcqgxFeatureclassAPI.FeatureClass, null);//将基础村级调查区数据插入到更新过程层,变更前变更后的属性数据一致 |
|
IFeatureClassAPI cjdcqgxFeatureclassAPI = psTempWorkspaceAPI.CreateFeatureClass("CJDCQGX", (CJDCQGXFeatureClass as IGeoDataset).SpatialReference, CJDCQGXFeatureClass.Fields); |
|
cjdcqgxFeatureclassAPI.AddField("IsJCTB", esriFieldType.esriFieldTypeString, "基础图斑"); |
|
IFeatureClassAPI fcAPI = new FeatureClassAPI(CJDCQGXFeatureClass); |
|
fcAPI.FcToFc(cjdcqgxFeatureclassAPI.FeatureClass, null, false); |
|
IQueryFilter filter = new QueryFilterClass(); |
|
filter.WhereClause = string.Format(" BGHZLDWDM is null or BGHZLDWDM=''"); |
|
CJDCQGXMSInsertGX(CJDCQGXGCFeatureClass, cjdcqgxFeatureclassAPI.FeatureClass, filter); |
|
|
|
IFeatureLayer cjdcqgxJCLayer = null; |
|
GPParamClass gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = new FeatureLayerClass() { FeatureClass = tempcjdcqgxFeatureclassAPI.FeatureClass }; |
|
gPParamClass.SecondFeatureLayer = new FeatureLayerClass() { FeatureClass = cjdcqgxFeatureclassAPI.FeatureClass }; |
|
gPParamClass.OutFeatureClassPath = System.IO.Path.Combine(path, "CJDCQGX_JC"); |
|
gPParamClass.IsGetOutPutFeature = true; |
|
gPParamClass.GPType = EnumGPType.Erase; |
|
//GeoprocessorHelper gpHelper = new GeoprocessorHelper(); |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref cjdcqgxJCLayer); |
|
fcAPI = new FeatureClassAPI(cjdcqgxJCLayer.FeatureClass); |
|
fcAPI.AddField("IsJCTB", esriFieldType.esriFieldTypeString, "基础图斑"); |
|
|
|
fcAPI = new FeatureClassAPI(cjdcqgxJCLayer.FeatureClass); |
|
fcAPI.FcToFc(cjdcqgxFeatureclassAPI.FeatureClass, null, false); |
|
|
|
filter = new QueryFilterClass(); |
|
filter.WhereClause = string.Format("SHAPE_AREA<0.1"); |
|
(cjdcqgxFeatureclassAPI.FeatureClass as ITable).DeleteSearchedRows(filter); |
|
|
|
// 村级调查区更新过程要素转线 |
|
IFeatureLayer cjdcqgxgcjxLayer = null; |
|
gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = new FeatureLayerClass() { FeatureClass = cjdcqgxFeatureclassAPI.FeatureClass }; |
|
gPParamClass.OutFeatureClassPath = System.IO.Path.Combine(path, "CJDCQGX_JX"); |
|
gPParamClass.IsGetOutPutFeature = true; |
|
gPParamClass.GPType = EnumGPType.PolygonToLine; |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref cjdcqgxgcjxLayer); |
|
|
|
// 村级调查区更新过程界线取消线分割 |
|
IFeatureLayer gxgcjxUnsplitLayer = null; |
|
gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = cjdcqgxgcjxLayer; |
|
gPParamClass.OutFeatureClassPath = System.IO.Path.Combine(path, "CJDCQGXGCJX_Unsplit"); |
|
gPParamClass.IsGetOutPutFeature = true; |
|
gPParamClass.ListDissolveFiledName = new List<string>() { "LEFT_FID", "RIGHT_FID" }; |
|
gPParamClass.GPType = EnumGPType.UnsplitLine; |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref gxgcjxUnsplitLayer); |
|
|
|
Dictionary<int, string> zldwdmDic = new Dictionary<int, string>(); |
|
Dictionary<int, string> isjctbDic = new Dictionary<int, string>(); |
|
int objectidIndex = cjdcqgxFeatureclassAPI.FeatureClass.Fields.FindField("OBJECTID"); |
|
int bghzldwdmIndex = cjdcqgxFeatureclassAPI.FeatureClass.Fields.FindField("ZLDWDM"); |
|
int gxgcIndex = cjdcqgxFeatureclassAPI.FeatureClass.Fields.FindField("IsJCTB"); |
|
IFeatureCursor gxgcjxCursor = cjdcqgxFeatureclassAPI.FeatureClass.Search(null, true); |
|
IFeature gxgcFeature = null; |
|
while ((gxgcFeature = gxgcjxCursor.NextFeature()) != null) |
|
{ |
|
if (objectidIndex == -1) |
|
continue; |
|
int objectid = int.Parse(gxgcFeature.Value[objectidIndex].ToString()); |
|
if (bghzldwdmIndex != -1) |
|
{ |
|
string zldwdm = gxgcFeature.Value[bghzldwdmIndex].ToString(); |
|
if (objectid != 0) |
|
zldwdmDic.Add(objectid, zldwdm); |
|
} |
|
if (gxgcIndex != -1) |
|
{ |
|
string jctb = gxgcFeature.Value[gxgcIndex].ToString(); |
|
|
|
if (objectid != 0) |
|
isjctbDic.Add(objectid, jctb); |
|
} |
|
Marshal.ReleaseComObject(gxgcFeature); |
|
} |
|
IFeatureClass CJDCQJXGXFeatureClass = gx_cjdcqjxLayer.FeatureClass;// _MapService.GetFeatureClassByName("CJDCQJXGX"); |
|
ITable table = CJDCQJXGXFeatureClass as ITable; |
|
table.DeleteSearchedRows(null); |
|
int leftidIndex = gxgcjxUnsplitLayer.FeatureClass.Fields.FindField("LEFT_FID"); |
|
int rightIndex = gxgcjxUnsplitLayer.FeatureClass.Fields.FindField("RIGHT_FID"); |
|
int shapeLengthIndex = gxgcjxUnsplitLayer.FeatureClass.Fields.FindField("SHAPE_LENGTH"); |
|
IFeatureCursor gxgcjxUnsplitCursor = null; |
|
IFeature f = null; |
|
List<int> MS_OID = new List<int>(); |
|
IFeatureCursor xzqgxCur = CJDCQGXFeatureClass.Search(null, true); |
|
IFeature xzqgx = null; |
|
while ((xzqgx = xzqgxCur.NextFeature()) != null) |
|
{ |
|
List<IFeature> jcjx_features = FeatureAPI.Identify2(xzqgx.ShapeCopy, JCCJDCQJXFeatureLayer); |
|
foreach (var item in jcjx_features) |
|
{ |
|
if (!MS_OID.Contains(item.OID)) |
|
MS_OID.Add(item.OID); |
|
} |
|
} |
|
if (cb_XZQDMChange == true) |
|
{ |
|
gxgcjxUnsplitCursor = JCCJDCQJXFeatureLayer.FeatureClass.Search(null, true); |
|
while ((f = gxgcjxUnsplitCursor.NextFeature()) != null) |
|
{ |
|
string jcjxlx2 = f.Value[f.Fields.FindField("JXLX")].ToString(); |
|
string jcjxxz2 = f.Value[f.Fields.FindField("JXXZ")].ToString(); |
|
InsertXZQGXFeature(f, 0, jcjxlx2, jcjxxz2, JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
if (MS_OID.Contains(f.OID)) |
|
MS_OID.Remove(f.OID); |
|
} |
|
} |
|
gxgcjxUnsplitCursor = gxgcjxUnsplitLayer.Search(null, true); |
|
while ((f = gxgcjxUnsplitCursor.NextFeature()) != null) |
|
{ |
|
IPolyline line = f.ShapeCopy as IPolyline; |
|
IPoint p = line.FromPoint; |
|
List<IFeature> lines = FeatureAPI.Identify2(p, gxgcjxUnsplitLayer); |
|
if (lines.Count < 3) |
|
{ |
|
foreach (var item in lines) |
|
{ |
|
if (item.OID == f.OID) |
|
continue; |
|
IFeatureEdit edit = item as IFeatureEdit; |
|
List<IPolyline> splitLines = FeatureAPI.SplitLineAtPoint(p, item.ShapeCopy as IPolyline); |
|
if (splitLines.Count > 1) |
|
edit.Split(p); |
|
} |
|
} |
|
} |
|
gxgcjxUnsplitCursor = gxgcjxUnsplitLayer.Search(null, true); |
|
string jxlx = "";//界线类型 |
|
List<int> JC_OID = new List<int>(); |
|
while ((f = gxgcjxUnsplitCursor.NextFeature()) != null) |
|
{ |
|
if (f.OID == 362) |
|
{ |
|
} |
|
if (leftidIndex == -1 || rightIndex == -1) |
|
{ |
|
continue; |
|
} |
|
List<IFeature> jcjx_features = FeatureAPI.Identify2(f.ShapeCopy, JCCJDCQJXFeatureLayer); |
|
int leftID = int.Parse(f.Value[leftidIndex].ToString()); |
|
int rightID = int.Parse(f.Value[rightIndex].ToString()); |
|
double gxshapeLength = f.Value[shapeLengthIndex].ToDouble(2); |
|
string leftzldwdm = leftID == -1 ? "" : zldwdmDic[leftID]; |
|
string rightzldwdm = rightID == -1 ? "" : zldwdmDic[rightID]; |
|
string leftIsjctb = leftID == -1 ? "0" : isjctbDic[leftID]; |
|
string rightIsjctb = rightID == -1 ? "0" : isjctbDic[rightID]; |
|
string bghJXLX = string.Empty; |
|
if (!string.IsNullOrWhiteSpace(leftIsjctb) && !string.IsNullOrWhiteSpace(rightIsjctb) && jcjx_features.Count > 1) |
|
{ |
|
foreach (var item in jcjx_features) |
|
{ |
|
if (MS_OID.Contains(item.OID)) |
|
MS_OID.Remove(item.OID); |
|
} |
|
continue; |
|
} |
|
if (leftzldwdm.Length == rightzldwdm.Length) |
|
{ |
|
if (leftzldwdm.Length == 0) |
|
{ |
|
bghJXLX = ""; |
|
|
|
} |
|
else if (leftzldwdm.Substring(0, 6) != rightzldwdm.Substring(0, 6)) |
|
{ |
|
//县界 |
|
bghJXLX = "650200"; |
|
} |
|
else if (leftzldwdm.Substring(0, 9) != rightzldwdm.Substring(0, 9)) |
|
{ |
|
//乡镇界 |
|
bghJXLX = "660200"; |
|
} |
|
else if (leftzldwdm.Substring(0, 12) == rightzldwdm.Substring(0, 12)) |
|
{ |
|
bghJXLX = ""; |
|
} |
|
else |
|
{ |
|
//村界 |
|
bghJXLX = "670500"; |
|
} |
|
} |
|
else |
|
{ |
|
//县界 |
|
bghJXLX = "650200"; |
|
} |
|
if (cb_XZQDMChange == true) |
|
{ |
|
InsertCJDCQGXFeature(f, 3, bghJXLX, "600001", JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
continue; |
|
} |
|
if (jcjx_features.Count > 1) |
|
{ |
|
//相关基础界线标记删除,新生成的界线标记新增 |
|
foreach (var item in jcjx_features) |
|
{ |
|
if (JC_OID.Contains(item.OID)) |
|
continue; |
|
JC_OID.Add(item.OID); |
|
string jcjxlx2 = item.Value[item.Fields.FindField("JXLX")].ToString(); |
|
string jcjxxz2 = item.Value[item.Fields.FindField("JXXZ")].ToString(); |
|
InsertCJDCQGXFeature(item, 0, jcjxlx2, jcjxxz2, JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
if (MS_OID.Contains(item.OID)) |
|
MS_OID.Remove(item.OID); |
|
} |
|
if (!string.IsNullOrWhiteSpace(bghJXLX)) |
|
InsertCJDCQGXFeature(f, 3, bghJXLX, "600001", JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
continue; |
|
} |
|
if (jcjx_features.Count == 0) |
|
{ |
|
//新生成的界线标记新增 |
|
InsertCJDCQGXFeature(f, 3, bghJXLX, "600001", JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
continue; |
|
} |
|
IFeature jcfeature = jcjx_features[0]; |
|
string jcjxlx = jcfeature.Value[jcfeature.Fields.FindField("JXLX")].ToString(); |
|
string jcjxxz = jcfeature.Value[jcfeature.Fields.FindField("JXXZ")].ToString(); |
|
double jcshapeLength = jcfeature.Value[jcfeature.Fields.FindField("SHAPE_LENGTH")].ToDouble(2); |
|
if (string.IsNullOrWhiteSpace(bghJXLX)) |
|
{ |
|
if (!JC_OID.Contains(jcfeature.OID)) |
|
{ |
|
JC_OID.Add(jcfeature.OID); |
|
InsertCJDCQGXFeature(jcfeature, 0, jcjxlx, jcjxxz, JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
if (MS_OID.Contains(jcfeature.OID)) |
|
MS_OID.Remove(jcfeature.OID); |
|
} |
|
continue; |
|
} |
|
if (gxshapeLength == jcshapeLength) |
|
{ |
|
if (!string.IsNullOrWhiteSpace(leftIsjctb) && !string.IsNullOrWhiteSpace(rightIsjctb)) |
|
{ |
|
continue; |
|
} |
|
//长度一样,表示界线图形为变化 |
|
if (bghJXLX == jcjxlx) |
|
{ |
|
IPointCollection gxPs = f.ShapeCopy as IPointCollection; |
|
IPointCollection jcPs = jcfeature.ShapeCopy as IPointCollection; |
|
if (gxPs.PointCount != jcPs.PointCount) |
|
{ |
|
InsertCJDCQGXFeature(jcfeature, 0, jcjxlx, jcjxxz, JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
InsertCJDCQGXFeature(f, 3, bghJXLX, jcjxxz, JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
} |
|
else |
|
{ |
|
InsertCJDCQGXFeature(jcfeature, 4, jcjxlx, jcjxxz, JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
} |
|
if (MS_OID.Contains(jcfeature.OID)) |
|
MS_OID.Remove(jcfeature.OID); |
|
continue; |
|
} |
|
else |
|
{ |
|
if (!JC_OID.Contains(jcfeature.OID)) |
|
{ |
|
JC_OID.Add(jcfeature.OID); |
|
InsertCJDCQGXFeature(jcfeature, 0, jcjxlx, jcjxxz, JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
if (MS_OID.Contains(jcfeature.OID)) |
|
MS_OID.Remove(jcfeature.OID); |
|
} |
|
//相关基础界线标记删除,新生成的界线标记新增 |
|
InsertCJDCQGXFeature(f, 3, bghJXLX, jcjxxz, JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
} |
|
} |
|
else |
|
{ |
|
if (!JC_OID.Contains(jcfeature.OID)) |
|
{ |
|
JC_OID.Add(jcfeature.OID); |
|
InsertCJDCQGXFeature(jcfeature, 0, jcjxlx, jcjxxz, JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
if (MS_OID.Contains(jcfeature.OID)) |
|
MS_OID.Remove(jcfeature.OID); |
|
} |
|
//相关基础界线标记删除,新生成的界线标记新增 |
|
InsertCJDCQGXFeature(f, 3, bghJXLX, jcjxxz, JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
} |
|
} |
|
foreach (var item in MS_OID) |
|
{ |
|
IFeature jcfeature = JCCJDCQJXFeatureLayer.FeatureClass.GetFeature(item); |
|
string jcjxlx = jcfeature.Value[jcfeature.Fields.FindField("JXLX")].ToString(); |
|
string jcjxxz = jcfeature.Value[jcfeature.Fields.FindField("JXXZ")].ToString(); |
|
InsertCJDCQGXFeature(jcfeature, 0, jcjxlx, jcjxxz, JCCJDCQJXFeatureLayer.FeatureClass, CJDCQJXGXFeatureClass); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("图斑变更发生异常!异常信息如下:"); |
|
LogAPI.Debug(ex); |
|
LogAPI.Debug("异常信息结束"); |
|
throw; |
|
} |
|
} |
|
|
|
private void JCCJDCQInsertGX(List<IFeature> jcfeatures, IFeatureClass gxfeatureClass, IQueryFilter pFilter) |
|
{ |
|
IFeatureCursor T_Cursor = null; |
|
try |
|
{ |
|
Dictionary<int, int> fieldsDic = new Dictionary<int, int>(); |
|
for (int i = 0; i < gxfeatureClass.Fields.FieldCount; i++) |
|
{ |
|
IField field = gxfeatureClass.Fields.Field[i]; |
|
if (field.Name == gxfeatureClass.ShapeFieldName || field.Name.Contains(gxfeatureClass.ShapeFieldName) || field.Name == gxfeatureClass.OIDFieldName || !field.Editable) continue; |
|
|
|
int index = -1; |
|
index = jcfeatures[0].Fields.FindField(field.Name); |
|
if (index == -1) |
|
index = jcfeatures[0].Fields.FindField(field.AliasName); |
|
if (index == -1) |
|
continue; |
|
fieldsDic.Add(i, index); |
|
} |
|
if (fieldsDic.Count != 0) |
|
{ |
|
IFeatureBuffer buffer = gxfeatureClass.CreateFeatureBuffer(); |
|
T_Cursor = gxfeatureClass.Insert(true); |
|
int gxgcIndex = gxfeatureClass.FindField("IsJCTB"); |
|
for (int i = 0; i < jcfeatures.Count; i++) |
|
{ |
|
IFeature f = jcfeatures[i]; |
|
buffer.Shape = f.ShapeCopy; |
|
|
|
foreach (int item in fieldsDic.Keys) |
|
{ |
|
if (string.IsNullOrWhiteSpace(f.Value[fieldsDic[item]].ToTrim())) |
|
buffer.Value[item] = DBNull.Value; |
|
buffer.Value[item] = f.Value[fieldsDic[item]]; |
|
} |
|
if (gxgcIndex != -1) |
|
{ |
|
buffer.Value[gxgcIndex] = "1"; |
|
} |
|
T_Cursor.InsertFeature(buffer); |
|
} |
|
T_Cursor.Flush(); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("基础村级调查区向临时库村级调查区更新层插入数据失败:" + ex.Message); |
|
} |
|
} |
|
|
|
|
|
private void CJDCQGXMSInsertGX(IFeatureClass gxgcfeatureClass, IFeatureClass gxfeatureClass, IQueryFilter pFilter) |
|
{ |
|
IFeatureCursor T_Cursor = null; |
|
IFeatureCursor S_Cursor = null; |
|
try |
|
{ |
|
Dictionary<int, int> fieldsDic = new Dictionary<int, int>(); |
|
for (int i = 0; i < gxfeatureClass.Fields.FieldCount; i++) |
|
{ |
|
IField field = gxfeatureClass.Fields.Field[i]; |
|
if (field.Name == gxfeatureClass.ShapeFieldName || field.Name.Contains(gxfeatureClass.ShapeFieldName) || field.Name == gxfeatureClass.OIDFieldName || !field.Editable) continue; |
|
|
|
int index = -1; |
|
string gxgcfield = "BGH" + field.Name; |
|
index = gxgcfeatureClass.Fields.FindField(gxgcfield); |
|
if (index == -1) |
|
continue; |
|
fieldsDic.Add(i, index); |
|
} |
|
if (fieldsDic.Count != 0) |
|
{ |
|
IFeatureBuffer buffer = gxfeatureClass.CreateFeatureBuffer(); |
|
T_Cursor = gxfeatureClass.Insert(true); |
|
int gxgcIndex = gxfeatureClass.FindField("IsJCTB"); |
|
|
|
IFeature gxgcfeature = null; |
|
S_Cursor = gxgcfeatureClass.Search(pFilter, true); |
|
while ((gxgcfeature = S_Cursor.NextFeature()) != null) |
|
{ |
|
buffer.Shape = gxgcfeature.ShapeCopy; |
|
foreach (int item in fieldsDic.Keys) |
|
{ |
|
if (string.IsNullOrWhiteSpace(gxgcfeature.Value[fieldsDic[item]].ToTrim())) |
|
buffer.Value[item] = DBNull.Value; |
|
buffer.Value[item] = gxgcfeature.Value[fieldsDic[item]]; |
|
} |
|
T_Cursor.InsertFeature(buffer); |
|
Marshal.ReleaseComObject(gxgcfeature); |
|
} |
|
T_Cursor.Flush(); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("基础村级调查区向临时库村级调查区更新层插入数据失败:" + ex.Message); |
|
} |
|
} |
|
|
|
|
|
public void InsertCJDCQGXFeature(IFeature pGXJX, int BGXW, string JXLX, string JXXZ, IFeatureClass JC_CJDCQJX, IFeatureClass CJDCQJXGX) |
|
{ |
|
IFeatureCursor gx_cursor = null; |
|
IFeatureBuffer gx_buffer = null; |
|
try |
|
{ |
|
bool IsInsert = true; |
|
var Identify = FeatureAPI.Identify2(pGXJX.Shape, new FeatureLayer() { FeatureClass = CJDCQJXGX }); |
|
if (Identify.Count > 0) |
|
{ |
|
foreach (var item in Identify) |
|
{ |
|
if (FeatureAPI.GetEqual(item.ShapeCopy, pGXJX.Shape) && FeatureAPI.GetEqual(pGXJX.Shape, item.ShapeCopy) && BGXW != 3) |
|
{ |
|
IsInsert = false; |
|
break; |
|
} |
|
} |
|
} |
|
if (IsInsert) |
|
{ |
|
if (string.IsNullOrWhiteSpace(strCJDCQJXMaxBSM)) |
|
{ |
|
strCJDCQJXMaxBSM = SetMaxBSM(JC_CJDCQJX, CJDCQJXGX); |
|
if (!strCJDCQJXMaxBSM.StartsWith(IDGParm.PrjInfo.CODE)) |
|
strCJDCQJXMaxBSM = IDGParm.PrjInfo.CODE + "1250" + "1".PadLeft(8, '0'); |
|
} |
|
else |
|
{ |
|
string bsmPrefix = IDGParm.PrjInfo.CODE + strCJDCQJXMaxBSM.Substring(6, 4); |
|
int MaxNum = Convert.ToInt32(strCJDCQJXMaxBSM.Substring(9)); |
|
strCJDCQJXMaxBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); |
|
} |
|
gx_cursor = CJDCQJXGX.Insert(true); |
|
gx_buffer = CJDCQJXGX.CreateFeatureBuffer(); |
|
gx_buffer.Shape = pGXJX.Shape; |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("BSM"), BGXW == 3 ? strCJDCQJXMaxBSM : pGXJX.Value[pGXJX.Fields.FindField("BSM")]); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("JXLX"), JXLX); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("JXXZ"), JXXZ); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("JXSM"), BGXW == 3 ? string.Empty : pGXJX.Value[pGXJX.Fields.FindField("JXSM")]); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("BZ"), BGXW == 3 ? string.Empty : pGXJX.Value[pGXJX.Fields.FindField("BZ")]); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("BGXW"), BGXW); |
|
gx_buffer.set_Value(gx_buffer.Fields.FindField("GXSJ"), DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31)); |
|
gx_cursor.InsertFeature(gx_buffer); |
|
gx_cursor.Flush(); |
|
Marshal.ReleaseComObject(gx_buffer); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("写入村级调查区界线更新层数据时发生异常,异常信息如下:"); |
|
LogAPI.Debug(ex); |
|
LogAPI.Debug("异常信息结束"); |
|
} |
|
finally |
|
{ |
|
if (gx_cursor != null) |
|
Marshal.ReleaseComObject(gx_cursor); |
|
if (gx_buffer != null) |
|
Marshal.ReleaseComObject(gx_buffer); |
|
} |
|
} |
|
|
|
private string strCJDCQJXMaxBSM = string.Empty; |
|
#endregion |
|
|
|
#region DelectDir |
|
public static void DelectDir(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 ex) |
|
{ |
|
LogAPI.Debug(ex + ":删除错误不处理"); |
|
} |
|
} |
|
#endregion |
|
|
|
#region GenerateGxgcData |
|
string JCTBName = string.Empty; |
|
public void GenerateGxgcData(IDGParameter pParm) |
|
{ |
|
Geoprocessor gp = null; |
|
IWorkspaceFactory pFtWsFct = null; |
|
IWorkspaceName workspaceName = null; |
|
try |
|
{ |
|
bool IsZLMCBG = false; |
|
//IMapService _MapService = MapsManager.Instance.MapService; |
|
gp = new Geoprocessor() |
|
{ |
|
OverwriteOutput = true |
|
}; |
|
//IGpValueTableObject gpValueTableObject = new GpValueTableObjectClass();//对两个要素类进行相交运算 |
|
//gpValueTableObject.SetColumns(2); |
|
object o1 = JcCjdcqLayer;//.JC_CJDCQLay; |
|
object o2 = GxCjdcqLayer;//.GX_CJDCQLay; |
|
//gpValueTableObject.AddRow(ref o2); |
|
//gpValueTableObject.AddRow(ref o1); |
|
//string gdbFolder = Directory.GetCurrentDirectory() + "\\Temp\\GXGC"; |
|
//if (!Directory.Exists(gdbFolder)) |
|
//{ |
|
// Directory.CreateDirectory(gdbFolder); |
|
//} |
|
//try |
|
//{ DelectDir(gdbFolder); } |
|
//catch |
|
//{ } |
|
//pFtWsFct = new FileGDBWorkspaceFactory(); |
|
//string gdbFileName = Guid.NewGuid().ToString() + ".gdb"; |
|
//string path = System.IO.Path.Combine(gdbFolder, gdbFileName); |
|
//workspaceName = pFtWsFct.Create(gdbFolder, gdbFileName, null, 0); |
|
|
|
IFeatureLayer pjbntFeatureLayer = null; |
|
GPParamClass gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = GxCjdcqLayer;//.GX_CJDCQLay as IFeatureLayer; |
|
//gPParamClass.FirstFeatureClassPath = pParm.ZLDbPath + "\\CJDCQGX"; |
|
gPParamClass.SecondFeatureLayer = JcCjdcqLayer;// pParm.JC_CJDCQLay as IFeatureLayer; |
|
//gPParamClass.SecondFeatureClassPath = pParm.JcDbPath + "\\CJDCQ"; |
|
gPParamClass.OutFeatureClassPath = TempGDBPath + "\\" + "TempCJDCQGXGC"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
gPParamClass.ListDissolveFiledName = new List<string>(); |
|
gPParamClass.GPType = EnumGPType.Union; |
|
//GeoprocessorHelper gpHelper = new GeoprocessorHelper(); |
|
//gpHelper.UnionAnalysis(gPParamClass, ref pjbntFeatureLayer); |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref pjbntFeatureLayer); |
|
|
|
IFeatureClass outFc = null; |
|
gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = pjbntFeatureLayer; |
|
gPParamClass.OutFeatureClassPath = TempGDBPath + "\\" + "TempGXGC_MToS"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
gPParamClass.GPType = EnumGPType.MultipartToSinglePath; |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref pjbntFeatureLayer); |
|
//gpHelper.MultipartToSinglePath(gPParamClass, ref pjbntFeatureLayer); |
|
|
|
|
|
//string dbPath = pParm.ProjDir + @"\BGTJ.sqlite"; |
|
IWorkspaceFactory pOutWorkFactory = new SqlWorkspaceFactoryClass(); |
|
IWorkspace pOutWork = pOutWorkFactory.OpenFromFile(TempDBPath, 0); |
|
IFeatureWorkspace SchemeWork = (pjbntFeatureLayer.FeatureClass as FeatureClass).Workspace as IFeatureWorkspace; |
|
KGIS.Framework.DBOperator.IRDBHelper rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + TempDBPath, DatabaseType.SQLite); |
|
rdbHelper.ExecuteSQL(" drop table TempGXGC_MToS "); |
|
TableToTable(SchemeWork, pOutWork, "TempGXGC_MToS"); |
|
JCTBName = (JcCjdcqLayer.FeatureClass as FeatureClass).Name; |
|
string strSql = $"select ZLDWDM,ZLDWDM_1,MSSM,MSSM_1,HDMC from TempGXGC_MToS where ZLDWDM<>ZLDWDM_1 or objectid not in (select objectid from (select * from TempGXGC_MToS group by FID_{JCTBName} HAVING count(0)=1) where FID_CJDCQGX>-1 and FID_{JCTBName}>-1)"; |
|
if (IsZLMCBG) |
|
{ |
|
strSql = $"select ZLDWDM,ZLDWDM_1,zldwmc,zldwmc_1,MSSM,MSSM_1,HDMC from TempGXGC_MToS where ZLDWDM<>ZLDWDM_1 or zldwmc<>zldwmc_1 or objectid not in (select objectid from (select * from TempGXGC_MToS group by FID_{JCTBName} HAVING count(0)=1) where FID_CJDCQGX>-1 and FID_{JCTBName}>-1)"; |
|
} |
|
DataTable ChangeDT = rdbHelper.ExecuteDatatable("change", strSql, true); |
|
List<string> listZL = new List<string>(); |
|
if (ChangeDT != null) |
|
{ |
|
if (ChangeDT.Rows.Count == 0) |
|
return; |
|
foreach (System.Data.DataRow dr in ChangeDT.Rows) |
|
{ |
|
string zl = dr["ZLDWDM"].ToTrim(); |
|
if (string.IsNullOrWhiteSpace(zl)) |
|
zl = dr["ZLDWDM_1"].ToTrim(); |
|
string zlmc = ChangeDT.Columns.Contains("ZLDWMC") ? dr["ZLDWMC"].ToTrim() : ""; |
|
if (string.IsNullOrWhiteSpace(zlmc) && ChangeDT.Columns.Contains("ZLDWMC_1")) |
|
zlmc = dr["ZLDWMC_1"].ToTrim(); |
|
string mssm = dr["MSSM"].ToTrim(); |
|
if (string.IsNullOrWhiteSpace(mssm)) |
|
mssm = dr["MSSM_1"].ToTrim(); |
|
string hdmc = ""; |
|
string key = zl + "_" + mssm + "_" + hdmc; |
|
if (IsZLMCBG) |
|
{ |
|
key = zl + "_" + zlmc + "_" + mssm + "_" + hdmc; |
|
} |
|
if (string.IsNullOrWhiteSpace(zl)) continue; |
|
if (listZL.Contains(key)) continue; |
|
listZL.Add(key); |
|
} |
|
} |
|
strSql = $"select objectid,ZLDWDM_1,MSSM_1,HDMC_1 from (select * from TempGXGC_MToS group by FID_{JCTBName} HAVING count(0)=1) where FID_CJDCQGX>-1 and FID_{JCTBName}>-1 and ZLDWDM=ZLDWDM_1"; |
|
if (IsZLMCBG) |
|
{ |
|
strSql = $"select objectid,ZLDWDM_1,ZLDWMC_1,MSSM_1,HDMC_1 from (select * from TempGXGC_MToS group by FID_{JCTBName} HAVING count(0)=1) where FID_CJDCQGX>-1 and FID_{JCTBName}>-1 and ZLDWDM=ZLDWDM_1 and ZLDWMC=ZLDWMC_1"; |
|
} |
|
System.Data.DataTable delDt = rdbHelper.ExecuteDatatable("del", strSql, true); |
|
DataTable allDT = rdbHelper.ExecuteDatatable("All", "select * from TempGXGC_MToS", true); |
|
if (delDt != null) |
|
{ |
|
foreach (System.Data.DataRow dr in delDt.Rows) |
|
{ |
|
int oid = dr["OBJECTID"].ToInt(); |
|
string zl = dr["ZLDWDM_1"].ToTrim(); |
|
string zlmc = ChangeDT.Columns.Contains("ZLDWMC_1") ? dr["ZLDWMC_1"].ToTrim() : ""; |
|
string mssm = dr["MSSM_1"].ToTrim(); |
|
string xzqmc = ""; |
|
string key = zl + "_" + mssm + "_" + xzqmc; |
|
if (IsZLMCBG) |
|
{ |
|
key = zl + "_" + zlmc + "_" + mssm + "_" + xzqmc; |
|
} |
|
if (listZL.Contains(key)) continue; |
|
try |
|
{ |
|
pjbntFeatureLayer.FeatureClass.GetFeature(oid).Delete(); |
|
} |
|
catch (Exception ex) |
|
{ |
|
} |
|
} |
|
} |
|
outFc = pjbntFeatureLayer.FeatureClass; |
|
IFeatureClassAPI gcFcAPI = new FeatureClassAPI(outFc); |
|
gcFcAPI.AddField("XZQTZLX", esriFieldType.esriFieldTypeString, ""); |
|
Dictionary<int, BGHAttributeModel> bghAttr = new Dictionary<int, BGHAttributeModel>(); |
|
Dictionary<int, GXAttributeModel> gxAttr = new Dictionary<int, GXAttributeModel>(); |
|
SetAttribue(outFc, (JcCjdcqLayer as IFeatureLayer).FeatureClass, (GxCjdcqLayer as IFeatureLayer).FeatureClass, ref bghAttr, ref gxAttr); |
|
IFeatureClass gxgcFc = (GxgcCjdcqLayer as IFeatureLayer).FeatureClass; |
|
ITable cjdcqgxgcTb = gxgcFc as ITable; |
|
cjdcqgxgcTb.DeleteSearchedRows(null);//删除村级调查区更新过程所有数据 |
|
Dictionary<int, int> target_SourMaping = new Dictionary<int, int>(); |
|
Dictionary<string, object> fieldValues = new Dictionary<string, object>(); |
|
for (int i = 0; i < gxgcFc.Fields.FieldCount; i++) |
|
{ |
|
IField field = gxgcFc.Fields.Field[i]; |
|
if (!field.Editable || field.Name.Contains(gxgcFc.ShapeFieldName)) continue; |
|
int sIndex = outFc.FindField(field.Name); |
|
if (field.Name.StartsWith("BGQ")) |
|
{ |
|
if (sIndex == -1) |
|
sIndex = outFc.FindField(field.Name.Replace("BGQ", "") + "_1"); |
|
if (sIndex == -1) |
|
sIndex = outFc.FindField(field.Name.Replace("BGQTB", "") + "_1"); |
|
if (sIndex != -1) |
|
{ |
|
target_SourMaping.Add(i, sIndex); |
|
fieldValues.Add(field.Name, sIndex); |
|
} |
|
continue; |
|
} |
|
else if (field.Name.StartsWith("BGH")) |
|
{ |
|
if (sIndex == -1) |
|
sIndex = outFc.FindField(field.Name.Replace("BGH", "")); |
|
if (sIndex == -1) |
|
sIndex = outFc.FindField(field.Name.Replace("BGHTB", "")); |
|
if (sIndex != -1) |
|
{ |
|
target_SourMaping.Add(i, sIndex); |
|
fieldValues.Add(field.Name, sIndex); |
|
} |
|
continue; |
|
} |
|
else if (field.Name == "BGMJ") |
|
{ |
|
if (sIndex == -1) |
|
sIndex = outFc.FindField("TBMJ"); |
|
if (sIndex != -1) |
|
{ |
|
target_SourMaping.Add(i, sIndex); |
|
fieldValues.Add(field.Name, sIndex); |
|
} |
|
continue; |
|
} |
|
if (sIndex != -1) |
|
{ |
|
target_SourMaping.Add(i, sIndex); |
|
fieldValues.Add(field.Name, sIndex); |
|
} |
|
} |
|
IFeatureCursor t_cursor = gxgcFc.Insert(true); |
|
IFeatureCursor s_cursor = outFc.Search(null, true); |
|
|
|
IFeatureLayer _tempLayer = null; |
|
pjbntFeatureLayer.FeatureClass = outFc; |
|
gPParamClass = new GPParamClass(); |
|
gPParamClass.FirstFeatureLayer = pjbntFeatureLayer; |
|
gPParamClass.SecondFeatureLayer = NmTbLayer; |
|
gPParamClass.OutFeatureClassPath = TempGDBPath + "\\" + "TempCJDCQGXGC_DLTB"; |
|
gPParamClass.IsGetOutPutFeature = true; |
|
gPParamClass.GPType = EnumGPType.Intersect; |
|
GPHelper.Instance.ExeGPForProces(gPParamClass, ref _tempLayer); |
|
|
|
|
|
IFeatureClass outFc2 = _tempLayer.FeatureClass; |
|
Console.WriteLine("cjdcq"); |
|
ITable table = outFc2 as ITable; |
|
ICursor cursor = table.Search(new QueryFilterClass() { SubFields = "OBJECTID,SHAPE,FID_TempGXGC_MToS,FID_DLTB_NMK,BSM_12,ZLDWDM,ZLDWMC,TBMJ,MSSM,XZQTZLX_1" }, true); |
|
IRow row = null; |
|
List<int> DicNMKOids = new List<int>(); |
|
int nmkoidIdx = table.FindField("FID_DLTB_NMK"); |
|
int oidIdx = table.FindField("FID_TempGXGC_MToS"); |
|
int mjIdx = table.FindField("TBMJ"); |
|
int xzqdmIdx = table.FindField("ZLDWDM"); |
|
int xzqmcIdx = table.FindField("ZLDWMC"); |
|
int mssmIdx = table.FindField("MSSM"); |
|
int nmkBSMIdx = table.FindField("BSM_12"); |
|
int xzqtzlxIdx = table.FindField("XZQTZLX_1"); |
|
int ShapeIdx = table.FindField("SHAPE"); |
|
Dictionary<int, List<PCModel>> dicPcList = new Dictionary<int, List<PCModel>>(); |
|
Dictionary<int, string> dicXZQTZLX = new Dictionary<int, string>(); |
|
while ((row = cursor.NextRow()) != null) |
|
{ |
|
if (nmkoidIdx == -1) |
|
break; |
|
if (mjIdx == -1) |
|
break; |
|
int gxoid = -1; |
|
if (oidIdx != -1) |
|
{ |
|
gxoid = row.Value[oidIdx].ToInt(); |
|
if (xzqtzlxIdx != -1 && gxoid != -1) |
|
{ |
|
if (!dicXZQTZLX.ContainsKey(gxoid)) |
|
{ |
|
dicXZQTZLX.Add(gxoid, row.Value[xzqtzlxIdx].ToTrim()); |
|
} |
|
else |
|
{ |
|
if (string.IsNullOrWhiteSpace(dicXZQTZLX[gxoid])) |
|
{ |
|
dicXZQTZLX[gxoid] = row.Value[xzqtzlxIdx].ToTrim(); |
|
} |
|
} |
|
} |
|
} |
|
double mj = row.Value[mjIdx].ToDouble(); |
|
int oid = row.Value[nmkoidIdx].ToInt(); |
|
string nmkBSM = string.Empty; |
|
if (nmkBSMIdx != -1) |
|
nmkBSM = row.Value[nmkBSMIdx].ToTrim(); |
|
IGeometry geo = row.Value[ShapeIdx] as IGeometry; |
|
if (!dicPcList.ContainsKey(oid)) |
|
{ |
|
PCModel dic = new PCModel(); |
|
dic.OID = row.OID; |
|
dic.NMKOID = oid; |
|
dic.NMKBSM = nmkBSM; |
|
dic.TBMJ = mj; |
|
if (geo != null && !geo.IsEmpty) |
|
dic.JSMJ = (geo as IPolygon).GetEllipseArea().ToDouble(2); |
|
if (dic.JSMJ != 0) |
|
{ |
|
dicPcList.Add(oid, new List<PCModel>() { dic }); |
|
} |
|
else |
|
{ |
|
dic.TBMJ = dic.JSMJ; |
|
IRow tempRow = table.GetRow(row.OID); |
|
tempRow.Value[mjIdx] = dic.JSMJ; |
|
tempRow.Store(); |
|
} |
|
} |
|
else |
|
{ |
|
PCModel dic = new PCModel(); |
|
dic.OID = row.OID; |
|
dic.NMKOID = oid; |
|
dic.NMKBSM = nmkBSM; |
|
dic.TBMJ = mj; |
|
if (geo != null && !geo.IsEmpty) |
|
dic.JSMJ = (geo as IPolygon).GetEllipseArea().ToDouble(2); |
|
if (dic.JSMJ != 0) |
|
{ |
|
dicPcList[oid].Add(dic); |
|
} |
|
else |
|
{ |
|
dic.TBMJ = dic.JSMJ; |
|
IRow tempRow = table.GetRow(row.OID); |
|
tempRow.Value[mjIdx] = dic.JSMJ; |
|
tempRow.Store(); |
|
} |
|
} |
|
} |
|
xzqtzlxIdx = outFc.FindField("XZQTZLX"); |
|
foreach (var key in dicXZQTZLX.Keys) |
|
{ |
|
if (string.IsNullOrWhiteSpace(dicXZQTZLX[key]) || xzqtzlxIdx == -1) |
|
continue; |
|
IFeature gcF = outFc.GetFeature(key); |
|
gcF.Value[xzqtzlxIdx] = dicXZQTZLX[key]; |
|
gcF.Store(); |
|
} |
|
List<PCModel> pcList = new List<PCModel>(); |
|
IFeatureLayer tempLayer = GxgcTBLayer as IFeatureLayer;// _MapService.GetFeatureLayerByName("DLTBGXGC"); |
|
IFeatureLayer jcDLTBLayer = JcTbLayer as IFeatureLayer;// _MapService.GetFeatureLayerByLayerName("地类图斑"); |
|
foreach (var item in dicPcList) |
|
{ |
|
if (item.Value.Count > 1) |
|
{ |
|
foreach (var pc in item.Value) |
|
{ |
|
IFeature f = outFc2.GetFeature(pc.OID); |
|
List<IFeature> gcFList = FeatureAPI.Identify2(f.ShapeCopy, tempLayer); |
|
double bgmj = 0; |
|
if (gcFList.Count > 0) |
|
{ |
|
int gcBgmjIdx = tempLayer.FeatureClass.FindField("TBBGMJ"); |
|
if (gcBgmjIdx != -1) |
|
{ |
|
foreach (var gc in gcFList) |
|
{ |
|
bgmj += gc.Value[gcBgmjIdx].ToDouble(2); |
|
} |
|
pc.JSMJ = bgmj; |
|
} |
|
else |
|
{ |
|
pc.JSMJ = (f.ShapeCopy as IPolygon).GetEllipseArea().ToDouble(2); |
|
} |
|
} |
|
else |
|
{ |
|
List<IFeature> jcFeatures = FeatureAPI.Identify2(f.ShapeCopy, jcDLTBLayer); |
|
int idx = jcDLTBLayer.FeatureClass.FindField("TBMJ"); |
|
foreach (var jc in jcFeatures) |
|
{ |
|
bgmj = Math.Round(bgmj + jc.Value[idx].ToDouble(), 2); |
|
} |
|
if (bgmj == 0) |
|
continue; |
|
pc.JSMJ = bgmj; |
|
} |
|
} |
|
double jsmj = item.Value.Sum(p => p.JSMJ); |
|
double tbmj = item.Value[0].TBMJ; |
|
if (jsmj != tbmj) |
|
{ |
|
List<PCModel> list = item.Value.OrderByDescending(desc => desc.JSMJ).ToList(); |
|
double mjc = (jsmj - tbmj).ToDouble(2); |
|
while (mjc != 0 && Math.Abs(mjc) < 500) |
|
{ |
|
int tpsm = (int)(Math.Abs(Math.Round(mjc, 2)) / 0.01); |
|
int e = tpsm / list.Count; |
|
int f = tpsm % list.Count; |
|
if (f != 0) |
|
{ |
|
double tpmj = (e + 1) * 0.01; |
|
for (int i = 0; i < f; i++) |
|
{ |
|
if (mjc < 0) |
|
list[i].JSMJ += tpmj; |
|
else |
|
list[i].JSMJ -= tpmj; |
|
} |
|
} |
|
if (e != 0) |
|
{ |
|
double tpmj = e * 0.01; |
|
for (int i = f; i < list.Count; i++) |
|
{ |
|
if (mjc < 0) |
|
list[i].JSMJ += tpmj; |
|
else |
|
list[i].JSMJ -= tpmj; |
|
} |
|
} |
|
mjc = (list.Sum(sum => sum.JSMJ).ToDouble(2) - tbmj).ToDouble(2); |
|
} |
|
} |
|
pcList.AddRange(item.Value); |
|
} |
|
} |
|
Dictionary<int, double> bgmjList = new Dictionary<int, double>(); |
|
Dictionary<string, double> dcmjList = new Dictionary<string, double>(); |
|
cursor = table.Search(new QueryFilterClass() { SubFields = "OBJECTID,FID_TempGXGC_MToS,FID_DLTB_NMK,ZLDWDM,ZLDWMC,MSSM,TBMJ" }, true); |
|
while ((row = cursor.NextRow()) != null) |
|
{ |
|
if (oidIdx != -1 && mjIdx != -1) |
|
{ |
|
int oid = row.Value[oidIdx].ToInt(); |
|
double mj = row.Value[mjIdx].ToDouble(); |
|
PCModel pcModel = pcList.FirstOrDefault(m => m.OID == row.OID); |
|
if (pcModel != null) |
|
mj = pcModel.JSMJ; |
|
if (!bgmjList.ContainsKey(oid)) |
|
bgmjList.Add(oid, mj); |
|
else |
|
bgmjList[oid] += mj; |
|
if (xzqdmIdx != -1) |
|
{ |
|
string xzqdm = row.Value[xzqdmIdx].ToTrim(); |
|
string mssm = row.Value[mssmIdx].ToTrim(); |
|
string xzqmc = "";// row.Value[xzqmcIdx].ToTrim(); |
|
if (IsZLMCBG) |
|
{ |
|
xzqmc = row.Value[xzqmcIdx].ToTrim(); |
|
} |
|
string key = xzqdm + "_" + mssm + "_" + xzqmc; |
|
if (dcmjList.ContainsKey(key)) |
|
dcmjList[key] = Math.Round(dcmjList[key] + mj, 2); |
|
else |
|
dcmjList.Add(key, mj); |
|
} |
|
} |
|
} |
|
IFeature s = null; |
|
int gxsjIndex = gxgcFc.FindField("GXSJ"); |
|
int bghTBBSMIndex = gxgcFc.FindField("BGHBSM"); |
|
int bgmjIndex = gxgcFc.FindField("BGMJ"); |
|
int bgxwIndex = gxgcFc.FindField("BGXW"); |
|
int bgqDCMJIndex = gxgcFc.FindField("BGQDCMJ"); |
|
int bghDCMJIndex = gxgcFc.FindField("BGHDCMJ"); |
|
int bgqZLDWDMIndex = gxgcFc.FindField("BGQZLDWDM"); |
|
int bghZLDWDMIndex = gxgcFc.FindField("BGHZLDWDM"); |
|
|
|
int bghZLDWMCIndex = gxgcFc.FindField("BGHZLDWMC"); |
|
int bgqZLDWMCIndex = gxgcFc.FindField("BGQZLDWMC"); |
|
|
|
int bghMSSMIndex = gxgcFc.FindField("BGHMSSM"); |
|
int bgqMSSMIndex = gxgcFc.FindField("BGQMSSM"); |
|
|
|
int xzqtzlxIndex = outFc.FindField("XZQTZLX"); |
|
int bgqOIDIndex = outFc.FindField("FID_CJDCQGX"); |
|
IQueryFilter delFilter = new QueryFilterClass() { WhereClause = "1=2" }; |
|
while ((s = s_cursor.NextFeature()) != null) |
|
{ |
|
IFeatureBuffer buf = gxgcFc.CreateFeatureBuffer(); |
|
buf.Shape = s.ShapeCopy; |
|
foreach (var item in target_SourMaping) |
|
{ |
|
buf.Value[item.Key] = s.Value[item.Value]; |
|
} |
|
int gxOID = s.Value[bgqOIDIndex].ToInt(); |
|
int xzqtzlx = 0; |
|
if (xzqtzlxIndex != -1) |
|
{ |
|
xzqtzlx = s.Value[xzqtzlxIndex].ToInt(); |
|
} |
|
if (gxsjIndex != -1) |
|
{ |
|
buf.Value[gxsjIndex] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31); |
|
} |
|
if (bghDCMJIndex != -1 && bghZLDWDMIndex != -1) |
|
{ |
|
string xzqdm = buf.Value[bghZLDWDMIndex].ToTrim(); |
|
string mssm = buf.Value[bghMSSMIndex].ToTrim(); |
|
string xzqmc = ""; |
|
if (IsZLMCBG) |
|
{ |
|
xzqmc = buf.Value[bghZLDWMCIndex].ToTrim(); |
|
} |
|
string key = xzqdm + "_" + mssm + "_" + xzqmc; |
|
if (dcmjList.ContainsKey(key)) |
|
buf.Value[bghDCMJIndex] = Math.Round(dcmjList[key], 2); |
|
} |
|
if (bghAttr.ContainsKey(s.OID)) |
|
{ |
|
if (bghTBBSMIndex != -1) |
|
buf.Value[bghTBBSMIndex] = bghAttr[s.OID].BGHBSM; |
|
if (bgmjIndex != -1 && bgmjList.ContainsKey(s.OID)) |
|
{ |
|
buf.Value[bgmjIndex] = bgmjList[s.OID].ToDouble(2); |
|
} |
|
if (bgxwIndex != -1 && xzqtzlx != 4) |
|
buf.Value[bgxwIndex] = bghAttr[s.OID].BGXW; |
|
else |
|
buf.Value[bgxwIndex] = "0"; |
|
if (bghAttr[s.OID].BGXW == "0") |
|
{ |
|
buf.Value[bghTBBSMIndex] = ""; |
|
List<IFeature> gcFeatures = FeatureAPI.Identify2(s.ShapeCopy, tempLayer); |
|
if (gcFeatures.Count != 0) |
|
{ |
|
int idx = tempLayer.FeatureClass.FindField("TBBGMJ"); |
|
double bgmj = 0; |
|
IGeometry tempGeo = null; |
|
foreach (var item in gcFeatures) |
|
{ |
|
if (tempGeo == null) |
|
tempGeo = item.ShapeCopy; |
|
else |
|
tempGeo = FeatureAPI.Union(tempGeo, item.ShapeCopy); |
|
bgmj = Math.Round(bgmj + item.Value[idx].ToDouble(), 2); |
|
} |
|
if (!FeatureAPI.GetEqual(tempGeo, s.ShapeCopy)) |
|
{ |
|
tempGeo = FeatureAPI.Difference(s.ShapeCopy, tempGeo); |
|
List<IFeature> jcFeatures = FeatureAPI.Identify2(tempGeo, jcDLTBLayer); |
|
idx = jcDLTBLayer.FeatureClass.FindField("TBMJ"); |
|
foreach (var item in jcFeatures) |
|
{ |
|
bgmj = Math.Round(bgmj + item.Value[idx].ToDouble(), 2); |
|
} |
|
} |
|
if (bgmj == 0) |
|
continue; |
|
buf.Value[bgmjIndex] = bgmj; |
|
} |
|
else |
|
{ |
|
List<IFeature> jcFeatures = FeatureAPI.Identify2(s.ShapeCopy, jcDLTBLayer); |
|
int idx = jcDLTBLayer.FeatureClass.FindField("TBMJ"); |
|
double bgmj = 0; |
|
foreach (var item in jcFeatures) |
|
{ |
|
bgmj = Math.Round(bgmj + item.Value[idx].ToDouble(), 2); |
|
} |
|
if (bgmj == 0) |
|
continue; |
|
buf.Value[bgmjIndex] = bgmj; |
|
} |
|
} |
|
else if (bghAttr[s.OID].BGXW == "3") |
|
{ |
|
double jsmj = (s.ShapeCopy as IPolygon).GetEllipseArea().ToDouble(2); |
|
double bgmj = buf.Value[bgmjIndex].ToDouble(); |
|
if (Math.Abs(jsmj - bgmj) > 500) |
|
{ |
|
string xzqdm = buf.Value[bghZLDWDMIndex].ToTrim(); |
|
string mssm = buf.Value[bghMSSMIndex].ToTrim(); |
|
string xzqmc = ""; |
|
if (IsZLMCBG) |
|
{ |
|
xzqmc = buf.Value[bghZLDWMCIndex].ToTrim(); |
|
} |
|
string key = xzqdm + "_" + mssm + "_" + xzqmc; |
|
if (dcmjList.ContainsKey(key)) |
|
{ |
|
dcmjList[key] = dcmjList[key] - bgmj; |
|
buf.Value[bghDCMJIndex] = dcmjList[key]; |
|
} |
|
buf.Value[bgmjIndex] = jsmj; |
|
} |
|
} |
|
} |
|
if (xzqtzlx == 2 || xzqtzlx == 4) |
|
{ |
|
for (int i = 0; i < gxgcFc.Fields.FieldCount; i++) |
|
{ |
|
IField field = gxgcFc.Fields.Field[i]; |
|
if (field.Name.ToUpper().StartsWith("BGH")) |
|
{ |
|
if (field.Type == esriFieldType.esriFieldTypeString) |
|
buf.Value[i] = DBNull.Value; |
|
else if (field.Type == esriFieldType.esriFieldTypeDouble) |
|
buf.Value[i] = 0; |
|
} |
|
} |
|
} |
|
if (buf.Value[bgmjIndex].ToDouble() == 0 || (buf.Value[bgqDCMJIndex].ToDouble(2) == buf.Value[bghDCMJIndex].ToDouble(2) && buf.Value[bgqZLDWDMIndex].ToTrim() == buf.Value[bghZLDWDMIndex].ToTrim() && buf.Value[bgqMSSMIndex].ToTrim() == buf.Value[bghMSSMIndex].ToTrim() && buf.Value[bgqZLDWMCIndex].ToTrim() == buf.Value[bghZLDWMCIndex].ToTrim())) |
|
{ |
|
if (gxOID != -1 && buf.Value[bgmjIndex].ToDouble() != 0) |
|
{ |
|
delFilter.WhereClause = string.Format("OBJECTID = {0}", gxOID); |
|
(o2 as ITable).DeleteSearchedRows(delFilter); |
|
} |
|
continue; |
|
} |
|
t_cursor.InsertFeature(buf); |
|
} |
|
t_cursor.Flush(); |
|
cursor = (o2 as ITable).Update(null, true); |
|
row = null; |
|
int bsmIndex = (o2 as ITable).FindField("BSM"); |
|
int tbmjIndex = (o2 as ITable).FindField("TBMJ"); |
|
int kcxsIndex = (o2 as ITable).FindField("KCXS"); |
|
int tbdlmjIndex = (o2 as ITable).FindField("TBDLMJ"); |
|
int dcmjIndex = (o2 as ITable).FindField("DCMJ"); |
|
int mssmIndex = (o2 as ITable).FindField("MSSM"); |
|
int xzqdmIndex = (o2 as ITable).FindField("ZLDWDM"); |
|
int xzqmcIndex = (o2 as ITable).FindField("ZLDWMC"); |
|
xzqtzlxIndex = (o2 as ITable).FindField("XZQTZLX"); |
|
gxsjIndex = (o2 as ITable).FindField("GXSJ"); |
|
while ((row = cursor.NextRow()) != null) |
|
{ |
|
int xzqtzlx = 0; |
|
if (xzqtzlxIndex != -1) |
|
{ |
|
xzqtzlx = row.Value[xzqtzlxIndex].ToInt(); |
|
} |
|
if (gxsjIndex != -1) |
|
{ |
|
row.Value[gxsjIndex] = DateTime.Now.Month >= 10 ? new DateTime(DateTime.Now.Year, 12, 31) : new DateTime(DateTime.Now.Year - 1, 12, 31); |
|
} |
|
|
|
if (gxAttr.ContainsKey(row.OID) && xzqtzlx != 2 && xzqtzlx != 4) |
|
{ |
|
if (bsmIndex != -1) |
|
row.Value[bsmIndex] = gxAttr[row.OID].BSM; |
|
string xzqdm = row.Value[xzqdmIndex].ToTrim(); |
|
string mssm = row.Value[mssmIndex].ToTrim(); |
|
string hdmc = ""; |
|
if (IsZLMCBG) |
|
{ |
|
hdmc = row.Value[xzqmcIdx].ToTrim(); |
|
} |
|
string key = xzqdm + "_" + mssm + "_" + hdmc; |
|
if (dcmjList.ContainsKey(key)) |
|
row.Value[dcmjIndex] = dcmjList[key].ToDouble(2); |
|
cursor.UpdateRow(row); |
|
} |
|
else |
|
{ |
|
delFilter.WhereClause = string.Format("OBJECTID = {0}", row.OID); |
|
(o2 as ITable).DeleteSearchedRows(delFilter); |
|
} |
|
} |
|
cursor.Flush(); |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("生成更新过程数据失败:"); |
|
LogAPI.Debug(ex); |
|
} |
|
} |
|
#endregion |
|
|
|
#region TableToTable |
|
public static 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; |
|
} |
|
} |
|
#endregion |
|
|
|
|
|
#region 获取最新标识码 |
|
public string GetNewBSM(List<IFeatureClass> fcList) |
|
{ |
|
string result = string.Empty; |
|
int xh = 0; |
|
string leftStr = string.Empty; |
|
foreach (var item in fcList) |
|
{ |
|
string MaxBSM = GetMaxBSM(item); |
|
if (MaxBSM.Length != 18) |
|
continue; |
|
int xh2 = Convert.ToInt32(MaxBSM.Substring(10)); |
|
leftStr = MaxBSM.Substring(0, 10); |
|
if (xh < xh2) |
|
xh = xh2; |
|
} |
|
xh++; |
|
if (string.IsNullOrWhiteSpace(leftStr)) |
|
leftStr = IDGParm.PrjInfo.CODE + "1210"; |
|
result = leftStr + xh.ToString().PadLeft(8, '0'); |
|
return result; |
|
} |
|
private string GetMaxBSM(IFeatureClass fc) |
|
{ |
|
//System.Windows.Forms.Application.DoEvents(); |
|
string BSM = string.Empty; |
|
int BSMIndex = fc.FindField("BSM"); |
|
if (BSMIndex == -1) return BSM; |
|
|
|
ITable table = (ITable)fc; |
|
ITableSort tableSort = new TableSortClass(); |
|
tableSort.Table = table; |
|
tableSort.Fields = "BSM"; |
|
tableSort.set_Ascending("BSM", false); |
|
tableSort.Sort(null); |
|
ICursor cursor = tableSort.Rows; |
|
IRow row = cursor.NextRow(); |
|
if (row != null) |
|
{ |
|
int maxBSM = 0; |
|
int currBSM = 0; |
|
string BSMStr = row.Value[BSMIndex].ToString(); |
|
if (BSMStr.Length != 18) return BSM; |
|
string subBSMStr = BSMStr.Substring(9); |
|
try |
|
{ |
|
currBSM = Convert.ToInt32(subBSMStr); |
|
} |
|
catch (Exception) |
|
{ |
|
return BSM; |
|
} |
|
if (currBSM > maxBSM) maxBSM = currBSM; |
|
|
|
if (BSMStr.Length != 18) return BSM; |
|
string maxStr = maxBSM.ToString(); |
|
int zeroNum = 9 - maxStr.Length; |
|
for (int i = 0; i < zeroNum; i++) |
|
{ |
|
maxStr = 0 + maxStr; |
|
} |
|
BSM = BSMStr.Substring(0, 9) + maxStr; |
|
} |
|
return BSM; |
|
|
|
} |
|
#endregion |
|
|
|
#region SetAttribue |
|
public void SetAttribue(IFeatureClass pGxgcFc, IFeatureClass pJCFc, IFeatureClass pGxFc, ref Dictionary<int, BGHAttributeModel> bghAttr, ref Dictionary<int, GXAttributeModel> gxAttr) |
|
{ |
|
try |
|
{ |
|
//IMapService _MapService = MapsManager.Instance.MapService; |
|
IFeatureLayer gxLayer = new FeatureLayerClass() { FeatureClass = pGxFc }; |
|
IFeatureClass jcFc = pJCFc; |
|
IQueryFilter filter = new QueryFilterClass() { SubFields = $"OBJECTID,FID_{JCTBName},BSM_1,FID_CJDCQGX,ZLDWDM,XZQTZLX" }; |
|
IFeatureCursor cursor = pGxgcFc.Search(filter, true); |
|
IFeature fe = null; |
|
int jcOIDIndex = pGxgcFc.FindField($"FID_{JCTBName}"); |
|
int jcBSMIndex = pGxgcFc.FindField("BSM_1"); |
|
int XZQTZLXIndex = pGxgcFc.FindField("XZQTZLX"); |
|
int gxOIDIndex = pGxgcFc.FindField("FID_CJDCQGX"); |
|
int gxZLDWDMIndex = pGxgcFc.FindField("ZLDWDM"); |
|
List<OIDMapping> txbgOID = new List<OIDMapping>(); |
|
List<OIDMapping> list = new List<OIDMapping>(); |
|
while ((fe = cursor.NextFeature()) != null) |
|
{ |
|
int jcOID = (int)fe.Value[jcOIDIndex]; |
|
OIDMapping oMaping = new OIDMapping(); |
|
int gxOID = (int)fe.Value[gxOIDIndex]; |
|
oMaping.gcOID = fe.OID; |
|
oMaping.bgqOID = jcOID; |
|
oMaping.bgqTBBSM = fe.Value[jcBSMIndex].ToTrim(); |
|
oMaping.bghTBBSM = oMaping.bgqTBBSM; |
|
oMaping.bghTBBH = oMaping.bgqTBBH; |
|
oMaping.bghOID = gxOID; |
|
oMaping.bghZLDWDM = fe.Value[gxZLDWDMIndex].ToTrim(); |
|
oMaping.XZQTZLX = fe.Value[XZQTZLXIndex].ToTrim(); |
|
list.Add(oMaping); |
|
} |
|
string MaxBSM = string.Empty; |
|
if (string.IsNullOrWhiteSpace(MaxBSM)) |
|
MaxBSM = GetNewBSM(new List<IFeatureClass>() { jcFc }); |
|
if (!MaxBSM.StartsWith(IDGParm.PrjInfo.CODE)) |
|
{ |
|
MaxBSM = IDGParm.PrjInfo.CODE + MaxBSM.Substring(6); |
|
} |
|
IEnumerable<IGrouping<int, OIDMapping>> groupbgq = list.GroupBy(g => g.bgqOID); |
|
foreach (var item in groupbgq) |
|
{ |
|
List<OIDMapping> tempList = item.ToList(); |
|
if (tempList.Count > 1) |
|
{ |
|
|
|
double kzmj = tempList[0].BGMJ; |
|
tempList.ForEach(o => |
|
{ |
|
string bgqBSM = string.Empty; |
|
string bghBSM = string.Empty; |
|
string bsmPrefix = IDGParm.PrjInfo.CODE + MaxBSM.Substring(6, 4); |
|
int MaxNum = Convert.ToInt32(MaxBSM.Substring(9)); |
|
bghBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); |
|
MaxBSM = bghBSM; |
|
|
|
o.IsTXBG = true; |
|
o.bghTBBSM = MaxBSM; |
|
o.IsSplit = true; |
|
IFeature gcF = pGxgcFc.GetFeature(o.gcOID); |
|
o.BGMJ = (gcF.ShapeCopy as IPolygon).GetEllipseArea(); |
|
Marshal.ReleaseComObject(gcF); |
|
}); |
|
} |
|
else |
|
{ |
|
if (!tempList[0].bgqTBBSM.StartsWith(IDGParm.PrjInfo.CODE)) |
|
{ |
|
string bsmPrefix = IDGParm.PrjInfo.CODE + MaxBSM.Substring(6, 4); |
|
int MaxNum = Convert.ToInt32(MaxBSM.Substring(10)); |
|
string bghBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); |
|
MaxBSM = bghBSM; |
|
tempList[0].bghTBBSM = MaxBSM; |
|
} |
|
} |
|
} |
|
groupbgq = list.GroupBy(g => g.bghOID); |
|
foreach (var item in groupbgq) |
|
{ |
|
List<OIDMapping> tempList = item.ToList(); |
|
if (tempList.Count > 1) |
|
{ |
|
string bgqBSM = string.Empty; |
|
string bghBSM = string.Empty; |
|
if (string.IsNullOrWhiteSpace(MaxBSM)) |
|
MaxBSM = GetNewBSM(new List<IFeatureClass>() { jcFc }); |
|
string bsmPrefix = IDGParm.PrjInfo.CODE + MaxBSM.Substring(6, 4); |
|
int MaxNum = Convert.ToInt32(MaxBSM.Substring(9)); |
|
bghBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); |
|
MaxBSM = bghBSM; |
|
string bgqTBBH = string.Empty; |
|
string bghTBBH = string.Empty; |
|
string strZLDW = item.ToList()[0].bghZLDWDM; |
|
tempList.ForEach(o => |
|
{ |
|
o.IsTXBG = true; |
|
o.bghTBBSM = MaxBSM; |
|
o.bghTBBH = bghTBBH; |
|
}); |
|
} |
|
else |
|
{ |
|
if (!tempList[0].bgqTBBSM.StartsWith(IDGParm.PrjInfo.CODE)) |
|
{ |
|
string bsmPrefix = IDGParm.PrjInfo.CODE + MaxBSM.Substring(6, 4); |
|
int MaxNum = Convert.ToInt32(MaxBSM.Substring(10)); |
|
string bghBSM = bsmPrefix + (MaxNum + 1).ToString().PadLeft(8, '0'); |
|
MaxBSM = bghBSM; |
|
tempList[0].bghTBBSM = MaxBSM; |
|
} |
|
} |
|
} |
|
int idxBGQBSM = pGxgcFc.FindField("BSM_1"); |
|
int idxBGHZLDW = pGxgcFc.FindField("ZLDWDM"); |
|
List<IFeatureClass> fcList = new List<IFeatureClass>() { jcFc }; |
|
foreach (var item in list) |
|
{ |
|
string tempBGXW = item.IsTXBG ? "2" : "1"; |
|
if (item.bgqOID == -1) |
|
{ |
|
tempBGXW = "3"; |
|
} |
|
else if (item.bghOID == -1) |
|
{ |
|
tempBGXW = "0"; |
|
item.bghTBBH = ""; |
|
item.bghTBBSM = ""; |
|
} |
|
if (!bghAttr.ContainsKey(item.gcOID)) |
|
{ |
|
bghAttr.Add(item.gcOID, new BGHAttributeModel() |
|
{ |
|
BGHOID = item.bghOID, |
|
BGHTBBH = item.bghTBBH, |
|
BGHBSM = item.bghTBBSM, |
|
BGMJ = item.BGMJ, |
|
BGXW = tempBGXW, |
|
XZQTZLX = item.XZQTZLX |
|
}); |
|
} |
|
else |
|
{ |
|
bghAttr[item.gcOID] = new BGHAttributeModel() |
|
{ |
|
BGHOID = item.bghOID, |
|
BGHTBBH = item.bghTBBH, |
|
BGHBSM = item.bghTBBSM, |
|
BGMJ = item.BGMJ, |
|
BGXW = tempBGXW, |
|
XZQTZLX = item.XZQTZLX |
|
}; |
|
|
|
} |
|
if (!gxAttr.ContainsKey(item.bghOID)) |
|
{ |
|
gxAttr.Add(item.bghOID, new GXAttributeModel() |
|
{ |
|
TBBH = item.bghTBBH, |
|
BSM = item.bghTBBSM, |
|
TBMJ = item.BGMJ |
|
}); |
|
} |
|
else |
|
{ |
|
gxAttr[item.bghOID].TBMJ += item.BGMJ; |
|
} |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("属性赋值失败:"); |
|
LogAPI.Debug(ex); |
|
} |
|
} |
|
#endregion |
|
|
|
#region ReturnMessages |
|
private static string ReturnMessages(Geoprocessor gp) |
|
{ |
|
string ms = ""; |
|
if (gp.MessageCount > 0) |
|
{ |
|
for (int Count = 0; Count <= gp.MessageCount - 1; Count++) |
|
{ |
|
ms += "$" + gp.GetMessage(Count) + "\n\n"; |
|
} |
|
} |
|
return ms; |
|
} |
|
#endregion |
|
|
|
#region GetOutPutFeatureClass |
|
private static IFeatureClass GetOutPutFeatureClass(IGeoProcessorResult tGeoResult) |
|
{ |
|
IGPUtilities pGPUtilities = new GPUtilitiesClass(); |
|
IFeatureClass pFeatureClass = null; |
|
IQueryFilter pQueryFilter = null; |
|
try |
|
{ |
|
pGPUtilities.DecodeFeatureLayer(tGeoResult.GetOutput(0), out pFeatureClass, out pQueryFilter); |
|
return pFeatureClass; |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw new Exception("获取生成图层异常:" + ex.Message); |
|
} |
|
finally |
|
{ |
|
if (pQueryFilter != null) |
|
{ |
|
Marshal.ReleaseComObject(pQueryFilter); |
|
} |
|
} |
|
} |
|
#endregion |
|
public class CJDCQ_Param |
|
{ |
|
public IFeatureLayer JCLayer { get; set; } |
|
public IFeatureLayer JCJXLayer { get; set; } |
|
public IFeatureLayer GXLayer { get; set; } |
|
public IFeatureLayer GXGCLayer { get; set; } |
|
public IFeatureLayer GXJXLayer { get; set; } |
|
public IFeatureLayer NMTBLayer { get; set; } |
|
public IFeatureLayer GXGCTBLayer { get; set; } |
|
public IFeatureLayer JCTBLayer { get; set; } |
|
|
|
} |
|
} |
|
|
|
}
|
|
|