public static bool DelFeature(WebFeature.Feature f, DataRow dr) { try { bool b = true; string strWhere = "项目档案号='" + dr["项目档案号"].ToString() + "'"; //Log.WriteLog("strWhere>>>>" + strWhere); #region 要素存在时,删除 if (f.IsFeatureExistNew("两矿", "subjectType=CK&layerShortName=" + strLayerShortName, strWhere)) { b = f.DelFeatureNew("两矿", "subjectType=CK&layerShortName=" + strLayerShortName, 0, strWhere) && b; } #endregion if (b) { DebugInfo("DelFeatureNew()>>>>" + b.ToString()); } else { DebugInfo("DelFeatureNew()>>>>" + b.ToString()); } return(b); } catch (Exception ex) { return(false); throw ex; } }
/// <summary> /// 测试IGS服务是否正常 /// </summary> /// <param name="IGS_PATH">IGS服务所在的服务器IP</param> /// <param name="Message">提示信息</param> /// <returns></returns> public static bool TestIGS(string IGS_PATH, ref string Message) { try { try { WebFeature.Feature f = new WebFeature.Feature(); f.Url = "http://" + Config.GetConfigValue("IGS_PATH") + "//IGSLandService//Feature.asmx"; //bool b = Boolean.Parse(f.GetLayerAttCountNew("两矿","layerShortName="+strLayerShortName,"项目档案号 is not null").ToString()); bool b = Boolean.Parse(f.IsFeatureExistNew("两矿", "subjectType=CK&layerShortName=" + strLayerShortName, "项目档案号 is not null").ToString()); if (b) { Message = "连接成功"; } else { Message = "连接图形服务失败!"; } return(b); } catch (Exception ex) { Log.WriteLog(ex.Message); Message = "连接图形服务失败!"; return(false); throw ex; } } catch (Exception ex) { Log.WriteLog(ex.Message); throw ex; } }
/// <summary> /// 判断要素是否存在 /// </summary> /// <param name="f">IGS服务</param> /// <param name="dr">数据对象</param> /// <returns></returns> public static bool IsFeatureExitCKSQDJ(WebFeature.Feature f, DataRow dr)//CM.Map.Feature f,DataRow dr) { try { DebugInfo("IsFeatureExitCKSQDJ()方法开始执行..."); //bool b = false; string strWhere = "项目档案号='" + dr["项目档案号"].ToString() + "' and 签发时间='" + dr["签发时间"].ToString() + "'"; bool b = f.IsFeatureExistNew("两矿", "subjectType=CK&layerShortName=CKQSQDJ", strWhere); DebugInfo("【" + strWhere + "】结果为" + b.ToString()); return(b); } catch (Exception ex) { Log.WriteLog("IsFeatureExitCKSQDJ()方法报错>>>>" + ex.Message); errorMsg = "IsFeatureExitCKSQDJ()方法报错!"; return(false); throw ex; } }
public static bool UpdateFeature(WebFeature.Feature f, DataRow dr) { try { bool b = false; if (IsFeatureExitCKSQDJ(f, dr)) { DebugInfo("UpdateFeature()中判断要素已存在,不需要更新!"); return(true); } else { DebugInfo("UpdateFeature()中判断要素不存在,需要更新!"); #region attField string[] attField = { "CK_GUID", "申请序号", "许可证号", "项目档案号", "项目类型", "申请人", "电话", "地址", "邮编", "矿山名称", "经济类型", "项目审批机关", "批准文号", "资金来源", "设计年限", "开采主矿种", "其它主矿种", "设计规模", "规模单位", "开采方式", "采矿方法", "选矿方法", "应缴纳采矿权价款", "采深上限", "采深下限", "矿区面积", "采矿权使用费", "有效期限", "有效期起", "有效期止", "矿区编码", "原许可证号", "发证机关名称", "区域坐标", "设计利用储量", "坐标系统", "签发时间" }; #endregion #region attValue string[] attValue = { dr["CK_GUID"].ToString(), dr["申请序号"].ToString(), dr["许可证号"].ToString(), dr["项目档案号"].ToString(), dr["项目类型"].ToString(), dr["申请人"].ToString(), dr["电话"].ToString(), dr["地址"].ToString(), dr["邮编"].ToString(), dr["矿山名称"].ToString(), dr["经济类型"].ToString(), dr["项目审批机关"].ToString(), dr["批准文号"].ToString(), dr["资金来源"].ToString(), dr["设计年限"].ToString(), dr["开采主矿种"].ToString(), dr["其它主矿种"].ToString(), dr["设计规模"].ToString(), dr["规模单位"].ToString(), dr["开采方式"].ToString(), dr["采矿方法"].ToString(), dr["选矿方法"].ToString(), dr["应缴纳采矿权价款"].ToString(), dr["采深上限"].ToString(), dr["采深下限"].ToString(), dr["矿区面积"].ToString(), dr["采矿权使用费"].ToString(), dr["有效期限"].ToString(), dr["有效期起"].ToString(), dr["有效期止"].ToString(), dr["矿区编码"].ToString(), dr["原许可证号"].ToString(), dr["发证机关名称"].ToString(), dr["区域坐标"].ToString(), dr["设计利用储量"].ToString(), dr["坐标系统"].ToString(), dr["签发时间"].ToString() }; #endregion #region 判断当前『项目档案号』是否存在于图层中 string strWhere = "项目档案号='" + dr["项目档案号"].ToString() + "'"; #region 存在时先删除记录 if (f.IsFeatureExistNew("两矿", "subjectType=CK&layerShortName=" + strLayerShortName, strWhere)) { DebugInfo("同『项目档案号』要素已存在"); try { DebugInfo("调用DelFeature()方法"); #region 除对应记录 b = f.DelFeatureNew("两矿", "subjectType=CK&layerShortName=" + strLayerShortName, 0, strWhere); DebugInfo(b.ToString()); if (!b) { return(b); } #endregion } catch (Exception ex) { throw ex; } } #endregion #endregion #region 插入记录 //Log.WriteLog("AddFeatureNew"); ///尝试插入数据 if (f.AddFeatureNew("两矿", "subjectType=CK&layerShortName=" + strLayerShortName, GetCKFormattedDotString(dr["区域坐标"].ToString(), true), attField, attValue)) { DebugInfo("AddFeature()方法成功"); b = true; } else { DebugInfo("AddFeature()方法失败"); b = false; } #endregion DebugInfo("项目档案号=" + dr["项目档案号"].ToString()); #region UpdateFeature.Debug for (int i = 0; i < attField.Length; i++) { DebugInfo(attField[i].ToString() + ">>>>" + attValue[i].ToString()); } DebugInfo("==========================================================="); //for (int i = 0; i < attValue.Length; i++) // DebugInfo(attValue[i].ToString()); #endregion } return(b); } catch (Exception ex) { errorMsg = "UpdateFeature()方法出错!"; Log.WriteLog(errorMsg + ">>>>" + ex.Message); throw ex; } }
/// <summary> /// 同步图形中的CKSQDJ图层数据 /// </summary> /// <param name="dbMDB">MDB数据库对象</param> /// <param name="IGSUri">IGS服务地址</param> /// <returns></returns> public static bool SynIGS(DatabaseOledb dbMDB, string IGSUri) { try { bool b = true; //CM.Map.Feature f = new CM.Map.Feature("http://" + IGSUri + "/IGSLandService/Feature.asmx"); WebFeature.Feature f = new WebFeature.Feature(); f.Url = "http://" + IGSUri + "/IGSLandService/Feature.asmx";; string mdbSQL = "select * from 采矿申请登记 where 签发时间 is not null"; DataTable dt = new DataTable(); #region 判断是否查询到数据,若未查询到数据则不需要进行后面的判断 if (dbMDB.GetDataSet(mdbSQL).Tables.Count > 0) { try { dt = dbMDB.GetDataSet(mdbSQL).Tables[0]; DebugInfo("查询到数据"); } catch (Exception ex) { errorMsg = "同步错误,请检查采矿权数据库设置!"; return(false); throw ex; } } else { errorMsg = "同步错误,采矿权数据库(MDB)中未查询到数据!"; return(false); } #endregion DataRow dr = null; #region 遍历采矿申请登记表,更新采矿权图层 for (int i = 0; i < dt.Rows.Count; i++) { dr = dt.Rows[i]; try { b = UpdateFeature(f, dr) && b; //Log.WriteLog(string.Format(b.ToString() + "循环第{0}次", i + 1)); if (!b) { DebugInfo("UpdateFeature()失败!"); return(b); } //else // continue; } catch (Exception ex) { Log.WriteLog("UpdateFeature()>>>>" + ex.Message); return(false); throw ex; } } #endregion #region 查询项目档案中已注销矿权信息 #region 重新初始化数据对象 mdbSQL = string.Empty; dt = null; dr = null; #endregion mdbSQL = "select * from 项目档案 where 项目类型=1070"; if (dbMDB.GetDataSet(mdbSQL).Tables.Count > 0) { try { //Log.WriteLog(mdbSQL); dt = dbMDB.GetDataSet(mdbSQL).Tables[0]; } catch (Exception ex) { errorMsg = "同步错误,请检查采矿权数据库设置!"; return(false); throw ex; } } else { b = b && true; } #endregion #region 遍历项目档案登记表,删除已注销矿权 for (int i = 0; i < dt.Rows.Count; i++) { dr = dt.Rows[i]; try { b = DelFeature(f, dr) && b; //Log.WriteLog(string.Format("DelFeature()>>>>"+b.ToString() + "循环第{0}次", i + 1)); if (!b) { return(b); } //else // continue; } catch (Exception ex) { Log.WriteLog("DelFeature()>>>>" + ex.Message); return(false); throw ex; } } #endregion return(b); } catch (Exception ex) { Log.WriteLog("SynIGS错误>>>>" + ex.Message); errorMsg = "同步图形错误!"; return(false); throw ex; } }