示例#1
0
        /// <summary>
        /// Called by the MVC framework after the action method executes.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            ViewResult result = filterContext.Result as ViewResult;

            if (result != null)
            {
                var target = (ResolveTarget(result.ViewData.Model, PropertyName) ??
                              ResolveTarget(result.ViewData, PropertyName)) ??
                             result.ViewData[PropertyName];

                if (target != null)
                {
                    ISiteMap siteMap = SiteMaps.GetSiteMap(this.SiteMapCacheKey);
                    if (siteMap != null && siteMap.CurrentNode != null)
                    {
                        if (Target == AttributeTarget.ParentNode && siteMap.CurrentNode.ParentNode != null)
                        {
                            siteMap.CurrentNode.ParentNode.Title = target.ToString();
                        }
                        else
                        {
                            siteMap.CurrentNode.Title = target.ToString();
                        }
                    }
                }
            }
        }
示例#2
0
        public int AddSiteMaps(SiteMaps siteMaps, HtmlContents contents)
        {
            var siteMap = DayaxeDbContext.SiteMaps.FirstOrDefault(x => x.UrlSegment == siteMaps.UrlSegment);

            if (siteMap != null)
            {
                throw new Exception("Url has exists, please try another Url");
            }

            if (siteMaps.IsHomePage.HasValue && siteMaps.IsHomePage.Value)
            {
                var homePage = DayaxeDbContext.SiteMaps.FirstOrDefault(x => x.IsHomePage.HasValue && x.IsHomePage.Value);
                if (homePage != null)
                {
                    homePage.IsHomePage = false;
                }
            }

            DayaxeDbContext.SiteMaps.InsertOnSubmit(siteMaps);

            Commit();

            contents.SiteMapId = siteMaps.Id;
            DayaxeDbContext.HtmlContents.InsertOnSubmit(contents);

            Commit();

            return(siteMaps.Id);
        }
        public RedirectResult Logout()
        {
            HttpContext.GetOwinContext().Authentication.SignOut();

            string getLoginFlag = string.Empty;
            var    getCookie    = Request.Cookies["user_login"];

            getLoginFlag = getCookie == null ? "Y" :
                           EncryptString.desDecryptBase64(Server.UrlDecode(getCookie.Value)); //Value:N

            Session.Remove("IsAuthorized");                                                   //ckfinder用
            removeCookie("user_id");
            removeCookie("user_name");
            removeCookie("user_login");
            SiteMaps.ReleaseSiteMap();

            if (getLoginFlag == "Y")
            {
                return(Redirect("~"));
            }
            else
            {
                return(Redirect("~/_SysAdm?t=" + DateTime.Now.Ticks));
            }
        }
示例#4
0
        public async Task <ActionResult> DownloadSiteMap(long cookieToReturn)
        {
            SiteMaps sm       = new SiteMaps();
            string   filename = sm.GetSiteMapFileName();

            if (!await FileSystem.FileSystemProvider.FileExistsAsync(filename))
            {
                throw new Error(this.__ResStr("sitemapNotFound", "Site map not found - File '{0}' cannot be located", filename));
            }
#if MVC6
            Response.Headers.Remove("Cookie");
            Response.Cookies.Append(Basics.CookieDone, cookieToReturn.ToString(), new Microsoft.AspNetCore.Http.CookieOptions {
                HttpOnly = false, Path = "/"
            });
#else
            HttpCookie cookie = new HttpCookie(Basics.CookieDone, cookieToReturn.ToString());
            Response.Cookies.Remove(Basics.CookieDone);
            Response.SetCookie(cookie);
#endif

            string contentType = "application/octet-stream";
#if MVC6
            return(new PhysicalFileResult(filename, contentType)
            {
                FileDownloadName = Path.GetFileName(filename)
            });
#else
            FilePathResult result = new FilePathResult(filename, contentType);
            result.FileDownloadName = Path.GetFileName(filename);
            return(result);
#endif
        }
示例#5
0
        public async Task <ActionResult> RemoveSiteMap()
        {
            SiteMaps sm = new SiteMaps();
            await sm.RemoveAsync();

            return(Reload(null, Reload: ReloadEnum.ModuleParts, PopupText: this.__ResStr("sremDone", "The site map has been removed")));
        }
示例#6
0
        public async Task <ActionResult> CreateSiteMap()
        {
            SiteMaps sm = new SiteMaps();
            await sm.CreateAsync();

            return(Reload(null, Reload: ReloadEnum.ModuleParts, PopupText: this.__ResStr("screDone", "The site map has been successfully created")));
        }
示例#7
0
        public async Task <ModuleAction> GetAction_DownloadSiteMapAsync()
        {
            if (!IsAuthorized("SiteMaps"))
            {
                return(null);
            }
            SiteMaps sm       = new SiteMaps();
            string   filename = sm.GetSiteMapFileName();

            if (!await FileSystem.FileSystemProvider.FileExistsAsync(filename))
            {
                return(null);
            }
            return(new ModuleAction(this)
            {
                Url = Utility.UrlFor(typeof(PagesBrowseModuleController), nameof(PagesBrowseModuleController.DownloadSiteMap)),
                NeedsModuleContext = true,
                CookieAsDoneSignal = true,
                Image = await CustomIconAsync("Download.png"),
                LinkText = this.__ResStr("downloadLink", "Download Site Map"),
                MenuText = this.__ResStr("downloadMenu", "Download Site Map"),
                Tooltip = this.__ResStr("downloadTT", "Download the site map file"),
                Legend = this.__ResStr("downloadLegend", "Downloads the site map file"),
                Style = ModuleAction.ActionStyleEnum.Normal,
                Category = ModuleAction.ActionCategoryEnum.Read,
                Mode = ModuleAction.ActionModeEnum.Any,
                Location = ModuleAction.ActionLocationEnum.ModuleLinks,
            });
        }
        /// <summary>
        /// Creates a new MvcSiteMapProvider HtmlHelper.
        /// </summary>
        /// <param name="helper">The helper.</param>
        /// <param name="siteMapCacheKey">The SiteMap Cache Key.</param>
        /// <returns>
        /// A <see cref="MvcSiteMapHtmlHelper"/> instance
        /// </returns>
        public static MvcSiteMapHtmlHelper MvcSiteMap(this HtmlHelper helper, string siteMapCacheKey)
        {
            ISiteMap siteMap = SiteMaps.GetSiteMap(siteMapCacheKey);

            if (siteMap == null)
            {
                throw new UnknownSiteMapException();
            }
            return(MvcSiteMap(helper, siteMap));
        }
示例#9
0
        protected void SaveHtmlContentsClick(object sender, EventArgs e)
        {
            LblMessage.Visible = false;
            if (Request.Params["id"] == "0")
            {
                _siteMaps = new SiteMaps
                {
                    Code       = string.Empty,
                    IsActive   = IsActiveCheckBox.Checked,
                    Name       = PageNameText.Text.Trim(),
                    UrlSegment = GetPermalink(PageNameText.Text),
                    IsHomePage = IsHomePageCheckBox.Checked
                };
                _htmlContents = new HtmlContents
                {
                    Title = PageTitleText.Text,
                    Data  = ContentHtmlEditor.Text,
                    ScriptAnalyticsHeader = ScriptAnalyticsEditor.Text,
                    BodyClass             = BodyClassText.Text,
                    MetaDescription       = DescriptionText.Text,
                    MetaKeyword           = KeywordText.Text
                };
                int siteMapId;
                try
                {
                    siteMapId = _helper.AddSiteMaps(_siteMaps, _htmlContents);
                }
                catch (Exception ex)
                {
                    LblMessage.Text    = ex.Message;
                    LblMessage.Visible = true;
                    return;
                }
                Response.Redirect(string.Format("/ContentPage.aspx?id=" + siteMapId));
            }

            _siteMaps.Name       = PageNameText.Text.Trim();
            _siteMaps.UrlSegment = GetPermalink(PageNameText.Text);
            _siteMaps.IsHomePage = IsHomePageCheckBox.Checked;
            _siteMaps.IsActive   = IsActiveCheckBox.Checked;

            _htmlContents.Title = PageTitleText.Text;
            _htmlContents.Data  = ContentHtmlEditor.Text;
            _htmlContents.ScriptAnalyticsHeader = ScriptAnalyticsEditor.Text;
            _htmlContents.BodyClass             = BodyClassText.Text;
            _htmlContents.MetaDescription       = DescriptionText.Text;
            _htmlContents.MetaKeyword           = KeywordText.Text;

            _helper.UpdateSiteMaps(_siteMaps, _htmlContents);

            _helper.ResetCache();
        }
示例#10
0
        public ActionResult Main()
        {
            HttpContext.GetOwinContext().Authentication.SignOut();
            ViewData["username"] = "";
            ViewData["password"] = "";

#if DEBUG
            ViewData["username"] = CommWebSetup.AutoLoginUser;
            ViewData["password"] = CommWebSetup.AutoLoginPassword;
#endif
            removeCookie("user_id");
            removeCookie("user_name");
            removeCookie("user_login");
            SiteMaps.ReleaseSiteMap();

            ViewBag.BodyClass = "Login";
            ViewBag.Year      = DateTime.Now.Year;

            return(View("index"));
        }
        public int ClearOuputCache(string controller, string action)
        {
            if (string.IsNullOrEmpty(controller))
            {
                if (!string.IsNullOrEmpty(action))
                {
                    throw new ArgumentNullException(controller, "Controller must be provided when action not empty");
                }

                //Relase site map cache on clear all output cache for all stores
                foreach (var store in _storeClient.GetStores())
                {
                    //Need to set storeId for session because SiteMapStoreCacheKeyGenerator uses it to generate cache key
                    _sessionService.CustomerSession.StoreId = store.StoreId;
                    SiteMaps.ReleaseSiteMap();
                }
            }


            return(_outputCacheManager.RemoveItems(controller, action));
        }
示例#12
0
        public void UpdateSiteMaps(SiteMaps siteMaps, HtmlContents contents)
        {
            var siteMap = DayaxeDbContext.SiteMaps.FirstOrDefault(x => x.Id == siteMaps.Id);

            if (siteMap != null)
            {
                if (siteMaps.IsHomePage.HasValue && siteMaps.IsHomePage.Value)
                {
                    var homePage = DayaxeDbContext.SiteMaps.FirstOrDefault(x => x.IsHomePage.HasValue && x.IsHomePage.Value);
                    if (homePage != null)
                    {
                        homePage.IsHomePage = false;
                    }
                }

                siteMap.Name       = siteMaps.Name;
                siteMap.UrlSegment = siteMaps.UrlSegment;
                siteMap.IsHomePage = siteMaps.IsHomePage;
                siteMap.IsActive   = siteMaps.IsActive;

                var htmlContents = DayaxeDbContext.HtmlContents.FirstOrDefault(x => x.ContentId == contents.ContentId);
                if (htmlContents != null)
                {
                    htmlContents.Title = contents.Title;
                    htmlContents.Data  = contents.Data;
                    htmlContents.ScriptAnalyticsHeader = contents.ScriptAnalyticsHeader;
                    htmlContents.BodyClass             = contents.BodyClass;
                    htmlContents.MetaDescription       = contents.MetaDescription;
                    htmlContents.MetaKeyword           = contents.MetaKeyword;
                    htmlContents.ImageLandingDesktop   = contents.ImageLandingDesktop;
                    htmlContents.ImageLandingMobile    = contents.ImageLandingMobile;
                }

                Commit();
            }
        }
示例#13
0
 /// <summary>
 /// Add a <see cref="SiteMap"/> to the <see cref="SiteMaps"/> collection.
 /// </summary>
 /// <param name="siteMap"></param>
 public void AddSiteMap(SiteMap siteMap)
 {
     SiteMaps.Add(siteMap);
 }
示例#14
0
        protected void Page_Init(object sender, EventArgs e)
        {
            Session["Active"] = "ContentsPage";
            if (!IsPostBack)
            {
                Session["UserHotel"]   = null;
                Session["CurrentPage"] = 1;

                if (Request.Params["id"] == null)
                {
                    MarketMultiView.ActiveViewIndex = 0;
                    ContentPageRpt.DataSource       = _helper.GetAllSiteMaps();
                    ContentPageRpt.DataBind();
                }
                else
                {
                    MarketMultiView.ActiveViewIndex = 1;
                    int id = int.Parse(Request.Params["id"]);
                    // Add New
                    if (id > 0)
                    {
                        _siteMaps = _helper.GetSiteMapsById(id);
                        if (_siteMaps != null)
                        {
                            string json = JsonConvert.SerializeObject(_siteMaps, CustomSettings.SerializerSettings());
                            Session["SiteMaps"]        = json;
                            PageNameText.Text          = _siteMaps.Name;
                            UrlSegmentText.Text        = _siteMaps.UrlSegment;
                            IsHomePageCheckBox.Checked = _siteMaps.IsHomePage.HasValue && _siteMaps.IsHomePage.Value;
                            IsActiveCheckBox.Checked   = _siteMaps.IsActive;

                            _htmlContents = _helper.GetHtmlContentsBySiteMapsId(id);
                            if (_htmlContents != null)
                            {
                                json = JsonConvert.SerializeObject(_htmlContents, CustomSettings.SerializerSettings());
                                Session["HtmlContents"]      = json;
                                PageTitleText.Text           = _htmlContents.Title;
                                ScriptAnalyticsEditor.Text   = _htmlContents.ScriptAnalyticsHeader;
                                ContentHtmlEditor.Text       = _htmlContents.Data;
                                BodyClassText.Text           = _htmlContents.BodyClass;
                                DescriptionText.Text         = _htmlContents.MetaDescription;
                                KeywordText.Text             = _htmlContents.MetaKeyword;
                                LandingImageDesktop.ImageUrl = _htmlContents.ImageLandingDesktop;
                                LandingImageMobile.ImageUrl  = _htmlContents.ImageLandingMobile;
                            }
                        }
                    }
                    else
                    {
                        IsActiveCheckBox.Checked = true;
                    }
                }
            }
            else
            {
                string sessionSiteMaps = Session["SiteMaps"] != null ? Session["SiteMaps"].ToString() : string.Empty;
                _siteMaps = JsonConvert.DeserializeObject <SiteMaps>(sessionSiteMaps);
                string sessionHtmlContents = Session["HtmlContents"] != null ? Session["HtmlContents"].ToString() : string.Empty;
                _htmlContents = JsonConvert.DeserializeObject <HtmlContents>(sessionHtmlContents);
            }
        }
 /// <summary>
 /// Called by the MVC framework after the action method executes.
 /// </summary>
 /// <param name="filterContext">The filter context.</param>
 public override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     SiteMaps.ReleaseSiteMap(this.SiteMapCacheKey);
 }