wzp
2022-11-23 0200c90ad90c94cfc14264d1f46e0ea20a20ebbd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 
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<SysUser>, IRequiresSessionState
{
    private GwOpGroupDao _Dao = new GwOpGroupDao();
    private List<GwOp> 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<GwOp>)(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<GwOpGroup> groupList = this._Dao.GetGroupList();
        if (groupList.Count > 0)
        {
            foreach (GwOpGroup gwOpGroup in groupList)
            {
                stringBuilder.AppendLine("<tr>");
                stringBuilder.AppendFormat("<td>{0}</td>", (object)gwOpGroup.GroupName);
                stringBuilder.AppendFormat("<td>{0}</td>", (object)this.FormatGroupData(gwOpGroup.GroupData));
                stringBuilder.AppendFormat("<td><a href=\"javascript:;\"  class=\"action-modal-edit btn btn-xs btn-danger\" data-id=\"{0}\">编辑</a>&nbsp;<a href=\"javascript:;\"  class=\"action-delete btn btn-xs btn-default\" data-id=\"{0}\">删除</a></td>", (object)gwOpGroup.GroupID);
                stringBuilder.AppendLine("</tr>");
            }
        }
        else
            stringBuilder.AppendFormat("<tr><td colspan=\"4\">暂时无数据</td></tr>");
        return stringBuilder.ToString();
    }
 
    private string FormatGroupData(string p)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (JToken jtoken in JsonConvert.DeserializeObject<JArray>(p))
            stringBuilder.AppendFormat("<p>  权重 = <span class=\"label label-success\">{1}</span> <span class=\"label label-primary\">{0}</span> </p>", (object)this.GetOpName(jtoken.Value<int>((object)"opid")), (object)jtoken.Value<int>((object)"weight"));
        return stringBuilder.ToString();
    }
}