Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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));
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the menu.
        /// </summary>
        /// <param name="account">The account.</param>
        /// <param name="menuType">Type of the menu.</param>
        /// <returns>DataTable.</returns>
        public static DataTable GetMenu(String account, MenuType menuType)
        {
            if (string.IsNullOrEmpty(account))
            {
                throw new ArgumentNullException("account", "account cannot be a null reference (Nothing in VB) or empty!");
            }
            BAccounts mBAccount = new BAccounts(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement);
            DataTable mRetVal   = null;

            if (account.ToUpper(CultureInfo.InvariantCulture) == "ANONYMOUS")
            {
                String mAnonMenu = menuType.ToString() + "Anonymous";
                mRetVal = (DataTable)HttpContext.Current.Cache[mAnonMenu];
                if (mRetVal == null)
                {
                    mRetVal = mBAccount.GetMenu(account, menuType);
                    CacheController.AddToCacheDependency(mAnonMenu, mRetVal);
                }
            }
            else
            {
                String mMenuName = account + "_" + menuType.ToString() + "_MenuData";
                if (HttpContext.Current.Session != null)
                {
                    mRetVal = (DataTable)HttpContext.Current.Session[mMenuName];
                    if (mRetVal == null)
                    {
                        mRetVal = mBAccount.GetMenu(account, menuType);
                        foreach (DataRow item in mRetVal.Rows)
                        {
                            item["URL"] = "?Action=" + item["URL"].ToString();
                        }
                        HttpContext.Current.Session[mMenuName] = mRetVal;
                    }
                }
                else
                {
                    mRetVal = mBAccount.GetMenu(account, menuType);
                    foreach (DataRow item in mRetVal.Rows)
                    {
                        item["URL"] = "?Action=" + item["URL"].ToString();
                    }
                }
            }
            return(mRetVal);
        }
Esempio n. 4
0
        /// <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);
        }
Esempio n. 5
0
        /// <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);
        }
Esempio n. 6
0
        /// <summary>
        /// Searches the specified search criteria.
        /// </summary>
        /// <param name="searchCriteria">The search criteria.</param>
        /// <returns>DataTable.</returns>
        public static DataTable Search(MSearchCriteria searchCriteria)
        {
            BAccounts mBAccount = new BAccounts(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement);

            return(mBAccount.Search(searchCriteria));
        }
Esempio n. 7
0
        /// <summary>
        /// Deletes the specified account seq id.
        /// </summary>
        /// <param name="accountSeqId">The account seq id.</param>
        public static void Delete(int accountSeqId)
        {
            BAccounts mBAccount = new BAccounts(SecurityEntityUtility.CurrentProfile(), ConfigSettings.CentralManagement);

            mBAccount.Delete(accountSeqId);
        }