protected void Page_PreRender(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    SessionManager.CurrentAdminPage = "";
                    string customerLogo = "";
                    customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogo"];
                    if (string.IsNullOrEmpty(customerLogo) || customerLogo.Contains("Metricsoft"))
                    {
                        imgLogo.ImageUrl = "~/images/company/MetricsoftLogoSmall.png";
                    }
                    else
                    {
                        int pos = customerLogo.IndexOf('.');
                        customerLogo     = customerLogo.Substring(0, pos) + "Small." + customerLogo.Substring(pos + 1, customerLogo.Length - pos - 1);
                        imgLogo.ImageUrl = "~/images/company/" + customerLogo;
                    }

                    string title = System.Configuration.ConfigurationManager.AppSettings["MainTitle"];
                    if (!string.IsNullOrEmpty(title))
                    {
                        lblMainTitle.Text = title;
                    }

                    SetupPage();

                    var viewPortWidth = Convert.ToInt32(Session["vpWidth"]);
                    if (viewPortWidth <= 768)
                    {
                        RadMenu1.RenderMode = RenderMode.Mobile;
                    }

                    bool addConsole = false;
                    RadMenu1.Skin                       = "Metro";
                    RadMenu1.ExpandDelay                = 225;
                    RadMenu1.CollapseDelay              = 500;
                    RadMenu1.ExpandAnimation.Duration   = 40;
                    RadMenu1.CollapseAnimation.Duration = 20;
                    RadMenu1.DefaultGroupSettings.Flow  = Telerik.Web.UI.ItemFlow.Horizontal;

                    RadMenuItem HomeMenu = new RadMenuItem("Home");
                    RadMenu1.Items.Add(HomeMenu);
                    if (UserContext.GetScopePrivileges(SysScope.dashboard).Count() > 0)
                    {
                        HomeMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Dashboard", "/Home/Dashboard.aspx"));
                    }
                    if (UserContext.GetScopePrivileges(SysScope.inbox).Count() > 0)
                    {
                        HomeMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Calendar", "/Home/Calendar.aspx"));
                    }

                    if (UserContext.GetScopePrivileges(SysScope.system).Count() > 0 || UserContext.GetScopePrivileges(SysScope.busorg).Count() > 0)
                    {
                        RadMenuItem OrgMenu = new RadMenuItem("Organization");
                        RadMenu1.Items.Add(OrgMenu);
                        OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Business Structure", "/Admin/Administrate_ViewBusOrg.aspx"));
                        OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Exchange Rates", "/Admin/Administrate_CurrencyInput.aspx"));
                        if (UserContext.CheckUserPrivilege(SysPriv.admin, SysScope.system))
                        {
                            OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Settings", "/Admin/Administrate_SettingInput.aspx"));
                            OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Upload Data", "/Admin/Administrate_FileUpload.aspx"));
                        }
                    }

                    if (UserContext.GetScopePrivileges(SysScope.envdata).Count() > 0)
                    {
                        RadMenuItem EHSMenu1 = new RadMenuItem("Environmental");
                        RadMenu1.Items.Add(EHSMenu1);

                        if (UserContext.CheckUserPrivilege(SysPriv.config, SysScope.envdata))
                        {
                            EHSMenu1.Items.Add(new Telerik.Web.UI.RadMenuItem("Library", "/EHS/EHS_Resources.aspx"));
                            EHSMenu1.Items.Add(new Telerik.Web.UI.RadMenuItem("Metric Profiles", "/EHS/EHS_Profile.aspx"));
                        }
                        EHSMenu1.Items.Add(new Telerik.Web.UI.RadMenuItem("Data Input", "/EHS/EHS_MetricInput.aspx"));
                        EHSMenu1.Items.Add(new Telerik.Web.UI.RadMenuItem("Plant Analytics", "/EHS/EHS_ENVReport.aspx"));
                        if (addConsole == false && UserContext.GetScopePrivileges(SysScope.console).Count() > 0)
                        {
                            EHSMenu1.Items.Add(new Telerik.Web.UI.RadMenuItem("Console", "/EHS/EHS_Console.aspx?c=EHS"));
                            addConsole = true;
                        }
                    }

                    if (UserContext.GetScopePrivileges(SysScope.audit).Count() > 0 || UserContext.GetScopePrivileges(SysScope.incident).Count() > 0)
                    {
                        RadMenuItem EHSMenu2 = new RadMenuItem("Health & Safety");
                        RadMenu1.Items.Add(EHSMenu2);

                        if (UserContext.GetMaxScopePrivilege(SysScope.audit) <= SysPriv.originate)
                        {
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem("Audits", "/EHS/EHS_Audits.aspx"));
                        }
                        if (UserContext.GetMaxScopePrivilege(SysScope.audit) <= SysPriv.config)
                        {
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem("Audit Schedules", "/EHS/EHS_Audit_Scheduler.aspx"));
                        }
                        if (UserContext.GetScopePrivileges(SysScope.incident).Count() > 0)
                        {
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem("Incidents", "/EHS/EHS_Incidents.aspx"));
                        }
                        //if (UserContext.GetScopePrivileges(SysScope.prevent).Count() > 0)
                        //EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem("Preventative Actions", "/EHS/EHS_Incidents.aspx?mode=prevent"));
                        if (addConsole == false && UserContext.GetScopePrivileges(SysScope.console).Count() > 0)
                        {
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem("Console", "/EHS/EHS_Console.aspx?c=EHS"));
                        }
                    }

                    /*
                     * string menu8DActive = System.Configuration.ConfigurationManager.AppSettings["Menu8DActive"];
                     * if (!string.IsNullOrEmpty(menu8DActive)  &&  menu8DActive.ToUpper() == "FALSE")
                     * {
                     *      foreach (RadMenuItem mi in RadMenu1.Items)
                     *      {
                     *              foreach (RadMenuItem ms in mi.Items)
                     *              {
                     *                      if (ms.NavigateUrl.Contains("Problem_Case.aspx?c=QI"))
                     *                              ms.Visible = false;
                     *              }
                     *      }
                     * }
                     */
                }
            }

            catch (Exception ex)
            {
                // SQMLogger.LogException(ex);
            }
        }
 public static List <PRIVLIST> GetScopePrivileges(SysScope scope)
 {
     return(UserContext.GetScopePrivileges(scope));
 }
Example #3
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    if (menuXLATList == null || menuXLATList.Count == 0)
                    {
                        menuXLATList = SQMBasePage.SelectXLATList(new string[8] {
                            "MENU_HOME", "MENU_ORG", "MENU_ENV", "MENU_HS", "MENU_AUDIT", "MENU_DATA", "MENU_RM", "MENU_MEDIA"
                        });
                    }

                    SessionManager.CurrentAdminPage = "";
                    string customerLogo = "";
                    customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogo"];
                    if (string.IsNullOrEmpty(customerLogo) || customerLogo.Contains("Metricsoft"))
                    {
                        imgLogo.ImageUrl = "~/images/company/MetricsoftLogoSmall.png";
                    }
                    else
                    {
                        int pos = customerLogo.IndexOf('.');
                        customerLogo     = customerLogo.Substring(0, pos) + "Small." + customerLogo.Substring(pos + 1, customerLogo.Length - pos - 1);
                        imgLogo.ImageUrl = "~/images/company/" + customerLogo;
                    }

                    string title = System.Configuration.ConfigurationManager.AppSettings["MainTitle"];
                    if (!string.IsNullOrEmpty(title))
                    {
                        lblMainTitle.Text = title;
                    }

                    SetupPage();

                    bool addConsole = false;
                    RadMenu1.Skin                       = "Metro";
                    RadMenu1.ExpandDelay                = 225;
                    RadMenu1.CollapseDelay              = 500;
                    RadMenu1.ExpandAnimation.Duration   = 40;
                    RadMenu1.CollapseAnimation.Duration = 20;
                    RadMenu1.DefaultGroupSettings.Flow  = Telerik.Web.UI.ItemFlow.Horizontal;

                    RadMenuItem HomeMenu = new RadMenuItem(GetMenu("MENU_HOME", "0").DESCRIPTION);
                    RadMenu1.Items.Add(HomeMenu);
                    if (UserContext.GetScopePrivileges(SysScope.dashboard).Count() > 0)
                    {
                        HomeMenu.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_HOME", "11").DESCRIPTION, GetMenu("MENU_HOME", "11").DESCRIPTION_SHORT));
                    }
                    if (UserContext.GetScopePrivileges(SysScope.inbox).Count() > 0)
                    {
                        HomeMenu.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_HOME", "12").DESCRIPTION, GetMenu("MENU_HOME", "12").DESCRIPTION_SHORT));
                    }

                    if (UserContext.GetMaxScopePrivilege(SysScope.busorg) <= SysPriv.admin)
                    {
                        RadMenuItem OrgMenu = new RadMenuItem(GetMenu("MENU_ORG", "0").DESCRIPTION);
                        RadMenu1.Items.Add(OrgMenu);
                        OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_ORG", "11").DESCRIPTION, GetMenu("MENU_ORG", "11").DESCRIPTION_SHORT));
                        OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_ORG", "12").DESCRIPTION, GetMenu("MENU_ORG", "12").DESCRIPTION_SHORT));
                        if (UserContext.CheckUserPrivilege(SysPriv.admin, SysScope.system) && SessionManager.UserContext.Person.PERSON_ID == 1)
                        {
                            OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_ORG", "13").DESCRIPTION, GetMenu("MENU_ORG", "13").DESCRIPTION_SHORT));
                            OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_ORG", "14").DESCRIPTION, GetMenu("MENU_ORG", "14").DESCRIPTION_SHORT));
                        }
                    }

                    if (UserContext.GetScopePrivileges(SysScope.envdata).Count() > 0)
                    {
                        RadMenuItem EHSMenu1 = new RadMenuItem(GetMenu("MENU_ENV", "0").DESCRIPTION);
                        RadMenu1.Items.Add(EHSMenu1);

                        if (UserContext.CheckUserPrivilege(SysPriv.config, SysScope.envdata))
                        {
                            EHSMenu1.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_ENV", "11").DESCRIPTION, GetMenu("MENU_ENV", "11").DESCRIPTION_SHORT));
                            EHSMenu1.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_ENV", "12").DESCRIPTION, GetMenu("MENU_ENV", "12").DESCRIPTION_SHORT));
                        }
                        EHSMenu1.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_ENV", "13").DESCRIPTION, GetMenu("MENU_ENV", "13").DESCRIPTION_SHORT));
                        EHSMenu1.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_ENV", "14").DESCRIPTION, GetMenu("MENU_ENV", "14").DESCRIPTION_SHORT));
                        if (addConsole == false && UserContext.GetScopePrivileges(SysScope.console).Count() > 0)
                        {
                            EHSMenu1.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_ENV", "15").DESCRIPTION, GetMenu("MENU_ENV", "15").DESCRIPTION_SHORT));
                            addConsole = true;
                        }
                    }

                    if (UserContext.GetScopePrivileges(SysScope.incident).Count() > 0)
                    {
                        RadMenuItem EHSMenu2 = new RadMenuItem(GetMenu("MENU_HS", "0").DESCRIPTION);
                        RadMenu1.Items.Add(EHSMenu2);
                        if (UserContext.GetScopePrivileges(SysScope.incident).Count() > 0)
                        {
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_HS", "11").DESCRIPTION, GetMenu("MENU_HS", "11").DESCRIPTION_SHORT));
                        }
                        if (UserContext.GetScopePrivileges(SysScope.console).Count() > 0)
                        {
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_HS", "12").DESCRIPTION, GetMenu("MENU_HS", "12").DESCRIPTION_SHORT));
                        }
                    }

                    if (UserContext.GetScopePrivileges(SysScope.audit).Count() > 0)
                    {
                        RadMenuItem EHSMenu2 = new RadMenuItem(GetMenu("MENU_AUDIT", "0").DESCRIPTION);
                        RadMenu1.Items.Add(EHSMenu2);
                        if (UserContext.GetMaxScopePrivilege(SysScope.audit) <= SysPriv.config && GetMenu("MENU_AUDIT", "11").STATUS.ToUpper() == "A")
                        {
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_AUDIT", "11").DESCRIPTION, GetMenu("MENU_AUDIT", "11").DESCRIPTION_SHORT));
                        }
                        if (UserContext.GetMaxScopePrivilege(SysScope.audit) <= SysPriv.originate)
                        {
                            if (GetMenu("MENU_AUDIT", "12").STATUS.ToUpper() == "A")
                            {
                                EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_AUDIT", "12").DESCRIPTION, GetMenu("MENU_AUDIT", "12").DESCRIPTION_SHORT));
                            }
                            if (GetMenu("MENU_AUDIT", "15").STATUS.ToUpper() == "A")
                            {
                                EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_AUDIT", "15").DESCRIPTION, GetMenu("MENU_AUDIT", "15").DESCRIPTION_SHORT));
                            }
                        }
                        if (UserContext.GetMaxScopePrivilege(SysScope.audit) <= SysPriv.originate && GetMenu("MENU_AUDIT", "13").STATUS.ToUpper() == "A")
                        {
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_AUDIT", "13").DESCRIPTION, GetMenu("MENU_AUDIT", "13").DESCRIPTION_SHORT));
                        }
                    }

                    if (SessionManager.GetUserSetting("MODULE", "PREVACTION") != null && SessionManager.GetUserSetting("MODULE", "PREVACTION").VALUE.ToUpper() == "A")
                    {
                        if (UserContext.GetScopePrivileges(SysScope.prevent).Count() > 0 && IsMenuActive("MENU_RM"))
                        {
                            RadMenuItem EHSMenu2 = new RadMenuItem(GetMenu("MENU_RM", "0").DESCRIPTION);
                            RadMenu1.Items.Add(EHSMenu2);
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_RM", "11").DESCRIPTION, GetMenu("MENU_RM", "11").DESCRIPTION_SHORT));
                        }
                    }

                    if (SessionManager.GetUserSetting("MODULE", "EHSDATA") != null && SessionManager.GetUserSetting("MODULE", "EHSDATA").VALUE.ToUpper() == "A")
                    {
                        if (UserContext.GetMaxScopePrivilege(SysScope.ehsdata) <= SysPriv.originate && IsMenuActive("MENU_DATA"))
                        {
                            RadMenuItem EHSMenu2 = new RadMenuItem(GetMenu("MENU_DATA", "0").DESCRIPTION);
                            RadMenu1.Items.Add(EHSMenu2);
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_DATA", "11").DESCRIPTION, GetMenu("MENU_DATA", "11").DESCRIPTION_SHORT));
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_DATA", "12").DESCRIPTION, GetMenu("MENU_DATA", "12").DESCRIPTION_SHORT));
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_DATA", "13").DESCRIPTION, GetMenu("MENU_DATA", "13").DESCRIPTION_SHORT));
                            if (UserContext.GetMaxScopePrivilege(SysScope.ehsdata) <= SysPriv.config)
                            {
                                EHSMenu2.Items.Add(new RadMenuItem(GetMenu("MENU_DATA", "21").DESCRIPTION, GetMenu("MENU_DATA", "21").DESCRIPTION_SHORT));
                                EHSMenu2.Items.Add(new RadMenuItem(GetMenu("MENU_DATA", "22").DESCRIPTION, GetMenu("MENU_DATA", "22").DESCRIPTION_SHORT));
                            }
                            if (UserContext.CheckUserPrivilege(SysPriv.approve, SysScope.ehsdata) || UserContext.CheckUserPrivilege(SysPriv.approve1, SysScope.ehsdata))
                            {
                                EHSMenu2.Items.Add(new RadMenuItem(GetMenu("MENU_DATA", "25").DESCRIPTION, GetMenu("MENU_DATA", "25").DESCRIPTION_SHORT));
                            }
                        }
                    }

                    if (SessionManager.GetUserSetting("MODULE", "MEDIA") != null && SessionManager.GetUserSetting("MODULE", "MEDIA").VALUE.ToUpper() == "A")
                    {
                        if (UserContext.GetMaxScopePrivilege(SysScope.media) <= SysPriv.originate)
                        {
                            RadMenuItem EHSMenu2 = new RadMenuItem(GetMenu("MENU_MEDIA", "0").DESCRIPTION);
                            RadMenu1.Items.Add(EHSMenu2);
                            EHSMenu2.Items.Add(new Telerik.Web.UI.RadMenuItem(GetMenu("MENU_MEDIA", "11").DESCRIPTION, GetMenu("MENU_MEDIA", "11").DESCRIPTION_SHORT));
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                // SQMLogger.LogException(ex);
            }
        }
Example #4
0
        public void LoadProfileInput(DateTime targetDate, EHSProfileStatus selectStatus)
        {
            UserContext.CheckUserPrivilege(SysPriv.originate, SysScope.envdata);
            LocalProfile().LoadPeriod(targetDate);
            if (LocalProfile().InputPeriod != null)
            {
                LocalProfile().MapPlantAccountingInputs(true, false);

                uclInputHdr.BindProfileInputHdr(LocalProfile());
                EHSProfileStatus status = BindProfileInputList(LocalProfile().MeasureList(true, UserContext.GetScopePrivileges(SysScope.envdata)).ToList(), LocalProfile().Profile);
                if (status == EHSProfileStatus.Normal)
                {
                    if (LocalProfile().Profile.APPROVER_ID == SessionManager.UserContext.Person.PERSON_ID || UserContext.CheckUserPrivilege(SysPriv.approve, SysScope.envdata))
                    {
                        cbFinalApproval.Enabled = true;
                    }
                    if (LocalProfile().InputPeriod.PlantAccounting.APPROVER_ID.HasValue&& LocalProfile().InputPeriod.PlantAccounting.APPROVAL_DT.HasValue)
                    {
                        cbFinalApproval.Checked  = true;
                        cbFinalApproval.Enabled  = false;
                        hfWasApproved.Value      = lblFinalApprovalBy.Text = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)LocalProfile().InputPeriod.PlantAccounting.APPROVER_ID, ""));
                        lblFinalApprovalBy.Text += ("  " + SQMBasePage.FormatDate((DateTime)LocalProfile().InputPeriod.PlantAccounting.APPROVAL_DT, "", false));
                    }
                    else
                    {
                        cbFinalApproval.Checked = false;
                        hfWasApproved.Value     = lblFinalApprovalBy.Text = "";
                    }
                }
                MessageDisplay(selectStatus == EHSProfileStatus.Normal ? status : selectStatus);
                btnSave1.Enabled = btnSave2.Enabled = btnCancel1.Enabled = btnCancel2.Enabled = UserContext.GetMaxScopePrivilege(SysScope.envdata) < SysPriv.notify ? true : false;
            }
            else
            {
                MessageDisplay(EHSProfileStatus.NoInputs);
            }
        }