private JavaScriptObject UserInfoToJSON(SysUser user, ref DataTable dtExcel) { if (user == null) { return(null); } JavaScriptObject obj2 = new JavaScriptObject(); /* * foreach (KeyValuePair<string, string> pair in user.GetUserInfo()) * { * obj2.Add(pair.Key, pair.Value); * } * */ obj2.Add("ID", user.ID); obj2.Add("用户名", user.UserName); obj2.Add("角色ID", user.RoleId); obj2.Add("管理ID", user.DistrictId); string managelName = DistrictModule.GetDistrictName(user.DistrictId); obj2.Add("管理名称", managelName); string roleName = RoleModule.GetRoleName(user.RoleId); obj2.Add("角色名称", roleName); if (dtExcel != null) { dtExcel.Rows.Add(new object[0]); int num = dtExcel.Rows.Count - 1; dtExcel.Rows[num]["用户名"] = user.UserName; dtExcel.Rows[num]["角色名称"] = roleName; dtExcel.Rows[num]["单位名称"] = managelName; } return(obj2); }
public string GetUserRoles(string loginIdentifer) { JavaScriptObject obj2 = new JavaScriptObject(); obj2.Add("Result", false); obj2.Add("Message", ""); JavaScriptArray array = new JavaScriptArray(); obj2.Add("UserRoles", array); LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer); if (loginUser == null) { obj2["Message"] = "未登录"; return(JavaScriptConvert.SerializeObject(obj2)); } if (loginUser.LoginTimeout) { obj2["Message"] = "登录超时"; return(JavaScriptConvert.SerializeObject(obj2)); } loginUser.LastOperateTime = DateTime.Now; CommonUtil.WaitMainLibInit(); try { foreach (long str in RoleModule.GetRoleID()) { JavaScriptObject item = new JavaScriptObject(); item.Add("ID", str); item.Add("Name", RoleModule.GetRoleName(str)); item.Add("UserCount", SysUserModule.GetUserListByRole(str).Count); array.Add(item); } } catch (Exception exception) { obj2["Message"] = exception.Message; return(JavaScriptConvert.SerializeObject(obj2)); } obj2["Result"] = true; return(JavaScriptConvert.SerializeObject(obj2)); }