private void ReadDataFromRouteData()
        {
            if (RouteData.Values["clientId"].GetType() == typeof(System.Int32))
            {
                clientId = (int)RouteData.Values["clientId"];
            }
            else
            {
                clientId = int.Parse((string)RouteData.Values["clientId"]);
            }

            if (RouteData.Values["portalId"].GetType() == typeof(System.Int32))
            {
                portalId = (int)RouteData.Values["portalId"];
            }
            else
            {
                portalId = int.Parse((string)RouteData.Values["portalId"]);
            }
            _user = HttpContext.Session.GetUser(portalId);
            _portal = Session.GetPortalSessions().GetPortalSession(portalId, clientId).Portal;
            _articleManager.Portal = _portal;
            _articleManager.User = _user;
            resources = Session.Resource(portalId, clientId, "ARTICLE", _portal.Language.Name);
            CommonResources = Session.Resource(portalId, clientId, "common", _portal.Language.Name);
            ViewData["CommonViewModel"] = Utilities.CreateCommonViewModel(clientId, portalId, this._portal.PortalType, this._portal.Configuration, "article");
            headerVM = ((CommonViewModel)ViewData["CommonViewModel"]).HeaderViewModel;
        }
예제 #2
0
        private static HeaderViewModel CreateHeaderViewModel(int clientId, int portalId, PortalType portalType, PortalUIConfiguration configuration, string selectedModule)
        {
            try
            {
                HeaderViewModel headerViewModel = new HeaderViewModel();
                headerViewModel.NavigationList = new List<SelectListItem>();
                headerViewModel.BeforePortal = configuration.BeforePortal;
                headerViewModel.portalId = portalId;
                headerViewModel.clientId = clientId;
                headerViewModel.portalType = portalType;

                List<PortalModule> OrderedModuleList = configuration.Modules.OrderBy(x => x.DisplayOrder).ToList();
                List<PortalModule> SelectedModuleList = OrderedModuleList.Where(x => x.Display == true).ToList();
                if (configuration.ShowPortalNavigation)
                {
                    foreach (PortalModule module in SelectedModuleList)
                    {
                        SelectListItem navItem = new SelectListItem() { Text = module.ModuleName, Value = module.ModuleType, Selected = false };
                        if (module.ModuleType == selectedModule)
                        {
                            navItem.Selected = true;
                        }
                        if (module.ModuleType == "articles")
                        {
                            navItem.Value = "article";
                        }
                        headerViewModel.NavigationList.Add(navItem);
                    }
                }
                if (HttpContext.Current.Session["UserSession_" + portalId.ToString()] != null)
                {
                    var usr = (User)HttpContext.Current.Session["UserSession_" + portalId.ToString()];
                    if (usr != null)
                    {
                        headerViewModel.isActiveDiretoryUser = usr.isActiveDirectoryUser;
                    }

                }
                return headerViewModel;
            }
            catch (Exception ex)
            {
                KBCustomException kbCustExp = KBCustomException.ProcessException(ex, KBOp.CreateViewModel, KBErrorHandler.GetMethodName(), GeneralResources.CreateViewModelError,
                    new KBExceptionData("clientId", clientId), new KBExceptionData("portalType", portalType), new KBExceptionData("selectedModule", selectedModule), new KBExceptionData("configuration.AfterPortal", configuration.AfterPortal));
                throw kbCustExp;
            }
        }
예제 #3
0
 public static string getModuleText(HeaderViewModel headerVM, string headerModuleValue)
 {
     string mText = headerVM.NavigationList.Find(r => r.Value == headerModuleValue) != null ? headerVM.NavigationList.Find(r => r.Value == headerModuleValue).Text : string.Empty;
     return mText;
 }
        private void ReadDataFromRouteData()
        {
            try
            {
                if (RouteData.Values["clientId"].GetType() == typeof(System.Int32))
                {
                    clientId = (int)RouteData.Values["clientId"];
                }
                else
                {
                    clientId = int.Parse((string)RouteData.Values["clientId"]);
                }

                if (RouteData.Values["portalId"].GetType() == typeof(System.Int32))
                {
                    portalId = (int)RouteData.Values["portalId"];
                }
                else
                {
                    portalId = int.Parse((string)RouteData.Values["portalId"]);
                }
                _user = HttpContext.Session.GetUser(portalId);
                _portal = Session.GetPortalSessions().GetPortalSession(portalId,clientId).Portal;
                _searchesManager.Portal = _portal;
                _searchesManager.User = _user;
                //resource object
                Resources = Session.Resource(portalId, clientId, "search", _portal.Language.Name);
                CommonResources = Session.Resource(portalId, clientId, "common", _portal.Language.Name);
                ViewData["CommonViewModel"] = Utilities.CreateCommonViewModel(clientId, portalId, this._portal.PortalType, this._portal.Configuration,"article");
                headerVM = ((CommonViewModel)ViewData["CommonViewModel"]).HeaderViewModel;
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error:" + " " + ex.Message, ex);
                throw ex;
            }
        }
        private void ReadDataFromRouteData()
        {
            if (RouteData.Values["clientId"].GetType() == typeof(System.Int32))
            {
                clientId = (int)RouteData.Values["clientId"];
            }
            else
            {
                clientId = int.Parse((string)RouteData.Values["clientId"]);
            }

            if (RouteData.Values["portalId"].GetType() == typeof(System.Int32))
            {
                portalId = (int)RouteData.Values["portalId"];
            }
            else
            {
                portalId = int.Parse((string)RouteData.Values["portalId"]);
            }
            _portal = Session.GetPortalSessions().GetPortalSession(portalId, clientId).Portal;

            catModule = (CategoryBrowseModule)_portal.Configuration.BrowseModule;
            if (catModule == null)
            {
                KBCustomException kbCustExp = KBCustomException.ProcessException(null, KBOp.LoadBrowsePage, KBErrorHandler.GetMethodName(), GeneralResources.BrowseModuleNotFoundError, LogEnabled.False);
                throw kbCustExp;
            }
            //Assign portal and user object to artilceManger
            this._categoryManager.Portal = _portal;
            this._categoryManager.User = HttpContext.Session.GetUser(portalId);
            //Assign portal and user object to artilceManger
            this._articleManager.Portal = _portal;
            this._articleManager.User = HttpContext.Session.GetUser(portalId);

            this._searchesManager.Portal = _portal;
            this._searchesManager.User = HttpContext.Session.GetUser(portalId);

            ViewData["CommonViewModel"] = Utilities.CreateCommonViewModel(clientId, portalId, this._portal.PortalType, this._portal.Configuration, "browse");

            //get Module name and create navigation
            headerVM = ((CommonViewModel)ViewData["CommonViewModel"]).HeaderViewModel;
            homeText = Utilities.getModuleText(headerVM, "home");
            browseText = Utilities.getModuleText(headerVM, "browse");
            //resource object
            resources = Session.Resource(portalId, clientId, "browse", _portal.Language.Name);
            CommonResources = Session.Resource(portalId, clientId, "common", _portal.Language.Name);
        }
        private void ReadDataFromRouteData()
        {
            if (RouteData.Values["clientId"].GetType() == typeof(System.Int32))
            {
                clientId = (int)RouteData.Values["clientId"];
            }
            else
            {
                clientId = int.Parse((string)RouteData.Values["clientId"]);
            }

            if (RouteData.Values["portalId"].GetType() == typeof(System.Int32))
            {
                portalId = (int)RouteData.Values["portalId"];
            }
            else
            {
                portalId = int.Parse((string)RouteData.Values["portalId"]);
            }
            _portal = Session.GetPortalSessions().GetPortalSession(portalId, clientId).Portal;
            _user = HttpContext.Session.GetUser(portalId);
            SolutionFinderModule SFModule = (SolutionFinderModule)_portal.Configuration.SolutionFinderModule;
            if (SFModule == null)
            {
                KBCustomException kbCustExp = KBCustomException.ProcessException(null, KBOp.LoadSolutionFinderPage, KBErrorHandler.GetMethodName(), GeneralResources.SolutionFinderModuleNotFoundError, LogEnabled.False);
                throw kbCustExp;
            }

            //Assign portal and user object to artilceManger
            this._solFinderManager.Portal = _portal;
            this._solFinderManager.User = HttpContext.Session.GetUser(portalId);
            //Assign portal and user object to artilceManger
            this._articleManager.Portal = _portal;
            this._articleManager.User = HttpContext.Session.GetUser(portalId);
            //resource object
            ViewData["CommonViewModel"] = Utilities.CreateCommonViewModel(clientId, portalId, this._portal.PortalType, this._portal.Configuration, "solutionFinder");
            headerVM = ((CommonViewModel)ViewData["CommonViewModel"]).HeaderViewModel;
            Resources = Session.Resource(portalId, clientId, "solutionFinder", _portal.Language.Name);
            ResourcesArticle = Session.Resource(portalId, clientId, "ARTICLE", _portal.Language.Name);
            Resources = Resources.Concat(ResourcesArticle).ToDictionary(x => x.Key, x => x.Value);
            CommonResources = Session.Resource(portalId, clientId, "common", _portal.Language.Name);
            //get Module name and create navigation
            homeText = Utilities.getModuleText(headerVM, "home");
            SFText = Utilities.getModuleText(headerVM, "solutionFinder");
        }