/** 版本信息模板在安装目录下,可自行修改。 * admin_user.cs * * 功 能: N/A * 类 名: admin_user * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── * V0.01 2021/3/30 8:46:18 N/A 初版 * * Copyright (c) 2012 Maticsoft Corporation. All rights reserved. *┌──────────────────────────────────┐ *│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │ *│ 版权所有:动软卓越(北京)科技有限公司              │ *└──────────────────────────────────┘ */ using System; using System.Data; using System.Collections.Generic; using Maticsoft.Common; using DataService.Model; using System.Web; using System.IO; namespace DataService.BLL { /// /// admin_user /// public partial class admin_user { private readonly DataService.DAL.admin_user dal = new DataService.DAL.admin_user(); public admin_user() { } #region BasicMethod /// /// 是否存在该记录 /// public bool Exists(string user_id) { return dal.Exists(user_id); } /// /// 增加一条数据 /// public bool Add(DataService.Model.admin_user model) { return dal.Add(model); } /// /// 更新一条数据 /// public bool Update(DataService.Model.admin_user model) { return dal.Update(model); } /// /// 删除一条数据 /// public bool Delete(string user_id) { return dal.Delete(user_id); } /// /// 删除一条数据 /// public bool DeleteList(string user_idlist) { return dal.DeleteList(user_idlist); } /// /// 得到一个对象实体 /// public DataService.Model.admin_user GetModel(string user_id) { return dal.GetModel(user_id); } /// /// 得到一个对象实体,从缓存中 /// public DataService.Model.admin_user GetModelByCache(string user_id) { string CacheKey = "admin_userModel-" + user_id; object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey); if (objModel == null) { try { objModel = dal.GetModel(user_id); if (objModel != null) { int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache"); Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero); } } catch { } } return (DataService.Model.admin_user)objModel; } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { return dal.GetList(strWhere); } /// /// 获得数据列表 /// public List GetModelList(string strWhere) { DataSet ds = dal.GetList(strWhere); return DataTableToList(ds.Tables[0]); } /// /// 获得数据列表 /// public List DataTableToList(DataTable dt) { List modelList = new List(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { DataService.Model.admin_user model; for (int n = 0; n < rowsCount; n++) { model = dal.DataRowToModel(dt.Rows[n]); if (model != null) { modelList.Add(model); } } } return modelList; } /// /// 获得数据列表 /// public DataSet GetAllList() { return GetList(""); } /// /// 分页获取数据列表 /// public int GetRecordCount(string strWhere) { return dal.GetRecordCount(strWhere); } /// /// 分页获取数据列表 /// public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex) { return dal.GetListByPage(strWhere, orderby, startIndex, endIndex); } /// /// 分页获取数据列表 /// //public DataSet GetList(int PageSize,int PageIndex,string strWhere) //{ //return dal.GetList(PageSize,PageIndex,strWhere); //} #endregion BasicMethod #region ExtensionMethod /// /// 获取教员及管理员 /// /// /// public DataSet GetSysUsers(string strWhere) { return dal.GetSysUsers(strWhere); } /// /// 获取学员 /// /// /// public DataSet GetUsrUsers(string strWhere) { return dal.GetUsrUsers(strWhere); } ///获取用户姓名 public static string get_real_name(string user_id) { if (string.IsNullOrEmpty(user_id)) return string.Empty; string CacheKey = "admin_userModel-Name-" + user_id; object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey); if (objModel == null) { try { objModel = DataService.DAL.admin_user.get_real_name(user_id); if (objModel != null) { int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache"); Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero); } } catch { } } return objModel.ToString(); } /// /// 加载登录信息 /// /// public static DataService.Model.admin_user load_login() { DataService.Model.admin_user admin_cookie_user = new DataService.Model.admin_user(); HttpContext context = HttpContext.Current; if (HttpContext.Current.Request.Cookies["admin_user_token"] != null) { if (HttpContext.Current.Request.Cookies["admin_user_token"].Values.Count > 1) { string tmpUid = HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies["admin_user_token"].Values.Get(0)); ; string user_desc = HttpContext.Current.Request.Cookies["admin_user_token"].Values.Get(1).Replace("'", ""); user_desc = HttpUtility.UrlDecode(user_desc); string[] temp = user_desc.Split('|'); admin_cookie_user.user_id = temp[0]; admin_cookie_user.login_name = temp[1]; admin_cookie_user.real_name = temp[2]; //admin_cookie_user.grade = temp[3]; //admin_cookie_user.major = temp[4]; } } else { HttpContext.Current.Response.Redirect("~/Login.aspx"); } return admin_cookie_user; } /// /// 是否存在该记录-按照工号查询 /// public bool ExistsByJobNumber(string job_number) { return dal.ExistsByJobNumber(job_number); } /// /// 得到一个对象实体--根据工号 /// public DataService.Model.admin_user GetModelByJobNumber(string job_number) { return dal.GetModelByJobNumber(job_number); } /// /// 得到一个对象实体 /// public DataService.Model.admin_user GetUserModel(string strWhere) { return dal.GetUserModel(strWhere); } /// /// 得到一个对象实体,从缓存中 /// public List GetModelListByCache(string strWhere) { string CacheKey = "admin_userModelList"; object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey); if (objModel == null) { try { objModel = GetModelList(strWhere); if (objModel != null) { Maticsoft.Common.DataCache.SetCache(CacheKey, objModel); } } catch { } } return (List)objModel; } /// /// 获取运维人员的管理员 /// /// /// public List GetDevUsers(string strWhere) { DataSet ds = dal.GetDevUsers(strWhere); return DataTableToList(ds.Tables[0]); } /// /// 获得数据列表 /// public DataSet GetUserList(string strWhere) { return dal.GetUserList(strWhere); } /// /// 使用事务批量操作删除 /// /// 要删除的用户id /// public int OperationData(string user_id) { return dal.OperationData(user_id); } /// /// 枚举字段值 /// /// public List GetUnitValues() { List list = new List(); var dt = dal.GetUnitValues().Tables[0]; int rowsCount = dt.Rows.Count; for (int n = 0; n < rowsCount; n++) { var row = dt.Rows[n]; var value = row[0].ToString(); list.Add(value); } return list; } #endregion ExtensionMethod } }