/// <summary> /// Save New User and organization accesses provided to it. /// </summary> /// <param name="Name"></param> /// <param name="Email"></param> /// <param name="Value"></param> /// <param name="password"></param> /// <param name="mobile"></param> /// <param name="OrgID"></param> /// <returns></returns> public String SaveNewUser(string Name, string Email, string Value, string password, string mobile, List <int> OrgID) { string msg; string info = ""; MUser user = new MUser(ctx, 0, null); user.SetName(Name); user.SetIsLoginUser(true); user.SetEMail(Email); if (!string.IsNullOrEmpty(password)) { string key = ctx.GetSecureKey(); password = SecureEngineBridge.DecryptByClientKey(password, key); user.SetPassword(password); } if (!String.IsNullOrEmpty(mobile)) { user.SetMobile(mobile); } if (!string.IsNullOrEmpty(Value)) { user.SetValue(Value); } if (user.Save()) { if (OrgID != null) { for (int i = 0; i < OrgID.Count; i++) { MOrg org = new MOrg(ctx, OrgID[i], null); MUserOrgAccess roles = new MUserOrgAccess(org, user.GetAD_User_ID()); roles.SetAD_Client_ID(ctx.GetAD_Client_ID()); roles.SetAD_Org_ID(OrgID[i]); roles.SetIsReadOnly(false); roles.Save(); } } } else { ValueNamePair ppE = VAdvantage.Logging.VLogger.RetrieveError(); if (ppE != null) { msg = ppE.GetValue(); info = ppE.GetName(); } } return(info); }
/// <summary> /// Save New User and organization accesses provided to it. /// </summary> /// <param name="Name"></param> /// <param name="Email"></param> /// <param name="Value"></param> /// <param name="password"></param> /// <param name="mobile"></param> /// <param name="OrgID"></param> /// <returns></returns> public bool SaveNewUser(string Name, string Email, string Value, string password, string mobile, List <int> OrgID) { bool retValue = false; MUser user = new MUser(ctx, 0, null); user.SetName(Name); user.SetIsLoginUser(true); user.SetEMail(Email); if (!string.IsNullOrEmpty(password)) { string key = ctx.GetSecureKey(); password = SecureEngineBridge.DecryptByClientKey(password, key); user.SetPassword(password); } if (!String.IsNullOrEmpty(mobile)) { user.SetMobile(mobile); } if (!string.IsNullOrEmpty(Value)) { user.SetValue(Value); } if (user.Save()) { if (OrgID != null) { for (int i = 0; i < OrgID.Count; i++) { MOrg org = new MOrg(ctx, OrgID[i], null); MUserOrgAccess roles = new MUserOrgAccess(org, user.GetAD_User_ID()); roles.SetAD_Client_ID(ctx.GetAD_Client_ID()); roles.SetAD_Org_ID(OrgID[i]); roles.SetIsReadOnly(false); roles.Save(); } } retValue = true; } return(retValue); }