/// <summary>
 /// Insert a path in cSiteMapNode
 /// </summary>
 /// <param name="path">Insert URL (Ex. ~/default.aspx)</param>
 /// <param name="title">Inser title of URL</param>
 /// <param name="langaugeId">Insert ID of that langauge it write in</param>
 /// <param name="userId">Insert UserId</param>
 /// <param name="showSiteMapNode">Show URL in menu or not? (true)Show - (false)Dont show in menu</param>
 /// <param name="sort"></param>
 public void CreateSiteMapNode(string path,
                               string title,
                               int langaugeId,
                               Guid userId,
                               bool showSiteMapNode,
                               int sort,
                               SiteMapNodeMetatagsObject m)
 {
     CreateSiteMapNode_Single(path,
                              userId,
                              showSiteMapNode,
                              null,
                              title,
                              langaugeId,
                              sort,
                              m);
 }
 /// <summary>
 /// Update a path in cSiteMapNode
 /// (Insert RoleIds with AddRoleId)
 /// (Remove RoleIds with RemoveRoleId)
 /// </summary>
 /// <param name="siteMapNodeId">Insert SiteMapId</param>
 /// <param name="path">Insert URL (Ex. ~/default.aspx)</param>
 /// <param name="title">Inser title of URL</param>
 /// <param name="langaugeId">Insert ID of that langauge it write in</param>
 /// <param name="userId">Insert UserId</param>
 /// <param name="showSiteMapNode">Insert showSiteMapNode</param>
 /// <param name="newLangId">Insert newLangId</param>
 /// <param name="sort"></param>
 public void UpdateSiteMapNode(int siteMapNodeId,
                               string path,
                               string title,
                               int langaugeId,
                               Guid userId,
                               bool showSiteMapNode,
                               int?newLangId,
                               int sort,
                               SiteMapNodeMetatagsObject m)
 {
     UpdateSiteMap(siteMapNodeId,
                   langaugeId,
                   path,
                   userId,
                   showSiteMapNode,
                   null,
                   title,
                   newLangId,
                   sort,
                   m);
 }
예제 #3
0
        /// <summary>
        /// Update a path in cSiteMapNode
        /// (Insert RoleIds with AddRoleId and Remove RoleIds with RemoveRoleId)
        /// </summary>
        /// <param name="siteMapNodeId">Insert SiteMapId</param>
        /// <param name="path">Insert URL (Ex. ~/default.aspx)</param>
        /// <param name="userId">Insert UserId</param>
        /// <param name="showSiteMapNode">Show URL in menu or not? (true)Show - (false)Dont show in menu</param>
        /// <param name="siteMapNodeSubId">If you want this URL like a sub for a URL, then insert ID of the URL</param>
        /// <param name="title">Inser title of URL</param>
        /// <param name="langaugeId">Insert ID of that langauge it write in</param>
        /// <param name="newLangId">Insert newLangId</param>
        protected void UpdateSiteMap(int siteMapNodeId,
                                     int langaugeId,
                                     string path,
                                     Guid userId,
                                     bool showSiteMapNode,
                                     int?siteMapNodeSubId,
                                     string title,
                                     int?newLangId,
                                     int sort,
                                     SiteMapNodeMetatagsObject m)
        {
            DateTime dateTimeNow = TimeZoneManager.DateTimeNow;

            // using statement free the memory after metode is done
            using (Searchwar_netEntities db = new Searchwar_netEntities())
            {
                SW_SiteMapNode siteMapNode = (from s in db.SW_SiteMapNode
                                              where s.SiteMapNodeId.Equals(siteMapNodeId)
                                              select s).SingleOrDefault();

                // Check SiteMapId in database
                if (siteMapNode != null)
                {
                    siteMapNode.SiteMapNodePath       = path;
                    siteMapNode.SiteMapNodeShow       = showSiteMapNode;
                    siteMapNode.SiteMapNodeSubId      = siteMapNodeSubId;
                    siteMapNode.SiteMapNodeEditUserId = userId;
                    siteMapNode.SiteMapNodeEditDate   = dateTimeNow;
                    siteMapNode.SiteMapNodeSort       = sort;

                    SW_SiteMapNodeData siteMapNodeData = siteMapNode.SW_SiteMapNodeData.Single <SW_SiteMapNodeData>(d => d.SiteMapNodeId.Equals(siteMapNodeId) && d.LangId.Equals(langaugeId));
                    siteMapNodeData.SiteMapNodeTitle = title;
                    if (newLangId.HasValue)
                    {
                        siteMapNodeData.LangId = newLangId.Value;
                    }

                    db.SaveChanges();

                    object checkMetaTags =
                        db.SW_SiteMapNodeMetaTags.Where(mt => mt.MetaTagsId == siteMapNodeId).SingleOrDefault();

                    if (m != null && checkMetaTags != null)
                    {
                        new SearchWar.SiteMap.MetaTags.SiteMapNodeMetaTags().UpdateMetaTags(siteMapNodeId,
                                                                                            langaugeId,
                                                                                            m.MetaTagTitle,
                                                                                            m.MetaTagDescription,
                                                                                            m.MetaTagKeywords,
                                                                                            m.MetaTagLanguage,
                                                                                            m.MetaTagAuthor,
                                                                                            m.MetaTagPublisher,
                                                                                            m.MetaTagCopyright,
                                                                                            m.MetaTagRevisitAfter,
                                                                                            m.MetaTagRobots,
                                                                                            m.MetaTagCache,
                                                                                            m.MetaTagCacheControl,
                                                                                            null,
                                                                                            userId);
                    }
                }
                else
                {
                    throw (new ArgumentNullException("siteMapNodeId", "Cant find SiteMap '" + siteMapNodeId + "' in database"));
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Insert a path in cSiteMapNode (Insert RoleIds with AddRoleId)
        /// </summary>
        /// <param name="path">Insert URL (Ex. ~/default.aspx)</param>
        /// <param name="userId">Insert UserId</param>
        /// <param name="showSiteMapNode">Show URL in menu or not? (true)Show - (false)Dont show in menu</param>
        /// <param name="siteMapNodeSubId">If you want this URL like a sub for a URL, then insert ID of the URL</param>
        /// <param name="title">Inser title of URL</param>
        /// <param name="langaugeId">Insert ID of that langauge it write in</param>
        /// <param name="metatagsObject">to add metatags to sitemap (just left it null if you dont want metatags with)</param>
        protected void CreateSiteMapNode_Single(string path,
                                                Guid userId,
                                                bool showSiteMapNode,
                                                int?siteMapNodeSubId,
                                                string title,
                                                int langaugeId,
                                                int sort,
                                                SiteMapNodeMetatagsObject m)
        {
            DateTime dateTimeNow = TimeZoneManager.DateTimeNow;

            // using statement free the memory after metode is done
            using (Searchwar_netEntities db = new Searchwar_netEntities())
            {
                SW_SiteMapNode createSiteMapNode = new SW_SiteMapNode
                {
                    SiteMapNodePath        = path,
                    SiteMapNodeAddedUserId = userId,
                    SiteMapNodeEditUserId  = userId,
                    SiteMapNodeShow        = showSiteMapNode,
                    SiteMapNodeEditDate    = dateTimeNow,
                    SiteMapNodeAddedDate   = dateTimeNow,
                    SiteMapNodeSort        = sort
                };

                SW_SiteMapNodeData createSiteMapNodeData = new SW_SiteMapNodeData
                {
                    LangId = langaugeId
                };


                // Check title for empty
                if (!string.IsNullOrEmpty(title))
                {
                    createSiteMapNodeData.SiteMapNodeTitle = title;
                }


                // Check SubId for empty
                if (siteMapNodeSubId.HasValue)
                {
                    SW_SiteMapNode siteMapNodeSub = (from s in db.SW_SiteMapNode
                                                     where s.SiteMapNodeId.Equals(siteMapNodeSubId)
                                                     select s).SingleOrDefault();

                    // Check path is in database
                    if (siteMapNodeSub != null)
                    {
                        createSiteMapNode.SiteMapNodeSubId = siteMapNodeSubId;
                    }
                    else
                    {
                        throw (new ArgumentNullException("siteMapNodeSubId", "Cant find SiteMapId '" + siteMapNodeSubId + "' in database"));
                    }
                }

                db.SW_SiteMapNode.AddObject(createSiteMapNode);
                db.SaveChanges();

                // Insert SiteMapId
                createSiteMapNodeData.SiteMapNodeId = createSiteMapNode.SiteMapNodeId;

                db.SW_SiteMapNodeData.AddObject(createSiteMapNodeData);
                db.SaveChanges();


                if (m != null)
                {
                    new SearchWar.SiteMap.MetaTags.SiteMapNodeMetaTags().CreateMetaTags(createSiteMapNode.SiteMapNodeId,
                                                                                        m.MetaTagTitle,
                                                                                        m.MetaTagDescription,
                                                                                        m.MetaTagKeywords,
                                                                                        m.MetaTagLanguage,
                                                                                        m.MetaTagAuthor,
                                                                                        m.MetaTagPublisher,
                                                                                        m.MetaTagCopyright,
                                                                                        m.MetaTagRevisitAfter,
                                                                                        m.MetaTagRobots,
                                                                                        m.MetaTagCache,
                                                                                        m.MetaTagCacheControl,
                                                                                        userId,
                                                                                        langaugeId);
                }
            }
        }
예제 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Select current langauge
        string currentLang = new LangaugeSystem().CurrentLang;

        // Show if javascript is disable
        ErrorJS.InnerText = GetLocalResourceObject("JavascriptBoxErrorMessageError").ToString();

        // url for JS
        string pageId = Context.Request.AppRelativeCurrentExecutionFilePath.ToString();
        string jsurl  = ("~/js.axd?p=" + HttpUtility.UrlEncode(pageId)).ChangeToJsHost();

        scriptsall.Scripts.Add(new System.Web.UI.ScriptReference(jsurl));


        if (Page.IsPostBack)
        {
            return;
        }


        // get timezone
        ANO_User GetUserCookie = ANOProfile.GetCookieValues(CurrentUserIP);
        string   currentZone   = GetUserCookie.TimeZone;

        if (string.IsNullOrEmpty(currentZone))
        {
            DivTimeZone.Visible = true;
        }
        else
        {
            DivTimeZone.Visible = false;
        }



        // check cache
        System.Collections.ObjectModel.ReadOnlyCollection <TimeZoneInfo> getTimeZones = (System.Collections.ObjectModel.ReadOnlyCollection <TimeZoneInfo>)Cache["masterpage_timezones"];
        if (getTimeZones == null)
        {
            getTimeZones = TimeZoneInfo.GetSystemTimeZones();
            if (getTimeZones != null)
            {
                // add Cache
                Cache.Add("masterpage_timezones", getTimeZones, null, TimeZoneManager.DateTimeNow.AddDays(30),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }
        }

        DdlTimeZones.Items.Clear();
        foreach (var zone in getTimeZones)
        {
            DdlTimeZones.Items.Add(new ListItem(zone.DisplayName.ToString(), zone.BaseUtcOffset.ToString()));
        }
        if (!string.IsNullOrEmpty(currentZone))
        {
            DdlTimeZones.Items.FindByValue(currentZone).Selected = true;
        }


        // Insert Langauges in DropDownList
        DropDownList ddlLang = DdlSelectLang;

        ddlLang.Items.Clear();

        // check cache

        List <SW_Lang> langs = (List <SW_Lang>)Cache["masterpage_langs"];
        LangaugeSystem ls    = new LangaugeSystem();

        if (langs == null)
        {
            langs = ls.GetLangs();
            if (langs != null)
            {
                // add Cache
                Cache.Add("masterpage_langs", langs, null, TimeZoneManager.DateTimeNow.AddDays(10),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }
        }

        foreach (var lang in langs)
        {
            ddlLang.Items.Add(new ListItem(lang.LangName, lang.LangShortname));
        }


        // check cache
        int?currentLangId = (int?)Cache["masterpage_LangId" + currentLang];

        if (currentLangId.HasValue == false)
        {
            currentLangId = ls.GetLang(currentLang).LangId;
            if (currentLangId.HasValue == true)
            {
                // add Cache
                Cache.Add("masterpage_LangId" + currentLang, currentLangId, null, TimeZoneManager.DateTimeNow.AddDays(10),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }
        }

        if (!string.IsNullOrEmpty(currentLang))
        {
            DdlSelectLang.Items.FindByValue(currentLang).Selected = true;
        }



        // change url for logo (Now with shortlang)

        CustomSiteMapNode csm = new CustomSiteMapNode();
        cSiteMapNode      homeCSiteMapNode = csm.GetSiteMapNode(2, currentLangId.Value);
        string            getPath          = homeCSiteMapNode.SiteMapNodePath;

        if (!string.IsNullOrEmpty(homeCSiteMapNode.SiteMapNodeRewrittedPath))
        {
            getPath = homeCSiteMapNode.SiteMapNodeRewrittedPath;
        }
        HyperImgLogo.NavigateUrl = getPath;

        // Insert menu data
        // check cache
        List <cSiteMapNode> sitemapnodes = (List <cSiteMapNode>)Cache["masterpage_nodes" + currentLangId];

        if (sitemapnodes == null)
        {
            sitemapnodes = csm.GetSiteMapNodes((int)currentLangId, false);
            if (sitemapnodes != null)
            {
                // add Cache
                Cache.Add("masterpage_nodes" + currentLangId, sitemapnodes, null, TimeZoneManager.DateTimeNow.AddDays(1),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }
        }
        CMenu.DataSource    = sitemapnodes;
        CMenu.CurrentUserIP = CurrentUserIP;
        CMenu.DataBind();



        // Properties for metatags event
        SiteMapNodeMetatagsObject getMapMetaTags = null;
        cSiteMapNode getCurrentSiteMap           = null;
        int          currentSiteMapId;

        // Get CurrentSiteMapNode
        getCurrentSiteMap = csm.GetCurrentSiteMapNode((int)currentLangId);
        currentSiteMapId  = getCurrentSiteMap.SiteMapNodeId;

        // Get Metatags for current cSiteMapNode
        // check cache
        getMapMetaTags = (SiteMapNodeMetatagsObject)Cache["masterpage_NodeMetatags" + currentSiteMapId.ToString() + currentLangId.ToString()];
        SiteMapNodeMetaTags smm = new SiteMapNodeMetaTags();

        if (getMapMetaTags == null)
        {
            getMapMetaTags = smm.GetMetaTags(currentSiteMapId, (int)currentLangId);
            if (getMapMetaTags != null)
            {
                // add cache
                Cache.Add("masterpage_NodeMetatags" + currentSiteMapId.ToString() + currentLangId.ToString(),
                          getMapMetaTags,
                          null,
                          TimeZoneManager.DateTimeNow.AddDays(4),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }
        }


        // Insert MetaTags
        string pageTitle = Request.Url.Host;

        if (getMapMetaTags != null)
        {
            MetaAuthor.Content       = getMapMetaTags.MetaTagAuthor;
            MetaCache.Content        = getMapMetaTags.MetaTagCache;
            MetaCopyright.Content    = getMapMetaTags.MetaTagCopyright;
            MetaDescription.Content  = getMapMetaTags.MetaTagDescription;
            MetaKeywords.Content     = getMapMetaTags.MetaTagKeywords;
            MetaLanguage.Content     = getMapMetaTags.MetaTagLanguage;
            MetaPublisher.Content    = getMapMetaTags.MetaTagPublisher;
            MetaRobots.Content       = getMapMetaTags.MetaTagRobots;
            MetaRevisitAfter.Content = getMapMetaTags.MetaTagRevisitAfter;
            MetaCacheControl.Content = getMapMetaTags.MetaTagCacheControl;
            pageTitle += " - " + getMapMetaTags.MetaTagTitle;
        }


        Page.Title = pageTitle;
    }