示例#1
0
        /// <summary>
        /// Determine visibility of control based on UserType
        /// </summary>
        private void SetButtonVisibility()
        {
            // Determine if page is ProjectMgmt page and read user type
            // to determine visibility
            if (Page is ProjectMgmtBasePage)
            {
                ProjectMgmtBasePage projectPage       = Page as ProjectMgmtBasePage;
                ProjectMgmtContext  activePageContext = projectPage.ProjectContext;
                ProjectMgmtUsers    activeUserType    = projectPage.UserType;

                // Buttons default visibility = false
                bool hasPermission = false;

                foreach (ProjectMgmtUsers type in _userTypes)
                {
                    if (activeUserType == type && (!_customContext || _customContext && _projectContext == activePageContext))
                    {
                        hasPermission = true;
                        break;
                    }
                }

                // Finally set button visibility
                this.Visible = hasPermission;
                this.Enabled = hasPermission;
            }
        }
示例#2
0
        /// <summary>
        /// Initalizes page level variables accoring to the Context of the Page
        /// </summary>
        private void SetPageContextAndVariables()
        {
            // is wizard
            string wiz = GetQueryValue(QUERY_IS_WIZARD_KEY);

            if (!string.IsNullOrEmpty(wiz))
            {
                isWizard = bool.Parse(wiz);
            }
            else
            {
                isWizard = false;
            }


            // Context shouldn't be passed in query string
            //// Set page context
            //string contextQueryParam = GetQueryValue(QUERY_CONTEXT_KEY);
            //// If context is passed as part of query string, set context
            //if (Enum.IsDefined(typeof(ProjectMgmtContext), contextQueryParam))
            //{
            //    _projectContext = (ProjectMgmtContext)Enum.Parse(typeof(ProjectMgmtContext), contextQueryParam, true);
            //}
            //// Else, context will be determined based on query params
            //else
            //{


            if (string.IsNullOrEmpty(_projectId) && string.IsNullOrEmpty(_organizationId))
            {
                _projectContext = ProjectMgmtContext.Global;
            }
            else if (!string.IsNullOrEmpty(_projectId) && string.IsNullOrEmpty(_organizationId))
            {
                _projectContext = ProjectMgmtContext.Project;
            }
            else if (!string.IsNullOrEmpty(_projectId) && !string.IsNullOrEmpty(_organizationId))
            {
                _projectContext = ProjectMgmtContext.Organization;
            }
            else
            {
                // In this case projectId is empty but org id is valid, should not
                // be the case??
                _projectContext = ProjectMgmtContext.Global;
            }
            //}
            // After context is set, we need to then handle variables
            // NOTE: Do not empty out variables???
            //switch (_projectContext)
            //{
            //    // Project and Organization have no meaning in this context
            //    case (ProjectMgmtContext.Global):
            //        _projectId = string.Empty;
            //        _organizationId = string.Empty;
            //        break;
            //    // In the context of a project, no org should exist
            //    case (ProjectMgmtContext.Project):
            //        _organizationId = string.Empty;
            //        break;
            //    // Case doesn't need to be handled, values initally defined above
            //    case (ProjectMgmtContext.Organization):
            //        break;
            //}
        }