/// <summary> /// 為一個主頁面增加相關的 Page、Zone、Card 信息 /// </summary> /// <param name="sourcePage">原始頁面</param> /// <param name="targetSiteId">站點 ID</param> /// <param name="targetMenuId">選單 ID</param> /// <returns>返回 CardID</returns> public static long CopyPage(PagesModels sourcePage, long targetSiteId, long targetMenuId) { long CardNO = 0; long PageNo = WorkLib.GetItem.NewSN(); var sourceMnu = WorkV3.Models.DataAccess.MenusDAO.GetInfo(sourcePage.SiteID, sourcePage.MenuID); var targetMnu = WorkV3.Models.DataAccess.MenusDAO.GetInfo(targetSiteId, targetMenuId); PagesModels newPage = new PagesModels { No = PageNo, SiteID = targetSiteId, MenuID = targetMenuId, SN = targetMnu.SN, Title = sourcePage.Title + "- (複製)" }; newPage.SN += "_" + newPage.No; //WorkLib.WriteLog.Write(true, "newPage.No:" + newPage.No.ToString()+"/"+ newPage.Title); SysLog.SaveLog(SysActions.Add, SysMgrNo.Page, newPage.Title, targetSiteId, targetMenuId, PageNo); PagesDAO.SetPageInfo(newPage); var sourceZones = WorkV3.Models.DataAccess.ZonesDAO.GetPageData(sourcePage.SiteID, sourcePage.No); foreach (WorkV3.Models.ZonesModels sourceZone in sourceZones) { ZonesModels newZone = new ZonesModels { No = WorkLib.GetItem.NewSN(), SiteID = targetSiteId, PageNo = newPage.No, StyleID = sourceZone.StyleID, Sort = sourceZone.Sort, ShowStatus = sourceZone.ShowStatus }; ZonesDAO.SetZoneInfo(newZone); var sourceCards = WorkV3.Models.DataAccess.CardsDAO.GetZoneData(sourceZone.SiteID, sourceZone.No); foreach (WorkV3.Models.CardsModels sourceCard in sourceCards) { CardsModels newCard = new CardsModels { No = WorkLib.GetItem.NewSN(), ZoneNo = newZone.No, CardsType = sourceCard.CardsType, ViewAction = sourceCard.ViewAction, Status = sourceCard.Status, StylesID = sourceCard.StylesID }; CardsDAO.SetCardInfo(newCard); if (newCard.CardsType == "Article" || newCard.CardsType == "Event") { CardNO = newCard.No; } } } return(CardNO); }
/// <summary> /// 為一個主頁面增加相關的 Page、Zone、Card 信息 /// </summary> /// <param name="siteId">站點 ID</param> /// <param name="menuId">選單 ID</param> /// <param name="name">頁面名稱</param> /// <param name="cardType">Card 类型(對應到 Controller)</param> /// <param name="viewAction">操作(對應到 Controller Action)</param> /// <param name="appendIdToName">是否將 ID 附加到頁面名稱後</param> /// <param name="title">頁面標題</param> /// <param name="styleId">指定樣式</param> /// <returns>返回 CardID</returns> public static long AddPage(long siteId, long menuId, string name, string cardType, string viewAction = null, bool appendIdToName = false, string title = null, int ZoneStyleId = 1, bool isMenuAdd = false, int CardStyleId = 1) { long CardNO = 0; long PageNo = WorkLib.GetItem.NewSN(); if (isMenuAdd == true) { PageNo = menuId; } PagesModels page = new PagesModels { No = PageNo, SiteID = siteId, MenuID = menuId, SN = name, Title = title }; if (appendIdToName) { page.SN += "_" + page.No; } SysLog.SaveLog(SysActions.Add, SysMgrNo.Page, title, siteId, menuId, PageNo); PagesDAO.SetPageInfo(page); #region 增加動態 ZONE、CARD switch (cardType) { //例外的卡 case "Intro": break; default: ZonesModels zone = new ZonesModels { No = WorkLib.GetItem.NewSN(), SiteID = siteId, PageNo = page.No, StyleID = ZoneStyleId, Sort = 10, //需排在固定項後 ShowStatus = 1 }; ZonesDAO.SetZoneInfo(zone); if (string.IsNullOrEmpty(viewAction) && cardType == "Form") { viewAction = "Edit"; } CardsModels card = new CardsModels { No = WorkLib.GetItem.NewSN(), ZoneNo = zone.No, CardsType = cardType, StylesID = CardStyleId, ViewAction = viewAction, Status = 1 }; CardsDAO.SetCardInfo(card); CardNO = card.No; break; } #endregion if (cardType == "Reward") { return(CardNO);// wei 20180914 集點捨去固定ZONE內容 } #region 固定ZONE //CardsType,Zones.Style,Zones.Sort,Cards.StyleID string[,] FixedItem = { { "Header", "1000", "1", WebInfo.StyleHeader }, { "BreadCrumbs", "1002", "5", "1" }, { "Footer", "1001", "20", WebInfo.StyleFooter } }; if (FixedItem.Rank > 0) { for (int i = 0; i < FixedItem.GetLength(0); i++) { if (page.SN.ToLower() == "index" && FixedItem[i, 0] == "BreadCrumbs") { } else { ZonesModels NewZone = new ZonesModels { No = WorkLib.GetItem.NewSN(), SiteID = siteId, PageNo = page.No, StyleID = int.Parse(FixedItem[i, 1]), Sort = byte.Parse(FixedItem[i, 2]), ShowStatus = 1 }; ZonesDAO.SetZoneInfo(NewZone); CardsModels NewCard = new CardsModels { No = WorkLib.GetItem.NewSN(), ZoneNo = NewZone.No, CardsType = FixedItem[i, 0], Status = 1, StylesID = int.Parse(FixedItem[i, 3]) }; CardsDAO.SetCardInfo(NewCard); } } } #endregion return(CardNO); }