/// <summary> /// 新增使用者 /// </summary> /// <param name="model"></param> /// <param name="loginUserID"></param> /// <returns></returns> public static bool AddUserMember(UserMemberViewModel model, string loginUserID) { var success = false; var actionType = "AddUser"; try { var salt = Guid.NewGuid().ToString(); var pwd = model.PWD + salt; var encodePWD = HanboSecurityHelper.GetEncrypt(pwd); var user = new UserMember() { UserID = model.Uid, Name = model.UName, Email = model.Email, Password = encodePWD, Salt = salt, DeptName = model.DeptName, CreateOn = DateTime.Now, ModifiedOn = DateTime.Now, CreateBy = loginUserID, ModifiedBy = loginUserID, Disabled = model.AccountDisable, }; int singleSN = _dc.Code_Function.SingleOrDefault(p => p.Code == "Single").SN; int continueSN = _dc.Code_Function.SingleOrDefault(p => p.Code == "Continue").SN; int macroSN = _dc.Code_Function.SingleOrDefault(p => p.Code == "MacroPlan").SN; int adjustSN = _dc.Code_Function.SingleOrDefault(p => p.Code == "Adjustment").SN; int accountSN = _dc.Code_Function.SingleOrDefault(p => p.Code == "UserAccount").SN; user.UserAuthorizedFunction.Add(new UserAuthorizedFunction() { UserID = model.Uid, FunctionSN = accountSN, Authorized = model.AuthorizedAccount }); user.UserAuthorizedFunction.Add(new UserAuthorizedFunction() { UserID = model.Uid, FunctionSN = adjustSN, Authorized = model.AuthorizedAdjust }); user.UserAuthorizedFunction.Add(new UserAuthorizedFunction() { UserID = model.Uid, FunctionSN = continueSN, Authorized = model.AuthorizedContinue }); user.UserAuthorizedFunction.Add(new UserAuthorizedFunction() { UserID = model.Uid, FunctionSN = macroSN, Authorized = model.AuthorizedMacroPlan }); user.UserAuthorizedFunction.Add(new UserAuthorizedFunction() { UserID = model.Uid, FunctionSN = singleSN, Authorized = model.AuthorizedSingle }); _dc.UserMember.InsertOnSubmit(user); _dc.SubmitChanges(); success = true; } catch (Exception ex) { Hanbo.Log.LogManager.Error(ex.Message); } finally { _dc.ActionLog.InsertOnSubmit(new ActionLog() { ActionType = actionType, ActionData = "UserID:" + model.Uid, CreateOn = DateTime.Now, UserID = loginUserID, Note = success ? "Success" : "Fail", }); _dc.SubmitChanges(); } return success; }
partial void UpdateUserMember(UserMember instance);
partial void DeleteUserMember(UserMember instance);
partial void InsertUserMember(UserMember instance);