Exemplo n.º 1
0
        /// <summary>
        /// 連結檔案選單
        /// </summary>
        /// <param name="data"></param>
        public static void Save_Menu(ResourceLinksModels data)
        {
            SQLData.Database db = new SQLData.Database(WebInfo.Conn);

            string Sql =
                "IF EXISTS (SELECT 1 FROM ResourceLinks WHERE ID=@ID and SiteID=@SiteID and SourceNo=@SourceNo and SourceType=@SourceType and Ver=@Ver and AreaID=@AreaID)" +

                " UPDATE ResourceLinks SET LinkType=@LinkType, LinkInfo=@LinkInfo, Descriptions=Descriptions, Detail=@Detail, ClickType=@ClickType, Modifier=@Modifier, ModifyTime=GetDate() WHERE ID=@ID and SiteID=@SiteID and SourceNo=@SourceNo and SourceType=@SourceType and Ver=@Ver and AreaID=@AreaID" +

                " ELSE" +

                " INSERT INTO ResourceLinks(ID,SiteID,SourceNo, SourceType,Ver,AreaID,LinkType,LinkInfo,Descriptions,Detail,ClickType,Creator,CreateTime)VALUES(@ID,@SiteID,@SourceNo,@SourceType,@Ver,@AreaID,@LinkType,@LinkInfo,@Descriptions,@Detail,@ClickType,@Creator,GetDate())";

            SQLData.ParameterCollection para = new SQLData.ParameterCollection();

            para.Add("@ID", data.Id);
            para.Add("@SiteID", data.SiteID);
            para.Add("@SourceNo", data.SourceNo);
            para.Add("@SourceType", data.SourceType);
            para.Add("@Ver", data.Ver);
            para.Add("@AreaID", data.AreaID);
            para.Add("@LinkType", data.LinkType);
            para.Add("@LinkInfo", data.LinkInfo);
            para.Add("@Descriptions", data.Descriptions);
            para.Add("@Detail", data.Detail);
            para.Add("@ClickType", data.ClickType);
            para.Add("@Creator", MemberDAO.SysCurrent.Id);
            para.Add("@Modifier", MemberDAO.SysCurrent.Id);
            db.ExecuteNonQuery(Sql, para);
        }
Exemplo n.º 2
0
        public static void SetItem(ResourceLinksModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("ResourceLinks");
            tableObj.GetDataFromObject(item);

            string sql   = "Select 1 From ResourceLinks Where ID = " + item.Id;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["ClickType"]  = 0;
                tableObj["Creator"]    = MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;

                tableObj.Insert();
            }
            else
            {
                string[] removeFields = { "ID", "SiteID", "SourceNo", "SourceType", "Ver", "AreaID", "ClickType", "Code", "Creator", "CreateTime" };
                foreach (string f in removeFields)
                {
                    tableObj.Remove(f);
                }

                tableObj["Modifier"]   = MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = DateTime.Now;

                SQLData.ParameterCollection keys = new SQLData.ParameterCollection();
                keys.Add("@ID", item.Id);
                keys.Add("@SiteID", item.SiteID);
                keys.Add("@SourceNo", item.SourceNo);
                keys.Add("@SourceType", item.SourceType);
                keys.Add("@Ver", item.Ver);
                keys.Add("@AreaID", item.AreaID);

                tableObj.Update(keys);
            }
        }
Exemplo n.º 3
0
        private static ResourceLinksModels CreateData(DataRow dr)
        {
            ResourceLinksModels nData = new ResourceLinksModels
            {
                Id           = (long)dr["id"],
                SiteID       = (long)dr["SiteID"],
                SourceNo     = (long)dr["SourceNo"],
                SourceType   = (byte)dr["SourceType"],
                Ver          = (int)dr["Ver"],
                AreaID       = (byte)dr["AreaID"],
                LinkType     = dr["LinkType"].ToString().Trim(),
                LinkInfo     = dr["LinkInfo"].ToString().Trim(),
                Descriptions = dr["Descriptions"].ToString().Trim(),
                Detail       = dr["Detail"].ToString().Trim(),
                ClickType    = (int)dr["ClickType"],
                Creator      = (long)dr["Creator"],
                CreateTime   = dr["CreateTime"] as DateTime?,
                Modifier     = dr["Modifier"] as long?,
                ModifyTime   = dr["ModifyTime"] as DateTime?
            };

            return(nData);
        }
Exemplo n.º 4
0
        public static ResourceLinksModels GetInfo(long SiteID, long SourceNo, byte SourceType, int AreaID, long Id, int Ver)
        {
            SQLData.Database db  = new SQLData.Database(WebInfo.Conn);
            string           Sql = "Select * From ResourceLinks Where Id=@Id and SiteID=@SiteID and SourceNo=@SourceNo and SourceType=@SourceType and Ver=@Ver and AreaID=@AreaID";

            SQLData.ParameterCollection para = new SQLData.ParameterCollection();

            para.Add("@ID", Id);
            para.Add("@SiteID", SiteID);
            para.Add("@SourceNo", SourceNo);
            para.Add("@SourceType", SourceType);
            para.Add("@Ver", Ver);
            para.Add("@AreaID", AreaID);
            DataTable dt = db.GetDataTable(Sql, para);

            ResourceLinksModels _TempRow = new ResourceLinksModels();

            if (dt.Rows.Count > 0)
            {
                _TempRow = CreateData(dt.Rows[0]);
            }

            return(_TempRow);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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());
        }