private void AddHomePage(Sitemap sitemap, CmsPage page, string homePage)
 {
     var url = new SitemapUrl();
     url.Location = homePage;
     url.ChangeFrequency = CalculateFrequency(page.ModifiedAt);
     url.Priority = 0.9;
     url.LastModified = page.ModifiedAt.ToString();
     sitemap.Insert(0,
                    url);
 }
Beispiel #2
0
        private void AddHomePage(Sitemap sitemap, CmsPage page, string homePage)
        {
            var url = new SitemapUrl();

            url.Location        = homePage;
            url.ChangeFrequency = CalculateFrequency(page.ModifiedAt);
            url.Priority        = 0.9;
            url.LastModified    = page.ModifiedAt.ToString();
            sitemap.Insert(0,
                           url);
        }
Beispiel #3
0
        // check session when redirect
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!Request.IsAjaxRequest())
            {
                var           routeData  = filterContext.RouteData;
                var           controller = routeData.Values["controller"].ToString();
                var           action     = routeData.Values["action"].ToString();
                CommonService comService = new CommonService();

                var check        = ((controller != "UserAccount" && action != "Login") && (controller != "Home" && action != "Index") && (controller != "Home" && action != "Intro") && (controller != "PDFManage" && action != "ViewPdf") && (controller != "Home" && action != "SupportCenter") && (controller != "Common" && action != "AuthentTimeout") && (controller != "ManageNews" && action != "TopNews") && (controller != "ManageNews" && action != "ViewNews"));
                var sessionLogin = Session["CmnEntityModel"] as CmnEntityModel;

                if ((sessionLogin == null || sessionLogin.ID == 0) && check)
                {
                    filterContext.Result = new RedirectToRouteResult(
                        new RouteValueDictionary(new { controller = "Login", action = "Login" }));
                }

                int pos = Sitemap.FindIndex(item => item.ControllerName == controller && item.ActionName == action);

                if (0 <= pos)
                {
                    Sitemap.RemoveRange(pos, 0);
                }
                else
                {
                    var item = new SitemapItem
                    {
                        ControllerName = controller,
                        ActionName     = action,
                        RestoreData    = null
                    };

                    Sitemap.Insert(0, item);
                }
                base.OnActionExecuting(filterContext);
            }
        }
Beispiel #4
0
        /// <summary>
        /// This method is called before the acion method
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var routeData  = filterContext.RouteData;
            var controller = routeData.Values["controller"].ToString();
            var loginUser  = GetLoginUser();

            // Check login by license of user's company
            if (loginUser != null && controller != "PMS01001")
            {
                if (_service.CheckLicense(loginUser.CompanyCode) == 0)
                {
                    if (Request.IsAjaxRequest())
                    {
                        this.Response.StatusCode = 420;
                        return;
                    }
                    else
                    {
                        filterContext.Result = new RedirectResult(Url.Action("", "ErrorOutOfDate"));
                        return;
                    }
                }
            }

            if (!Request.IsAjaxRequest())
            {
                var action = routeData.Values["action"].ToString();

                // Check user password is expired
                if (loginUser != null &&
                    action != "PersonalSetting" &&
                    action != "Logout" &&
                    action != "AuthentTimeout" &&
                    controller != "ErrorAuthent" &&
                    controller != "Error")
                {
                    if (loginUser.Is_expired_password)
                    {
                        Session[Constant.PASSWORD_OUT_OF_DATE] = 1;
                        filterContext.Result = new RedirectResult(Url.Action("PersonalSetting", "PMS01002"));
                        return;
                    }
                }

                int      pos           = Sitemap.FindIndex(item => item.ControllerName == controller);
                string[] controllerArr = { "PMS06001", "PMS09001", "PMS09002", "PMS09003", "PMS09004", "PMS09005" };

                // Clear Jquery datatable state data
                if (controllerArr.Contains(controller) &&
                    action == "ClearSaveCondition" &&
                    0 <= pos)
                {
                    Sitemap[pos].RestoreData = null;
                }

                if (0 <= pos)
                {
                    Sitemap.RemoveRange(pos, 0);
                }
                else
                {
                    var item = new SitemapItem
                    {
                        ControllerName = controller,
                        RestoreData    = null
                    };

                    Sitemap.Insert(0, item);
                }
            }

            base.OnActionExecuting(filterContext);
        }