public string Add(AddUserServiceForm form) { var currentUser = bll.GetCurrentUser(); User u = new User { ID = form.ID, Enabled = form.Enabled, Name = form.Name, Password = form.Password, }; u.Creator = currentUser.User.ID; UserInfo ui = new UserInfo { CnName = form.CnName, WX = form.WX, Mobile = form.Mobile, Identity = form.Identity, QQ = form.QQ, Remark = form.Remark, Address = form.Address, }; return bll.Add(u, ui, form.RoleIDList); }
public bool UpdateUser(UpdateUserServiceForm form) { UserBLL bll = new UserBLL(); var currentUser = bll.GetCurrentUser(); User u = new User { ID = currentUser.User.ID, LastUpdator = currentUser.User.ID, Enabled = form.Enabled, }; UserInfo ui = new UserInfo { ID = currentUser.User.ID, Address = form.Address, CnName = form.CnName, Identity = form.Identity, Mobile = form.Mobile, QQ = form.QQ, Remark = form.Remark, WX = form.WX, }; return bll.Update(u, ui, null); }
public bool Update(UpdateUserServiceForm form) { var currentUser = bll.GetCurrentUser(); User u = new User { ID = form.ID, LastUpdator = currentUser.User.ID, Enabled = form.Enabled, }; UserInfo ui = new UserInfo { ID = form.ID, Address = form.Address, CnName = form.CnName, Identity = form.Identity, Mobile = form.Mobile, QQ = form.QQ, Remark = form.Remark }; return bll.Update(u, ui, form.RoleIDList); }
public bool Update(Model.User user, UserInfo ui, List<string> roleidlist) { #region risk update ISqlMapper mapper = Common.GetMapperFromSession(); UserDao udao = new UserDao(mapper); UserInfoDao uidao = new UserInfoDao(mapper); if (user != null) { Model.User entity = new User { ID = user.ID, Enabled = user.Enabled, }; udao.Update(new UserUpdateForm { Entity = entity, UserQueryForm = new UserQueryForm { ID = user.ID } }); } if (ui != null) { uidao.Update(new UserInfoUpdateForm { Entity = ui, UserInfoQueryForm = new UserInfoQueryForm { ID = ui.ID } }); } if (roleidlist != null) { User_RoleDao urdao = new User_RoleDao(mapper); urdao.Delete(new User_RoleQueryForm { UserID = user.ID }); foreach (var role in roleidlist) { User_Role ur = new User_Role { RoleID = role, UserID = user.ID }; urdao.Add(ur); } } #endregion #region weixin api RoleDao roledao = new RoleDao(mapper); var roles = roledao.Query(new RoleQueryForm { IDs = roleidlist }); var weixinids = (from r in roles where !string.IsNullOrEmpty(r.WeiXinID) select Convert.ToInt32(r.WeiXinID)).ToArray(); var user_temp = udao.Query(new UserQueryForm { ID = user.ID }).FirstOrDefault(); var ui_temp = uidao.Query(new UserInfoQueryForm { ID = user.ID }).FirstOrDefault(); try { SOAFramework.Library.WeiXin.WeiXinApi.User.Update(new SOAFramework.Library.WeiXin.User { department = weixinids, mobile = ui_temp.Mobile, name = ui_temp.CnName, weixinid = ui_temp.WX, userid = user_temp.Name, enable = 1, }); } catch (SOAFramework.Library.WeiXin.WeiXinException ex) { switch (ex.Code) { case "60111"://如果微信上不存在用户,就新建 SOAFramework.Library.WeiXin.WeiXinApi.User.Create(new SOAFramework.Library.WeiXin.User { enable = 1, userid = user_temp.Name, name = ui_temp.CnName, mobile = ui_temp.Mobile, weixinid = ui_temp.WX, department = weixinids, }); break; default: throw ex; } } #endregion return true; }
public bool ChangePassword(ChangePasswordUpdateForm form) { ISqlMapper mapper = Common.GetMapperFromSession(); UserDao dao = new UserDao(mapper); Model.User user = new User { ID = form.UserID, Password = form.NewPassword, }; dao.Update(new UserUpdateForm { Entity = user }); return true; }