CNCEC_SUBQHSE_WUHUAN/SGGL/BLL/SysManage/UserService.cs

1606 lines
65 KiB
C#
Raw Normal View History

2021-04-30 10:28:37 +08:00
namespace BLL
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web.UI.WebControls;
public static class UserService
{
public static Model.SGGLDB db = Funs.DB;
/// <summary>
/// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
/// </summary>
/// <param name="userId"><3E>û<EFBFBD>Id</param>
/// <returns><3E>û<EFBFBD><C3BB><EFBFBD>Ϣ</returns>
public static Model.Sys_User GetUserByUserId(string userId)
{
return Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == userId);
}
2023-06-07 18:55:33 +08:00
/// <summary>
/// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
/// </summary>
/// <param name="userId"><3E>û<EFBFBD>Id</param>
/// <returns><3E>û<EFBFBD><C3BB><EFBFBD>Ϣ</returns>
public static Model.Sys_User GetUserByIdentityCard(string identityCard)
{
return Funs.DB.Sys_User.FirstOrDefault(e => e.IdentityCard == identityCard);
}
2021-04-30 10:28:37 +08:00
/// <summary>
///<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public static Model.Sys_User GetUserByUserName(string userName)
{
return Funs.DB.Sys_User.FirstOrDefault(e => e.UserName == userName);
}
/// <summary>
/// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ŀ<EFBFBD>Ͻ<EFBFBD>ɫList
/// </summary>
/// <param name="userId"><3E>û<EFBFBD>Id</param>
/// <returns><3E>û<EFBFBD><C3BB><EFBFBD>Ϣ</returns>
public static List<string> GetRoleListByProjectIdUserId(string projectId, string userId)
{
List<string> roleList = new List<string>();
var getUser = GetUserByUserId(userId);
if (getUser != null)
{
string rolesStr = string.Empty;
if (!string.IsNullOrEmpty(getUser.RoleId))
{
rolesStr = getUser.RoleId;
}
var pUser = ProjectUserService.GetProjectUserByUserIdProjectId(projectId, userId); ////<2F>û<EFBFBD>
if (pUser != null && !string.IsNullOrEmpty(pUser.RoleId))
{
if (string.IsNullOrEmpty(rolesStr))
{
rolesStr = pUser.RoleId;
}
else
{
if (!rolesStr.Contains(pUser.RoleId))
{
rolesStr += "," + pUser.RoleId;
}
}
}
roleList = Funs.GetStrListByStr(rolesStr, ',');
}
return roleList;
}
/// <summary>
/// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
/// </summary>
/// <param name="userId"><3E>û<EFBFBD>Id</param>
/// <returns><3E>û<EFBFBD><C3BB><EFBFBD>Ϣ</returns>
public static void UpdateLastUserInfo(string userId, string LastMenuType, bool LastIsOffice, string LastProjectId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var uU = db.Sys_User.FirstOrDefault(e => e.UserId == userId);
if (uU != null)
{
uU.LastMenuType = LastMenuType;
uU.LastIsOffice = LastIsOffice;
uU.LastMenuType = LastMenuType;
uU.LastProjectId = LastProjectId;
db.SubmitChanges();
}
}
}
/// <summary>
/// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB>˺<EFBFBD><CBBA>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="userId"><3E>û<EFBFBD>id</param>
/// <param name="account"><3E>˺<EFBFBD></param>
/// <returns><3E>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD></returns>
public static bool IsExistUserAccount(string userId, string account)
{
bool isExist = false;
var role = Funs.DB.Sys_User.FirstOrDefault(x => x.Account == account && (x.UserId != userId || (userId == null && x.UserId != null)));
if (role != null)
{
isExist = true;
}
return isExist;
}
/// <summary>
/// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB>˺<EFBFBD><CBBA>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="userId"><3E>û<EFBFBD>id</param>
/// <param name="identityCard"><3E><><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD></param>
/// <returns><3E>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD></returns>
public static bool IsExistUserIdentityCard(string userId, string identityCard)
{
bool isExist = false;
var role = Funs.DB.Sys_User.FirstOrDefault(x => x.IdentityCard == identityCard && (x.UserId != userId || (userId == null && x.UserId != null)));
if (role != null)
{
isExist = true;
}
return isExist;
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public static string GetPasswordByUserId(string userId)
{
Model.Sys_User m = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == userId);
return m.Password;
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public static string GetUserNameByUserId(string userId)
{
string userName = string.Empty;
Model.Sys_User user = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == userId);
if (user != null)
{
userName = user.UserName;
}
return userName;
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public static string GetUserNameAndTelByUserId(string userId)
{
string userName = string.Empty;
Model.Sys_User user = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == userId);
if (user != null)
{
userName = user.UserName;
if (!string.IsNullOrEmpty(user.Telephone))
{
userName += "<22><>" + user.Telephone;
}
}
return userName;
}
/// <summary>
/// <20>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="userId"></param>
/// <param name="password"></param>
public static void UpdatePassword(string userId, string password)
{
2022-07-26 13:51:21 +08:00
Model.Sys_User m = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == userId);
2021-04-30 10:28:37 +08:00
if (m != null)
{
2022-07-26 13:51:21 +08:00
m.RawPassword = password;
2021-04-30 10:28:37 +08:00
m.Password = Funs.EncryptionPassword(password);
2022-07-26 13:51:21 +08:00
Funs.DB.SubmitChanges();
2021-04-30 10:28:37 +08:00
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>Ϣ
/// </summary>
/// <param name="user"><3E><>Աʵ<D4B1><CAB5></param>
public static void AddUser(Model.Sys_User user)
{
Model.SGGLDB db = Funs.DB;
string newKeyID = SQLHelper.GetNewID(typeof(Model.Sys_User));
Model.Sys_User newUser = new Model.Sys_User
{
UserId = newKeyID,
Account = user.Account,
UserName = user.UserName,
UserCode = user.UserCode,
2022-07-26 13:51:21 +08:00
RawPassword = user.RawPassword,
2021-04-30 10:28:37 +08:00
Password = user.Password,
UnitId = user.UnitId,
RoleId = user.RoleId,
IsPost = user.IsPost,
IdentityCard = user.IdentityCard,
PageSize = 10,
IsOffice = user.IsOffice,
Telephone = user.Telephone,
DataSources = user.DataSources,
SignatureUrl = user.SignatureUrl,
DepartId = user.DepartId,
Politicalstatus = user.Politicalstatus,
Hometown = user.Hometown,
Education = user.Education,
Graduate = user.Graduate,
Major = user.Major,
CertificateId = user.CertificateId,
IntoDate = user.IntoDate,
ValidityDate = user.ValidityDate,
Sex = user.Sex,
BirthDay = user.BirthDay,
PositionId = user.PositionId,
PostTitleId = user.PostTitleId,
WorkPostId = user.WorkPostId,
MainCNProfessionalId = user.MainCNProfessionalId,
ViceCNProfessionalId = user.ViceCNProfessionalId,
WorkNo = user.WorkNo,
2022-12-26 14:34:56 +08:00
HomePageType = user.HomePageType,
2021-04-30 10:28:37 +08:00
};
db.Sys_User.InsertOnSubmit(newUser);
db.SubmitChanges();
}
#region <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>Ϣά<EFBFBD><EFBFBD> --<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// <summary>
/// <20>޸<EFBFBD><DEB8>û<EFBFBD><C3BB><EFBFBD>Ϣ
/// </summary>
/// <param name="user"><3E><>Աʵ<D4B1><CAB5></param>
public static void UpdateSysUser(Model.Sys_User user)
{
Model.SGGLDB db = Funs.DB;
Model.Sys_User newUser = db.Sys_User.FirstOrDefault(e => e.UserId == user.UserId);
if (newUser != null)
{
newUser.Account = user.Account;
newUser.UserName = user.UserName;
newUser.UserCode = user.UserCode;
if (!string.IsNullOrEmpty(user.Password))
{
newUser.Password = user.Password;
}
newUser.IdentityCard = user.IdentityCard;
newUser.UnitId = user.UnitId;
newUser.RoleId = user.RoleId;
newUser.IsPost = user.IsPost;
newUser.IsOffice = user.IsOffice;
newUser.Telephone = user.Telephone;
newUser.SignatureUrl = user.SignatureUrl;
newUser.DepartId = user.DepartId;
newUser.MainCNProfessionalId = user.MainCNProfessionalId;
newUser.ViceCNProfessionalId = user.ViceCNProfessionalId;
db.SubmitChanges();
}
}
/// <summary>
/// <20>޸<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>Ϣ
/// </summary>
/// <param name="user"><3E><>Աʵ<D4B1><CAB5></param>
public static void UpdateUser(Model.Sys_User user)
{
Model.Sys_User newUser = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == user.UserId);
if (newUser != null)
{
newUser.Account = user.Account;
newUser.UserName = user.UserName;
newUser.UserCode = user.UserCode;
if (!string.IsNullOrEmpty(user.Password))
{
newUser.Password = user.Password;
}
newUser.IdentityCard = user.IdentityCard;
newUser.UnitId = user.UnitId;
newUser.RoleId = user.RoleId;
newUser.IsPost = user.IsPost;
newUser.IsOffice = user.IsOffice;
newUser.Telephone = user.Telephone;
newUser.SignatureUrl = user.SignatureUrl;
newUser.DepartId = user.DepartId;
newUser.Politicalstatus = user.Politicalstatus;
newUser.Hometown = user.Hometown;
newUser.Education = user.Education;
newUser.Graduate = user.Graduate;
newUser.Major = user.Major;
newUser.CertificateId = user.CertificateId;
newUser.IntoDate = user.IntoDate;
newUser.ValidityDate = user.ValidityDate;
newUser.Sex = user.Sex;
newUser.BirthDay = user.BirthDay;
newUser.PositionId = user.PositionId;
newUser.PostTitleId = user.PostTitleId;
newUser.WorkPostId = user.WorkPostId;
newUser.ProjectId = user.ProjectId;
newUser.ProjectRoleId = user.ProjectRoleId;
newUser.ProjectWorkPostId = user.ProjectWorkPostId;
newUser.MainCNProfessionalId = user.MainCNProfessionalId;
newUser.ViceCNProfessionalId = user.ViceCNProfessionalId;
newUser.WorkNo = user.WorkNo;
2022-12-26 14:34:56 +08:00
newUser.HomePageType = user.HomePageType;
2021-04-30 10:28:37 +08:00
Funs.DB.SubmitChanges();
}
}
#endregion
2021-09-17 16:04:52 +08:00
/// <summary>
/// <20>޸<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>Ϣ
/// </summary>
/// <param name="user"><3E><>Աʵ<D4B1><CAB5></param>
public static void UpdateUserInfo(Model.Sys_User user)
{
Model.Sys_User newUser = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == user.UserId);
if (newUser != null)
{
newUser.Account = user.Account;
newUser.UserName = user.UserName;
newUser.UserCode = user.UserCode;
newUser.IdentityCard = user.IdentityCard;
newUser.Email = user.Email;
newUser.Telephone = user.Telephone;
Funs.DB.SubmitChanges();
}
}
2021-04-30 10:28:37 +08:00
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԱIdɾ<64><C9BE>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>Ϣ
/// </summary>
/// <param name="userId"></param>
public static void DeleteUser(string userId)
{
Model.SGGLDB db = Funs.DB;
Model.Sys_User user = db.Sys_User.FirstOrDefault(e => e.UserId == userId);
if (user != null)
{
var logs = from x in db.Sys_Log where x.UserId == userId select x;
if (logs.Count() > 0)
{
db.Sys_Log.DeleteAllOnSubmit(logs);
}
db.Sys_User.DeleteOnSubmit(user);
db.SubmitChanges();
}
}
/// <summary>
/// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetUserList()
{
var list = (from x in Funs.DB.Sys_User orderby x.UserName select x).ToList();
return list;
}
/// <summary>
/// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1> <20><>Ŀ <20><>ɫ <20>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <returns></returns>
public static List<Model.SpSysUserItem> GetProjectRoleUserListByProjectId(string projectId, string unitId)
{
Model.SGGLDB db = Funs.DB;
IQueryable<Model.SpSysUserItem> users = null;
if (!string.IsNullOrEmpty(projectId))
{
List<Model.SpSysUserItem> returUsers = new List<Model.SpSysUserItem>();
List<Model.Project_ProjectUser> getPUser = new List<Model.Project_ProjectUser>();
if (!string.IsNullOrEmpty(unitId))
{
getPUser = (from x in db.Project_ProjectUser
join u in db.Project_ProjectUnit on new { x.ProjectId, x.UnitId } equals new { u.ProjectId, u.UnitId }
where x.ProjectId == projectId && (u.UnitId == unitId || u.UnitType == BLL.Const.ProjectUnitType_1 || u.UnitType == BLL.Const.ProjectUnitType_3 || u.UnitType == BLL.Const.ProjectUnitType_4)
2021-09-07 11:10:20 +08:00
&& x.IsPost == true
2021-04-30 10:28:37 +08:00
select x).ToList();
}
else
{
getPUser = (from x in db.Project_ProjectUser
2021-09-07 11:10:20 +08:00
where x.ProjectId == projectId && x.IsPost == true
2021-04-30 10:28:37 +08:00
select x).ToList();
}
if (getPUser.Count() > 0)
{
foreach (var item in getPUser)
{
List<string> roleIdList = Funs.GetStrListByStr(item.RoleId, ',');
2021-09-07 11:10:20 +08:00
var getRoles = db.Sys_Role.FirstOrDefault(x => roleIdList.Contains(x.RoleId));
2021-04-30 10:28:37 +08:00
if (getRoles != null)
{
string userName = RoleService.getRoleNamesRoleIds(item.RoleId) + "-" + UserService.GetUserNameByUserId(item.UserId);
Model.SpSysUserItem newsysUser = new Model.SpSysUserItem
{
UserId = item.UserId,
UserName = userName,
};
returUsers.Add(newsysUser);
}
}
}
return returUsers;
}
else
{
if (!string.IsNullOrEmpty(unitId))
{
users = (from x in db.Sys_User
join z in db.Sys_Role on x.RoleId equals z.RoleId
where x.IsPost == true && x.UnitId == unitId
orderby x.UserCode
select new Model.SpSysUserItem
{
UserName = z.RoleName + "- " + x.UserName,
UserId = x.UserId,
});
}
else
{
users = (from x in db.Sys_User
join z in db.Sys_Role on x.RoleId equals z.RoleId
2021-09-07 11:10:20 +08:00
where x.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserCode
select new Model.SpSysUserItem
{
UserName = z.RoleName + "- " + x.UserName,
UserId = x.UserId,
});
}
}
return users.ToList();
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>ź͵<C5BA>λId<49><64>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetUserListByProjectIdAndUnitId(string projectId, string unitId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<Model.Sys_User> list = new List<Model.Sys_User>();
if (!string.IsNullOrEmpty(projectId))
{
if (!string.IsNullOrEmpty(unitId))
{
list = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where y.ProjectId == projectId && x.UnitId == unitId && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
}
else
{
list = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where y.ProjectId == projectId && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
}
}
else
{
list = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
where x.UnitId == unitId && x.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
}
return list;
}
}
/// <summary>
/// <20><>ȡ<EFBFBD>ڸ<EFBFBD><DAB8>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetProjectUserListByProjectId(string projectId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var users = (from x in db.Sys_User
where x.IsPost == true && x.UserId != Const.hfnbdId && x.UserId != Const.sedinId
orderby x.UserName
select x).ToList();
if (!string.IsNullOrEmpty(projectId))
{
users = (from x in users
join y in db.Project_ProjectUser on x.UserId equals y.UserId
2021-09-07 11:10:20 +08:00
where y.ProjectId == projectId && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
}
return users;
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>źͽ<C5BA>ɫId<49><64>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetUserListByProjectIdAndRoleId(string projectId, string roleIds)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<string> listRoles = Funs.GetStrListByStr(roleIds, ',');
List<Model.Sys_User> list = new List<Model.Sys_User>();
if (!string.IsNullOrEmpty(projectId))
{
if (listRoles.Count() > 0)
{
list = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where y.ProjectId == projectId && listRoles.Contains(y.RoleId) && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
}
else
{
list = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where y.ProjectId == projectId && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
}
}
else
{
list = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
where x.UserId != BLL.Const.hfnbdId && x.UserId != Const.sedinId && x.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
if (listRoles.Count() > 0)
{
list = list.Where(x => listRoles.Contains(x.RoleId)).ToList();
}
}
return list;
}
}
2021-09-07 11:10:20 +08:00
2021-04-30 10:28:37 +08:00
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>źͽ<C5BA>ɫId<49><64>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
/// </summary>
/// <returns></returns>
2021-09-07 11:10:20 +08:00
public static List<Model.Sys_User> GetUserListByProjectIdUnitIdRoleId(string projectId, string unitId, string roleIds)
2021-04-30 10:28:37 +08:00
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<string> listRoles = Funs.GetStrListByStr(roleIds, ',');
List<Model.Sys_User> list = new List<Model.Sys_User>();
if (!string.IsNullOrEmpty(projectId))
{
if (listRoles.Count() > 0)
{
list = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where y.ProjectId == projectId && x.UnitId == unitId && listRoles.Contains(y.RoleId) && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
}
else
{
list = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where y.ProjectId == projectId && x.UnitId == unitId && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
}
}
else
{
list = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
where x.UnitId == unitId && x.UserId != BLL.Const.hfnbdId && x.UserId != Const.sedinId
&& x.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
if (listRoles.Count() > 0)
{
list = list.Where(x => listRoles.Contains(x.RoleId)).ToList();
}
}
return list;
}
}
2023-05-22 18:45:58 +08:00
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>ź͵<C5BA>λId<49><64>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetUserListByProjectIdAndUnitIdAndNotCopyManId(string projectId, string unitId, string notCopyManId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<Model.Sys_User> list = new List<Model.Sys_User>();
if (!string.IsNullOrEmpty(projectId))
{
if (!string.IsNullOrEmpty(unitId))
{
list = (from x in db.Sys_User
join y in db.Project_ProjectUser
on x.UserId equals y.UserId
join z in db.Base_Depart on x.DepartId equals z.DepartId
where y.ProjectId == projectId && x.UnitId == unitId && x.IsPost == true && y.IsPost == true && x.UserId != notCopyManId
orderby z.DepartCode, x.UserName
select x).ToList();
}
else
{
list = (from x in db.Sys_User
join y in db.Project_ProjectUser
on x.UserId equals y.UserId
join z in db.Base_Depart on x.DepartId equals z.DepartId
where y.ProjectId == projectId && x.IsPost == true && y.IsPost == true && x.UserId != notCopyManId
orderby z.DepartCode, x.UserName
select x).ToList();
}
}
else
{
list = (from x in db.Sys_User
join z in db.Base_Depart on x.DepartId equals z.DepartId
where x.UnitId == unitId && x.IsPost == true && x.UserId != notCopyManId
orderby z.DepartCode, x.UserName
select x).ToList();
}
return list;
}
}
2021-04-30 10:28:37 +08:00
#region <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// <summary>
/// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="projectId"><3E><>Ŀid</param>
/// <param name="isShowPlease"><3E>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE>ѡ<EFBFBD><D1A1></param>
public static void InitUserDropDownList(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease)
{
dropName.DataValueField = "UserId";
dropName.DataTextField = "UserName";
dropName.DataSource = BLL.UserService.GetProjectUserListByProjectId(projectId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>ɫ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="projectId"><3E><>Ŀid</param>
/// <param name="isShowPlease"><3E>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE>ѡ<EFBFBD><D1A1></param>
public static void InitFlowOperateControlUserDropDownList(FineUIPro.DropDownList dropName, string projectId, string unitId, bool isShowPlease)
{
dropName.DataValueField = "UserId";
dropName.DataTextField = "UserName";
dropName.DataSource = BLL.UserService.GetProjectRoleUserListByProjectId(projectId, unitId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="projectId"><3E><>Ŀid</param>
/// <param name="isShowPlease"><3E>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE>ѡ<EFBFBD><D1A1></param>
public static void InitUserProjectIdUnitIdDropDownList(FineUIPro.DropDownList dropName, string projectId, string unitId, bool isShowPlease)
{
dropName.DataValueField = "UserId";
dropName.DataTextField = "UserName";
dropName.DataSource = BLL.UserService.GetUserListByProjectIdAndUnitId(projectId, unitId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="projectId"><3E><>Ŀid</param>
/// <param name="roleIds"><3E><>ɫid</param>
/// <param name="isShowPlease"><3E>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE>ѡ<EFBFBD><D1A1></param>
public static void InitUserProjectIdRoleIdDropDownList(FineUIPro.DropDownList dropName, string projectId, string roleIds, bool isShowPlease)
{
dropName.DataValueField = "UserId";
dropName.DataTextField = "UserName";
dropName.DataSource = BLL.UserService.GetUserListByProjectIdAndRoleId(projectId, roleIds);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="projectId"><3E><>Ŀid</param>
/// <param name="roleIds"><3E><>ɫid</param>
/// <param name="isShowPlease"><3E>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE>ѡ<EFBFBD><D1A1></param>
public static void InitUserProjectIdUnitIdRoleIdDropDownList(FineUIPro.DropDownList dropName, string projectId, string unitId, string roleIds, bool isShowPlease)
{
dropName.DataValueField = "UserId";
dropName.DataTextField = "UserName";
2021-09-07 11:10:20 +08:00
dropName.DataSource = BLL.UserService.GetUserListByProjectIdUnitIdRoleId(projectId, unitId, roleIds);
2021-04-30 10:28:37 +08:00
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="dataId"></param>
public static void DeleteUserRead(string dataId)
{
Model.SGGLDB db = Funs.DB;
var userRs = from x in Funs.DB.Sys_UserRead where x.DataId == dataId select x;
if (userRs.Count() > 0)
{
Funs.DB.Sys_UserRead.DeleteAllOnSubmit(userRs);
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>ʩ<EFBFBD><CAA9><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>̡<EFBFBD>רҵ<D7A8><D2B5>ȡ<EFBFBD><EFBFBD><E9BFB4>Ϣ<EFBFBD>û<EFBFBD>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetSeeUserList(string projectId, string subUnitId, string cNProfessionalCode, string unitWorkId, string subUserId, string mainUserId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<Model.Sys_User> users = new List<Model.Sys_User>();
//<2F>ְ<EFBFBD><D6B0>û<EFBFBD>
var q1 = (from x in db.Project_ProjectUser
2021-09-07 11:10:20 +08:00
join y in db.Sys_User on x.UserId equals y.UserId
join z in db.SitePerson_Person on y.IdentityCard equals z.IdentityCard
join a in db.Base_WorkPost on z.WorkPostId equals a.WorkPostId
2021-04-30 10:28:37 +08:00
where x.IsPost == true && x.UnitId == subUnitId
&& a.CNCodes.Contains(cNProfessionalCode)
&& x.UserId != subUserId
&& x.ProjectId == projectId && z.ProjectId == projectId
orderby x.UserId
select x).ToList();
foreach (var item in q1)
{
if (!string.IsNullOrEmpty(item.WorkAreaId))
{
string[] workAreas = item.WorkAreaId.Split(',');
foreach (var workArea in workAreas)
{
if (workArea == unitWorkId)
{
users.Add(GetUserByUserId(item.UserId));
}
}
}
}
//<2F>ܰ<EFBFBD><DCB0>û<EFBFBD>
Model.Base_Unit mainUnit = BLL.UnitService.GetUnitByProjectIdUnitTypeList(projectId, Const.ProjectUnitType_1)[0];
string mainUnitId = string.Empty;
if (mainUnit != null)
{
mainUnitId = mainUnit.UnitId;
}
var q2 = (from x in db.Project_ProjectUser
2021-09-07 11:10:20 +08:00
join y in db.Sys_User on x.UserId equals y.UserId
join z in db.SitePerson_Person on y.IdentityCard equals z.IdentityCard
join a in db.Base_WorkPost on z.WorkPostId equals a.WorkPostId
2021-04-30 10:28:37 +08:00
where x.IsPost == true && x.UnitId == mainUnitId && a.CNCodes.Contains(cNProfessionalCode)
&& x.UserId != mainUserId
&& x.ProjectId == projectId && z.ProjectId == projectId
orderby x.UserId
select x).ToList();
foreach (var item in q2)
{
if (!string.IsNullOrEmpty(item.WorkAreaId))
{
string[] workAreas = item.WorkAreaId.Split(',');
foreach (var workArea in workAreas)
{
if (workArea == unitWorkId)
{
users.Add(GetUserByUserId(item.UserId));
}
}
}
}
return users;
}
}
/// <summary>
/// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="projectId"><3E><>Ŀid</param>
/// <param name="isShowPlease"><3E>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE>ѡ<EFBFBD><D1A1></param>
public static void InitUserDropDownList(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease, string UnitId)
{
dropName.DataValueField = "Value";
dropName.DataTextField = "Text";
if (!string.IsNullOrWhiteSpace(UnitId))
{
dropName.DataSource = GetUserByUnitId(projectId, UnitId);
}
else
{
dropName.DataSource = GetMainUserList(projectId);
}
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20><><EFBFBD>յ<EFBFBD>λ<EFBFBD><CEBB>ѯ<EFBFBD>û<EFBFBD>
/// </summary>
/// <param name="projectId"></param>
/// <param name="unitId"></param>
/// <returns></returns>
public static ListItem[] GetUserByUnitId(string projectId, string unitId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var user = (from x in db.Sys_User
where x.IsPost == true
orderby x.UserId
select x).ToList();
if (!string.IsNullOrEmpty(projectId) && !string.IsNullOrEmpty(unitId))
{
user = (from x in user
join y in db.Project_ProjectUser on x.UserId equals y.UserId
2021-09-07 11:10:20 +08:00
where (y.ProjectId == projectId && y.UnitId == unitId) && y.IsPost == true
2021-04-30 10:28:37 +08:00
select x).ToList();
}
else
{
user = (from x in user
join y in db.Project_ProjectUser on x.UserId equals y.UserId
2021-09-07 11:10:20 +08:00
where (y.ProjectId == projectId) && y.IsPost == true
2021-04-30 10:28:37 +08:00
select x).ToList();
}
ListItem[] lis = new ListItem[user.Count()];
for (int i = 0; i < user.Count(); i++)
{
lis[i] = new ListItem(user[i].UserName ?? "", user[i].UserId.ToString());
}
return lis;
}
}
/// <summary>
/// <20><>ȡ<EFBFBD><C8A1>Ŀ<EFBFBD>ܰ<EFBFBD><DCB0>û<EFBFBD>
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public static ListItem[] GetMainUserList(string projectId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var user = (from x in db.Sys_User
join y in db.Project_ProjectUser on x.UserId equals y.UserId
join z in db.Project_ProjectUnit on x.UnitId equals z.UnitId
2021-09-07 11:10:20 +08:00
where x.IsPost == true && y.ProjectId == projectId && z.ProjectId == projectId
&& z.UnitType == Const.ProjectUnitType_1 && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserId
select x).ToList();
ListItem[] lis = new ListItem[user.Count()];
for (int i = 0; i < user.Count(); i++)
{
lis[i] = new ListItem(user[i].UserName ?? "", user[i].UserId.ToString());
}
return lis;
}
}
public static void Init(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease)
{
dropName.DataValueField = "Text";
dropName.DataTextField = "Text";
dropName.DataSource = GetMainUserList(projectId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>ʩ<EFBFBD><CAA9><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>̡<EFBFBD>רҵ<D7A8><D2B5>ȡ<EFBFBD><EFBFBD><E9BFB4>Ϣ<EFBFBD>û<EFBFBD>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetSeeUserList2(string projectId, string subUnitId, string cNProfessionalCode, string unitWorkId, string mainUserId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<Model.Sys_User> users = new List<Model.Sys_User>();
//<2F>ְ<EFBFBD><D6B0>û<EFBFBD>
var q1 = (from x in db.Project_ProjectUser
2021-09-07 11:10:20 +08:00
join y in db.Sys_User on x.UserId equals y.UserId
join z in db.SitePerson_Person on y.IdentityCard equals z.IdentityCard
join a in db.Base_WorkPost on z.WorkPostId equals a.WorkPostId
2021-04-30 10:28:37 +08:00
where x.IsPost == true && x.UnitId == subUnitId && a.CNCodes.Contains(cNProfessionalCode)
2021-09-07 11:10:20 +08:00
&& x.ProjectId == projectId && z.ProjectId == projectId && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserId
select x).ToList();
foreach (var item in q1)
{
if (!string.IsNullOrEmpty(item.WorkAreaId))
{
string[] workAreas = item.WorkAreaId.Split(',');
foreach (var workArea in workAreas)
{
if (workArea == unitWorkId)
{
users.Add(GetUserByUserId(item.UserId));
}
}
}
}
//<2F>ܰ<EFBFBD><DCB0>û<EFBFBD>
Model.Base_Unit mainUnit = BLL.UnitService.GetUnitByProjectIdUnitTypeList(projectId, Const.ProjectUnitType_1)[0];
string mainUnitId = string.Empty;
if (mainUnit != null)
{
mainUnitId = mainUnit.UnitId;
}
var q2 = (from x in db.Project_ProjectUser
2021-09-07 11:10:20 +08:00
join y in db.Sys_User on x.UserId equals y.UserId
join z in db.SitePerson_Person on y.IdentityCard equals z.IdentityCard
join a in db.Base_WorkPost on z.WorkPostId equals a.WorkPostId
2021-04-30 10:28:37 +08:00
where x.IsPost == true && x.UnitId == mainUnitId && a.CNCodes.Contains(cNProfessionalCode)
2021-09-07 11:10:20 +08:00
&& x.UserId != mainUserId && y.IsPost == true
2021-04-30 10:28:37 +08:00
&& x.ProjectId == projectId && z.ProjectId == projectId
orderby x.UserId
select x).ToList();
foreach (var item in q2)
{
if (!string.IsNullOrEmpty(item.WorkAreaId))
{
string[] workAreas = item.WorkAreaId.Split(',');
foreach (var workArea in workAreas)
{
if (workArea == unitWorkId)
{
users.Add(GetUserByUserId(item.UserId));
}
}
}
}
return users;
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>ʩ<EFBFBD><CAA9><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>̡<EFBFBD>רҵ<D7A8><D2B5>ȡ<EFBFBD><EFBFBD><E9BFB4>Ϣ<EFBFBD>û<EFBFBD>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetSeeUserList3(string projectId, string unitId1, string unitId2, string unitId3, string cNProfessionalCode, string unitWorkId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<Model.Sys_User> users = new List<Model.Sys_User>();
var q1 = (from x in db.Project_ProjectUser
2021-09-07 11:10:20 +08:00
join y in db.Sys_User on x.UserId equals y.UserId
join z in db.SitePerson_Person on y.IdentityCard equals z.IdentityCard
join a in db.Base_WorkPost on z.WorkPostId equals a.WorkPostId
2021-04-30 10:28:37 +08:00
where x.IsPost == true && (x.UnitId == unitId1 || x.UnitId == unitId2) && a.CNCodes.Contains(cNProfessionalCode)
2021-09-07 11:10:20 +08:00
&& x.ProjectId == projectId && z.ProjectId == projectId && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserId
select x).ToList();
foreach (var item in q1)
{
if (!string.IsNullOrEmpty(item.WorkAreaId))
{
string[] workAreas = item.WorkAreaId.Split(',');
foreach (var workArea in workAreas)
{
if (workArea == unitWorkId)
{
users.Add(GetUserByUserId(item.UserId));
}
}
}
}
if (!string.IsNullOrEmpty(unitId3))
{
var q2 = (from x in db.Project_ProjectUser
2021-09-07 11:10:20 +08:00
join y in db.Sys_User on x.UserId equals y.UserId
join z in db.SitePerson_Person on y.IdentityCard equals z.IdentityCard
join a in db.Base_WorkPost on z.WorkPostId equals a.WorkPostId
2021-04-30 10:28:37 +08:00
where x.IsPost == true && a.CNCodes.Contains(cNProfessionalCode)
2021-09-07 11:10:20 +08:00
&& x.ProjectId == projectId && z.ProjectId == projectId && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserId
select x).ToList();
var q3 = (from x in q2
where unitId3.Split(',').Contains(x.UnitId)
select x).ToList();
foreach (var item in q3)
{
if (!string.IsNullOrEmpty(item.WorkAreaId))
{
string[] workAreas = item.WorkAreaId.Split(',');
foreach (var workArea in workAreas)
{
if (workArea == unitWorkId)
{
users.Add(GetUserByUserId(item.UserId));
}
}
}
}
}
return users;
}
}
/// <summary>
/// <20><><EFBFBD>ض൥λ<E0B5A5>µ<EFBFBD><C2B5>û<EFBFBD>
/// </summary>
/// <param name="dropName"></param>
/// <param name="projectId"></param>
/// <param name="isShowPlease"></param>
/// <param name="UnitId"></param>
public static void InitUsersDropDownList(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease, string UnitId)
{
dropName.DataValueField = "Value";
dropName.DataTextField = "Text";
if (!string.IsNullOrWhiteSpace(UnitId))
{
dropName.DataSource = GetUserByUnitIds(projectId, UnitId);
}
else
{
dropName.DataSource = GetMainUserList(projectId);
}
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20><>ȡ<EFBFBD>൥λ<E0B5A5><CEBB><EFBFBD>û<EFBFBD>
/// </summary>
/// <param name="projectId"></param>
/// <param name="unitIds"></param>
/// <returns></returns>
public static ListItem[] GetUserByUnitIds(string projectId, string unitIds)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var user = (from x in db.Sys_User
where x.IsPost == true
orderby x.UserId
select x).ToList();
if (!string.IsNullOrEmpty(projectId) && !string.IsNullOrEmpty(unitIds))
{
user = (from x in user
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where (y.ProjectId == projectId && unitIds.Split(',').Contains(y.UnitId))
2021-09-07 11:10:20 +08:00
&& y.IsPost == true
2021-04-30 10:28:37 +08:00
select x).ToList();
}
else
{
user = (from x in user
join y in db.Project_ProjectUser on x.UserId equals y.UserId
2021-09-07 11:10:20 +08:00
where (y.ProjectId == projectId) && y.IsPost == true
2021-04-30 10:28:37 +08:00
select x).ToList();
}
ListItem[] lis = new ListItem[user.Count()];
for (int i = 0; i < user.Count(); i++)
{
lis[i] = new ListItem(user[i].UserName ?? "", user[i].UserId.ToString());
}
return lis;
}
}
/// <summary>
/// <20><><EFBFBD>ݵ<EFBFBD>λId<49><64><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>ȡ<EFBFBD><EFBFBD><E9BFB4>Ϣ<EFBFBD>û<EFBFBD>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetSeeUserListByRole(string projectId, string unitId, string role1, string role2, string role3, string role4)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
return (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join z in db.Project_ProjectUser on x.UserId equals z.UserId
join y in db.Sys_Role on z.RoleId equals y.RoleId
2021-04-30 10:28:37 +08:00
where x.IsPost == true && x.UnitId == unitId && (y.RoleId == role1 || y.RoleId == role2 || y.RoleId == role3 || y.RoleId == role4)
2021-09-07 11:10:20 +08:00
&& z.ProjectId == projectId && z.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserId
select x).Distinct().ToList();
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>ʩ<EFBFBD><CAA9><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>̡<EFBFBD>רҵ<D7A8><D2B5>ȡ<EFBFBD><EFBFBD><E9BFB4>Ϣ<EFBFBD>û<EFBFBD>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetSeeUserList4(string projectId, string unitId1, string unitId2, string unitId3)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<Model.Sys_User> users = new List<Model.Sys_User>();
var q1 = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where x.IsPost == true && x.UnitId == unitId1 && y.ProjectId == projectId && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserId
select x).ToList();
users.AddRange(q1);
if (!string.IsNullOrEmpty(unitId2))
{
var q2 = from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where y.ProjectId == projectId && x.IsPost == true && y.IsPost == true
2021-04-30 10:28:37 +08:00
select x;
var q3 = (from x in q2 where unitId2.Split(',').Contains(x.UnitId) select x).ToList();
users.AddRange(q3);
}
if (!string.IsNullOrEmpty(unitId3))
{
var q4 = from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where y.ProjectId == projectId && x.IsPost == true && y.IsPost == true
2021-04-30 10:28:37 +08:00
select x;
var q5 = (from x in q4 where unitId3.Split(',').Contains(x.UnitId) select x).ToList();
users.AddRange(q5);
}
return users;
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="projectId"><3E><>Ŀid</param>
/// <param name="isShowPlease"><3E>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE>ѡ<EFBFBD><D1A1></param>
public static void InitJLUserDropDownList(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease)
{
dropName.DataValueField = "Value";
dropName.DataTextField = "Text";
dropName.DataSource = GetJLUserList(projectId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20><>ȡ<EFBFBD><C8A1>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public static ListItem[] GetJLUserList(string projectId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var user = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
join z in db.Project_ProjectUnit on y.UnitId equals z.UnitId
2021-04-30 10:28:37 +08:00
where x.IsPost == true && y.ProjectId == projectId && z.UnitType == BLL.Const.ProjectUnitType_3
2021-09-07 11:10:20 +08:00
&& y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserId
select x).ToList();
ListItem[] lis = new ListItem[user.Count()];
for (int i = 0; i < user.Count(); i++)
{
lis[i] = new ListItem(user[i].UserName ?? "", user[i].UserId.ToString());
}
return lis;
}
}
/// <summary>
/// ҵ<><D2B5><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="projectId"><3E><>Ŀid</param>
/// <param name="isShowPlease"><3E>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE>ѡ<EFBFBD><D1A1></param>
public static void InitYZUserDropDownList(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease)
{
dropName.DataValueField = "Value";
dropName.DataTextField = "Text";
dropName.DataSource = GetYZUserList(projectId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20><>ȡ<EFBFBD><C8A1>Ŀҵ<C4BF><D2B5><EFBFBD>û<EFBFBD>
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public static ListItem[] GetYZUserList(string projectId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var user = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
join z in db.Project_ProjectUnit on y.UnitId equals z.UnitId
2021-04-30 10:28:37 +08:00
where x.IsPost == true && y.ProjectId == projectId && z.UnitType == BLL.Const.ProjectUnitType_4
2021-09-07 11:10:20 +08:00
&& y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserId
select x).ToList();
ListItem[] lis = new ListItem[user.Count()];
for (int i = 0; i < user.Count(); i++)
{
lis[i] = new ListItem(user[i].UserName ?? "", user[i].UserId.ToString());
}
return lis;
}
}
/// <summary>
/// <20><><EFBFBD>ݵ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="projectId"><3E><>Ŀid</param>
/// <param name="isShowPlease"><3E>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE>ѡ<EFBFBD><D1A1></param>
public static void InitUserProjectIdUnitTypeDropDownList(FineUIPro.DropDownList dropName, string projectId, string unitType, bool isShowPlease)
{
dropName.DataValueField = "UserId";
dropName.DataTextField = "UserName";
dropName.DataSource = BLL.UserService.GetUserListByProjectIdAndUnitType(projectId, unitType);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>ź͵<C5BA>λ<EFBFBD><CEBB><EFBFBD>ͻ<EFBFBD>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetUserListByProjectIdAndUnitType(string projectId, string unitType)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<Model.Sys_User> list = new List<Model.Sys_User>();
if (!string.IsNullOrEmpty(projectId))
{
list = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
join y in db.Project_ProjectUser on x.UserId equals y.UserId
join z in db.Project_ProjectUnit on x.UnitId equals z.UnitId
2023-08-17 09:39:51 +08:00
where y.ProjectId == projectId && z.ProjectId == projectId && (z.UnitType == unitType || string.IsNullOrEmpty(unitType))
2021-09-07 11:10:20 +08:00
&& y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
}
return list;
}
}
#region <EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><EFBFBD>û<EFBFBD>ID<EFBFBD>õ<EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
/// <summary>
/// <20><><EFBFBD>ݶ<EFBFBD><DDB6>û<EFBFBD>ID<49>õ<EFBFBD><C3B5>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
/// </summary>
/// <param name="bigType"></param>
/// <returns></returns>
public static string getUserNamesUserIds(object userIds)
{
string userName = string.Empty;
if (userIds != null)
{
string[] ids = userIds.ToString().Split(',');
foreach (string id in ids)
{
var q = GetUserNameByUserId(id);
if (q != null)
{
userName += q + ",";
}
}
if (userName != string.Empty)
{
userName = userName.Substring(0, userName.Length - 1); ;
}
}
return userName;
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="projectId"></param>
/// <param name="name"></param>
/// <returns></returns>
public static List<Model.Sys_User> GetProjectUserListByProjectIdForApi(string projectId, string name)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var users = (from x in db.Sys_User
where x.IsPost == true && x.UserId != BLL.Const.hfnbdId
where name == "" || x.UserName.Contains(name)
orderby x.UserName
select x).ToList();
if (!string.IsNullOrEmpty(projectId))
{
users = (from x in users
join y in db.Project_ProjectUser on x.UserId equals y.UserId
2021-09-07 11:10:20 +08:00
where y.ProjectId == projectId && y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
}
return users;
}
}
/// <summary>
///
/// </summary>
/// <param name="projectId"></param>
/// <param name="unitId"></param>
/// <param name="unitType"></param>
/// <param name="name"></param>
/// <returns></returns>
public static List<Model.Sys_User> GetProjectUserListByProjectIdForApi(string projectId, string unitId, string unitType, string name)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<Model.Sys_User> list = new List<Model.Sys_User>();
if (!string.IsNullOrEmpty(projectId))
{
string[] unitTypes = { };
string[] unitIds = { };
if (!string.IsNullOrEmpty(unitType))
{
unitTypes = unitType.Split(',');
}
if (!string.IsNullOrEmpty(unitId))
{
unitIds = unitId.Split(',');
}
list = (from x in db.Sys_User
join y in db.Project_ProjectUser on x.UserId equals y.UserId
join z in db.Project_ProjectUnit on x.UnitId equals z.UnitId
where name == "" || x.UserName.Contains(name)
where y.ProjectId == projectId && z.ProjectId == projectId
where unitType == "" || unitTypes.Contains(z.UnitType)
where unitId == "" || unitIds.Contains(z.UnitId)
2021-09-07 11:10:20 +08:00
where y.IsPost == true
2021-04-30 10:28:37 +08:00
orderby z.UnitType descending, x.UserName
select x).ToList();
}
return list;
}
}
/// <summary>
///
/// </summary>
/// <param name="account"></param>
/// <returns></returns>
public static Model.Sys_User FindUserByAccount(string account)
{
var q = from y in Funs.DB.Sys_User
where y.Account == account && y.IsPost == true
select y;
return q.FirstOrDefault();
}
/// <summary>
/// <20><><EFBFBD>ݵ<EFBFBD>λId<49><64>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetUserListByUnitId(string unitId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<Model.Sys_User> list = new List<Model.Sys_User>();
list = (from x in db.Sys_User
where x.UnitId == unitId
orderby x.UserName
select x).ToList();
return list;
}
}
/// <summary>
/// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="isShowPlease"><3E>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE>ѡ<EFBFBD><D1A1></param>
public static void InitUserUnitIdDropDownList(FineUIPro.DropDownList dropName, string unitId, bool isShowPlease)
{
dropName.DataValueField = "UserId";
dropName.DataTextField = "UserName";
dropName.DataSource = BLL.UserService.GetUserListByUnitId(unitId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20><><EFBFBD>ݽ<EFBFBD>ɫ<EFBFBD><C9AB>ȡ<EFBFBD><EFBFBD>û<EFBFBD>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetUserListByRole(string role)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
return (from x in db.Sys_User
where x.RoleId == role
orderby x.UserId
select x).Distinct().ToList();
}
}
/// <summary>
///
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public static string getSignatureName(string userId)
{
string userName = string.Empty;
var getUser = UserService.GetUserByUserId(userId);
if (getUser != null)
{
userName = getUser.UserName;
if (!string.IsNullOrEmpty(getUser.SignatureUrl))
{
string url = Funs.RootPath + getUser.SignatureUrl;
FileInfo info = new FileInfo(url);
if (info.Exists)
{
userName = "<img width='90' height='35' src='" + (Funs.SGGLUrl + getUser.SignatureUrl).Replace('\\', '/') + "'></img>";
}
}
}
return userName;
}
/// <summary>
2021-09-07 11:10:20 +08:00
/// <20><><EFBFBD>ݵ<EFBFBD>λId<49><64><EFBFBD>Ż<EFBFBD>ȡʩ<C8A1><CAA9><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
2021-04-30 10:28:37 +08:00
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetUserListByUnitIdDepartId(string unitId, string DepartId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<Model.Sys_User> list = new List<Model.Sys_User>();
list = (from x in db.Sys_User
2021-09-07 11:10:20 +08:00
where x.UnitId == unitId && x.DepartId == DepartId && x.IsPost == true
2021-04-30 10:28:37 +08:00
orderby x.UserName
select x).ToList();
return list;
}
}
/// <summary>
/// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="isShowPlease"><3E>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE>ѡ<EFBFBD><D1A1></param>
public static void InitUserUnitIdDepartIdDropDownList(FineUIPro.DropDownList dropName, string unitId, string DepartId, bool isShowPlease)
{
dropName.DataValueField = "UserId";
dropName.DataTextField = "UserName";
dropName.DataSource = BLL.UserService.GetUserListByUnitIdDepartId(unitId, DepartId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>ʩ<EFBFBD><CAA9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="dropName"></param>
/// <param name="isShowPlease"></param>
public static void InitSGBUser(FineUIPro.DropDownList dropName, bool isShowPlease)
{
dropName.DataValueField = "Value";
dropName.DataTextField = "Text";
dropName.DataSource = GetSGBUserList();
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20><>ȡʩ<C8A1><CAA9><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public static ListItem[] GetSGBUserList()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var user = (from x in db.Sys_User
where x.IsPost == true && x.UnitId == Const.UnitId_CWCEC && x.DepartId == Const.Depart_constructionId
orderby x.UserId
select x).ToList();
ListItem[] lis = new ListItem[user.Count()];
for (int i = 0; i < user.Count(); i++)
{
lis[i] = new ListItem(user[i].UserName ?? "", user[i].UserId.ToString());
}
return lis;
}
}
2023-04-28 09:18:02 +08:00
public static void InitUserByRoleIdDropDownList(FineUIPro.DropDownList dropName, string projectId, string roleId, bool isShowPlease)
2023-09-21 17:42:56 +08:00
2023-04-28 09:18:02 +08:00
{
dropName.DataValueField = "UserId";
dropName.DataTextField = "UserName";
dropName.DataSource = BLL.UserService.GetUserListByRoleId(projectId, roleId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>źͽ<C5BA>ɫId<49><64>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
/// </summary>
/// <returns></returns>
public static List<Model.Sys_User> GetUserListByRoleId(string projectId, string roleId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<Model.Sys_User> list = new List<Model.Sys_User>();
if (!string.IsNullOrEmpty(projectId))
{
list = (from x in db.Sys_User
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where y.ProjectId == projectId && y.RoleId.Contains(roleId) && y.IsPost == true
orderby x.UserName
select x).ToList();
}
return list;
}
}
2021-04-30 10:28:37 +08:00
}
}