/// <summary> /// 更新一条数据 /// </summary> public bool Update(big_data.Model.RegionInfos model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update RegionInfos set "); strSql.Append("RegionID=@RegionID,"); strSql.Append("RegionXYInfo=@RegionXYInfo,"); strSql.Append("AddTime=@AddTime,"); strSql.Append("UnifiedAddressLibraryID=@UnifiedAddressLibraryID"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@RegionID", SqlDbType.Int, 4), new SqlParameter("@RegionXYInfo", SqlDbType.NVarChar, -1), new SqlParameter("@AddTime", SqlDbType.DateTime2, 8), new SqlParameter("@UnifiedAddressLibraryID", SqlDbType.NVarChar, -1), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.RegionID; parameters[1].Value = model.RegionXYInfo; parameters[2].Value = model.AddTime; parameters[3].Value = model.UnifiedAddressLibraryID; parameters[4].Value = model.ID; int rows = DbHelperSql.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(big_data.Model.RegionInfos model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into RegionInfos("); strSql.Append("RegionID,RegionXYInfo,AddTime,UnifiedAddressLibraryID)"); strSql.Append(" values ("); strSql.Append("@RegionID,@RegionXYInfo,@AddTime,@UnifiedAddressLibraryID)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@RegionID", SqlDbType.Int, 4), new SqlParameter("@RegionXYInfo", SqlDbType.NVarChar, -1), new SqlParameter("@AddTime", SqlDbType.DateTime2, 8), new SqlParameter("@UnifiedAddressLibraryID", SqlDbType.NVarChar, -1) }; parameters[0].Value = model.RegionID; parameters[1].Value = model.RegionXYInfo; parameters[2].Value = model.AddTime; parameters[3].Value = model.UnifiedAddressLibraryID; object obj = DbHelperSql.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public big_data.Model.RegionInfos DataRowToModel(DataRow row) { big_data.Model.RegionInfos model = new big_data.Model.RegionInfos(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["RegionID"] != null && row["RegionID"].ToString() != "") { model.RegionID = int.Parse(row["RegionID"].ToString()); } if (row["RegionXYInfo"] != null) { model.RegionXYInfo = row["RegionXYInfo"].ToString(); } if (row["AddTime"] != null && row["AddTime"].ToString() != "") { model.AddTime = DateTime.Parse(row["AddTime"].ToString()); } if (row["UnifiedAddressLibraryID"] != null) { model.UnifiedAddressLibraryID = row["UnifiedAddressLibraryID"].ToString(); } } return(model); }
/// <summary> /// 区域基础数据整理 /// </summary> public void QuYuinfo() { DataSet dss = regionInfobll.GetList("1=1"); if (dss.Tables[0].Rows.Count > 0) { for (int i = 0; i < dss.Tables[0].Rows.Count; i++) { string Ids = dss.Tables[0].Rows[i]["RegionID"].ToString(); string zbx = dss.Tables[0].Rows[i]["RegionX"].ToString(); //经度 string zby = dss.Tables[0].Rows[i]["RegionY"].ToString(); //纬度 DataSet dssbs = regionInfosbll.GetList("RegionID=" + Ids); if (dssbs.Tables[0].Rows.Count > 0) { regionInfosmodel = regionInfosbll.GetModel(Convert.ToInt32(dssbs.Tables[0].Rows[0]["ID"])); regionInfosmodel.RegionID = Convert.ToInt32(Ids); if (regionInfosmodel.RegionXYInfo.ToString() != "") { regionInfosmodel.RegionXYInfo += "|" + zbx + "," + zby; } else { regionInfosmodel.RegionXYInfo = zbx + "," + zby; } regionInfosmodel.UnifiedAddressLibraryID = ""; regionInfosmodel.AddTime = DateTime.Now; regionInfosbll.Update(regionInfosmodel); } else { regionInfosmodel.RegionID = Convert.ToInt32(Ids); regionInfosmodel.RegionXYInfo = zbx + "," + zby; regionInfosmodel.UnifiedAddressLibraryID = ""; regionInfosmodel.AddTime = DateTime.Now; regionInfosbll.Add(regionInfosmodel); } } } LogHelper.WriteLog(typeof(FrmMainServer), "数据更新完成!!!"); //AlertAndStay("数据更新完成!!!"); }
/// <summary> /// 得到一个对象实体 /// </summary> public big_data.Model.RegionInfos GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,RegionID,RegionXYInfo,AddTime,UnifiedAddressLibraryID from RegionInfos "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; big_data.Model.RegionInfos model = new big_data.Model.RegionInfos(); DataSet ds = DbHelperSql.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 地址库数据区域数据匹配 /// </summary> public void UnifiedAddressLibraryQuYuinfo() { DataSet dss = unifiedAddressLibrarybll.GetList("1=1"); if (dss.Tables[0].Rows.Count > 0) { for (int i = 0; i < dss.Tables[0].Rows.Count; i++) { string UnifiedAddressLibraryID = dss.Tables[0].Rows[i]["ID"].ToString(); double xinfo = Convert.ToDouble(dss.Tables[0].Rows[i]["LON"].ToString()); double yinfo = Convert.ToDouble(dss.Tables[0].Rows[i]["LAT"].ToString()); DataSet dssab = regionInfosbll.GetList("1=1"); if (dssab.Tables[0].Rows.Count > 0) { for (int i1 = 0; i1 < dssab.Tables[0].Rows.Count; i1++) { string ids = dssab.Tables[0].Rows[i1]["ID"].ToString(); string xyinfolist = dssab.Tables[0].Rows[i1]["RegionXYInfo"].ToString(); if (xyinfolist != "") { string[] listitem = xyinfolist.Split('|'); if (listitem.Length > 0) { Point point11 = new Point(xinfo, yinfo); Point[] ps = new Point[listitem.Length]; for (int i2 = 0; i2 < listitem.Length; i2++) { string[] xylist = listitem[i2].Split(','); if (xylist.Length > 0) { ps[i2] = new Point(Convert.ToDouble(xylist[0]), Convert.ToDouble(xylist[1])); } } if (PointInFences(point11, ps)) { regionInfosmodel = regionInfosbll.GetModel(Convert.ToInt32(ids)); if (!("," + regionInfosmodel.UnifiedAddressLibraryID + ",").Contains("," + UnifiedAddressLibraryID + ",")) { if (regionInfosmodel.UnifiedAddressLibraryID != "") { regionInfosmodel.UnifiedAddressLibraryID += "," + UnifiedAddressLibraryID; } else { regionInfosmodel.UnifiedAddressLibraryID = UnifiedAddressLibraryID; } regionInfosmodel.AddTime = DateTime.Now; regionInfosbll.Update(regionInfosmodel); } } } } } } unifiedAddressLibrarymodel = unifiedAddressLibrarybll.GetModel(Convert.ToInt32(UnifiedAddressLibraryID)); unifiedAddressLibrarymodel.REMARK = "1"; unifiedAddressLibrarymodel.AddTime = DateTime.Now.ToString(); unifiedAddressLibrarybll.Update(unifiedAddressLibrarymodel); } } //AlertAndStay("数据更新完成!!!"); LogHelper.WriteLog(typeof(FrmMainServer), "数据更新完成!!!"); }