Ejemplo n.º 1
0
        public void UpdateMap(string mapId, List <string> layers)
        {
            if (layers != null && layers.Count > 0)
            {
                var map = _IMapRepository.Get(mapId);
                if (map != null)
                {
                    var list = _ILayerContentRepository.GetAll().Where(t => layers.Contains(t.Id)).ToList();
                    if (list != null)
                    {
                        Dictionary <string, decimal?> bbox = new Dictionary <string, decimal?>();
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (i == 0)
                            {
                                bbox.Add("MaxX", list[i].MaxX);
                                bbox.Add("MinX", list[i].MinX);
                                bbox.Add("MaxY", list[i].MaxY);
                                bbox.Add("MinY", list[i].MinY);
                            }
                            else
                            {
                                if (list[i].MaxX > bbox["MaxX"])
                                {
                                    bbox["MaxX"] = list[i].MaxX;
                                }
                                if (list[i].MaxY > bbox["MaxY"])
                                {
                                    bbox["MaxY"] = list[i].MaxY;
                                }
                                if (list[i].MinX < bbox["MinX"])
                                {
                                    bbox["MinX"] = list[i].MinX;
                                }
                                if (list[i].MinY < bbox["MinY"])
                                {
                                    bbox["MinY"] = list[i].MinY;
                                }
                            }
                        }

                        map.MaxX = bbox["MaxX"];
                        map.MinX = bbox["MinX"];
                        map.MaxY = bbox["MaxY"];
                        map.MinY = bbox["MinY"];

                        _IMapRepository.Update(map);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据帐号和图层ID获取通知
        /// </summary>
        public ListResultOutput <LayerReadLogOutputDto> GetDetailByLayer(LayerReadLogOutputDto input)
        {
            try
            {
                string layerID = input.LayerID, user = input.CreateBy;
                ListResultOutput <LayerReadLogOutputDto> list;
                var layer = _ILayerContentRepository.GetAll();
                //var readLog = _ILayerReadLogRepository.GetAll().Where(q => (string.IsNullOrEmpty(layerID) ? true : q.LayerID.Contains(layerID)) && (string.IsNullOrEmpty(user) ? true : (q.CreateBy.Contains(user) && q.MsgStatus.Value.Equals(0))));

                var readLog = _ILayerReadLogRepository.GetAll();
                if (string.IsNullOrEmpty(layerID))
                {
                    readLog = readLog.Where(q => (q.CreateBy.Contains(user) && q.MsgStatus == 1));
                }
                else
                {
                    readLog = readLog.Where(q => q.LayerID.Contains(layerID) && (q.CreateBy.Contains(user) && q.MsgStatus == 1));
                }
                var query = (from r in readLog
                             join l in layer on r.LayerID equals l.Id into rl
                             from rre in rl.DefaultIfEmpty()
                             select new LayerReadLogOutputDto
                {
                    Id = r.Id,
                    LayerID = r.LayerID,
                    LayerName = (rre == null) ? "" : rre.LayerName,
                    ShpFileName = r.ShpFileName,
                    ReadStatus = r.ReadStatus,
                    Message = r.Message,
                    CreateDT = r.CreateDT,
                    CreateBy = r.CreateBy,
                    ReadStartDT = r.ReadStartDT,
                    ReadEndDT = r.ReadEndDT,
                    MsgStatus = r.MsgStatus
                }).OrderByDescending(x => x.CreateDT).ToList();

                list = new ListResultOutput <LayerReadLogOutputDto>(query.MapTo <List <LayerReadLogOutputDto> >());
                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 3
0
        /// <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("");
            }
        }