示例#1
0
        public void MenuEdit_Link(MenusModels MData, string Sites, string[] Pages, string PageDetailID)
        {
            ViewBag.HasChildren = false;
            var childList = MenusDAO.GetChildren(MData.ID);

            if (childList != null && childList.Count() > 0)
            {
                ViewBag.HasChildren = true;
            }
            MenusDAO.Save_Single(MData);


            ResourceLinksModels newLink = new ResourceLinksModels();

            newLink.Id         = 1;
            newLink.SiteID     = MData.SiteID;
            newLink.SourceNo   = MData.ID;
            newLink.SourceType = (byte)SourceType.Menu;
            newLink.Ver        = 1;
            newLink.AreaID     = 1;
            bool isOpenNewWin = Request["OpenNewWin"].Contains("true");

            if (isOpenNewWin)
            {
                newLink.ClickType = (byte)ClickType.OpenNewWin;
            }
            else
            {
                newLink.ClickType = (byte)ClickType.PageOpen;
            }
            //WorkLib.WriteLog.Write(true, Request["inLink"]);
            if (Request["inLink"].Contains("true"))
            {
                newLink.LinkInfo = Request["LinkInfo"].ToString();

                newLink.LinkType = ResourceLinkType.inLink;
                if (!string.IsNullOrEmpty(PageDetailID))
                {
                    newLink.Detail = PageDetailID;
                    var pageInfo = WorkV3.Areas.Backend.Models.DataAccess.PagesDAO.GetPageInfo(long.Parse(PageDetailID));
                    if (pageInfo != null)
                    {
                        var siteInfo = WorkV3.Models.DataAccess.SitesDAO.GetInfo(pageInfo.SiteID);
                        newLink.LinkInfo = Url.RouteUrl("FrontSitePage", new { SiteSN = siteInfo.SN, PageSN = pageInfo.SN });
                    }
                }
                else if (Pages != null)
                {
                    for (int i = 0; i < Pages.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(Pages[i]))
                        {
                            newLink.Detail = Pages[i];
                        }
                    }
                    if (!string.IsNullOrEmpty(newLink.Detail))
                    {
                        var pageInfo = WorkV3.Areas.Backend.Models.DataAccess.PagesDAO.GetPageInfo(long.Parse(newLink.Detail));
                        if (pageInfo != null)
                        {
                            var siteInfo = WorkV3.Models.DataAccess.SitesDAO.GetInfo(pageInfo.SiteID);
                            newLink.LinkInfo = Url.RouteUrl("FrontSitePage", new { SiteSN = siteInfo.SN, PageSN = pageInfo.SN });
                        }
                    }
                }
            }
            else
            {
                newLink.LinkType = ResourceLinkType.outLink;
                newLink.LinkInfo = Request["LinkInfo"].ToString();
            }

            ResourceLinksDAO.Save_Menu(newLink);

            SysLog.SaveLog(SysActions.Edit, SysMgrNo.Menu, MData.Title, MData.SiteID, MData.ID);
            TempData["refreshData"] = SysActions.Edit;
            Response.Redirect(Request.RawUrl);
        }
示例#2
0
 public IEnumerable <ResourceLinksModels> GetLinks()
 {
     return(ResourceLinksDAO.GetItems(ID, "Match"));
 }
示例#3
0
        public ActionResult MenuEdit_Link(long?id)
        {
            ViewBag.HasChildren = false;
            List <long> MenuIDs = new List <long>();
            Dictionary <int, WorkV3.Models.MenusModels> MenuList = new Dictionary <int, WorkV3.Models.MenusModels>();

            if (uCheck.IsNumeric(id))
            {
                long                SiteID  = GetItem.SiteID();
                MenusModels         mm      = MenusDAO.GetInfo(GetItem.SiteID(), (long)id);
                ResourceLinksModels newLink = ResourceLinksDAO.GetInfo(SiteID, (long)id, (byte)SourceType.Menu, 1, 1, 1);
                ViewBag.LinkInfo = newLink;
                var childList = MenusDAO.GetChildren(id.Value);
                if (childList != null && childList.Count() > 0)
                {
                    ViewBag.HasChildren = true;
                }
                int menuLev = 0;
                if (!string.IsNullOrEmpty(newLink.Detail))
                {
                    var menuInfo = WorkV3.Models.DataAccess.MenusDAO.GetInfo(long.Parse(newLink.Detail));
                    if (menuInfo != null && !string.IsNullOrEmpty(menuInfo.Title))
                    {
                        ViewBag.DefaultSiteID = menuInfo.SiteID;
                        menuLev++;
                        MenuList.Add(menuLev, menuInfo);
                        while (menuInfo.ParentID != 0)
                        {
                            menuInfo = WorkV3.Models.DataAccess.MenusDAO.GetInfo(menuInfo.ParentID);
                            if (menuInfo != null && !string.IsNullOrEmpty(menuInfo.Title))
                            {
                                menuLev++;
                                MenuList.Add(menuLev, menuInfo);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        var pageInfo = WorkV3.Areas.Backend.Models.DataAccess.PagesDAO.GetPageInfo(long.Parse(newLink.Detail));
                        if (pageInfo != null && !string.IsNullOrEmpty(pageInfo.Title))
                        {
                            ViewBag.DefaultSiteID    = pageInfo.SiteID;
                            ViewBag.DefaultPageTitle = pageInfo.Title;
                            var page_menuInfo = WorkV3.Models.DataAccess.MenusDAO.GetInfo(pageInfo.MenuID);
                            if (page_menuInfo != null)
                            {
                                menuLev++;
                                MenuList.Add(menuLev, page_menuInfo);
                                while (page_menuInfo.ParentID != 0)
                                {
                                    page_menuInfo = WorkV3.Models.DataAccess.MenusDAO.GetInfo(page_menuInfo.ParentID);
                                    if (page_menuInfo != null && !string.IsNullOrEmpty(page_menuInfo.Title))
                                    {
                                        menuLev++;
                                        MenuList.Add(menuLev, page_menuInfo);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (MenuList != null && MenuList.Count > 0)
                    {
                        var orderMenus = MenuList.OrderByDescending(p => p.Key).Select(p => p.Value.Id);
                        MenuIDs = orderMenus.ToList();
                    }
                    ViewBag.DefaultMenus = MenuIDs;
                }
                return(View(mm));
            }
            return(View());
        }