/// <summary> /// Gets the NVP. /// </summary> /// <param name="nameValuePairSeqId">The NVP seq ID.</param> /// <returns>MNameValuePair.</returns> public static MNameValuePair GetNameValuePair(int nameValuePairSeqId) { MSecurityEntityProfile mSecurityProfile = SecurityEntityUtility.CurrentProfile(); BNameValuePairs myNameValuePair = new BNameValuePairs(mSecurityProfile); return(new MNameValuePair(myNameValuePair.GetNameValuePair(nameValuePairSeqId))); }
int IDSecurityEntity.Save(MSecurityEntityProfile profile) { if (profile == null) { throw new ArgumentNullException("profile", "profile can not be nothing"); } SqlParameter mPrimaryKey = GetSqlParameter("@P_PRIMARY_KEY", null, ParameterDirection.Output); mPrimaryKey.Size = 10; string mStoredProcedure = "ZGWSecurity.Set_Security_Entity"; SqlParameter[] mParameters = { new SqlParameter("@P_Security_Entity_SeqID", profile.Id), new SqlParameter("@P_NAME", profile.Name), new SqlParameter("@P_DESCRIPTION", profile.Description), new SqlParameter("@P_URL", profile.Url), new SqlParameter("@P_Status_SeqID", profile.StatusSeqId), new SqlParameter("@P_DAL", profile.DataAccessLayer), new SqlParameter("@P_DAL_Name", profile.DataAccessLayerAssemblyName), new SqlParameter("@P_DAL_NAME_SPACE", profile.DataAccessLayerNamespace), new SqlParameter("@P_DAL_STRING", profile.ConnectionString), new SqlParameter("@P_SKIN", profile.Skin), new SqlParameter("@P_STYLE", profile.Style), new SqlParameter("@P_ENCRYPTION_TYPE", profile.EncryptionType), new SqlParameter("@P_Parent_Security_Entity_SeqID", profile.ParentSeqId), new SqlParameter("@P_Added_Updated_By", GetAddedUpdatedBy(profile)), mPrimaryKey }; base.ExecuteNonQuery(mStoredProcedure, mParameters); profile.Id = int.Parse(GetParameterValue("@P_PRIMARY_KEY", mParameters).ToString(), CultureInfo.InvariantCulture); return(profile.Id); }
/// <summary> /// GetNVPs will return all Name Value Pairs avalible for a given account /// </summary> /// <param name="accountId">The account the list of NVPs are for</param> /// <returns>Returns a data table of name value pairs for a given account</returns> /// <remarks></remarks> public static DataTable GetNameValuePairs(int accountId) { MSecurityEntityProfile mSecurityProfile = SecurityEntityUtility.CurrentProfile(); BNameValuePairs myNameValuePair = new BNameValuePairs(mSecurityProfile); return(myNameValuePair.GetAllNameValuePair(accountId)); }
/// <summary> /// Returns a collection of MSecurityEntityProfile objects for the given. /// </summary> /// <returns> /// Collection of MSecurityEntityProfile /// </returns> /// <remarks></remarks> public Collection <MSecurityEntityProfile> SecurityEntities() { Collection <MSecurityEntityProfile> mRetVal = new Collection <MSecurityEntityProfile>(); DataTable mDataTable = null; try { if (ConfigSettings.DBStatus.ToUpper(CultureInfo.InvariantCulture) == "ONLINE") { mDataTable = m_DSecurityEntity.GetSecurityEntities(); foreach (DataRow item in mDataTable.Rows) { MSecurityEntityProfile mProfile = new MSecurityEntityProfile(item); mRetVal.Add(mProfile); } } } catch (Exception) { throw; } finally { if (mDataTable != null) { mDataTable.Dispose(); } } return(mRetVal); }
/// <summary> /// Retrieves the selected groups for the name value pair /// </summary> /// <param name="nameValuePairSeqId">The primary key of the name value pair</param> /// <returns>String array list of groups</returns> /// <remarks></remarks> public static string[] GetSelectedGroups(int nameValuePairSeqId) { MSecurityEntityProfile mSecurityProfile = SecurityEntityUtility.CurrentProfile(); BNameValuePairs myNameValuePair = new BNameValuePairs(mSecurityProfile); DataTable myDataTable = myNameValuePair.GetNameValuePairGroups(nameValuePairSeqId); return(GetStringArrayList(myDataTable, "Groups")); }
/// <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); }
/// <summary> /// Searches the specified search criteria. /// </summary> /// <param name="searchCriteria"></param> /// <returns></returns> public static DataTable Search(MSearchCriteria searchCriteria) { if (searchCriteria == null) { throw new ArgumentNullException("searchCriteria", "searchCriteria cannot be a null reference (Nothing in Visual Basic)!"); } MSecurityEntityProfile mSecurityProfile = SecurityEntityUtility.CurrentProfile(); BNameValuePairs mBNameValuePairs = new BNameValuePairs(mSecurityProfile); return(mBNameValuePairs.Search(searchCriteria)); }
/// <summary> /// Updates the roles. /// </summary> /// <param name="nameValuePairId">The NV p_ ID.</param> /// <param name="securityEntityId">The security entity ID.</param> /// <param name="commaSeparatedRoles">The comma separated roles.</param> /// <param name="nameValuePairProfile">MNameValuePair.</param> public static void UpdateRoles(int nameValuePairId, int securityEntityId, string commaSeparatedRoles, MNameValuePair nameValuePairProfile) { if (nameValuePairProfile == null) { throw new ArgumentNullException("nameValuePairProfile", "nameValuePairProfile cannot be a null reference (Nothing in Visual Basic)!"); } MSecurityEntityProfile mSecurityProfile = SecurityEntityUtility.CurrentProfile(); BNameValuePairs myNameValuePair = new BNameValuePairs(mSecurityProfile); myNameValuePair.UpdateRoles(nameValuePairId, securityEntityId, commaSeparatedRoles, nameValuePairProfile); }
public static void GetNameValuePairDetails(ref DataTable yourDataTable) { yourDataTable = (DataTable)HttpContext.Current.Cache[CachedNameValuePairDetailsTableName]; if (yourDataTable == null) { MSecurityEntityProfile mSecurityProfile = SecurityEntityUtility.CurrentProfile(); BNameValuePairs myNameValuePairDetails = new BNameValuePairs(mSecurityProfile); yourDataTable = myNameValuePairDetails.GetAllNameValuePairDetail(); CacheController.AddToCacheDependency(CachedNameValuePairDetailsTableName, yourDataTable); } }
/// <summary> /// Saves the detail. /// </summary> /// <param name="profile">The profile.</param> /// <returns>System.Int32.</returns> public static void SaveDetail(MNameValuePairDetail profile) { if (profile == null) { throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in Visual Basic)!"); } MSecurityEntityProfile mSecurityProfile = SecurityEntityUtility.CurrentProfile(); BNameValuePairs mBNameValuePairs = new BNameValuePairs(mSecurityProfile); CacheController.RemoveFromCache(CachedNameValuePairDetailsTableName); mBNameValuePairs.SaveNameValuePairDetail(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"; }
/// <summary> /// Save Function information to the database /// </summary> /// <param name="profile">MSecurityEntityProfile</param> /// <returns>Integer</returns> public int Save(MSecurityEntityProfile profile) { if (profile == null) { throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in Visual Basic)!"); } profile.Id = profile.Id; if (ConfigSettings.DBStatus.ToUpper(CultureInfo.InvariantCulture) == "ONLINE") { m_DSecurityEntity.Save(profile); } return(profile.Id); }
/// <summary> /// Creates and returns MSecurityEntityProfile populated with information from the /// configuration file. /// </summary> /// <returns>MSecurityEntityProfile</returns> public static MSecurityEntityProfile DefaultProfile() { if (s_DefaultProfile == null) { MSecurityEntityProfile mDefaultProfile = new MSecurityEntityProfile(); mDefaultProfile.Id = int.Parse(ConfigSettings.DefaultSecurityEntityId.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); mDefaultProfile.DataAccessLayer = ConfigSettings.DataAccessLayer; mDefaultProfile.DataAccessLayerNamespace = ConfigSettings.DataAccessLayerNamespace(mDefaultProfile.DataAccessLayer); mDefaultProfile.DataAccessLayerAssemblyName = ConfigSettings.DataAccessLayerAssemblyName(mDefaultProfile.DataAccessLayer); mDefaultProfile.ConnectionString = ConfigSettings.ConnectionString(mDefaultProfile.DataAccessLayer); s_DefaultProfile = mDefaultProfile; } return(s_DefaultProfile); }
/// <summary> /// Saves the specified profile. /// </summary> /// <param name="profile">The profile.</param> public static void Save(MSecurityEntityProfile profile) { try { BSecurityEntity mBSecurityEntities = new BSecurityEntity(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement); mBSecurityEntities.Save(profile); CacheController.RemoveAllCache(); } catch (DataAccessLayerException ex) { Logger mLog = Logger.Instance(); mLog.Error(ex); } }
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> /// Saves the specified profile. /// </summary> /// <param name="profile">The profile.</param> public static void Save(MDirectoryProfile profile) { if (profile == null) { throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in Visual Basic)!"); } CacheController.RemoveFromCache(s_DirectoryInfoCachedName); MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile(); Logger mLog = Logger.Instance(); try { profile.ImpersonatePassword = CryptoUtility.Decrypt(profile.ImpersonatePassword, mSecurityEntityProfile.EncryptionType); } catch (CryptoUtilityException) { profile.ImpersonatePassword = CryptoUtility.Encrypt(profile.ImpersonatePassword, mSecurityEntityProfile.EncryptionType); } try { profile.Directory = CryptoUtility.Decrypt(profile.Directory, mSecurityEntityProfile.EncryptionType); } catch (CryptoUtilityException) { profile.Directory = CryptoUtility.Encrypt(profile.Directory, mSecurityEntityProfile.EncryptionType); } try { profile.ImpersonateAccount = CryptoUtility.Decrypt(profile.ImpersonateAccount, mSecurityEntityProfile.EncryptionType); } catch (CryptoUtilityException) { profile.ImpersonateAccount = CryptoUtility.Encrypt(profile.ImpersonateAccount, mSecurityEntityProfile.EncryptionType); } BDirectories myBLL = new BDirectories(mSecurityEntityProfile, ConfigSettings.CentralManagement); try { myBLL.Save(profile); } catch (DataAccessLayerException ex) { mLog.Error(ex); throw new WebSupportException("Could not save the directory information!"); } String mCacheName = mSecurityEntityProfile.Id.ToString(CultureInfo.CurrentCulture) + "_" + s_DirectoryInfoCachedName; CacheController.RemoveFromCache(mCacheName); }
/// <summary> /// Gets the messages. /// </summary> /// <returns>Collection{MMessageProfile}.</returns> public static Collection <MMessageProfile> Messages() { MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile(); string mCacheName = MessagesUnitCachedCollectionName(mSecurityEntityProfile.Id); Collection <MMessageProfile> mMessageCollection = null; mMessageCollection = (Collection <MMessageProfile>)HttpContext.Current.Cache[mCacheName]; if (mMessageCollection == null) { BMessages mBMessages = new BMessages(mSecurityEntityProfile, ConfigSettings.CentralManagement); mMessageCollection = mBMessages.GetMessages(mSecurityEntityProfile.Id); CacheController.AddToCacheDependency(mCacheName, mMessageCollection); } return(mMessageCollection); }
/// <summary> /// Gets the directories. /// </summary> /// <returns>Collection{MDirectoryProfile}.</returns> public static Collection <MDirectoryProfile> Directories() { MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile(); BDirectories mBDirectories = new BDirectories(mSecurityEntityProfile, ConfigSettings.CentralManagement); String mCacheName = mSecurityEntityProfile.Id.ToString(CultureInfo.InvariantCulture) + "_" + s_DirectoryInfoCachedName; Collection <MDirectoryProfile> mRetVal = null; mRetVal = (Collection <MDirectoryProfile>)(HttpContext.Current.Cache[mCacheName]); if (mRetVal == null) { mRetVal = mBDirectories.Directories(); CacheController.AddToCacheDependency(mCacheName, mRetVal); } return(mRetVal); }
/// <summary> /// Retrieves all functions from the either the database or cache /// </summary> /// <returns>A Collection of MFunctinProfiles</returns> public static Collection <MFunctionProfile> Functions() { MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile(); BFunctions mBFunctions = new BFunctions(mSecurityEntityProfile, ConfigSettings.CentralManagement); String mCacheName = mSecurityEntityProfile.Id.ToString(CultureInfo.InvariantCulture) + "_Functions"; Collection <MFunctionProfile> mRetVal = null; mRetVal = (Collection <MFunctionProfile>)(HttpContext.Current.Cache[mCacheName]); if (mRetVal == null) { mRetVal = mBFunctions.GetFunctions(mSecurityEntityProfile.Id); CacheController.AddToCacheDependency(mCacheName, mRetVal); } return(mRetVal); }
/// <summary> /// Inserts or updates a name value pair given a NameValuePair profile /// </summary> /// <param name="profile">Details of the profile to added or updated</param> /// <returns>The Primary sequence ID</returns> /// <remarks></remarks> public static int Save(MNameValuePair profile) { if (profile == null) { throw new ArgumentNullException("profile", "profile cannot be a null reference (Nothing in Visual Basic)!"); } int mRetVal = -1; MSecurityEntityProfile mSecurityProfile = SecurityEntityUtility.CurrentProfile(); BNameValuePairs myNameValuePair = new BNameValuePairs(mSecurityProfile); CacheController.RemoveFromCache(CachedNameValuePairTableName); CacheController.RemoveFromCache(CachedNameValuePairDetailsTableName); mRetVal = myNameValuePair.Save(profile); return(mRetVal); }
/// <summary> /// Get a single function given it's id. /// </summary> /// <param name="securityEntitySeqId">int or Integer</param> /// <returns>MSecurityEntityProfile</returns> public static MSecurityEntityProfile GetProfile(int securityEntitySeqId) { MSecurityEntityProfile mRetVal = new MSecurityEntityProfile(); var mResult = from mProfile in Profiles() where mProfile.Id == securityEntitySeqId select mProfile; try { mRetVal = mResult.First(); } catch (NullReferenceException) { mRetVal = null; } return(mRetVal); }
/// <summary> /// Returns the current MSecurityEntityProfile from context. If one is not found in context then /// the default values from the config file will be returned. /// </summary> /// <returns>MSecurityEntityProfile</returns> public static MSecurityEntityProfile CurrentProfile() { MSecurityEntityProfile mRetProfile = null; String mAccount = AccountUtility.HttpContextUserName(); MClientChoicesState mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(mAccount); if (mClientChoicesState != null) { int mSecurityEntity = int.Parse(mClientChoicesState[MClientChoices.SecurityEntityId].ToString(), CultureInfo.InvariantCulture); mRetProfile = GetProfile(mSecurityEntity); } if (mRetProfile == null) { mRetProfile = DefaultProfile(); } return(mRetProfile); }
/// <summary> /// Get a single function given it's action. /// </summary> /// <param name="name">String</param> /// <returns>MSecurityEntityProfile</returns> public static MSecurityEntityProfile GetProfile(String name) { MSecurityEntityProfile mRetVal = new MSecurityEntityProfile(); var mResult = from mProfile in Profiles() where mProfile.Name.ToLower(CultureInfo.CurrentCulture) == name.ToLower(CultureInfo.CurrentCulture) select mProfile; try { mRetVal = mResult.First(); } catch (NullReferenceException) { mRetVal = null; } return(mRetVal); }
/// <summary> /// Save the client choices to the database. /// </summary> /// <param name="clientChoicesState">MClientChoicesState</param> /// <param name="updateContext">bool</param> /// <remarks></remarks> public static void Save(MClientChoicesState clientChoicesState, bool updateContext) { if (clientChoicesState == null) { throw new ArgumentNullException("clientChoicesState", "clientChoicesState cannot be a null reference (Nothing in Visual Basic)! (Nothing in VB)!"); } MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.DefaultProfile(); BClientChoices mBClientChoices = new BClientChoices(mSecurityEntityProfile, ConfigSettings.CentralManagement); mBClientChoices.Save(clientChoicesState); if (updateContext) { if (HttpContext.Current.Cache != null) { HttpContext.Current.Cache[MClientChoices.SessionName] = clientChoicesState; } } }
protected new void Page_PreInit(object sender, EventArgs e) { base.Page_PreInit(sender, e); if (ConfigSettings.ForceHttps && HttpContext.Current.Request.Url.Scheme.ToLowerInvariant() != "https") { Response.Redirect(ConfigSettings.RootSite); } MSecurityEntityProfile mSecProfile = SecurityEntityUtility.CurrentProfile(); String mMasterPage = "Content/Skins/" + mSecProfile.Skin + "/" + mSecProfile.Skin + ".master"; string fileName = null; fileName = HttpContext.Current.Server.MapPath("~\\") + mMasterPage; if (!File.Exists(fileName)) { mMasterPage = "Content/Skins/Default/Default.Master"; } this.MasterPageFile = mMasterPage; }
protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["SecurityEntitySeqId"])) { int mAccountSeqID = int.Parse(Request.QueryString["SecurityEntitySeqId"]); if (mAccountSeqID != -1) { m_Profile = SecurityEntityUtility.GetProfile(mAccountSeqID); } else { m_Profile = new MSecurityEntityProfile(); m_Profile.DataAccessLayerAssemblyName = "GrowthWareFramework"; m_Profile.DataAccessLayerNamespace = "GrowthWare.Framework.DataAccessLayer.SQLServer.V2008"; } } HttpContext.Current.Session.Add("EditId", m_Profile.Id); populatePage(); }
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 state of the client choices. /// </summary> /// <param name="account">The account.</param> /// <param name="fromDB">if set to <c>true</c> [from database].</param> /// <returns>MClientChoicesState.</returns> public static MClientChoicesState GetClientChoicesState(String account, bool fromDB) { if (string.IsNullOrEmpty(account)) { throw new ArgumentNullException("account", "account cannot be a null reference (Nothing in VB) or empty!"); } MClientChoicesState mRetVal = null; MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.DefaultProfile(); BClientChoices mBClientChoices = new BClientChoices(mSecurityEntityProfile, ConfigSettings.CentralManagement); if (fromDB) { return(mBClientChoices.GetClientChoicesState(account)); } if (account.Trim().ToLower(CultureInfo.CurrentCulture) != "anonymous") { if (HttpContext.Current.Session != null) { mRetVal = (MClientChoicesState)HttpContext.Current.Session[MClientChoices.SessionName]; if (mRetVal == null) { mRetVal = mBClientChoices.GetClientChoicesState(account); HttpContext.Current.Session[MClientChoices.SessionName] = mRetVal; } else if (mRetVal.AccountName.Trim().ToUpper(CultureInfo.InvariantCulture) != account.Trim().ToUpper(CultureInfo.InvariantCulture)) { mRetVal = mBClientChoices.GetClientChoicesState(account); HttpContext.Current.Session[MClientChoices.SessionName] = mRetVal; } } } else { mRetVal = (MClientChoicesState)HttpContext.Current.Cache[s_CachedAnonymousChoicesState]; if (mRetVal == null) { mRetVal = mBClientChoices.GetClientChoicesState(account); CacheController.AddToCacheDependency(ClientChoicesUtility.s_CachedAnonymousChoicesState, mRetVal); } } return(mRetVal); }
/// <summary> /// Parameters are need to pass along to the factory for correct connection to the desired datastore. /// </summary> /// <param name="securityEntityProfile">The Security Entity profile used to obtain the DAL name, DAL name space, and the Connection String</param> /// <param name="centralManagement">Boolean value indicating if the system is being used to manage multiple database instances.</param> /// <remarks></remarks> /// <example> This sample shows how to create an instance of the class. /// <code language="VB.NET"> /// <![CDATA[ /// MSecurityEntityProfile mSecurityEntityProfile = MSecurityEntityProfile = New MSecurityEntityProfile(); /// mSecurityEntityProfile.ID = ConfigSettings.DefaultSecurityEntityID; /// mSecurityEntityProfile.DAL = ConfigSettings.DAL; /// mSecurityEntityProfile.DAL_Namespace = ConfigSettings.DAL_NameSpace(mSecurityEntityProfile.DAL); /// mSecurityEntityProfile.DAL_Name = ConfigSettings.DAL_AssemblyName(mSecurityEntityProfile.DAL); /// mSecurityEntityProfile.ConnectionString = ConfigSettings.ConnectionString; /// /// Dim mBClientChoices As BClientChoices = New BClientChoices(mSecurityEntityProfile, ConfigSettings.CentralManagement) /// ]]> /// </code> /// <code language="C#"> /// <![CDATA[ /// Dim mSecurityEntityProfile As MSecurityEntityProfile = New MSecurityEntityProfile() /// mSecurityEntityProfile.ID = ConfigSettings.DefaultSecurityEntityID /// mSecurityEntityProfile.DAL = ConfigSettings.DAL /// mSecurityEntityProfile.DAL_Namespace = ConfigSettings.DAL_NameSpace(mSecurityEntityProfile.DAL) /// mSecurityEntityProfile.DAL_Name = ConfigSettings.DAL_AssemblyName(mSecurityEntityProfile.DAL) /// mSecurityEntityProfile.ConnectionString = ConfigSettings.ConnectionString /// /// BClientChoices mBClientChoices = new BClientChoices(mSecurityEntityProfile, ConfigSettings.CentralManagement); /// ]]> /// </code> /// </example> public BSecurityEntity(MSecurityEntityProfile securityEntityProfile, bool centralManagement) { if (securityEntityProfile == null) { throw new ArgumentNullException("securityEntityProfile", "The securityEntityProfile cannot be a null reference (Nothing in Visual Basic)!!"); } if (centralManagement) { if (m_DSecurityEntity == null) { m_DSecurityEntity = (IDSecurityEntity)ObjectFactory.Create(securityEntityProfile.DataAccessLayerAssemblyName, securityEntityProfile.DataAccessLayerNamespace, "DSecurityEntity"); } } else { m_DSecurityEntity = (IDSecurityEntity)ObjectFactory.Create(securityEntityProfile.DataAccessLayerAssemblyName, securityEntityProfile.DataAccessLayerNamespace, "DSecurityEntity"); } m_DSecurityEntity.ConnectionString = securityEntityProfile.ConnectionString; }