<%@ 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> 编辑";
|
str += "</a> ";
|
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> 删除";
|
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) "同步上行路由成功!");
|
}
|
}
|