yzh
2022-05-23 41ecad7e49a93c493832282b5ecd6c69f464b648
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<%@ WebHandler Language="C#" Class="GwMoRouteHandler" %>
 
using Common;
using Dao;
using Model;
using System;
using System.Collections.Generic;
 
public class GwMoRouteHandler : PageHandler<SysUser>
{
  private GwMoRouteDao _Dao = new GwMoRouteDao();
  private GwSpDao _SpDao = new GwSpDao();
 
  public override JsonPageResult ProcessRequestInternal(PageContext<SysUser> context)
  {
    string @string = context.GetString("action");
    switch (@string)
    {
      case "loadGwMoRoutePageList":
        return this.LoadGwMoRoutePageList(context);
      case "save":
        return this.Save(context);
      case "update":
        return this.Update(context);
      case "delete":
        return this.Delete(context);
      case "getGwMoRoute":
        return this.GetGwMoRoute(context);
      case "getGwSp":
        return this.GetGwSp(context);
      case "loadRefresh":
        return this.LoadRefresh(context);
      default:
        throw new Exception("Invalid Action=" + @string);
    }
  }
 
  private JsonPageResult LoadGwMoRoutePageList(PageContext<SysUser> context)
  {
    int int1 = context.GetInt("opID");
    string string1 = context.GetString("spID");
    string string2 = context.GetString("accessCode");
    int recordcount = 0;
    int int2 = context.GetInt("pageIndex", 1);
    int int3 = context.GetInt("pageSize", 20);
    string str = "";
    using (GwMoRouteDao gwMoRouteDao = new GwMoRouteDao())
    {
      List<GwMoRoute> list = gwMoRouteDao.LoadInfoList(int1, string1, string2, out recordcount, int2, int3);
      if (list != null && list.Count > 0)
      {
        foreach (GwMoRoute gwMoRoute in list)
        {
          string priorityName = gwMoRoute.PriorityName;
          str = str + (object) "<tr ><td>" + (object) gwMoRoute.OpID + "</td><td>" + gwMoRoute.AccessCode + "</td><td>" + priorityName + "</td><td>" + gwMoRoute.SpID + "</td>";
          str += "<td>";
          if (gwMoRoute.IsManual == 1)
          {
            str += string.Format("<a class=\"action-modal-edit btn btn-success btn-xs \" href=\"javascript:;\" data-id=\"{0}\">", (object) gwMoRoute.RouteID);
            str += "<i class='fa fa-edit'></i>&nbsp;编辑";
            str += "</a>&nbsp;";
            str += string.Format("<a class=\"action-delete btnbtn btn btn-default btn-xs\" href=\"javascript:;\" data-id=\"{0}\">", (object) gwMoRoute.RouteID);
            str += "<i class='fa fa-trash'></i>&nbsp;删除";
            str += "</a>";
          }
          else
            str += "<span class=\"text-mute\">系统生成,无法更改</span>";
          str += "</td>";
          str += "</tr>";
        }
      }
      else
        str += "<tr><td colspan=\"5\" style=\"text-align: center;\">暂无信息</td></tr>";
    }
    return new JsonPageResult(true, (object) new
    {
      Table = str.ToString(),
      TotalCount = recordcount
    });
  }
 
  private JsonPageResult Save(PageContext<SysUser> context)
  {
    int int1 = context.GetInt("priority", 0);
    int int2 = context.GetInt("opID");
    string string1 = context.GetString("spID");
    string string2 = context.GetString("accessCode");
    if (int2 <= 0)
      throw new ArgumentException("请选择通道!");
    if (string.IsNullOrEmpty(string2))
      throw new ArgumentException("上行接入号不能为空!");
    if (string.IsNullOrEmpty(string1))
      throw new ArgumentException("请选择帐号!");
    GwMoRoute o = new GwMoRoute();
    o.Priority = int1;
    o.OpID = int2;
    o.AccessCode = string2;
    o.SpID = string1;
    context.CheckRight("3061", FailedOperation.PromptOnly);
    this._Dao.Add(o);
    return new JsonPageResult(true, (object) "创建上行路由成功!");
  }
 
  private JsonPageResult Update(PageContext<SysUser> context)
  {
    int int1 = context.GetInt("routeID");
    int int2 = context.GetInt("priority", 0);
    int int3 = context.GetInt("opID");
    string string1 = context.GetString("spID");
    string string2 = context.GetString("accessCode");
    if (int3 <= 0)
      throw new ArgumentException("请选择通道!");
    if (string.IsNullOrEmpty(string2))
      throw new ArgumentException("上行接入号不能为空!");
    if (string.IsNullOrEmpty(string1))
      throw new ArgumentException("请选择帐号!");
    context.CheckRight("3062", FailedOperation.PromptOnly);
    this._Dao.Update(new GwMoRoute()
    {
      RouteID = int1,
      Priority = int2,
      OpID = int3,
      AccessCode = string2,
      SpID = string1
    });
    return new JsonPageResult(true, (object) "修改上行路由成功!");
  }
 
  private JsonPageResult Delete(PageContext<SysUser> context)
  {
    context.CheckRight("3063", FailedOperation.PromptOnly);
    this._Dao.Delete(context.GetInt("routeID"));
    return new JsonPageResult(true, (object) "删除上行路由成功!");
  }
 
  private JsonPageResult GetGwMoRoute(PageContext<SysUser> context)
  {
    return new JsonPageResult(true, (object) this._Dao.GetGwMoRoute(context.GetInt("routeID")));
  }
 
  private JsonPageResult GetGwSp(PageContext<SysUser> context)
  {
    return new JsonPageResult(true, (object) this._SpDao.Get(context.GetString("spID")));
  }
 
  private JsonPageResult LoadRefresh(PageContext<SysUser> context)
  {
    this._Dao.LoadRefresh();
    return new JsonPageResult(true, (object) "同步上行路由成功!");
  }
}