/** 版本信息模板在安装目录下,可自行修改。
* 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 Competition.Mysql.Model;
using System.Web;
using System.Linq;
namespace Competition.Mysql.BLL
{
///
/// admin_user
///
public partial class admin_user
{
private readonly Competition.Mysql.DAL.admin_user dal = new Competition.Mysql.DAL.admin_user();
public admin_user()
{ }
#region BasicMethod
///
/// 是否存在该记录
///
public bool Exists(string user_id)
{
return dal.Exists(user_id);
}
///
/// 增加一条数据
///
public bool Add(Competition.Mysql.Model.admin_user model)
{
return dal.Add(model);
}
///
/// 更新一条数据
///
public bool Update(Competition.Mysql.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 Competition.Mysql.Model.admin_user GetModel(string user_id)
{
return dal.GetModel(user_id);
}
///
/// 得到一个对象实体,从缓存中
///
public Competition.Mysql.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 (Competition.Mysql.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)
{
Competition.Mysql.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 List GetUsrUsersByFault(string strWhere)
{
DataSet ds = dal.GetList(strWhere);
return DataTableToList(ds.Tables[0]);
}
///
/// 是否存在该记录-按照工号查询
///
public bool ExistsByJobNumber(string job_number)
{
return dal.ExistsByJobNumber(job_number);
}
///
/// 是否存在该记录-按照身份证号查询
///
public bool ExistsByIdcard(string id_card)
{
return dal.ExistsByIdcard(id_card);
}
///
/// 得到一个对象实体--根据工号
///
public Competition.Mysql.Model.admin_user GetModelByJobNumber(string job_number)
{
return dal.GetModelByJobNumber(job_number);
}
public Competition.Mysql.Model.admin_user GetModelByIdcard(string id_card)
{
return dal.GetModelByIdcard(id_card);
}
///
/// 批量更新学员故障点
///
///
///
///
public bool update_fault(string fault_id, string user_idlist)
{
return dal.update_fault(fault_id, user_idlist);
}
///
/// 获取带有故障编码的学员信息
///
///
///
public DataSet GetUsrUsersWithFault(string strWhere)
{
return dal.GetUsrUsersWithFault(strWhere);
}
///
/// 枚举字段值
///
///
public List GetFieldValues(string filedName)
{
List list = new List();
var dt = dal.GetFieldValues(filedName).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;
}
///
/// 得到一个对象实体
///
public Competition.Mysql.Model.admin_user GetUserModel(string strWhere)
{
return dal.GetUserModel(strWhere);
}
/*
public bool IsAdministrator(Competition.Mysql.Model.admin_user user )
{
if (null != user && user.id_card == "admin")
return true;
return false;
}
*/
///
/// 是否老师
///
///
///
public bool IsTeacher(Competition.Mysql.Model.admin_user user)
{
if (null != user)
{
if (user.role_id == getTeacherRoleId())
return true;
}
return false;
}
///
/// 是否学员
///
public bool IsStudent(Competition.Mysql.Model.admin_user user)
{
if (null != user)
{
if (user.role_id == getStudentRoleId())
return true;
}
return false;
}
/*
public bool IsAdministrator(Competition.Mysql.Model.admin_user user)
{
if (null != user && (user.role_id == getAdminRoleId() || user.role_id == getTeacherRoleId()))
return true;
return false;
}
*/
public bool IsAdministrator(Competition.Mysql.Model.admin_user user)
{
if (null != user && user.role_id == getAdminRoleId())
return true;
return false;
}
public string getAdminRoleId()
{
return "0";
}
public string getTeacherRoleId()
{
return "1";
}
public string getStudentRoleId()
{
return "2";
}
///
/// 使用事务批量新增和修改用户
///
///
public int BatchAddUpdateUser(List list_update, List list_add)
{
return dal.BatchAddUpdateUser(list_update, list_add);
}
///
/// 使用事务批量修改用户密码
///
///
public int BatchUpdateUser(List list_update, string pwd)
{
return dal.BatchUpdateUser(list_update, pwd);
}
///
/// 更新一条数据
///
public bool UpdateToken(string user_id, string token)
{
return dal.UpdateToken(user_id, token);
}
///
/// 创建6位随机密码 3位英文+3位数字
///
///
public string CreateRandomPassword()
{
var array1 = new string[] {
//"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"
};
var array2 = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
string temp = "";
for (int i = 0; i < 3; i++)
{
temp = temp + array1.OrderBy(s => Guid.NewGuid()).First();
}
for (int i = 0; i < 3; i++)
{
temp = temp + array2.OrderBy(s => Guid.NewGuid()).First();
}
return temp;
}
///
/// 获得数据列表
///
public List GetLogin(string login_name, string password)
{
DataSet ds = dal.GetLogin(login_name, password);
return DataTableToList(ds.Tables[0]);
}
///
/// 得到一个对象实体
///
public Competition.Mysql.Model.admin_user GetCUserModel(string login_name)
{
return dal.GetCUserModel(login_name);
}
///
/// 获取记录总数
///
public int GetRecordLoginCount(string login_name)
{
return dal.GetRecordLoginCount(login_name);
}
public string GetString(string str)
{
return dal.GetString(str);
}
#endregion ExtensionMethod
}
}