public void EditUserRole(string itcode, string bu, List <UserRole> roles) { List <UserRole> existRoles = UserDa.GetUserRole(itcode, null, bu); List <UserRole> rolesAdd = new List <UserRole>(); List <UserRole> rolesDel = new List <UserRole>(); //foreach (UserRole role in existRoles) //{ // if (!roles.Exists(r => (r.Role == role.Role && r.BU == role.BU))) // rolesDel.Add(role); // //if (!user.Roles.Exists(delegate(UserRole r) { return r.Role == role.Role && r.BU == role.BU; })) // //{ } //} //foreach (UserRole role in roles) //{ // if (!existRoles.Exists(r => (r.Role == role.Role && r.BU == role.BU))) // rolesAdd.Add(role); //} // 如果没有实际更改 if (rolesAdd.Count == 0 && rolesDel.Count == 0) { return; } using (TranscationHelper trans = TranscationHelper.GetInstance()) { trans.BeginTrans(); try { foreach (UserRole role in rolesDel) { UserDa.DeleteUserRole(role, trans); } foreach (UserRole role in rolesAdd) { UserDa.InsertUserRole(role, trans); } trans.CommitTrans(); } catch { trans.RollTrans(); throw; } } }
/// <summary> /// 发送邮件 /// </summary> public void SendMail(string to, string cc, string subject, string body, MailPriority priority, params Guid[] files) { using (TranscationHelper trans = TranscationHelper.GetInstance()) { trans.BeginTrans(); try { SendMail(trans, to, cc, subject, body, priority, files); trans.CommitTrans(); } catch { trans.RollTrans(); throw; } } }
public void AddUser(User user) { if (user.UID == Guid.Empty) { user.UID = Guid.NewGuid(); } if (user.Organ == null) { throw new BusinessObjectLogicException("Invalid Organ!"); } //if (user.Superior == null) throw new BusinessObjectLogicException("Invalid Manager!"); user.CreateTime = DateTime.Now; user.Password = RandomString.GetPassword(); using (TranscationHelper trans = TranscationHelper.GetInstance()) { trans.BeginTrans(); try { UserDa.InsertUser(user, trans); foreach (UserRole role in user.Roles) { UserDa.InsertUserRole(role, trans); } trans.CommitTrans(); } catch { trans.RollTrans(); throw; } } if (user.Superior == null) // 更新为自己 { user.Superior = new UserBase(user.ItCode); UserDa.UpdateUser(user); } }
internal static void SendMail(TranscationHelper trans, string to, string cc, string subject, string body, MailPriority priority, params Guid[] files) { Message message = new Message(); message.From = Sender.GetDefaultFrom(); message.To = to; message.CC = cc; message.Subject = subject; message.Body = body; message.Priority = priority; MessageDa.InsertMaillQueue(message, trans); if (files != null) { foreach (Guid file in files) { MessageDa.InsertMaillAttach(file, Utils.SysFileDir(), message.UID, trans); } } }
public static void InsertMaillSend(Message message, TranscationHelper trans) { InsertMaillSend(message, trans.DataBase, trans.Transaction); }
public static void UpdateMaillQueue(Message mail, TranscationHelper trans) { UpdateMaillQueue(mail, trans.DataBase, trans.Transaction); }
public static void UpdateOrgan(Organ organ, TranscationHelper trans) { UpdateOrgan(organ, trans.DataBase, trans.Transaction); }
public void EditUser(User user) { User existUser = UserDa.GetUserByItCode(user.ItCode); existUser.Roles.AddRange(UserDa.GetUserRole(existUser.ItCode, null, null)); if (user == null) { throw new BusinessObjectLogicException("Invalid User!"); } if (user.Organ == null) { throw new BusinessObjectLogicException("Invalid Organ!"); } if (user.Superior == null) { throw new BusinessObjectLogicException("Invalid Manager!"); } if (user.Disabled && existUser.Disabled) { throw new BusinessObjectLogicException("User is disabled!"); } bool updateUser = false; if (existUser.FirstName != user.FirstName || existUser.LastName != user.LastName || existUser.AbbrName != user.AbbrName || existUser.Organ.ID != user.Organ.ID || existUser.Superior.ItCode != user.Superior.ItCode || existUser.Phone != user.Phone || existUser.Disabled != user.Disabled || existUser.Department != user.Department) { existUser.FirstName = user.FirstName; existUser.LastName = user.LastName; existUser.AbbrName = user.AbbrName; existUser.Organ = user.Organ; existUser.Superior = user.Superior; existUser.Phone = user.Phone; existUser.Disabled = user.Disabled; existUser.Department = user.Department; updateUser = true; } List <UserRole> rolesAdd = new List <UserRole>(); List <UserRole> rolesDel = new List <UserRole>(); //foreach (UserRole role in existUser.Roles) //{ // if (!user.Roles.Exists(r => (r.Role == role.Role && r.BU == role.BU))) // rolesDel.Add(role); // //if (!user.Roles.Exists(delegate(UserRole r) { return r.Role == role.Role && r.BU == role.BU; })) // //{ } //} //foreach (UserRole role in user.Roles) //{ // if (!existUser.Roles.Exists(r => (r.Role == role.Role && r.BU == role.BU))) // rolesAdd.Add(role); //} // 如果没有实际更改 if (!updateUser && rolesAdd.Count == 0 && rolesDel.Count == 0) { return; } using (TranscationHelper trans = TranscationHelper.GetInstance()) { trans.BeginTrans(); try { if (updateUser) { UserDa.UpdateUser(existUser, trans); } foreach (UserRole role in rolesDel) { UserDa.DeleteUserRole(role, trans); } foreach (UserRole role in rolesAdd) { UserDa.InsertUserRole(role, trans); } trans.CommitTrans(); } catch { trans.RollTrans(); throw; } } }
public static void UpdateUserDelegate(string itcode, string delegateUser, TranscationHelper trans) { UpdateUserDelegate(itcode, delegateUser, trans.DataBase, trans.Transaction); }
public static void SaveSysPara(string key, string bu, string value, TranscationHelper trans) { SaveSysPara(key, bu, value, trans.DataBase, trans.Transaction); }
public static void DeleteAttach(Guid id, TranscationHelper trans) { DeleteAttach(id, trans.DataBase, trans.Transaction); }
public static void UpdateDefaultBu(string itcode, string bu, TranscationHelper trans) { UpdateDefaultBu(itcode, bu, trans.DataBase, trans.Transaction); }
public static void DeleteMaillQueue(Guid uid, TranscationHelper trans) { DeleteMaillQueue(uid, trans.DataBase, trans.Transaction); }
public static void InsertMaillAttach(Attach attach, TranscationHelper trans) { InsertMaillAttach(attach, trans.DataBase, trans.Transaction); }
public static void UpdateMaillQueue(Message mail, TranscationHelper trans) { UpdateMaillQueue(mail, trans.DataBase, trans.Transaction); }
public static void InsertMaillSend(Message message, TranscationHelper trans) { InsertMaillSend(message, trans.DataBase, trans.Transaction); }
public static void InsertMaillAttach(Guid fileID, string directory, Guid mailID, TranscationHelper trans) { InsertMaillAttach(fileID, directory, mailID, trans.DataBase, trans.Transaction); }
public static void InsertUser(User user, TranscationHelper trans) { InsertUser(user, trans.DataBase, trans.Transaction); }
public static void DeleteAttach(Guid id, TranscationHelper trans) { DeleteAttach(id, trans.DataBase, trans.Transaction); }
public static void InsertUserRole(UserRole role, TranscationHelper trans) { InsertUserRole(role, trans.DataBase, trans.Transaction); }
public static void UpdateUser(User user, TranscationHelper trans) { UpdateUser(user, trans.DataBase, trans.Transaction); }
public static void UpdateUser(User user, TranscationHelper trans) { UpdateUser(user, trans.DataBase, trans.Transaction); }
public static void UpdateUserDelegate(string itcode, string delegateUser, TranscationHelper trans) { UpdateUserDelegate(itcode, delegateUser, trans.DataBase, trans.Transaction); }
public static void DeleteUserRole(UserRole role, TranscationHelper trans) { DeleteUserRole(role, trans.DataBase, trans.Transaction); }
public static void DeleteUserRole(UserRole role, TranscationHelper trans) { DeleteUserRole(role, trans.DataBase, trans.Transaction); }
public static void InsertUser(User user, TranscationHelper trans) { InsertUser(user, trans.DataBase, trans.Transaction); }
public static void InsertOrgan(Organ organ, TranscationHelper trans) { InsertOrgan(organ, trans.DataBase, trans.Transaction); }
public static void UpdateDefaultBu(string itcode, string bu, TranscationHelper trans) { UpdateDefaultBu(itcode, bu, trans.DataBase, trans.Transaction); }
public static void DeleteMaillQueue(Guid uid, TranscationHelper trans) { DeleteMaillQueue(uid, trans.DataBase, trans.Transaction); }
public static void InsertUserRole(UserRole role, TranscationHelper trans) { InsertUserRole(role, trans.DataBase, trans.Transaction); }
public static void InsertMaillAttach(Attach attach, TranscationHelper trans) { InsertMaillAttach(attach, trans.DataBase, trans.Transaction); }
public static void SaveSysPara(string key, string bu, string value, TranscationHelper trans) { SaveSysPara(key, bu, value, trans.DataBase, trans.Transaction); }
public static void InsertMaillAttach(Guid fileID, string directory, Guid mailID, TranscationHelper trans) { InsertMaillAttach(fileID, directory, mailID, trans.DataBase, trans.Transaction); }