public DataTable GetLayerElementAttrs(string layerId, string elementId) { var sql = "select * from " + layerId + " where guid='" + elementId + "'"; var db = new PostgrelVectorHelper(); return(db.getDataTable(sql)); }
/// <summary> /// Called by the <see cref="IScheduler" /> when a <see cref="ITrigger" /> /// fires that is associated with the <see cref="IJob" />. /// </summary> /// <remarks> /// The implementation may wish to set a result object on the /// JobExecutionContext before this method exits. The result itself /// is meaningless to Quartz, but may be informative to /// <see cref="IJobListener" />s or /// <see cref="ITriggerListener" />s that are watching the job's /// execution. /// </remarks> /// <param name="context">The execution context.</param> public void Execute(IJobExecutionContext context) { logger.Info("ThumbnailInitialize running..."); //mysql = new MySqlHelper(); postgis = new PostgrelVectorHelper(); DataTable dt = dtCreate(); dtLayer(dt); dtMap(dt); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { string bboxStr = string.Format("{0},{1},{2},{3}", dr["MinX"], dr["MinY"], dr["MaxX"], dr["MaxY"]); ThumbnailCreate(dr["Name"].ToString(), dr["Type"].ToString(), bboxStr); } } Thread.Sleep(TimeSpan.FromSeconds(5)); logger.Info("ThumbnailInitialize run finished."); }
/// <summary> /// 框选查询结果 /// </summary> /// <param name="layerID">图层ID</param> /// <param name="queryType">查询类型</param> /// <param name="strSQL1">SQL1</param> /// <param name="strSQL2">SQL2</param> /// <returns></returns> public string GetLayerAttrByLayerID(string layerID, string queryType, string strSQL1, string strSQL2) { try { bool success = false; string result = string.Empty; StringBuilder sb = new StringBuilder(); var layerList = layerID.Split(','); if (layerList != null) { result += "["; int intIndex = 0; foreach (var item in layerList) { string layerAttrTable = string.Empty, layerDataType = string.Empty, layerName = string.Empty; var layer = _ILayerContentRepository.GetAll(); var dataType = _IDicDataCodeRepository.GetAll(); var query = from a in layer join b in dataType on a.DataType equals b.Id where a.Id == item select new { a.LayerName, a.LayerAttrTable, b.CodeValue }; if (query != null) { if (query.Count() > 0) { foreach (var it in query) { layerName = it.LayerName; layerAttrTable = it.LayerAttrTable; layerDataType = it.CodeValue; } } } var field = _ILayerFieldRepository.GetAllList(q => q.LayerID == item); StringBuilder str = new StringBuilder(); StringBuilder att = new StringBuilder(); str.Append("\""); str.Append("sid"); str.Append("\""); str.Append(","); foreach (var ite in field) { str.Append("\""); str.Append(ite.AttributeName); str.Append("\""); str.Append(","); att.Append(ite.AttributeName); att.Append("#"); } if (str.Length > 0) { str.Length = str.Length - 1; att.Length = att.Length - 1; } #region [图层属性取值] string tableName = "public." + layerAttrTable; string strSQL = string.Empty; if (layerDataType.ToUpper() == "POLYGON" && queryType == "Pt") { strSQL = string.Format(strSQL1, str.ToString(), tableName); } else { strSQL = string.Format(strSQL2, str.ToString(), tableName);; } PostgrelVectorHelper actal = new PostgrelVectorHelper(); DataTable dt = actal.GetData(strSQL); #endregion #region [组JSON串] if (dt != null && dt.Rows.Count > 0) { success = true; result += "{"; string lay = layerAttrTable; string layName = layerName; string layID = item; result += "\"" + "layer" + "\":" + "\"" + lay + "\"," + "\"" + "layerName" + "\":" + "\"" + layName + "\"," + "\"" + "layerID" + "\":" + "\"" + layID + "\","; result += "\"" + "attr" + "\":" + "\"" + att + "\","; string data = JsonConvert.SerializeObject(dt); result += "\"" + "data" + "\":" + data; result += "},"; } #endregion intIndex++; } if (success) { result = result.Substring(0, result.Length - 1); } result += "]"; } if (success) { return(result); } else { return(""); } } catch (Exception ex) { return(""); } }