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); }
//private static Collection<MMessageProfile> AllMessages() //{ // DataTable mDataTable = new DataTable(); // Collection<MMessageProfile> mMessagesCollection = null; // BMessages mBMessages = new BMessages(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement); // DataSet myDataSet = new DataSet(); // try // { // int mySecurityEntity = ClientChoicesUtility.SelectedSecurityEntity(); // mMessagesCollection = mBMessages.GetMessages(mySecurityEntity); // } // catch (Exception ex) // { // throw ex; // } // finally // { // if ((myDataSet != null)) // { // myDataSet.Dispose(); // myDataSet = null; // } // if ((mDataTable != null)) // { // mDataTable.Dispose(); // mDataTable = null; // } // if ((mBMessages != null)) // { // mBMessages = null; // } // } // return mMessagesCollection; //} /// <summary> /// Saves the specified profile. /// </summary> /// <param name="profile">The profile.</param> public static void Save(MMessageProfile profile) { BMessages mBMessages = new BMessages(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement); mBMessages.Save(profile); RemoveCachedMessagesCollection(); }
/// <summary> /// Adds the message. /// </summary> /// <param name="profile">The message profile.</param> /// <returns>System.Int32.</returns> public void Save(MMessageProfile profile) { if (profile == null) { throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in Visual Basic)!!"); } if (DatabaseIsOnline()) { m_DMessages.Profile = profile; m_DMessages.Save(); } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString["messageSeqId"])) { int mMessageSeqId = int.Parse(Request.QueryString["messageSeqId"].ToString()); MMessageProfile mProfile = new MMessageProfile(); if (mMessageSeqId > -1) { mProfile = MessageUtility.GetProfile(mMessageSeqId); } HttpContext.Current.Session.Add("EditId", mProfile.Id); populatePage(mProfile); } }
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> /// Gets the message profile by id. /// </summary> /// <param name="messageSeqId">The Message Sequence ID.</param> /// <returns>MMessageProfile.</returns> public static MMessageProfile GetProfile(int messageSeqId) { var mResult = from mProfile in Messages() where mProfile.Id == messageSeqId select mProfile; MMessageProfile mRetVal = null; try { mRetVal = mResult.First(); } catch (InvalidOperationException ex) { Logger mLog = Logger.Instance(); mLog.Error(ex); mRetVal = null; } return(mRetVal); }
public string SetSelectedSecurityEntity(int selectedSecurityEntityId) { MSecurityEntityProfile targetSEProfile = SecurityEntityUtility.GetProfile(selectedSecurityEntityId); MSecurityEntityProfile currentSEProfile = SecurityEntityUtility.CurrentProfile(); MClientChoicesState mClientChoicesState = (MClientChoicesState)HttpContext.Current.Cache[MClientChoices.SessionName]; MMessageProfile mMessageProfile = null; try { if (!ConfigSettings.CentralManagement) { //SecurityEntityUtility.SetSessionSecurityEntity(targetSEProfile) mClientChoicesState[MClientChoices.SecurityEntityId] = targetSEProfile.Id.ToString(CultureInfo.InvariantCulture); mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name; } else { if (currentSEProfile.ConnectionString == targetSEProfile.ConnectionString) { mClientChoicesState[MClientChoices.SecurityEntityId] = targetSEProfile.Id.ToString(CultureInfo.InvariantCulture); mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name; } else { mClientChoicesState[MClientChoices.SecurityEntityId] = ConfigSettings.DefaultSecurityEntityId.ToString(CultureInfo.InvariantCulture); mClientChoicesState[MClientChoices.SecurityEntityName] = "System"; } } ClientChoicesUtility.Save(mClientChoicesState); AccountUtility.RemoveInMemoryInformation(true); mMessageProfile = MessageUtility.GetProfile("ChangedSelectedSecurityEntity"); } catch (Exception ex) { MMessageProfile myMessageProfile = new MMessageProfile(); Logger mLog = Logger.Instance(); mMessageProfile = MessageUtility.GetProfile("NoDataFound"); Exception myEx = new Exception("SelectSecurityEntity:: reported an error.", ex); mLog.Error(myEx); } // update all of your in memory information return(mMessageProfile.Body); }
public IHttpActionResult SelectSecurityEntity([FromUri] int selectedSecurityEntityId) { MSecurityEntityProfile targetSEProfile = SecurityEntityUtility.GetProfile(selectedSecurityEntityId); MSecurityEntityProfile currentSEProfile = SecurityEntityUtility.CurrentProfile(); MClientChoicesState mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(AccountUtility.CurrentProfile().Account); MMessageProfile mMessageProfile = null; try { if (!ConfigSettings.CentralManagement) { mClientChoicesState[MClientChoices.SecurityEntityId] = targetSEProfile.Id.ToString(); mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name; } else { if (currentSEProfile.ConnectionString == targetSEProfile.ConnectionString) { mClientChoicesState[MClientChoices.SecurityEntityId] = targetSEProfile.Id.ToString(); mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name; } else { mClientChoicesState[MClientChoices.SecurityEntityId] = ConfigSettings.DefaultSecurityEntityId.ToString(); mClientChoicesState[MClientChoices.SecurityEntityName] = "System"; } } MMessageProfile myMessageProfile = new MMessageProfile(); // update all of your in memory information AccountUtility.RemoveInMemoryInformation(true); ClientChoicesUtility.Save(mClientChoicesState); mMessageProfile = MessageUtility.GetProfile("ChangedSelectedSecurityEntity"); } catch (Exception ex) { Logger mLog = Logger.Instance(); mMessageProfile = MessageUtility.GetProfile("NoDataFound"); Exception myEx = new Exception("SelectSecurityEntity:: reported an error.", ex); mLog.Error(myEx); } // refresh the view return(Ok(mMessageProfile.Body)); }
/// <summary> /// Gets the name of the message profile by. /// </summary> /// <param name="name">The name.</param> /// <returns>MMessageProfile.</returns> public static MMessageProfile GetProfile(string name) { var mResult = from mProfile in Messages() where mProfile.Name.ToLower(CultureInfo.CurrentCulture) == name.ToLower(CultureInfo.CurrentCulture) select mProfile; MMessageProfile mRetVal = new MMessageProfile(); try { mRetVal = mResult.First(); } catch (InvalidOperationException) { String mMSG = "Count not find function: " + name + " in the database"; Logger mLog = Logger.Instance(); mLog.Error(mMSG); mRetVal = null; } return(mRetVal); }
private void populatePage(MMessageProfile profile) { txtMessageSeqID.Value = profile.Id.ToString(); lblName.Text = profile.Name; txtName.Text = profile.Name; txtDescription.Text = profile.Description; txtMessageTitle.Text = profile.Title; txtMessageBody.Text = profile.Body; chkFormatAsHTML.Checked = profile.FormatAsHtml; if (profile.Id == -1) { txtName.Style.Add("display", "inline"); lblName.Visible = false; } IMessageProfile mProfile = default(IMessageProfile); try { mProfile = (IMessageProfile)ObjectFactory.Create("GrowthWare.Framework", "GrowthWare.Framework.Model.Profiles", "M" + profile.Name); } catch (Exception ex) { Logger mLog = Logger.Instance(); mLog.Debug(ex); } finally { if (mProfile == null) { txtTags.Text = profile.GetTags(Environment.NewLine); } else { txtTags.Text = mProfile.GetTags(Environment.NewLine); } } }
public IHttpActionResult Save(UIMessageProfile profile) { if (profile == null) { throw new ArgumentNullException("profile", "uiProfile cannot be a null reference (Nothing in Visual Basic)!"); } string mRetVal = "False"; MAccountProfile mCurrentAccountProfile = AccountUtility.CurrentProfile(); Logger mLog = Logger.Instance(); MMessageProfile mProfileToSave = populateProfile(profile, mCurrentAccountProfile); if (HttpContext.Current.Items["EditId"] != null) { int mEditId = int.Parse(HttpContext.Current.Items["EditId"].ToString()); if (mEditId == profile.Id) { MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditMessages", true)), AccountUtility.CurrentProfile()); if (mSecurityInfo != null) { if (mEditId != 1) { if (mSecurityInfo.MayEdit) { MessageUtility.Save(mProfileToSave); mLog.Debug("Saved message " + profile.Name + " by " + mCurrentAccountProfile.Account); mRetVal = "true"; } else { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to edit"); mLog.Error(mError); return(this.InternalServerError(mError)); } } else { if (mSecurityInfo.MayAdd) { MessageUtility.Save(mProfileToSave); mLog.Debug("Added message " + profile.Name + " by " + mCurrentAccountProfile.Account); mRetVal = "true"; } else { 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)); } } } else { Exception mError = new Exception("Security Info is not in context nothing has been saved!!!!"); mLog.Error(mError); return(this.InternalServerError(mError)); } } else { 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)); } } return(Ok(mRetVal)); }
public IHttpActionResult ChangePassword(MChangePassword mChangePassword) { if (mChangePassword == null) { throw new ArgumentNullException("mChangePassword", "mChangePassword cannot be a null reference (Nothing in Visual Basic)!"); } MMessageProfile mMessageProfile = new MMessageProfile(); MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile(); MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); string mCurrentPassword = ""; mMessageProfile = MessageUtility.GetProfile("SuccessChangePassword"); try { mCurrentPassword = CryptoUtility.Decrypt(mAccountProfile.Password, mSecurityEntityProfile.EncryptionType); } catch (Exception) { mCurrentPassword = mAccountProfile.Password; } if (mAccountProfile.Status != (int)SystemStatus.ChangePassword) { if (mChangePassword.OldPassword != mCurrentPassword) { mMessageProfile = MessageUtility.GetProfile("PasswordNotMatched"); } else { mAccountProfile.PasswordLastSet = System.DateTime.Now; mAccountProfile.Status = (int)SystemStatus.Active; mAccountProfile.FailedAttempts = 0; mAccountProfile.Password = CryptoUtility.Encrypt(mChangePassword.NewPassword.Trim(), mSecurityEntityProfile.EncryptionType); try { AccountUtility.Save(mAccountProfile, false, false); } catch (Exception) { mMessageProfile = MessageUtility.GetProfile("UnSuccessChangePassword"); } } } else { try { var _with2 = mAccountProfile; _with2.PasswordLastSet = System.DateTime.Now; _with2.Status = (int)SystemStatus.Active; _with2.FailedAttempts = 0; _with2.Password = CryptoUtility.Encrypt(mChangePassword.NewPassword.Trim(), mSecurityEntityProfile.EncryptionType); AccountUtility.Save(mAccountProfile, false, false); } catch (Exception) { mMessageProfile = MessageUtility.GetProfile("UnSuccessChangePassword"); } } AccountUtility.RemoveInMemoryInformation(true); return(Ok(mMessageProfile.Body)); }
public IHttpActionResult Logon(LogonInfo jsonData) { if (jsonData == null) { throw new ArgumentNullException("jsonData", "jsonData cannot be a null reference (Nothing in Visual Basic)!"); } if (string.IsNullOrEmpty(jsonData.Account)) { throw new NullReferenceException("jsonData.Account cannot be a null reference (Nothing in Visual Basic)!"); } if (string.IsNullOrEmpty(jsonData.Password)) { throw new NullReferenceException("jsonData.Password cannot be a null reference (Nothing in Visual Basic)!"); } string mRetVal = "false"; bool mDomainPassed = false; if (jsonData.Account.Contains("\\")) { mDomainPassed = true; } if (ConfigSettings.AuthenticationType.ToUpper() == "LDAP" & !mDomainPassed) { jsonData.Account = ConfigSettings.LdapDomain + "\\" + jsonData.Account; } if (AccountUtility.Authenticated(jsonData.Account, jsonData.Password)) { MAccountProfile mAccountProfile = AccountUtility.GetProfile(jsonData.Account); mAccountProfile.LastLogOn = DateTime.Now; if (mAccountProfile.Status == Convert.ToInt32(SystemStatus.Disabled)) { mAccountProfile.Status = Convert.ToInt32(SystemStatus.Active); } mAccountProfile.FailedAttempts = 0; AccountUtility.Save(mAccountProfile, false, false); AccountUtility.SetPrincipal(mAccountProfile); mRetVal = "true"; } else { MAccountProfile mAccountProfile = AccountUtility.GetProfile(jsonData.Account); if (mAccountProfile != null) { if (mAccountProfile.Account.ToUpper(new CultureInfo("en-US", false)) == jsonData.Account.ToUpper(new CultureInfo("en-US", false))) { if (ConfigSettings.AuthenticationType.ToUpper() == "INTERNAL") { if (mAccountProfile.Status != Convert.ToInt32(SystemStatus.Disabled) || mAccountProfile.Status != Convert.ToInt32(SystemStatus.Inactive)) { mRetVal = "Request"; } else { MMessageProfile mMessageProfile = MessageUtility.GetProfile("DisabledAccount"); if (mMessageProfile != null) { mRetVal = mMessageProfile.Body; } } } else { MMessageProfile mMessageProfile = MessageUtility.GetProfile("Logon Error"); if (mMessageProfile != null) { mRetVal = mMessageProfile.Body; } } } } else { MMessageProfile mMessageProfile = MessageUtility.GetProfile("Logon Error"); if (mMessageProfile != null) { mRetVal = mMessageProfile.Body; } } } return(Ok(mRetVal)); }