using FangYar.Common ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Linq ;
using System.Web ;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// MenuHandler 的摘要说明
/// </summary>
public class MenuHandler : IHttpHandler
{
private FangYar . BLL . BaseUserBLL bll = new BLL . BaseUserBLL ( ) ;
private FangYar . BLL . FIRE . FIRE_ORG bll_org = new FangYar . BLL . FIRE . FIRE_ORG ( ) ;
public void ProcessRequest ( HttpContext context )
{
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Other , "菜单操作请求" , "" ) ;
context . Response . ContentType = "text/json" ;
string action = context . Request . Params [ "Action" ] ;
string returnstr = "" ;
switch ( action )
{
case "List" :
returnstr = GetUserList ( context ) ;
break ;
case "Add" :
returnstr = AddUser ( context ) ;
break ;
case "Edit" :
returnstr = DelUser ( context ) ;
break ;
case "Del" :
returnstr = DelUser ( context ) ;
break ;
case "EditPwd" :
returnstr = DelUser ( context ) ;
break ;
case "GetUserMenu" :
returnstr = GetUserMenu ( context ) ;
break ;
case "typegetmenu" :
returnstr = typegetmenu ( context ) ;
break ;
}
context . Response . Write ( returnstr ) ;
}
//查询
private string GetUserList ( HttpContext context )
{
string returnstr = "" ;
try
{
string keywords = context . Request . Params [ "keywords" ] ;
string where = null ;
if ( ! string . IsNullOrEmpty ( keywords ) )
{
where = "USERS_UID like '" + keywords + "' or USERS_NAME like '" + keywords + "' " ;
}
returnstr = "{\"code\":0,\"msg\":\"\"," ;
List < FangYar . Model . BaseUserModel > list = bll . QueryList ( 1 , 1 0 , where , null ) ;
returnstr + = "\"count\":" + list . Count + ",\"data\":" ;
if ( list . Count = = 0 )
{
returnstr + = "[]" ;
}
else
{
returnstr + = FangYar . Common . JsonHelper . ToJson ( list ) ;
}
returnstr + = "}" ;
}
catch ( Exception e )
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}" ;
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Error , "菜单操作请求" , "查询异常:" + e ) ;
}
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Query , "菜单操作请求" , "查询" ) ;
return returnstr ;
}
//添加
private string AddUser ( HttpContext context )
{
string returnstr = "" ;
int code = - 1 ;
string msg = "" ;
try
{
string userUID = context . Request . Params [ "userUID" ] ;
string userPwd = context . Request . Params [ "userPwd" ] ;
string userType = context . Request . Params [ "userType" ] ;
string userName = context . Request . Params [ "userName" ] ;
if ( string . IsNullOrEmpty ( userUID ) )
{
msg = "账号不能为空!" ;
}
else if ( userUID . Length < 4 )
{
msg = "账号长度最少为4个字符!" ;
}
else if ( string . IsNullOrEmpty ( userPwd ) )
{
msg = "密码不能为空!" ;
}
else if ( userUID . Length < 4 )
{
msg = "密码长度最少为4个字符!" ;
}
else if ( string . IsNullOrEmpty ( userName ) )
{
msg = "名称不能为空!" ;
}
else if ( bll . CheckLoginByUserID ( userUID ) ! = null )
{
msg = "用户已存在!" ;
}
else
{
FangYar . Model . BaseUserModel model = new Model . BaseUserModel ( ) ;
model . ID = Guid . NewGuid ( ) . ToString ( "N" ) ;
model . USERS_UID = userUID ;
model . USERS_PWD = FangYar . Common . Md5 . GetMD5String ( userPwd ) ;
model . USERS_NAME = userName ;
model . USERS_TYPE = userType ;
if ( bll . AddUser ( model ) )
{
msg = "添加成功!" ;
code = 1 ;
}
else
{
msg = "添加失败!" ;
}
}
}
catch ( Exception e )
{
msg = "添加失败!" ;
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Error , "菜单操作请求" , "添加异常:" + e ) ;
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}" ;
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Add , "菜单操作请求" , "添加" ) ;
return returnstr ;
}
//修改
private string EditUser ( HttpContext context )
{
string returnstr = "" ;
int code = - 1 ;
string msg = "" ;
try
{
string ID = context . Request . Params [ "ID" ] ;
string userUID = context . Request . Params [ "userUID" ] ;
string userPwd = context . Request . Params [ "userPwd" ] ;
string userType = context . Request . Params [ "userType" ] ;
string userName = context . Request . Params [ "userName" ] ;
FangYar . Model . BaseUserModel model = bll . GetUserByID ( ID ) ;
if ( model = = null )
{
msg = "用户不存在!" ;
}
else
{
model . USERS_UID = userUID ;
model . USERS_PWD = FangYar . Common . Md5 . GetMD5String ( userPwd ) ;
model . USERS_NAME = userName ;
model . USERS_TYPE = userType ;
if ( bll . AddUser ( model ) )
{
msg = "修改成功!" ;
code = 1 ;
}
else
{
msg = "修改失败!" ;
}
}
}
catch ( Exception e )
{
msg = "修改失败!" ;
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Error , "菜单操作请求" , "修改异常:" + e ) ;
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}" ;
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Update , "菜单操作请求" , "修改" ) ;
return returnstr ;
}
//删除
private string DelUser ( HttpContext context )
{
string returnstr = "" ;
int code = - 1 ;
string msg = "" ;
try
{
string UIDList = context . Request . Params [ "UIDList" ] ;
if ( bll . DeleteUser ( UIDList ) )
{
msg = "删除成功!" ;
code = 1 ;
}
else
{
msg = "删除失败!" ;
}
}
catch ( Exception e )
{
msg = "删除失败!" ;
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Error , "菜单操作请求" , "删除异常:" + e ) ;
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}" ;
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Delete , "菜单操作请求" , "删除" ) ;
return returnstr ;
}
//修改密码
private string EditPwd ( HttpContext context )
{
string returnstr = "" ;
int code = - 1 ;
string msg = "" ;
try
{
string ID = context . Request . Params [ "ID" ] ;
string userUID = context . Request . Params [ "userUID" ] ;
string userPwd = context . Request . Params [ "userPwd" ] ;
string userType = context . Request . Params [ "userType" ] ;
string userName = context . Request . Params [ "userName" ] ;
FangYar . Model . BaseUserModel model = bll . GetUserByID ( ID ) ;
if ( string . IsNullOrEmpty ( userPwd ) )
{
msg = "密码不能为空!" ;
}
else if ( userUID . Length < 4 )
{
msg = "密码长度最少为4个字符!" ;
}
else if ( model = = null )
{
msg = "用户不存在!" ;
}
else if ( model . USERS_PWD = = FangYar . Common . Md5 . GetMD5String ( userPwd ) )
{
msg = "修改密码不能和旧密码一致!" ;
}
else
{
model . USERS_UID = userUID ;
model . USERS_PWD = FangYar . Common . Md5 . GetMD5String ( userPwd ) ;
model . USERS_NAME = userName ;
model . USERS_TYPE = userType ;
if ( bll . AddUser ( model ) )
{
msg = "密码修改成功!" ;
code = 1 ;
}
else
{
msg = "密码修改失败!" ;
}
}
}
catch ( Exception e )
{
msg = "密码修改失败!" ;
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Error , "菜单操作请求" , "修改密码异常:" + e ) ;
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}" ;
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Update , "菜单操作请求" , "修改密码" ) ;
return returnstr ;
}
//private string GetUserMenu2(HttpContext context)
//{
// string returnstr = "[";
// try
// {
// FangYar.Model.LoginUserModel user = FangYar.WebUI.WebCommon.HttpUtil.GetUser(context);
// if (user != null)
// {
// DataTable dt = getmenu(user, null);
// string id, title, url, fid, type, level, state, action, icon;
// for (int i = 0; i < dt.Rows.Count; i++)
// {
// id = dt.Rows[i]["ID"].ToString();
// title = dt.Rows[i]["MENU_TITLE"].ToString();
// url = dt.Rows[i]["MENU_URL"].ToString();
// fid = dt.Rows[i]["MENU_PARENT"].ToString();
// type = dt.Rows[i]["MENU_TYPE"].ToString();
// level = dt.Rows[i]["MENU_LEVEL"].ToString();
// state = dt.Rows[i]["MENU_FLAG"].ToString();
// action = dt.Rows[i]["MENU_ACTION"].ToString();
// icon = dt.Rows[i]["MENU_ICON"].ToString();
// if (i > 0) { returnstr += ","; }
// returnstr += "{";
// returnstr += "\"title\":\"" + title + "\"";
// //returnstr += ",\"icon\":\"layui-icon " + icon + "\"";
// returnstr += ",\"icon\":\"iconfont " + icon + "\"";
// returnstr += ",\"spread\":\"false\"";
// returnstr += ",\"href\":\"" + url + "\"";
// returnstr += ",\"id\":\"" + id + "\"";
// returnstr += ",\"type\":\"" + type + "\"";
// returnstr += ",\"state\":\"" + state + "\"";
// returnstr += ",\"level\":\"" + level + "\"";
// returnstr += ",\"action\":\"" + action + "\"";
// returnstr += ",\"children\":[";
// DataTable dtc = getmenu(user, id);
// for (int j = 0; j < dtc.Rows.Count; j++)
// {
// id = dtc.Rows[j]["ID"].ToString();
// title = dtc.Rows[j]["MENU_TITLE"].ToString();
// url = dtc.Rows[j]["MENU_URL"].ToString();
// type = dtc.Rows[j]["MENU_TYPE"].ToString();
// level = dtc.Rows[j]["MENU_LEVEL"].ToString();
// state = dtc.Rows[j]["MENU_FLAG"].ToString();
// action = dtc.Rows[j]["MENU_ACTION"].ToString();
// icon = dtc.Rows[j]["MENU_ICON"].ToString();
// if (j > 0) { returnstr += ","; }
// returnstr += "{";
// returnstr += "\"title\":\"" + title + "\"";
// //returnstr += ",\"icon\":\"layui-icon " + "layui-icon-rate-half" + "\"";
// returnstr += ",\"icon\":\"iconfont " + icon + "\"";
// returnstr += ",\"spread\":\"false\"";
// returnstr += ",\"href\":\"" + url + "\"";
// returnstr += ",\"id\":\"" + id + "\"";
// returnstr += ",\"type\":\"" + type + "\"";
// returnstr += ",\"state\":\"" + state + "\"";
// returnstr += ",\"level\":\"" + level + "\"";
// returnstr += ",\"action\":\"" + action + "\"";
// returnstr += ",\"children\":[";
// DataTable dtcd = getmenu(user, id);
// for (int k = 0; k < dtcd.Rows.Count; k++)
// {
// id = dtcd.Rows[k]["ID"].ToString();
// title = dtcd.Rows[k]["MENU_TITLE"].ToString();
// url = dtcd.Rows[k]["MENU_URL"].ToString();
// type = dtcd.Rows[k]["MENU_TYPE"].ToString();
// level = dtcd.Rows[k]["MENU_LEVEL"].ToString();
// state = dtcd.Rows[k]["MENU_FLAG"].ToString();
// action = dtcd.Rows[k]["MENU_ACTION"].ToString();
// icon = dtcd.Rows[k]["MENU_ICON"].ToString();
// if (k > 0) { returnstr += ","; }
// returnstr += "{";
// returnstr += "\"title\":\"" + title + "\"";
// //returnstr += ",\"icon\":\"layui-icon " + "layui-icon-rate-half" + "\"";
// returnstr += ",\"icon\":\"iconfont " + icon + "\"";
// returnstr += ",\"spread\":\"false\"";
// returnstr += ",\"href\":\"" + url + "\"";
// returnstr += ",\"id\":\"" + id + "\"";
// returnstr += ",\"type\":\"" + type + "\"";
// returnstr += ",\"state\":\"" + state + "\"";
// returnstr += ",\"level\":\"" + level + "\"";
// returnstr += ",\"action\":\"" + action + "\"";
// returnstr += "}";
// }
// returnstr += "]";
// returnstr += "}";
// }
// returnstr += "]";
// returnstr += "}";
// }
// }
// }
// catch (Exception e)
// {
// }
// returnstr += "]";
// return returnstr;
//}
private string GetUserMenu ( HttpContext context ) //平台菜单、主菜单、子菜单需要设置好等级
{
string returnstr = "[" ;
try
{
FangYar . Model . LoginUserModel user = FangYar . WebUI . WebCommon . HttpUtil . GetUser ( context ) ;
if ( user ! = null )
{
DataTable dt = getmenu ( user , null ) ;
var listAll = DataTableToList ( dt ) ;
string id , title , url , fid , type , level , state , action , icon , idone , idtwo , flowtype ;
var list1 = listAll . Where ( p = > p . MENU_PARENT = = "630FEFF3081342ECB99CEC3449A01126" ) . ToList ( ) ;
for ( int i = 0 ; i < list1 . Count ; i + + )
{
var mo1 = list1 [ i ] ;
if ( mo1 . MENU_PARENT = = "630FEFF3081342ECB99CEC3449A01126" )
{
id = mo1 . ID ;
title = mo1 . MENU_TITLE ;
url = mo1 . MENU_URL ;
fid = mo1 . MENU_PARENT ;
type = mo1 . MENU_TYPE ;
level = mo1 . MENU_LEVEL ;
state = mo1 . MENU_FLAG ;
action = mo1 . MENU_ACTION ;
icon = mo1 . MENU_ICON ;
flowtype = mo1 . FLOWTYPE + "" ;
if ( i > 0 ) { returnstr + = "," ; }
returnstr + = "{" ;
returnstr + = "\"title\":\"" + title + "\"" ;
//returnstr += ",\"icon\":\"layui-icon " + icon + "\"";
returnstr + = ",\"icon\":\"iconfont " + icon + "\"" ;
returnstr + = ",\"spread\":\"false\"" ;
returnstr + = ",\"href\":\"" + url + "\"" ;
returnstr + = ",\"id\":\"" + id + "\"" ;
returnstr + = ",\"type\":\"" + type + "\"" ;
returnstr + = ",\"state\":\"" + state + "\"" ;
returnstr + = ",\"level\":\"" + level + "\"" ;
returnstr + = ",\"action\":\"" + action + "\"" ;
returnstr + = ",\"flowtype\":\"" + flowtype + "\"" ;
returnstr + = ",\"children\":[" ;
var list2 = listAll . Where ( p = > p . MENU_PARENT = = id ) . ToList ( ) ;
for ( int j = 0 ; j < list2 . Count ; j + + )
{
var mo2 = list2 [ j ] ;
id = mo2 . ID ;
title = mo2 . MENU_TITLE ;
url = mo2 . MENU_URL ;
var list3 = listAll . Where ( p = > p . MENU_PARENT = = id ) . ToList ( ) ;
// 判断如果没有子集菜单则不加载父级菜单
if ( list3 . Count < 1 & & string . IsNullOrWhiteSpace ( url ) )
{
continue ;
}
type = mo2 . MENU_TYPE ;
level = mo2 . MENU_LEVEL ;
state = mo2 . MENU_FLAG ;
action = mo2 . MENU_ACTION ;
icon = mo2 . MENU_ICON ;
flowtype = mo2 . FLOWTYPE + "" ;
if ( j > 0 ) { returnstr + = "," ; }
returnstr + = "{" ;
returnstr + = "\"title\":\"" + title + "\"" ;
//returnstr += ",\"icon\":\"layui-icon " + "layui-icon-rate-half" + "\"";
returnstr + = ",\"icon\":\"iconfont " + icon + "\"" ;
returnstr + = ",\"spread\":\"false\"" ;
returnstr + = ",\"href\":\"" + url + "\"" ;
returnstr + = ",\"id\":\"" + id + "\"" ;
returnstr + = ",\"type\":\"" + type + "\"" ;
returnstr + = ",\"state\":\"" + state + "\"" ;
returnstr + = ",\"level\":\"" + level + "\"" ;
returnstr + = ",\"action\":\"" + action + "\"" ;
returnstr + = ",\"flowtype\":\"" + flowtype + "\"" ;
returnstr + = ",\"children\":[" ;
for ( int k = 0 ; k < list3 . Count ; k + + )
{
var mo3 = list3 [ k ] ;
id = mo3 . ID ;
title = mo3 . MENU_TITLE ;
url = mo3 . MENU_URL ;
type = mo3 . MENU_TYPE ;
level = mo3 . MENU_LEVEL ;
state = mo3 . MENU_FLAG ;
action = mo3 . MENU_ACTION ;
icon = mo3 . MENU_ICON ;
flowtype = mo3 . FLOWTYPE + "" ;
if ( k > 0 ) { returnstr + = "," ; }
returnstr + = "{" ;
returnstr + = "\"title\":\"" + title + "\"" ;
//returnstr += ",\"icon\":\"layui-icon " + "layui-icon-rate-half" + "\"";
returnstr + = ",\"icon\":\"iconfont " + icon + "\"" ;
returnstr + = ",\"spread\":\"false\"" ;
returnstr + = ",\"href\":\"" + url + "\"" ;
returnstr + = ",\"id\":\"" + id + "\"" ;
returnstr + = ",\"type\":\"" + type + "\"" ;
returnstr + = ",\"state\":\"" + state + "\"" ;
returnstr + = ",\"level\":\"" + level + "\"" ;
returnstr + = ",\"action\":\"" + action + "\"" ;
returnstr + = ",\"flowtype\":\"" + flowtype + "\"" ;
returnstr + = ",\"children\":[" ;
returnstr + = "]" ;
returnstr + = "}" ;
}
returnstr + = "]" ;
returnstr + = "}" ;
}
returnstr + = "]" ;
returnstr + = "}" ;
}
}
}
}
catch ( Exception e )
{
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Error , "菜单操作请求" , "平台菜单、主菜单、子菜单需要设置好等级异常:" + e ) ;
}
returnstr + = "]" ;
// 记录操作日志
BLL . SysOperationLogHelp . AddSysOperationLog ( context , Common . EnumOperationLogType . Query , "菜单操作请求" , "平台菜单、主菜单、子菜单需要设置好等级" ) ;
return returnstr ;
}
private DataTable getmenu ( FangYar . Model . LoginUserModel user , string fid )
{
DataTable dt = new DataTable ( ) ;
try
{
if ( user ! = null )
{
string baseRoleId = ",''" ;
var org = bll_org . GetModel ( user . OrgID ) ; //所在单位
if ( org ! = null )
{
//0:支队;1:特勤站;2:大队;3:总队
switch ( org . EXTENDCODE1 )
{
case "0" :
baseRoleId = ",'d7f83a97208f4e049fe2e980095a7a65'" ;
break ;
case "1" :
baseRoleId = ",'03c85152f80a49f0ad3cfea202af00b4'" ;
break ;
case "2" :
baseRoleId = ",'5805857f2fae4daf9482996dbed726b7'" ;
break ;
case "3" :
baseRoleId = ",'ca8b271020d047db816cf6b18a6852ad'" ;
break ;
}
}
string sqlwhere = " find_in_set(id,cids) and id in(select menu_id from TBL_SYS_ROLEMENU t where role_id in ('" + user . roles . Replace ( "," , "','" ) + "'" + baseRoleId + ")) " +
" and id not in (SELECT id from tbl_sys_menu WHERE id in(select menu_id from tbl_sys_rolemenu_not t where role_id in ('" + user . roles . Replace ( "," , "','" ) + "')) ) " + //and MENU_LEVEL = 3
" order by MENU_TYPE ,menu_level,menu_order " ;
if ( user . OrgID = = "1" | | user . UserCode = = "iamasuperman" )
{
sqlwhere = " 1=1 order by MENU_TYPE ,menu_level,menu_order " ;
}
dt = new FangYar . BLL . CommomBLL ( ) . GetTableList ( "*" , " tbl_sys_menu ,(select get_Menu_child_list('630FEFF3081342ECB99CEC3449A01126') cids) s " , sqlwhere ) ;
}
else
{
}
}
catch ( Exception e )
{
}
return dt ;
}
/// <summary>
/// DataRow转model实体类对象
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private Model . TBL . TBL_SYS_MENU_Model DataRowToModel ( DataRow dr )
{
Model . TBL . TBL_SYS_MENU_Model model = new Model . TBL . TBL_SYS_MENU_Model ( ) ;
model . ID = dr [ "ID" ] + "" ;
model . APP_ID = dr [ "APP_ID" ] + "" ;
model . MENU_TITLE = dr [ "MENU_TITLE" ] + "" ;
model . MENU_URL = dr [ "MENU_URL" ] + "" ;
model . MENU_PARENT = dr [ "MENU_PARENT" ] + "" ;
model . MENU_TYPE = dr [ "MENU_TYPE" ] + "" ;
model . MENU_FLAG = dr [ "MENU_FLAG" ] + "" ;
model . MENU_LEVEL = dr [ "MENU_LEVEL" ] + "" ;
model . MENU_ORDER = Convert . ToInt32 ( "0" + dr [ "MENU_ORDER" ] ) ;
model . MENU_MAP = dr [ "MENU_MAP" ] + "" ;
model . MENU_ACTION = dr [ "MENU_ACTION" ] + "" ;
model . MENU_ICON = dr [ "MENU_ICON" ] + "" ;
model . Address = dr [ "ADDRESS" ] + "" ;
model . Type = dr [ "TYPE" ] + "" ;
if ( dr . Table . Columns . Contains ( "OPENMODE" ) )
{
if ( dr [ "OPENMODE" ] ! = null & & dr [ "OPENMODE" ] . ToString ( ) ! = "" )
{
model . OpenMode = int . Parse ( dr [ "OPENMODE" ] . ToString ( ) ) ;
}
}
//if (dr.Table.Columns.Contains("WIDTH"))
//{
// if (dr["WIDTH"] != null && dr["WIDTH"].ToString() != "")
// {
// model.Width = int.Parse(dr["WIDTH"].ToString());
// }
//}
//if (dr.Table.Columns.Contains("HEIGHT"))
//{
// if (dr["HEIGHT"] != null && dr["HEIGHT"].ToString() != "")
// {
// model.Height = int.Parse(dr["HEIGHT"].ToString());
// }
//}
model . Params = dr [ "PARAMS" ] + "" ;
model . Manager = dr [ "MANAGER" ] + "" ;
model . Note = dr [ "NOTE" ] + "" ;
model . Code = dr [ "CODE" ] + "" ;
model . UseMember = dr [ "USEMEMBER" ] + "" ;
if ( dr . Table . Columns . Contains ( "FLOWTYPE" ) )
{
if ( dr [ "FLOWTYPE" ] ! = null & & dr [ "FLOWTYPE" ] . ToString ( ) ! = "" )
{
model . FLOWTYPE = int . Parse ( dr [ "FLOWTYPE" ] . ToString ( ) ) ;
}
}
model . AUTHORITYTYPE = dr [ "AUTHORITYTYPE" ] + "" ;
model . ORG_ID = dr [ "ORG_ID" ] + "" ;
return model ;
}
/// <summary>
/// 把DataTable行转成实体类List集合
/// </summary>
private List < FangYar . Model . TBL . TBL_SYS_MENU_Model > DataTableToList ( DataTable dt )
{
List < FangYar . Model . TBL . TBL_SYS_MENU_Model > modellist = new List < Model . TBL . TBL_SYS_MENU_Model > ( ) ;
if ( dt . Rows . Count > 0 )
{
foreach ( DataRow myRow in dt . Rows )
{
modellist . Add ( DataRowToModel ( myRow ) ) ;
}
}
return modellist ;
}
private string typegetmenu ( HttpContext context )
{
string returnstr = "" ;
FangYar . BLL . TBL . SysMenuBLL mbll = new FangYar . BLL . TBL . SysMenuBLL ( ) ;
try
{
string type = context . Request . Params [ "type" ] . ToString ( ) ;
//if (type.IndexOf("-")>-1)
//{
// type = type.Replace("-","");
//}
returnstr = "{\"code\":1,\"msg\":\"\"," ;
List < FangYar . Model . TBL . TBL_SYS_MENU_Model > list = mbll . typegetmenu ( type ) ;
returnstr + = "\"count\":" + list . Count + ",\"data\":" ;
if ( list . Count = = 0 )
{
returnstr + = "[]" ;
}
else
{
returnstr + = FangYar . Common . JsonHelper . ToJson ( list ) ;
}
returnstr + = "}" ;
}
catch ( Exception e )
{
returnstr = "{\"code\":-1,\"msg\":\"" + e . Message + "\",\"count\":0,\"data\":[]" ;
}
return returnstr ;
}
public bool IsReusable
{
get
{
return false ;
}
}
}
}