private string GetCvPageXMLString()
 {
     using (StringWriter str = new Utf8StringWriter())
         using (XmlWriter writer = XmlWriter.Create(str))
         {
             XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
             ns.Add("", "http://www.sitemaps.org/schemas/sitemap/0.9");
             XmlSerializer xser  = new XmlSerializer(typeof(SiteMapModel));
             var           obj   = new SiteMapModel();
             List <string> users = new List <string> {
                 "AliPage.com", "VeliPage.com", "AysePage.com"
             };                                                                                  // Veritabanından bir kaynaktan gelebilir.
             foreach (var user in users)
             {
                 if (!String.IsNullOrEmpty(user))
                 {
                     obj.SiteMapUrls.Add(new SiteMapNodeModel()
                     {
                         Url = user, LastModified = DateTime.Now.ToString(), Priority = "0.8", Frequency = SiteMapFrequency.Monthly.ToString()
                     });
                 }
             }
             xser.Serialize(writer, obj, ns);
             return(str.ToString());
         }
 }
Esempio n. 2
0
        // GET: SiteMap
        public ActionResult Index()
        {
            List <SiteMapModel> lists = new List <SiteMapModel>();

            var controllers = Assembly.GetExecutingAssembly().GetExportedTypes().Where(t => typeof(ControllerBase).IsAssignableFrom(t)).Select(t => t);

            foreach (Type controller in controllers)
            {
                var actions = controller.GetMethods().Where(t => t.Name != "Dispose" && !t.IsSpecialName && t.DeclaringType.IsSubclassOf(typeof(ControllerBase)) && t.IsPublic && !t.IsStatic).ToList();

                foreach (var action in actions)
                {
                    string myAttributes = action.GetCustomAttributes(false).ToString();
                    for (int j = 0; j < myAttributes.Length; j++)
                    {
                        SiteMapModel list = new SiteMapModel();

                        list.ActionName = action.Name;
                        list.Url        = myAttributes[j].ToString();

                        lists.Add(list);
                    }
                    //s += string.Format("ActionName: {0}, Attribute: {1}< br >", action.Name, myAttributes[j]);
                }
            }

            ViewBag.Display = lists;
            return(View());
        }
        public ActionResult LoadPages(string node)
        {
            NodeCollection result = null;

            if (node == "_root")
            {
                result = SiteMapModel.CreateNode(SiteMap.RootNode).Children;
            }
            else
            {
                SiteMapNode           siteMapNode = SiteMap.Provider.FindSiteMapNodeFromKey(node);
                SiteMapNodeCollection children    = siteMapNode.ChildNodes;
                result = new NodeCollection();

                if (children != null && children.Count > 0)
                {
                    foreach (SiteMapNode mapNode in siteMapNode.ChildNodes)
                    {
                        result.Add(SiteMapModel.CreateNodeWithOutChildren(mapNode));
                    }
                }
            }

            return(this.Store(result));
        }
Esempio n. 4
0
        private ActionResult CreateSitemapInternal(string baseUrl, List <SiteMapNodeModel> nodes, IEnumerable <XmlSerializerNamespaceModel> namespaces = null)
        {
            nodes.ForEach(node => ValidateUrl(baseUrl, node));

            SiteMapModel sitemap = new SiteMapModel(nodes);

            return(actionResultFactory.CreateXmlResult(sitemap, namespaces));
        }
Esempio n. 5
0
        public JsonResult GetAssignedAndUnAssignedEmployeeDetails(string siteId, string stateId, string view)
        {
            SiteMapModel oSiteMapModel = new SiteMapModel()
            {
                Site  = siteId,
                State = stateId,
                View  = view
            };
            SiteMapResult result = oAdminManager.GetEmployeeMappedDetails(oSiteMapModel, CookieManager.GetCookie(CookieManager.CookieName).logindetail.EmpID);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
        // GET: /map/domain.com
        public ActionResult ShowMap(string domain)
        {
            if (String.IsNullOrWhiteSpace(domain))
            {
                return(HttpNotFound());
            }

            var model = new SiteMapModel();

            model.Domain = domain;

            return(View(model));
        }
Esempio n. 7
0
        private static void perpareNodeKeys(string roleID, SiteMapModel siteMapModel, ICollection <AspNetRoleSiteMapNode> AspNetRole_NodesKeys, string parentID = null)
        {
            if (siteMapModel.Selected)
            {
                string id = Guid.NewGuid().ToString();
                AspNetRole_NodesKeys.Add(new AspNetRoleSiteMapNode()
                {
                    ID = id, NodeKey = siteMapModel.Key, AspNetRoleID = roleID, ParentID = parentID
                });

                foreach (SiteMapModel tmpSiteMapModel in siteMapModel.SiteMapModels)
                {
                    perpareNodeKeys(roleID, tmpSiteMapModel, AspNetRole_NodesKeys, id);
                }
            }
        }
Esempio n. 8
0
 public SiteMapModel GetSitemap(int SiteID, string Url)
 {
     using (var _c = db)
     {
         bool _ECommerce = false;
         bool _Blog      = false;
         if (SiteID == 0)
         {
             var _Site = new SiteBLL().Get(Url, _c);
             SiteID     = _Site.SiteID;
             _ECommerce = _Site.ECommerce;
             _Blog      = _Site.Blog;
         }
         else
         {
             var _Site = new SiteBLL().Get(SiteID);
             _ECommerce = _Site.ECommerce;
             _Blog      = _Site.Blog;
         }
         var _S = new SiteMapModel();
         _S.Pages = (from p in _c.PageCultures
                     where p.Page.SiteID == SiteID
                     where p.Published && string.IsNullOrEmpty(p.RedirectUrl)
                     select new PageCultureBinding
         {
             CultureID = p.CultureID,
             FriendlyUrl = p.FriendlyUrl,
             RedirectUrl = p.RedirectUrl,
             Name = p.Name,
             PageAlias = p.Page.Alias
         }).Distinct().ToList();
         _S.Ecommerce = _ECommerce;
         _S.Blog      = _Blog;
         if (_ECommerce)
         {
             _S.Products   = new ProductBLL().GetSitemap(SiteID);
             _S.Categories = new CategoryBLL().GetSitemap(SiteID);
         }
         if (_Blog)
         {
             _S.Posts          = new BlogBLL().GetSitemap(SiteID);
             _S.BlogCategories = new BlogBLL().GetSitemapCategories(SiteID);
             _S.BlogTags       = new BlogBLL().GetSitemapTags(SiteID);
         }
         return(_S);
     }
 }
        public async Task <ActionResult> Index(SiteMapModel siteMap)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await testService.CreateTestAsync(siteMap.Host);
                }
                catch (Exception ex)
                {
                    ViewBag.Error = ex.Message;
                    return(View(siteMap));
                }

                return(RedirectToAction("TestResult"));
            }
            return(View(siteMap));
        }
Esempio n. 10
0
        private SiteMapModel GetSiteMapModel()
        {
            string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/');

            var model = new SiteMapModel()
            {
                HomeUrl = baseUrl
            };

            var articleInfos = _articleRepository.FetchArticleInfos().ToList();
            var galleryInfos = _galleryRepository.FetchGalleryInfos();

            model.Galleries = galleryInfos.ToDictionary(g => g.Title, g => "gallery/view/" + g.GalleryId.ToString());

            model.News    = articleInfos.Where(a => a.TypeName == "News").ToDictionary(a => a.Title, a => "article/view/" + a.ArticleId.ToString());
            model.Reviews = articleInfos.Where(a => a.TypeName == "Review").ToDictionary(a => a.Title, a => "article/review/" + a.ArticleId.ToString());

            return(model);
        }
Esempio n. 11
0
        public static void PrepareSiteMapModel(SiteMapModel siteMapModel, string role = null, ISiteMapNode siteMapNode = null)
        {
            if (siteMapNode == null)
            {
                siteMapNode = MvcSiteMapProvider.SiteMaps.GetSiteMap().RootNode;
            }

            if (IsRolesEditable(siteMapNode))
            {
                siteMapModel.Title    = siteMapNode.Title;
                siteMapModel.Key      = siteMapNode.Key;
                siteMapModel.Selected = _GetNodeRoles(siteMapNode).Any(x => x == role);
            }

            foreach (ISiteMapNode tmpSiteMapNode in siteMapNode.ChildNodes)
            {
                SiteMapModel tmpSiteMapModel = new SiteMapModel();
                PrepareSiteMapModel(tmpSiteMapModel, role, tmpSiteMapNode);
                if (!string.IsNullOrEmpty(tmpSiteMapModel.Key))
                {
                    siteMapModel.SiteMapModels.Add(tmpSiteMapModel);
                }
            }
        }
Esempio n. 12
0
        public JsonResult SetSiteMapping(SiteMapModel siteMapModel)
        {
            Message result = oAdminManager.SetSiteMapping(siteMapModel, CookieManager.GetCookie(CookieManager.CookieName).logindetail.EmpID);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 13
0
 public abstract bool updateSiteMapItem(Guid id, SiteMapModel item);
 public ActionResult Index()
 {
     return(View(SiteMapModel.CreateNode(SiteMap.RootNode)));
 }
Esempio n. 15
0
        /// <summary>
        /// Создаём новый раздел в карте сайта
        /// </summary>
        /// <param name="id">Идентификатор записи</param>
        /// <param name="item">Элемент карты сайта</param>
        /// <param name="userId">Идентификатор пользователя</param>
        /// <param name="IP">Ip-адрес</param>
        /// <returns></returns>
        public override bool createSiteMapItem(Guid id, SiteMapModel item)
        {
            using (var db = new CMSdb(_context))
            {
                using (var tran = db.BeginTransaction())
                {
                    var data = db.content_sitemaps.Where(w => w.id.Equals(id));
                    if (!data.Any())
                    {
                        var queryMaxSort = db.content_sitemaps
                                           .Where(w => w.f_site == item.Site)
                                           .Where(w => w.c_path.Equals(item.Path))
                                           .Select(s => s.n_sort);

                        int maxSort = queryMaxSort.Any() ? queryMaxSort.Max() + 1 : 1;

                        db.content_sitemaps
                        .Value(p => p.id, id)
                        .Value(p => p.f_site, item.Site)
                        .Value(p => p.f_front_section, item.FrontSection)
                        .Value(p => p.c_path, item.Path)
                        .Value(p => p.c_alias, item.Alias)
                        .Value(p => p.c_title, item.Title)
                        .Value(p => p.c_preview, item.Preview)
                        .Value(p => p.c_url, item.Url)
                        .Value(p => p.c_desc, item.Desc)
                        .Value(p => p.c_keyw, item.Keyw)
                        .Value(p => p.b_disabled, item.Disabled)
                        .Value(p => p.b_blocked, item.Blocked)
                        .Value(p => p.b_disabled_menu, item.DisabledMenu)
                        .Value(p => p.n_sort, maxSort)
                        .Value(p => p.c_text, item.Text)
                        .Value(p => p.uui_parent, item.ParentId)
                        .Value(p => p.c_photo, item.Photo != null ? item.Photo.Url : null)
                        .Insert();

                        // группы меню
                        if (item.MenuGroups != null)
                        {
                            foreach (var m in item.MenuGroups)
                            {
                                Guid menuId = Guid.Parse(m);

                                var _maxSortMenu = db.content_sitemap_menutypess
                                                   .Where(w => w.f_site.Equals(item.Site))
                                                   .Where(w => w.f_menutype.Equals(menuId))
                                                   .Select(s => s.n_sort);

                                int mS = _maxSortMenu.Any() ? _maxSortMenu.Max() : 0;

                                var menu = db.content_sitemap_menutypess
                                           .Value(p => p.f_sitemap, id)
                                           .Value(p => p.f_menutype, menuId)
                                           .Value(p => p.f_site, item.Site)
                                           .Value(p => p.n_sort, mS + 1)
                                           .Insert();
                            }
                        }

                        // логирование
                        //insertLog(userId, IP, "insert", id, String.Empty, "SiteMap", item.Title);
                        var log = new LogModel()
                        {
                            Site     = _domain,
                            Section  = LogSection.SiteMap,
                            Action   = LogAction.insert,
                            PageId   = id,
                            PageName = item.Title,
                            UserId   = _currentUserId,
                            IP       = _ip,
                        };
                        insertLog(log);

                        tran.Commit();
                        return(true);
                    }

                    return(false);
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Обновляем запись карты сайта
        /// </summary>
        /// <param name="id">Идентификатор записи</param>
        /// <param name="item">Элемент карты сайта</param>
        /// <param name="userId">Идентификатор пользователя</param>
        /// <param name="IP">Ip-адрес</param>
        /// <returns></returns>
        public override bool updateSiteMapItem(Guid id, SiteMapModel item)
        {
            using (var db = new CMSdb(_context))
            {
                using (var tran = db.BeginTransaction())
                {
                    var data = db.content_sitemaps.Where(w => w.id.Equals(id));

                    if (data.Any())
                    {
                        var oldRecord = data.SingleOrDefault();

                        data.Where(w => w.id.Equals(id))
                        .Set(u => u.f_site, item.Site)
                        .Set(u => u.f_front_section, item.FrontSection)
                        .Set(u => u.c_path, item.Path)
                        .Set(u => u.c_alias, item.Alias)
                        .Set(u => u.c_title, item.Title)
                        .Set(u => u.c_text, item.Text)
                        .Set(u => u.c_preview, item.Preview)
                        .Set(u => u.c_url, item.Url)
                        .Set(u => u.c_desc, item.Desc)
                        .Set(u => u.c_keyw, item.Keyw)
                        .Set(u => u.b_disabled, item.Disabled)
                        .Set(u => u.b_blocked, item.Blocked)
                        .Set(u => u.b_disabled_menu, item.DisabledMenu)
                        .Set(u => u.c_photo, item.Photo != null ? item.Photo.Url : null)
                        .Update();

                        #region обновим алиасы для дочерних эл-тов
                        // заменяемый путь
                        string _oldPath = oldRecord.c_path.Equals("/") ?
                                          oldRecord.c_path + oldRecord.c_alias : oldRecord.c_path + "/" + oldRecord.c_alias;

                        // новый путь
                        string _newPath = item.Path.Equals("/") ?
                                          item.Path + item.Alias : item.Path + "/" + item.Alias;

                        // список дочерних эл-тов для обновления алиаса
                        var listToUpdate = db.content_sitemaps
                                           .Where(w => w.f_site.Equals(item.Site))
                                           .Where(w => w.c_path.StartsWith(_oldPath));

                        if (listToUpdate.Any())
                        {
                            listToUpdate
                            .Set(u => u.c_path, u => u.c_path.Replace(_oldPath, _newPath))
                            .Update();
                        }
                        #endregion

                        #region группы меню
                        // группы меню
                        var menuOldQuery = db.content_sitemap_menutypess
                                           .Where(w => w.f_site.Equals(_domain))
                                           .Where(w => w.f_sitemap.Equals(id))
                                           .Select(s => s.f_menutype);

                        if (menuOldQuery.Any())
                        {
                            var menuOld = menuOldQuery.ToArray();

                            if (item.MenuGroups != null)
                            {
                                //удаляем значения
                                var CurrenMenuGroup = item.MenuGroups.Select(s => Guid.Parse(s)).ToArray();
                                foreach (var d in menuOld)
                                {
                                    if (!CurrenMenuGroup.Contains(d))
                                    {
                                        #region удаляем элемент из группы
                                        //смещаем приоритеты в группах
                                        int current_sort = db.content_sitemap_menutypess
                                                           .Where(w => w.f_site == _domain)
                                                           .Where(w => w.f_sitemap == id)
                                                           .Where(w => w.f_menutype == d)
                                                           .Select(s => s.n_sort).Single();

                                        //удаляем
                                        db.content_sitemap_menutypess
                                        .Where(w => (w.f_sitemap == id && w.f_menutype == d))
                                        .Delete();

                                        db.content_sitemap_menutypess
                                        .Where(w => w.f_site == _domain && w.f_menutype == d && w.n_sort >= current_sort)
                                        .Set(p => p.n_sort, p => p.n_sort - 1)
                                        .Update();

                                        #endregion
                                    }
                                }

                                //добавляем значения
                                foreach (var m in item.MenuGroups)
                                {
                                    Guid menuId = Guid.Parse(m);

                                    if (!menuOld.Contains(menuId))
                                    {
                                        var maxSortQuery = db.content_sitemap_menutypess
                                                           .Where(w => w.f_site.Equals(item.Site))
                                                           .Where(w => w.f_menutype.Equals(menuId));

                                        int maxSort = maxSortQuery.Any() ? maxSortQuery.Select(s => s.n_sort).Max() : 0;

                                        db.content_sitemap_menutypess
                                        .Value(p => p.f_sitemap, id)
                                        .Value(p => p.f_menutype, menuId)
                                        .Value(p => p.f_site, item.Site)
                                        .Value(p => p.n_sort, maxSort + 1)
                                        .Insert();
                                    }
                                    #region //
                                    //else
                                    //{
                                    //    //если в группе был и остается то нничего не делаем
                                    //    if (item.MenuGroups.Contains(menuId.ToString())){

                                    //    }
                                    //    else
                                    //    {
                                    //        #region удаляем элемент из группы
                                    //        //смещаем приоритеты в группах
                                    //        int current_sort = db.content_sitemap_menutypess
                                    //                                .Where(w => w.f_site.Equals(_domain))
                                    //                                .Where(w => w.f_sitemap.Equals(id))
                                    //                                .Where(w => w.f_menutype == menuId)
                                    //                                .Select(s => s.n_sort).Single();

                                    //        db.content_sitemap_menutypess
                                    //          .Where(w => w.f_site == _domain && w.f_menutype == menuId && w.n_sort > current_sort)
                                    //          .Set(p => p.n_sort, p => p.n_sort - 1)
                                    //          .Update();

                                    //        //удаляем
                                    //        db.content_sitemap_menutypess
                                    //          .Where(w => (w.f_sitemap == id && w.f_menutype == menuId))
                                    //          .Delete();
                                    //        #endregion
                                    //    }
                                    //}
                                    #endregion
                                }
                            }
                            else
                            {
                                //смещаем все приоритеты
                                var menu_type = db.content_sitemap_menutypess.Where(w => w.f_sitemap == id).Select(s => s.f_menutype).ToArray();
                                foreach (var mt in menu_type)
                                {
                                    int current_sort = db.content_sitemap_menutypess
                                                       .Where(w => w.f_site == _domain)
                                                       .Where(w => w.f_sitemap == id)
                                                       .Where(w => w.f_menutype == mt)
                                                       .Select(s => s.n_sort).Single();

                                    db.content_sitemap_menutypess
                                    .Where(w => w.f_site == _domain && w.f_menutype == mt && w.n_sort >= current_sort)
                                    .Set(p => p.n_sort, p => p.n_sort - 1)
                                    .Update();
                                }

                                //элемент удаляется из всех групп меню
                                db.content_sitemap_menutypess
                                .Where(w => w.f_sitemap.Equals(id)).Delete();
                            }
                        }
                        else
                        {
                            //случай когда до этого элемент карты не принадлежал ни к  одной группе
                            if (item.MenuGroups != null)
                            {
                                foreach (var m in item.MenuGroups)
                                {
                                    Guid menuId = Guid.Parse(m);

                                    var _maxSortMenu = db.content_sitemap_menutypess
                                                       .Where(w => w.f_site.Equals(item.Site))
                                                       .Where(w => w.f_menutype.Equals(menuId));

                                    int resmaxSortMenu = _maxSortMenu.Any() ? _maxSortMenu.Select(s => s.n_sort).Max() : 0;

                                    var res = db.content_sitemap_menutypess
                                              .Value(p => p.f_sitemap, id)
                                              .Value(p => p.f_menutype, menuId)
                                              .Value(p => p.f_site, item.Site)
                                              .Value(p => p.n_sort, resmaxSortMenu + 1)
                                              .Insert();
                                }
                            }
                        }
                        #endregion

                        // логирование
                        var log = new LogModel()
                        {
                            Site     = _domain,
                            Section  = LogSection.SiteMap,
                            Action   = LogAction.update,
                            PageId   = id,
                            PageName = item.Title,
                            UserId   = _currentUserId,
                            IP       = _ip,
                        };
                        insertLog(log);

                        tran.Commit();
                        return(true);
                    }

                    return(false);
                }
            }
        }
Esempio n. 17
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            Domain = "main";

            #region Получаем данные из адресной строки
            //Частные случаи (model.CurrentPage = null) рассматриваем в самих контроллерах
            _alias = "";
            _path  = "/";

            var url = HttpContext.Request.Url.AbsolutePath.ToLower();

            //Сюда попадаем еще, если на странице есть картинки или файлы
            if (url.LastIndexOf(".") > -1)
            {
                return;
            }

            //Обрезаем  query string (Все, что после ? )
            if (url.LastIndexOf("?") > -1)
            {
                url = url.Substring(0, url.LastIndexOf("?"));
            }
            //Сегменты пути
            var segments = url.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);


            if (segments != null && segments.Count() > 0)
            {
                _alias = segments.Last();

                if (segments.Count() > 1)
                {
                    _path = string.Join("/", segments.Take(segments.Length - 1));
                    _path = string.Format("/{0}/", _path);
                }
            }
            currentPage = _repository.getSiteMap(_path, _alias);
            #endregion

            HttpCookie MyCookie = Request.Cookies["order-id"];

            if (User.Identity.IsAuthenticated)
            {
                UserInfo = _repository.getCustomer(new Guid(User.Identity.Name));
                if (UserInfo != null)
                {
                    OrderId = _repository.getOrderId(UserInfo.Id);
                }
            }
            else
            {
                OrderId = (MyCookie != null) ? Guid.Parse(HttpUtility.UrlDecode(MyCookie.Value, Encoding.UTF8)) : Guid.Empty;

                if (MyCookie != null && !_repository.CheckOrder(OrderId))
                {
                    MyCookie.Expires = DateTime.Now.AddDays(-1);
                    Response.Cookies.Add(MyCookie);
                }
            }

            ViewName  = _repository.getView(filterContext.RouteData.Values["Controller"].ToString().ToLower());
            siteModel = _repository.getSiteInfo();
        }
Esempio n. 18
0
        public JsonResult GetEmployeeMappedDetails(SiteMapModel siteMapModel)
        {
            SiteMapResult result = oAdminManager.GetEmployeeMappedDetails(siteMapModel, CookieManager.GetCookie(CookieManager.CookieName).logindetail.EmpID);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }