/// <summary> /// 检查是否为管理员登陆 /// </summary> /// <returns></returns> public bool Isadminlogin() { ManagePage mana = new ManagePage(); if (mana.GetAdminInfo() == null) { return(true); } else { return(false); } }
public string mapToJson(string jsonName, string areacode, string keywords, int page, int pageSize) { ManagePage pg = new ManagePage(); var model = pg.GetAdminInfo(); string strwhere = " 1=1 "; StringBuilder strTemp = new StringBuilder(); keywords = keywords.Replace("'", ""); if (model.role_type != 1) { strwhere += $" and user_id={model.id} "; } if (!string.IsNullOrEmpty(areacode)) { strwhere += $" and area_code='{areacode.Replace("'", "")}' "; } if (!string.IsNullOrEmpty(keywords)) { strwhere += $" and (name like '%{keywords}%' or onenetnum='{keywords}')"; } BLL.dt_item bll = new BLL.dt_item(); var itemlist = bll.GetModelList(strwhere + " order by addtime desc "); string jsonstr = string.Empty; if (itemlist != null && itemlist.Count > 0) { itemlist = itemlist.Skip((page - 1) * pageSize).Take(pageSize).ToList(); jsonstr = JsonHelper2.Serialize(itemlist.Select(p => new { id = p.id, sbid = p.onenetnum, title = p.name, gps = p.position, online = p.online?1:0 })); //for (int i = 0; i < itemlist.Count; i++) //{ // Json.Append("{"); // Json.Append("id:\"" + itemlist[i].id + "\""); // Json.Append(","); // Json.Append("sbid:\"" + itemlist[i].onenetnum + "\""); // Json.Append(","); // Json.Append("title:\"" + itemlist[i].name + "\""); // Json.Append(","); // Json.Append("gps:\"" + itemlist[i].position + "\""); // Json.Append(","); // Json.Append("online:\"" + itemlist[i].online + "\""); // Json.Append("}"); // if (i != itemlist.Count - 1) // { // Json.Append(","); // } //} } return(jsonstr); }