/// <summary> /// Returns a collection of MAccountProfiles without any role information /// </summary> /// <param name="profile">An instance of MAccountProfile</param> /// <returns></returns> public Collection <MAccountProfile> GetAccounts(MAccountProfile profile) { Collection <MAccountProfile> mRetList = new Collection <MAccountProfile>(); DataTable mDataTable = null; try { m_DAccounts.Profile = profile; if (DatabaseIsOnline()) { mDataTable = m_DAccounts.GetAccounts; } if (mDataTable != null) { foreach (DataRow item in mDataTable.Rows) { mRetList.Add(new MAccountProfile(item)); } } return(mRetList); } catch (Exception) { throw; } finally { if (mDataTable != null) { mDataTable.Dispose(); } } }
/// <summary> /// Get a single account given it's id. /// </summary> /// <param name="id">int or Integer</param> /// <returns>MAccountProfile</returns> /// <remarks>Returns null object if not found</remarks> public static MAccountProfile GetProfile(int id) { var mResult = from mProfile in GetAccounts(CurrentProfile()) where mProfile.Id == id select mProfile; MAccountProfile mRetVal = null; try { mRetVal = mResult.First(); } catch (InvalidOperationException) { String mMSG = "Count not find account: " + id + " in the database"; Logger mLog = Logger.Instance(); mLog.Error(mMSG); } catch (IndexOutOfRangeException) { String mMSG = "Count not find account: " + id + " in the database"; Logger mLog = Logger.Instance(); mLog.Error(mMSG); } if (mRetVal != null) { BAccounts mBAccount = new BAccounts(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement); mRetVal = mBAccount.GetProfile(mRetVal.Account); } return(mRetVal); }
private MMessageProfile populateProfile(UIMessageProfile uiProfile, MAccountProfile accountProfile) { MMessageProfile mProfile = new MMessageProfile(); if (accountProfile == null) { accountProfile = new MAccountProfile(); } if (uiProfile.Id > 0) { mProfile = MessageUtility.GetProfile(uiProfile.Id); mProfile.UpdatedBy = accountProfile.Id; mProfile.UpdatedDate = DateTime.Now; } else { mProfile.AddedBy = accountProfile.Id; mProfile.AddedDate = DateTime.Now; } mProfile.Body = HttpContext.Current.Server.UrlDecode(uiProfile.Body); mProfile.Description = uiProfile.Description; mProfile.FormatAsHtml = uiProfile.FormatAsHtml; mProfile.Id = uiProfile.Id; mProfile.Name = uiProfile.Name; mProfile.SecurityEntitySeqId = SecurityEntityUtility.CurrentProfile().Id; mProfile.Title = uiProfile.Title; return(mProfile); }
/// <summary> /// Sets the principal by either retrieving roles from the db or by cookie /// </summary> /// <param name="accountProfile"></param> /// <remarks></remarks> public static void SetPrincipal(MAccountProfile accountProfile) { if (accountProfile == null) { throw new ArgumentNullException("accountProfile", "accountProfile cannot be a null reference (Nothing in Visual Basic)!!"); } HttpContext mCurrentConext = HttpContext.Current; String mAccountRoles = accountProfile.AssignedRoles.ToString().Replace(",", ";"); // generate authentication ticket FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, accountProfile.Account, DateTime.Now, DateTime.Now.AddHours(1), false, mAccountRoles); // Encrypt the ticket. String encryptedTicket = FormsAuthentication.Encrypt(authTicket); // Create a cookie and add the encrypted ticket to the cookie HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); mCurrentConext.Response.Cookies.Add(authCookie); String[] mRoles = new String[accountProfile.DerivedRoles.Count]; int i = 0; foreach (string item in accountProfile.DerivedRoles) { mRoles[i] = item; i++; } mCurrentConext.User = new GenericPrincipal(mCurrentConext.User.Identity, mRoles); }
public IHttpActionResult SaveMembers(UIAccounts groupAccounts) { string mRetVal = "false"; Logger mLog = Logger.Instance(); MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditGroups", true)), AccountUtility.CurrentProfile()); if (!mSecurityInfo.MayEdit) { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add"); mLog.Error(mError); return(this.InternalServerError(mError)); } if (HttpContext.Current.Items["EditId"] == null || HttpContext.Current.Items["EditId"].ToString().ToLowerInvariant() != groupAccounts.SeqId.ToString().ToLowerInvariant()) { Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!"); mLog.Error(mError); return(this.InternalServerError(mError)); } MAccountProfile accountProfile = AccountUtility.CurrentProfile(); MClientChoicesState mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(accountProfile.Account); MGroupRoles mProfile = new MGroupRoles(); mProfile.SecurityEntityId = SecurityEntityUtility.CurrentProfile().Id; mProfile.GroupSeqId = groupAccounts.SeqId; mProfile.Roles = String.Join(",", groupAccounts.Accounts); mProfile.AddedUpdatedBy = accountProfile.Id; GroupUtility.UpdateGroupRoles(mProfile); return(Ok(mRetVal)); }
/// <summary> /// Sends the mail. /// </summary> /// <param name="body">The body.</param> /// <param name="subject">The subject.</param> /// <param name="formatAsHTML">if set to <c>true</c> [format as HTML].</param> /// <param name="accountProfile">The account profile.</param> /// <param name="file">The file.</param> /// <param name="contentType">Type of the content.</param> public static void SendMail(string body, string subject, bool formatAsHTML, MAccountProfile accountProfile, FileInfo file, ContentType contentType) { if (!canSendMail()) { return; } string mFrom = ConfigSettings.SmtpFrom; if (mFrom.Trim().Length == 0) { Logger log = Logger.Instance(); log.Error("SMTP From not set in the WEB.CONFIG file"); return; } SmtpClient mailClient = getSmtpClient(); MailMessage mailMessage = new MailMessage(new MailAddress(mFrom), new MailAddress(accountProfile.Email)); mailMessage.Subject = subject; mailMessage.Body = body; mailMessage.IsBodyHtml = formatAsHTML; Stream mStream = file.OpenRead(); Attachment attachment = new Attachment(mStream, contentType); attachment.Name = file.Name; mailMessage.Attachments.Add(attachment); mailClient.Send(mailMessage); }
protected void Page_Load(object sender, EventArgs e) { MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); bool flag = mAccountProfile.Status == 4; if (flag) { this.trForceChange.Visible = true; this.trNormalChange.Visible = false; this.trOldPassword.Visible = false; this.NewPassword.Focus(); } else { this.trForceChange.Visible = false; this.trNormalChange.Visible = true; this.trOldPassword.Visible = true; this.OldPassword.Focus(); } Exception mException = GWWebHelper.ExceptionError; if (mException != null) { clientMessage.Style.Add("display", ""); clientMessage.InnerHtml = mException.Message.ToString(); GWWebHelper.ExceptionError = null; } }
/// <summary> /// AutoCreateAccount will automatically create an account based on infomration found both in the web.config file /// and the database. /// </summary> /// <returns>MAccountProfile</returns> public static MAccountProfile AutoCreateAccount() { MAccountProfile mCurrentAccountProfile = AccountUtility.GetProfile("System"); MAccountProfile mAccountProfileToSave = new MAccountProfile(); Logger mLog = Logger.Instance(); mAccountProfileToSave.Id = -1; bool mSaveGroups = true; bool mSaveRoles = true; string mGroups = ConfigSettings.RegistrationGroups; string mRoles = ConfigSettings.RegistrationRoles; if (string.IsNullOrEmpty(mGroups)) { mSaveGroups = false; } if (string.IsNullOrEmpty(mRoles)) { mSaveRoles = false; } mAccountProfileToSave.Account = AccountUtility.HttpContextUserName(); mAccountProfileToSave.FirstName = "Auto created"; mAccountProfileToSave.MiddleName = ""; mAccountProfileToSave.LastName = "Auto created"; mAccountProfileToSave.PreferredName = "Auto created"; mAccountProfileToSave.Email = "*****@*****.**"; mAccountProfileToSave.Location = "Hawaii"; mAccountProfileToSave.TimeZone = -8; mAccountProfileToSave.AddedBy = mCurrentAccountProfile.Id; mAccountProfileToSave.AddedDate = DateTime.Now; mAccountProfileToSave.SetGroups(mGroups); mAccountProfileToSave.SetRoles(mRoles); mAccountProfileToSave.PasswordLastSet = DateTime.Now; mAccountProfileToSave.LastLogOn = DateTime.Now; mAccountProfileToSave.Password = CryptoUtility.Encrypt(ConfigSettings.RegistrationPassword, ConfigSettings.EncryptionType); mAccountProfileToSave.Status = (int)SystemStatus.SetAccountDetails; MClientChoicesState mClientChoiceState = ClientChoicesUtility.GetClientChoicesState(ConfigSettings.RegistrationAccountChoicesAccount, true); MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.GetProfile(ConfigSettings.RegistrationSecurityEntityId); mClientChoiceState.IsDirty = false; mClientChoiceState[MClientChoices.AccountName] = mAccountProfileToSave.Account; mClientChoiceState[MClientChoices.SecurityEntityId] = mSecurityEntityProfile.Id.ToString(CultureInfo.InvariantCulture); mClientChoiceState[MClientChoices.SecurityEntityName] = mSecurityEntityProfile.Name; try { AccountUtility.Save(mAccountProfileToSave, mSaveRoles, mSaveGroups, mSecurityEntityProfile); ClientChoicesUtility.Save(mClientChoiceState, false); AccountUtility.SetPrincipal(mAccountProfileToSave); } catch (Exception ex) { mLog.Error(ex); throw; } return(mAccountProfileToSave); }
protected void Page_Load(object sender, EventArgs e) { MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); int mSecurityId = int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId]); dropSecurityEntities.DataSource = SecurityEntityUtility.GetValidSecurityEntities(mAccountProfile.Account, mSecurityId, mAccountProfile.IsSystemAdmin); dropSecurityEntities.DataValueField = "SE_SEQ_ID"; dropSecurityEntities.DataTextField = "NAME"; dropSecurityEntities.DataBind(); NameValuePairUtility.SetDropSelection(dropSecurityEntities, mSecurityId.ToString()); }
protected void Page_Load(object sender, EventArgs e) { string mAction = GWWebHelper.GetQueryValue(Request, "action"); if (!String.IsNullOrEmpty(mAction)) { MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); MFunctionProfile mFunctionProfile = FunctionUtility.GetProfile(mAction); MSecurityInfo mSecurityInfo = new MSecurityInfo(mFunctionProfile, mAccountProfile); SearchControl.ShowAddLink = mSecurityInfo.MayAdd; } }
/// <summary> /// Retruns a collection of MAccountProfiles given an MAccountProfile and the current SecurityEntitySeqID /// </summary> /// <param name="profile">MAccountProfile</param> /// <remarks>If the Profiles.IsSysAdmin is true then all accounts will be returned</remarks> public static Collection <MAccountProfile> GetAccounts(MAccountProfile profile) { // was thinking of adding cache here but // when you think of it it's not needed // account information needs to come from // the db to help ensure passwords are correct and what not. // besides which a list of accounts is only necessary // when editing an account and it that case // what accounts that are returned are dependend on the requesting account.IsSysAdmin bit. BAccounts mBAccount = new BAccounts(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement); return(mBAccount.GetAccounts(profile)); }
protected void Page_Load(object sender, EventArgs e) { int mSecurityEntityID = SecurityEntityUtility.DefaultProfile().Id; MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); if (mAccountProfile != null) { mSecurityEntityID = int.Parse(ClientChoicesUtility.GetClientChoicesState(AccountUtility.CurrentProfile().Account)[MClientChoices.SecurityEntityId].ToString()); } MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.GetProfile(mSecurityEntityID); formStyles.Attributes["href"] = GWWebHelper.RootSite + "/Content/FormStyles/" + mSecurityEntityProfile.Style + ".css"; }
public IHttpActionResult RequestChange(string account) { string mRetVal = string.Empty; MAccountProfile mProfile = AccountUtility.GetProfile(account); MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile(); MMessageProfile mMessageProfile = MessageUtility.GetProfile("Request Password Reset UI"); mRetVal = mMessageProfile.Body; string clearTextAccount = string.Empty; Logger mLog = Logger.Instance(); if (mProfile != null) { MAccountProfile mAccountProfile = mProfile; mAccountProfile.FailedAttempts = 0; mAccountProfile.Status = 4; mAccountProfile.Password = CryptoUtility.Encrypt(GWWebHelper.GetNewGuid, mSecurityEntityProfile.EncryptionType); mAccountProfile.UpdatedBy = AccountUtility.GetProfile("anonymous").Id; mAccountProfile.UpdatedDate = DateTime.Now; clearTextAccount = CryptoUtility.Decrypt(mProfile.Password, mSecurityEntityProfile.EncryptionType); try { mMessageProfile = MessageUtility.GetProfile("RequestNewPassword"); MRequestNewPassword mRequestNewPassword = new MRequestNewPassword(mMessageProfile); mRequestNewPassword.AccountName = HttpUtility.UrlEncode(CryptoUtility.Encrypt(mProfile.Account, mSecurityEntityProfile.EncryptionType)); mRequestNewPassword.FullName = mProfile.FirstName + " " + mProfile.LastName; mRequestNewPassword.Password = HttpUtility.UrlEncode(mProfile.Password); mRequestNewPassword.Server = GWWebHelper.RootSite; mProfile = AccountUtility.Save(mProfile, false, false); NotifyUtility.SendMail(mRequestNewPassword, mProfile); mLog.Debug("Reset password for account " + clearTextAccount); } catch (SmtpException ex) { Exception myException = new Exception("Could not send e-mail." + ex.Message); mLog.Error(myException); mMessageProfile = (MMessageProfile)MessageUtility.GetProfile("PasswordSendMailError"); mRetVal = mMessageProfile.Body; } catch (Exception ex) { Exception mException = new Exception("Could not set account details." + ex.Message); mLog.Error(mException); mMessageProfile = (MMessageProfile)MessageUtility.GetProfile("ErrorAccountDetails"); mRetVal = mMessageProfile.Body; } } return(Ok(mRetVal)); }
/// <summary> /// Returns Account model based given the acccount name /// </summary> /// <param name="account">String</param> /// <returns>MAccountProfile</returns> /// <remarks></remarks> /// <example> This sample shows how to create an instance of the class. /// <code language="VB.NET"> /// <![CDATA[ /// Dim mBll as new BAccounts(mySecurityEntityProfile) /// Dim mMAccountProfile as MAccountProfile = mbill.GetAccountProfile("Tester") /// ]]> /// </code> /// <code language="C#"> /// <![CDATA[ /// BAccounts mBll = new BAccounts(mySecurityEntityProfile); /// MAccountProfile mMAccountProfile = mbill.GetAccountProfile("Tester"); /// ]]> /// </code> /// </example> public MAccountProfile GetProfile(string account) { MAccountProfile mRetVal = null; if (DatabaseIsOnline()) { m_DAccounts.Profile = new MAccountProfile(); m_DAccounts.Profile.Account = account; DataTable mAssignedRoles = m_DAccounts.Roles(); DataTable mAssignedGroups = m_DAccounts.Groups(); DataTable mRoles = m_DAccounts.Security(); mRetVal = new MAccountProfile(m_DAccounts.GetAccount, mAssignedRoles, mAssignedGroups, mRoles); } return(mRetVal); }
public MUIAccountChoices GetPreferences() { MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); MClientChoicesState mClientChoicesState = null; MUIAccountChoices mRetVal = null; if (mAccountProfile != null) { mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(mAccountProfile.Account.ToString(CultureInfo.InvariantCulture)); mRetVal = new MUIAccountChoices(mClientChoicesState); mRetVal.Environment = GWWebHelper.DisplayEnvironment; mRetVal.Version = GWWebHelper.Version; mRetVal.FrameWorkVersion = GWWebHelper.FrameworkVersion; } return(mRetVal); }
protected void Page_Load(object sender, EventArgs e) { SearchControl.ShowAddLink = false; MDirectoryProfile mDirectoryProfile = DirectoryUtility.GetProfile(FunctionUtility.CurrentProfile().Id); String mLinks = FileUtility.GetDirectoryLinks("/", mDirectoryProfile.FunctionSeqId); directorySelector.InnerHtml = mLinks; MFunctionProfile mFunctionProfile = FunctionUtility.CurrentProfile(); MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); MSecurityInfo mSI = new MSecurityInfo(mFunctionProfile, mAccountProfile); UploadControl.Visible = mSI.MayAdd; tdNewDirectory.Visible = mSI.MayAdd; SearchControl.ShowDeleteAll = mSI.MayDelete; SearchControl.ShowSelect = mSI.MayDelete; }
/// <summary> /// Retrieves the current profile. /// </summary> /// <returns>MAccountProfile</returns> /// <remarks>If context does not contain a referance to an account anonymous will be returned</remarks> public static MAccountProfile CurrentProfile() { Logger mLog = Logger.Instance(); mLog.Debug("AccountUtility::GetCurrentProfile() Started"); MAccountProfile mRetProfile = null; String mAccountName = HttpContextUserName(); if (mAccountName.Trim() == s_AnonymousAccount) { if (HttpContext.Current.Cache != null) { mRetProfile = (MAccountProfile)(HttpContext.Current.Cache[s_CachedAnonymousAccount]); if (mRetProfile == null) { mRetProfile = GetProfile(mAccountName); CacheController.AddToCacheDependency(s_CachedAnonymousAccount, mRetProfile); } } else { mLog.Debug("AccountUtility::GetCurrentProfile() No cache available"); } } if (mRetProfile == null) { if (HttpContext.Current.Session != null) { mRetProfile = (MAccountProfile)HttpContext.Current.Session[mAccountName + "_Session"]; if (mRetProfile == null) { mRetProfile = GetProfile(mAccountName); if (mRetProfile != null) { HttpContext.Current.Session[mAccountName + "_Session"] = mRetProfile; } } } else { mLog.Debug("AccountUtility::GetCurrentProfile() No Session available"); mRetProfile = GetProfile(mAccountName); } } mLog.Debug("AccountUtility::GetCurrentProfile() Done"); return(mRetProfile); }
protected void Page_Load(object sender, EventArgs e) { String mAction = ClientChoicesState[MClientChoices.Action]; MFunctionProfile mFunctionProfile = FunctionUtility.GetProfile(mAction); MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); MSecurityInfo mSecurityInfo = new MSecurityInfo(mFunctionProfile, mAccountProfile); if (mSecurityInfo.MayView) { String mScript = "<script type='text/javascript' language='javascript'>window.location.hash = '?Action=" + mAction + "'</script>"; Page.ClientScript.RegisterStartupScript(this.GetType(), "", mScript); } else { Response.Write("Your favorite is not available. Please ensure that you have chosen the correct " + ConfigSettings.SecurityEntityTranslation); } }
public bool MoveMenu(int functionSeqId, string direction) { bool mRetVal = false; MFunctionProfile mProfile = FunctionUtility.GetProfile(functionSeqId); MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); DirectionType mDirection; Enum.TryParse(direction, out mDirection); if (direction == "up") { FunctionUtility.Move(mProfile, DirectionType.Up, mAccountProfile.Id, DateTime.Now); } else { FunctionUtility.Move(mProfile, DirectionType.Down, mAccountProfile.Id, DateTime.Now); } return(mRetVal); }
/// <summary> /// Inserts or updates account information /// </summary> /// <param name="profile">MAccountProfile</param> /// <param name="saveRoles">Boolean</param> /// <param name="saveGroups">Boolean</param> /// <param name="securityEntityProfile">MSecurityEntityProfile</param> /// <remarks>Changes will be reflected in the profile passed as a reference.</remarks> public static MAccountProfile Save(MAccountProfile profile, bool saveRoles, bool saveGroups, MSecurityEntityProfile securityEntityProfile) { if (profile == null) { throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in VB) or empty!"); } if (securityEntityProfile == null) { throw new ArgumentNullException("securityEntityProfile", "securityEntityProfile cannot be a null reference (Nothing in VB) or empty!"); } BAccounts mBAccount = new BAccounts(securityEntityProfile, ConfigSettings.CentralManagement); mBAccount.Save(profile, saveRoles, saveGroups); if (profile.Id == CurrentProfile().Id) { RemoveInMemoryInformation(true); } return(profile); }
public IHttpActionResult DeleteNameValuePairDetail(UINVPDetailProfile uiProfile) { string mRetVal = false.ToString(); String mAction = GWWebHelper.GetQueryValue(HttpContext.Current.Request, "Action"); int mEditId = int.Parse(HttpContext.Current.Items["EditId"].ToString()); MAccountProfile mUpdatingAccount = AccountUtility.CurrentProfile(); MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(mAction), mUpdatingAccount); Logger mLog = Logger.Instance(); if (mEditId != uiProfile.NVP_SEQ_DET_ID) { Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!"); mLog.Error(mError); return(this.InternalServerError(mError)); } if (!mSecurityInfo.MayDelete) { Exception mError = new Exception("The account (" + mUpdatingAccount.Account + ") being used does not have the correct permissions to delete"); mLog.Error(mError); return(this.InternalServerError(mError)); } try { MNameValuePairDetail mProfile = new MNameValuePairDetail(); mProfile.NameValuePairSeqId = uiProfile.NVP_SEQ_ID; mProfile.Id = uiProfile.NVP_SEQ_DET_ID; mProfile.UpdatedBy = mUpdatingAccount.Id; mProfile.UpdatedDate = DateTime.Now; mProfile.SortOrder = uiProfile.SortOrder; mProfile.Text = uiProfile.Text; mProfile.Value = uiProfile.Value; mProfile.Status = uiProfile.Status; NameValuePairUtility.DeleteDetail(mProfile); } catch (Exception ex) { mLog.Error(ex); throw; } return(this.Ok(mRetVal)); }
/// <summary> /// Performs either insert or update of an MAcountProfile, and re-populates the MAccountProfile with DB information. /// </summary> /// <param name="profile">MAccountProfile</param> /// <param name="saveRoles">MAccountProfile</param> /// <param name="saveGroups">MAccountProfile</param> /// <remarks> /// Updates the model object with information from the database<br></br> /// For example if you are creating a new account the ID will be sent into<br></br> /// this method as -1, after the call to this method the ID will from the database /// </remarks> /// <example> This sample shows how to create an instance of the class. /// <code language="VB.NET"> /// <![CDATA[ /// Dim mMAccountProfile as new MAccountProfile() /// mMAccountProfile.Account = "Account" /// mMAccountProfile.Password = CryptoUtility.Encrypt("my password", ConfigSettings.EncryptionType) /// mMAccountProfile.UpdatedBy = 1 /// mMAccountProfile.UpdagedDate = Date.Now /// Dim mBll as new BAccounts(mySecurityEntityProfile) /// Dim mSaveRoles As Boolean = False; /// Dim mSaveGroups As Boolean = False; /// mMAccountProfile = mbill.SaveAccount(mMAccountProfile, mSaveRoles, mSaveGroups) /// ]]> /// </code> /// <code language="C#"> /// MAccountProfile mMAccountProfile = new mMAccountProfile(); /// mMAccountProfile.Account = "Account"; /// mMAccountProfile.Password = CryptoUtility.Encrypt("my password", ConfigSettings.EncryptionType); /// mMAccountProfile.UpdatedBy = 1; /// mMAccountProfile.UpdagedDate = Date.Now(); /// BAccounts mBll = new BAccounts(mySecurityEntityProfile); /// bool mSaveRoles = false; /// bool mSaveGroups = true; /// mMAccountProfile = mbill.SaveAccount(ref mMAccountProfile, mSaveRoles, mSaveGroups); /// </code> /// </example> public void Save(MAccountProfile profile, bool saveRoles, bool saveGroups) { if (profile == null) { throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in Visual Basic)!"); } m_DAccounts.Profile = profile; if (DatabaseIsOnline()) { profile.Id = m_DAccounts.Save(); if (saveGroups) { m_DAccounts.SaveGroups(); } if (saveRoles) { m_DAccounts.SaveRoles(); } profile = new MAccountProfile(m_DAccounts.GetAccount, m_DAccounts.Roles(), m_DAccounts.Groups(), m_DAccounts.Security()); } }
private MAccountProfile populateAccountProfile(UIAccountProfile uiProfile, MAccountProfile accountProfile) { if (accountProfile == null) { accountProfile = new MAccountProfile(); } accountProfile.Account = uiProfile.Account; accountProfile.Email = uiProfile.EMail; accountProfile.EnableNotifications = uiProfile.EnableNotifications; accountProfile.FirstName = uiProfile.FirstName; if (AccountUtility.CurrentProfile().IsSystemAdmin) { accountProfile.IsSystemAdmin = uiProfile.IsSystemAdmin; } accountProfile.LastName = uiProfile.LastName; accountProfile.Location = uiProfile.Location; accountProfile.MiddleName = uiProfile.MiddleName; accountProfile.Name = uiProfile.Account; accountProfile.PreferredName = uiProfile.PreferredName; accountProfile.Status = uiProfile.Status; accountProfile.TimeZone = uiProfile.TimeZone; return(accountProfile); }
/// <summary> /// Sends the mail. /// </summary> /// <param name="messageProfile">Object implementing IMessageProfile</param> /// <param name="accountProfile">The account profile.</param> public static void SendMail(IMessageProfile messageProfile, MAccountProfile accountProfile) { if (!canSendMail()) { return; } string mFrom = ConfigSettings.SmtpFrom; if (mFrom.Trim().Length == 0) { Logger log = Logger.Instance(); log.Error("SMTP From not set in the WEB.CONFIG file"); return; } SmtpClient mailClient = getSmtpClient(); MailMessage mailMessage = new MailMessage(new MailAddress(mFrom), new MailAddress(accountProfile.Email)); mailMessage.Subject = messageProfile.Title; messageProfile.FormatBody(); mailMessage.Body = messageProfile.Body; mailMessage.IsBodyHtml = messageProfile.FormatAsHtml; mailClient.Send(mailMessage); }
/// <summary> /// Retrieves an account profile given the account /// </summary> /// <param name="account">String</param> /// <returns>a populated MAccountProfile</returns> public static MAccountProfile GetProfile(String account) { BAccounts mBAccount = new BAccounts(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement); MAccountProfile mRetVal = null; try { mRetVal = mBAccount.GetProfile(account); } catch (InvalidOperationException) { String mMSG = "Count not find account: " + account + " in the database"; Logger mLog = Logger.Instance(); mLog.Error(mMSG); } catch (IndexOutOfRangeException) { String mMSG = "Count not find account: " + account + " in the database"; Logger mLog = Logger.Instance(); mLog.Error(mMSG); } return(mRetVal); }
protected void Page_Load(object sender, EventArgs e) { MAccountProfile updatingAccount = null; MGroupProfile mGroupProfile = GroupUtility.GetProfile(int.Parse(HttpContext.Current.Request["GroupSeqId"])); txtEditID.Text = mGroupProfile.Id.ToString(); litGroup.Text = mGroupProfile.Name; HttpContext.Current.Session.Add("EditId", mGroupProfile.Id); updatingAccount = AccountUtility.CurrentProfile(); DataView myDataView = RoleUtility.GetAllRolesBySecurityEntity(int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId].ToString())).DefaultView; if (!updatingAccount.IsSystemAdmin) { String rowFilter = "IS_SYSTEM <> 1 AND IS_SYSTEM_ONLY <> 1"; myDataView.RowFilter = rowFilter; } try { MGroupProfile myGroupProfile = new MGroupProfile(); myGroupProfile = GroupUtility.GetProfile(int.Parse(txtEditID.Text.ToString())); litGroup.Text = myGroupProfile.Name; MGroupRoles mProfile = new MGroupRoles(); mProfile.SecurityEntityId = int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId].ToString()); mProfile.GroupSeqId = int.Parse(txtEditID.Text.ToString()); ctlMembers.SelectedItems = GroupUtility.GetSelectedRoles(mProfile); } catch (Exception ex) { Logger log = Logger.Instance(); log.Debug(ex); } ctlMembers.DataSource = myDataView; ctlMembers.DataField = "Name"; ctlMembers.DataBind(); }
public IHttpActionResult SaveMembers(UIAccounts roleAccounts) { string mRetVal = "false"; Logger mLog = Logger.Instance(); MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditRoles", true)), AccountUtility.CurrentProfile()); if (!mSecurityInfo.MayEdit) { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add"); mLog.Error(mError); return(this.InternalServerError(mError)); } if (HttpContext.Current.Items["EditId"] == null) { Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!"); mLog.Error(mError); return(this.InternalServerError(mError)); } MAccountProfile accountProfile = AccountUtility.CurrentProfile(); MClientChoicesState mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(accountProfile.Account); bool success = RoleUtility.UpdateAllAccountsForRole(roleAccounts.SeqId, int.Parse(mClientChoicesState[MClientChoices.SecurityEntityId]), roleAccounts.Accounts, accountProfile.Id); return(Ok(mRetVal)); }
protected void Page_Load(object sender, EventArgs e) { btnSave.Visible = false; m_Action = GWWebHelper.GetQueryValue(Request, "Action"); if (!String.IsNullOrEmpty(Request.QueryString["AccountSeqID"])) { int mAccountSeqID = int.Parse(Request.QueryString["AccountSeqID"].ToString()); if (mAccountSeqID != -1) { m_Profile = AccountUtility.GetProfile(mAccountSeqID); } else { m_Profile = new MAccountProfile(); } } else { m_Profile = AccountUtility.CurrentProfile(); btnSave.Visible = true; hdnCanSaveRoles.Value = false.ToString(); hdnCanSaveGroups.Value = false.ToString(); hdnCanSaveStatus.Value = false.ToString(); tdStatus.Style.Add("display", "none"); dropStatus.Style.Add("display", "none"); if (m_Action.ToUpper(CultureInfo.InvariantCulture).IndexOf("REGISTER") > -1) { m_Profile = new MAccountProfile(); trAccount.Visible = false; tabsDerivedRoles.Visible = false; derivedRolesTab.Visible = false; } } HttpContext.Current.Session.Add("EditId", m_Profile.Id); populatePage(); }
/// <summary> /// Inserts or updates account information /// </summary> /// <param name="profile">MAccountProfile</param> /// <param name="saveRoles">Boolean</param> /// <param name="saveGroups">Boolean</param> /// <remarks>Changes will be reflected in the profile passed as a reference.</remarks> public static MAccountProfile Save(MAccountProfile profile, bool saveRoles, bool saveGroups) { MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile(); return(Save(profile, saveRoles, saveGroups, mSecurityEntityProfile)); }
/// <summary> /// Sets the current profile. /// </summary> /// <param name="profile">The profile.</param> public static void SetCurrentProfile(MAccountProfile profile) { HttpContext.Current.Items.Add("CurrentAccount", profile); }