using Dao; using Model; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Text; using System.Web; using System.Web.Profile; using System.Web.SessionState; public partial class GwOpGroupPage : PageBase, IRequiresSessionState { private GwOpGroupDao _Dao = new GwOpGroupDao(); private List OpList; protected void Page_Load(object sender, EventArgs e) { using (GwOpDao gwOpDao = new GwOpDao()) this.OpList = gwOpDao.LoadInfoList(); } private string GetOpName(int opID) { if (this.OpList == null) return string.Empty; GwOp gwOp = this.OpList.Find((Predicate)(op => op.OpID == opID)); if (gwOp != null) return string.Format("{0}-{1}", (object)gwOp.OpID, (object)gwOp.OpName); return string.Empty; } public string RenderOpListJson() { using (GwOpDao gwOpDao = new GwOpDao()) return JsonConvert.SerializeObject((object)gwOpDao.LoadInfoList()); } public string RenderGroupList() { StringBuilder stringBuilder = new StringBuilder(); List groupList = this._Dao.GetGroupList(); if (groupList.Count > 0) { foreach (GwOpGroup gwOpGroup in groupList) { stringBuilder.AppendLine(""); stringBuilder.AppendFormat("{0}", (object)gwOpGroup.GroupName); stringBuilder.AppendFormat("{0}", (object)this.FormatGroupData(gwOpGroup.GroupData)); stringBuilder.AppendFormat("编辑 删除", (object)gwOpGroup.GroupID); stringBuilder.AppendLine(""); } } else stringBuilder.AppendFormat("暂时无数据"); return stringBuilder.ToString(); } private string FormatGroupData(string p) { StringBuilder stringBuilder = new StringBuilder(); foreach (JToken jtoken in JsonConvert.DeserializeObject(p)) stringBuilder.AppendFormat("

权重 = {1} {0}

", (object)this.GetOpName(jtoken.Value((object)"opid")), (object)jtoken.Value((object)"weight")); return stringBuilder.ToString(); } }