public static void Save_Single(MenusModels data) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject TableObj = db.GetTableObject("Menus"); TableObj.Add("Title", data.Title); //TableObj.Add("ParentID", data.ParentID); TableObj.Add("ShowStatus", data.ShowStatus); //TableObj.Add("Sort", data.Sort); TableObj.Add("Modifier", MemberDAO.SysCurrent.Id); TableObj.Add("ModifyTime", DateTime.Now.ToString(WebInfo.DateTimeFmt)); SQLData.ParameterCollection para = new SQLData.ParameterCollection(); para.Add("@ID", data.ID); TableObj.Update(para); PagesModels mPage = PagesDAO.GetPageInfo(data.SiteID, data.ID); if (mPage != null) { mPage.Title = data.Title; PagesDAO.SetPageInfo(mPage); } }
public static bool UpdateLastStaySeconds(string sessionID) { PagesModels nData = new PagesModels(); using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn)) { string sql = @"UPDATE PagesView_Log SET StaySeconds=LastPageViewLog.StaySeconds FROM ( SELECT ID, DATEDIFF(SECOND, [AddTime], GETDATE()) AS StaySeconds FROM ( SELECT top 1 * FROM PagesView_Log WHERE SessionID=@SessionID ORDER BY AddTime DESC ) AS LastPageViewTMP ) AS LastPageViewLog WHERE LastPageViewLog.ID=PagesView_Log.ID;"; conn.Execute(sql, new { SessionID = sessionID }); } return(true); }
public void Copy(long siteId, long menuId, long[] ArticleIds, long TargetMenuID) { ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.ActionType = "copy"; if (ArticleIds.Length == 0) { return; } var targetMenu = MenusDAO.GetInfo(TargetMenuID); foreach (long ArticleId in ArticleIds) { ArticleModels articleItem = ArticleDAO.GetItem(ArticleId); CardsModels cardItem = CardsDAO.GetByNo(articleItem.CardNo); ZonesModels zoneItem = ZonesDAO.GetByNo(cardItem.ZoneNo.Value); PagesModels pageItem = PagesDAO.GetPageInfo(zoneItem.PageNo); long newCardNo = WorkV3.Golbal.PubFunc.CopyPage(pageItem, targetMenu.SiteID, targetMenu.ID); long newArticleId = WorkLib.GetItem.NewSN(); bool IsForceRelative = false; if (pageItem.SiteID == targetMenu.SiteID && pageItem.MenuID == targetMenu.ID) { IsForceRelative = true; } ArticleDAO.CopyArticle(ArticleId, newArticleId, newCardNo, targetMenu.ID, targetMenu.SiteID, IsForceRelative); WorkV3.Golbal.PubFunc.CopyIcon(articleItem.Icon, siteId, menuId, targetMenu.SiteID, targetMenu.ID); WorkV3.Golbal.PubFunc.CopyParagraphPhotos(articleItem.ID, siteId, menuId, targetMenu.SiteID, targetMenu.ID); } }
public ActionResult AddDataPages(PagesModels entity) { entity.OpenId = TempData["pagesopenId"].ToString(); entity.SafetySecretKey = PluginCore.GetInstance.SafetySecretValue; entity.IsUsable = true; var result = IocPlugin.IocAddDataPagesPlugin.AddDataPages(entity); return(Json(result)); }
/// <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); }
public static PagesModels GetPageInfo(long SiteID, long PageNo) { PagesModels nData = new PagesModels(); string Sql = "Select * from Pages where No=@No and SiteID=@SiteID "; using (var SqlCn = new SqlConnection(WebInfo.Conn)) { var res = SqlCn.Query <PagesModels>( Sql, new { No = PageNo, SiteID = SiteID }); nData = res.FirstOrDefault(); } return(nData); }
public static void UpdatePageInfo(PagesModels page) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("Pages"); tableObj.GetDataFromObject(page); tableObj.Remove("No"); tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = DateTime.Now; SQLData.ParameterCollection keys = new SQLData.ParameterCollection(); keys.Add("@No", page.No); tableObj.Update(keys); }
/// <summary> /// 移動頁面 /// </summary> /// <param name="sourcePage">原始頁面</param> /// <param name="targetSiteId">站點 ID</param> /// <param name="targetMenuId">選單 ID</param> /// <returns>返回 bool</returns> public static bool MovePage(PagesModels sourcePage, long targetSiteId, long targetMenuId) { WorkV3.Areas.Backend.Models.DataAccess.ZonesDAO.MoveZone(sourcePage.No, targetSiteId); var sourceMenu = WorkV3.Models.DataAccess.MenusDAO.GetInfo(sourcePage.SiteID, sourcePage.MenuID); long sourceSiteID = sourcePage.SiteID; long sourceMenuID = sourcePage.MenuID; var targetMenu = WorkV3.Models.DataAccess.MenusDAO.GetInfo(targetSiteId, targetMenuId); sourcePage.SiteID = targetSiteId; sourcePage.MenuID = targetMenuId; sourcePage.SN = targetMenu.SN + "_" + sourcePage.No; SysLog.SaveLog(SysActions.Move, SysMgrNo.Page, sourcePage.Title, sourceSiteID, sourceMenuID, sourcePage.No); PagesDAO.UpdatePageInfo(sourcePage); return(true); }
public BaseResult AddDataPages(PagesModels entity) { this.SafetySecretKey = entity.SafetySecretKey; this.Usable = entity.IsUsable ? BasePluginType.Type.启用 : BasePluginType.Type.卸载; var result = new BaseResult() { Code = (int)EnumCore.CodeType.失败, Message = "系统错误", }; if (string.IsNullOrWhiteSpace(this.SafetySecretKey) || this.Usable == BasePluginType.Type.卸载 || PluginCore.GetInstance.VerifySafetySecretKey(this.SafetySecretKey)) { return(result); } if (MenuManager.GetInstance.AddAndUpPages(entity, out string message)) { result.Code = (int)EnumCore.CodeType.成功; } result.Message = message; return(result); }
public static bool AddPageLogs(PagesView_LogModel logModel) { PagesModels nData = new PagesModels(); using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn)) { string sql = @" UPDATE PagesView_Log SET StaySeconds=LastPageViewLog.StaySeconds FROM ( SELECT ID, DATEDIFF(SECOND, [AddTime], GETDATE()) AS StaySeconds FROM ( SELECT top 1 * FROM PagesView_Log WHERE SessionID=@SessionID ORDER BY AddTime DESC ) AS LastPageViewTMP ) AS LastPageViewLog WHERE LastPageViewLog.ID=PagesView_Log.ID; INSERT PagesView_Log(PagesNo, ReferrerUrl, ReferrerUrlTitle, ReferrerUrlPageNo, Lang, Browser, UserAgent, SiteID, SessionID, MemberID, AddTime, IP, IPNum) VALUES (@PagesNo, @ReferrerUrl, @ReferrerUrlTitle, @ReferrerUrlPageNo, @Lang, @Browser, @UserAgent, @SiteID, @SessionID, @MemberID, @AddTime, @IP, @IPNum);"; conn.Execute(sql, new { PagesNo = logModel.PagesNo, ReferrerUrl = logModel.ReferrerUrl, ReferrerUrlTitle = logModel.ReferrerUrlTitle, ReferrerUrlPageNo = logModel.ReferrerUrlPageNo, Lang = logModel.Lang, Browser = logModel.Browser, UserAgent = logModel.UserAgent, SiteID = logModel.SiteID, SessionID = logModel.SessionID, MemberID = logModel.MemberID, AddTime = logModel.AddTime, IP = logModel.IP, IPNum = logModel.IPNum }); } return(true); }
public void Move(long siteId, long menuId, long[] ArticleIds, long TargetMenuID) { ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.ActionType = "move"; if (ArticleIds.Length == 0) { return; } foreach (long ArticleId in ArticleIds) { ArticleModels articleItem = ArticleDAO.GetItem(ArticleId); CardsModels cardItem = CardsDAO.GetByNo(articleItem.CardNo); ZonesModels zoneItem = ZonesDAO.GetByNo(cardItem.ZoneNo.Value); PagesModels pageItem = PagesDAO.GetPageInfo(zoneItem.PageNo); var targetMenu = MenusDAO.GetInfo(TargetMenuID); WorkV3.Golbal.PubFunc.MovePage(pageItem, targetMenu.SiteID, targetMenu.ID); ArticleDAO.Move(ArticleId, targetMenu.ID, targetMenu.SiteID); WorkV3.Golbal.PubFunc.CopyIcon(articleItem.Icon, siteId, menuId, targetMenu.SiteID, targetMenu.ID); WorkV3.Golbal.PubFunc.CopyParagraphPhotos(articleItem.ID, siteId, menuId, targetMenu.SiteID, targetMenu.ID); } }
public static void SetPageInfo(PagesModels page) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("Pages"); tableObj.GetDataFromObject(page); string sql = $"Select 1 From Pages Where No = { page.No } AND Lang = '{ page.Lang.Replace("'", "''") }' AND Ver = { page.Ver } AND SiteID = { page.SiteID } AND MenuID = { page.MenuID }"; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { tableObj["Creator"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = DateTime.Now; tableObj.Insert(); } else { string[] removeFields = { "No", "Lang", "Ver", "SiteID", "MenuID", "Creator", "CreateTime" }; foreach (string field in removeFields) { tableObj.Remove(field); } tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["ModifyTime"] = DateTime.Now; SQLData.ParameterCollection keys = new SQLData.ParameterCollection(); keys.Add("@No", page.No); keys.Add("@Lang", page.Lang); keys.Add("@Ver", page.Ver); keys.Add("@SiteID", page.SiteID); keys.Add("@MenuID", page.MenuID); tableObj.Update(keys); } }
public ActionResult CleanIndex(string SiteSN, string PageSN, long?id) { bool PageisExist = false; byte ShowStatus = 3; SitesModels mSites = SitesDAO.GetSiteInfo(SiteSN); PageCache pageCache = new PageCache(); if (mSites != null) { ViewBag.SiteID = mSites.Id; PagesModels mPages = PagesDAO.GetPageInfo(mSites.Id, PageSN); if (mPages != null) { pageCache.SiteID = mPages.SiteID; pageCache.MenuID = mPages.MenuID; pageCache.PageNO = mPages.No; pageCache.PageSN = mPages.SN; pageCache.SiteName = mSites.Title; pageCache.SiteSN = mSites.SN; MenusModels mMenus = MenusDAO.GetInfo(mPages.SiteID, mPages.MenuID); if (mMenus != null) { ShowStatus = mMenus.ShowStatus; } if (ShowStatus != 3) { ShowStatus = mPages.ShowStatus; } PageisExist = true; ViewBag.PageNo = mPages.No; ViewBag.Title = mPages.Title; ViewBag.SiteName = mSites.Title; } #region GA List <SitesModels.GAInfoCont> GA = new List <SitesModels.GAInfoCont>(); if (mSites.GAInfo != string.Empty) { GA = JsonConvert.DeserializeObject <List <SitesModels.GAInfoCont> >(mSites.GAInfo); } ViewBag.GA = GA; #endregion } ViewBag.SiteSN = SiteSN; ViewBag.PageSN = PageSN; ViewBag.Id = id; PageCache.SetTempDataPageCache(TempData, pageCache); ViewBag.CustomCont = LoadCustomCont(pageCache); if (PageisExist == true) { if (ShowStatus == 3) { Response.Redirect(Url.Action("PageNotFound", "ErrorPages")); } else { #region 網頁點擊LOG long?memberID = null; WorkV3.Common.Member curUser = WorkV3.Common.Member.Current; if (curUser != null) { memberID = curUser.ID; } string referUrl = "", referUrlTitle = "", referrerUrlPageNo = ""; if (Request.UrlReferrer != null) { referUrl = Request.UrlReferrer.AbsoluteUri; if (referUrl.StartsWith(WorkLib.uUrl.GetURL())) { if (referUrl.Split('/').Length > 0) { string pageSN = referUrl.Split('/')[referUrl.Split('/').Length - 1]; Models.PagesModels pageInfo = Models.DataAccess.PagesDAO.GetPageInfo(pageCache.SiteID, pageSN); if (pageInfo != null) { referUrlTitle = pageInfo.Title; referrerUrlPageNo = pageInfo.No.ToString(); } else { Models.MenusModels menuInfo = Models.DataAccess.MenusDAO.GetInfo(pageCache.SiteID, pageSN); if (menuInfo != null) { referUrlTitle = menuInfo.Title; referrerUrlPageNo = menuInfo.Id.ToString(); } } } } } AddPageLog((long)pageCache.PageNO, mSites.Lang, 3, mSites.Id, getSessionID(), memberID, referUrl, referUrlTitle, referrerUrlPageNo); #endregion return(View()); } } else { string DefaultSiteSN = GetItem.appSet("DefaultSiteSN").ToString(); if (DefaultSiteSN != "") { Response.Redirect("~/w/" + DefaultSiteSN + "/index"); } } return(View("EmptyPage")); }
public ActionResult IndexWithoutLayout(string SiteSN, string PageSN, long?id, string lay = "") { PageCache pageCache = new PageCache(); bool PageisExist = false; byte ShowStatus = 3; SitesModels mSites = SitesDAO.GetSiteInfo(SiteSN); if (mSites != null) { ViewBag.SiteID = mSites.Id; PagesModels mPages = PagesDAO.GetPageInfo(mSites.Id, PageSN); if (mPages != null) { pageCache.SiteID = mPages.SiteID; pageCache.MenuID = mPages.MenuID; pageCache.PageNO = mPages.No; pageCache.PageSN = mPages.SN; pageCache.SiteName = mSites.Title; pageCache.SiteSN = mSites.SN; MenusModels mMenus = MenusDAO.GetInfo(mPages.SiteID, mPages.MenuID); if (mMenus != null) { ShowStatus = mMenus.ShowStatus; } if (ShowStatus != 3) { ShowStatus = mPages.ShowStatus; } PageisExist = true; ViewBag.PageNo = mPages.No; ViewBag.Title = mPages.Title; ViewBag.SiteName = mSites.Title; #region 網頁SEO wei 20180914 對集點 if (mPages != null) { string imgUrl = "", description = "", author = "", Title = ""; var pageSEO = PagesDAO.GetPageSEO(mPages.SiteID, mPages.No, mPages.Title); var siteSEO = Areas.Backend.Models.DataAccess.SiteSeoSettingDAO.GetItem(mPages.SiteID); var contentSEO = PagesDAO.GetContentSEO(mPages.SiteID, mPages.MenuID, mPages.No); string typeKeywords = contentSEO.Keywords;//PagesDAO.GetContentTypeKeyword(mPages.SiteID, mPages.MenuID, mPages.No); if (!string.IsNullOrEmpty(mPages.Title)) { ViewBag.SEO_Title = mPages.Title; // 以單頁的先給值 } //先設定頁面的 SEO //若PAGE SEO 存在, 則取代碼 => PAGE > SITE if (pageSEO != null) { string UploadUrl = UpdFileInfo.GetVPathByMenuID(mPages.SiteID, mPages.MenuID).TrimEnd('/') + "/"; if (!string.IsNullOrEmpty(pageSEO.Title)) { ViewBag.SEO_Title = pageSEO.Title; } if (!string.IsNullOrEmpty(pageSEO.Description)) { ViewBag.SEO_Description = pageSEO.Description; } if (!string.IsNullOrEmpty(pageSEO.Author)) { author = pageSEO.Author; } if (!string.IsNullOrEmpty(pageSEO.Copyright)) { ViewBag.SEO_Copyright = pageSEO.Copyright; } if (!string.IsNullOrEmpty(pageSEO.Keywords)) { ViewBag.SEO_Keywords = pageSEO.Keywords; } if (!string.IsNullOrEmpty(pageSEO.Image)) { ViewBag.SEO_Image = UploadUrl + pageSEO.Image; } description = ViewBag.SEO_Description; Title = ViewBag.SEO_Title; } if (contentSEO != null) { if (!string.IsNullOrEmpty(contentSEO.SocialImage)) { ViewBag.SEO_Image = contentSEO.SocialImage; } if (string.IsNullOrEmpty(description) && !string.IsNullOrEmpty(contentSEO.Description)) { ViewBag.SEO_Description = contentSEO.Description; } if (string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(contentSEO.Title)) { ViewBag.SEO_Title = contentSEO.Title; } if (contentSEO != null && !string.IsNullOrEmpty(contentSEO.Author)) { author = author.Trim(';') + ";" + contentSEO.Author; } } imgUrl = ViewBag.SEO_Image; ViewBag.SEO_Keywords = typeKeywords; //以SITE SEO 先給值, 若PAGE SEO 存在, 則取代碼 => PAGE > SITE if (siteSEO != null) { if (!string.IsNullOrEmpty(siteSEO.Title) && string.IsNullOrEmpty(ViewBag.SEO_Title)) { ViewBag.SEO_Title = siteSEO.Title; } if (!string.IsNullOrEmpty(siteSEO.Description) && string.IsNullOrEmpty(ViewBag.SEO_Description)) { ViewBag.SEO_Description = siteSEO.Description; } if (!string.IsNullOrEmpty(siteSEO.Author)) { author = author.Trim(';') + ";" + siteSEO.Author; } if (!string.IsNullOrEmpty(siteSEO.Copyright) && string.IsNullOrEmpty(ViewBag.SEO_Copyright)) { ViewBag.SEO_Copyright = siteSEO.Copyright; } if (!string.IsNullOrEmpty(siteSEO.Keywords)) { ViewBag.SEO_Keywords += (string.IsNullOrEmpty(ViewBag.SEO_Keywords) ? "" : ";") + siteSEO.Keywords; } WorkV3.Areas.Backend.Models.SocialSettingModels siteSocialSetting = WorkV3.Areas.Backend.Models.DataAccess.SocialSettingDAO.GetItem(mPages.SiteID); if (siteSocialSetting != null && !string.IsNullOrEmpty(siteSocialSetting.SocialDefaultImage)) { if (string.IsNullOrEmpty(imgUrl) && !string.IsNullOrEmpty(siteSocialSetting.SocialDefaultImage)) { string customImageFolder = "SocialImage"; WorkV3.Models.ImageModel imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <WorkV3.Models.ImageModel>(siteSocialSetting.SocialDefaultImage); string UploadUrl = UpdFileInfo.GetVPathBySiteID(mPages.SiteID, customImageFolder).TrimEnd('/') + "/"; ViewBag.SEO_Image = UploadUrl + imgModel.Img; } } } ViewBag.SEO_Author = author.Trim(';'); } #endregion } #region GA List <SitesModels.GAInfoCont> GA = new List <SitesModels.GAInfoCont>(); if (!string.IsNullOrEmpty(mSites.GAInfo)) { GA = JsonConvert.DeserializeObject <List <SitesModels.GAInfoCont> >(mSites.GAInfo); } ViewBag.GA = GA; #endregion } PageCache.SetTempDataPageCache(TempData, pageCache); ViewBag.SiteSN = SiteSN; ViewBag.PageSN = PageSN; ViewBag.Id = id; ViewBag.CustomCont = LoadCustomCont(pageCache); if (PageisExist == true) { if (ShowStatus == 3) { Response.Redirect(Url.Action("PageNotFound", "ErrorPages")); } else { #region 網頁點擊LOG long?memberID = null; WorkV3.Common.Member curUser = WorkV3.Common.Member.Current; if (curUser != null) { memberID = curUser.ID; } string referUrl = "", referUrlTitle = "", referrerUrlPageNo = ""; if (Request.UrlReferrer != null) { referUrl = Request.UrlReferrer.AbsoluteUri; if (referUrl.StartsWith(WorkLib.uUrl.GetURL())) { if (referUrl.Split('/').Length > 0) { string pageSN = referUrl.Split('/')[referUrl.Split('/').Length - 1]; Models.PagesModels pageInfo = Models.DataAccess.PagesDAO.GetPageInfo(pageCache.SiteID, pageSN); if (pageInfo != null) { referUrlTitle = pageInfo.Title; referrerUrlPageNo = pageInfo.No.ToString(); } else { Models.MenusModels menuInfo = Models.DataAccess.MenusDAO.GetInfo(pageCache.SiteID, pageSN); if (menuInfo != null) { referUrlTitle = menuInfo.Title; referrerUrlPageNo = menuInfo.Id.ToString(); } } } } } AddPageLog((long)pageCache.PageNO, mSites.Lang, 3, mSites.Id, getSessionID(), memberID, referUrl, referUrlTitle, referrerUrlPageNo); #endregion ViewBag.lay = null; if (lay != "") { ViewBag.lay = lay; } return(View()); } } else { string DefaultSiteSN = GetItem.appSet("DefaultSiteSN").ToString(); if (DefaultSiteSN != "") { Response.Redirect("~/w/" + DefaultSiteSN + "/index"); } } return(View("EmptyPage")); }
public ActionResult Index(string SiteSN, string PageSN, long?id) { bool PageisExist = false; byte ShowStatus = 3; SitesModels mSites = SitesDAO.GetSiteInfo(SiteSN); PageCache pageCache = new PageCache(); if (mSites != null) { if (mSites.IsDelete || !mSites.Issue) { var member = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent; if (member == null) { return(HttpNotFound()); } } ViewBag.SiteID = mSites.Id; Areas.Backend.Models.SiteSeoSettingModels siteSeoSetting = Areas.Backend.Models.DataAccess.SiteSeoSettingDAO.GetItem(mSites.Id); if (siteSeoSetting != null) { if (!siteSeoSetting.Robot) { ViewBag.NoRobot = true; } ViewBag.GoogleSearchCode = siteSeoSetting.GoogleSearch; ViewBag.BaidoSearchCode = siteSeoSetting.BaiduMA; ViewBag.BingSearchCode = siteSeoSetting.Bing; if (!string.IsNullOrEmpty(siteSeoSetting.GA)) { ViewBag.GACode = "<script async src=\"https://www.googletagmanager.com/gtag/js?id=" + siteSeoSetting.GA + "\"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', '" + siteSeoSetting.GA + "');</script>"; } if (!string.IsNullOrEmpty(siteSeoSetting.Baidu)) { ViewBag.Baidu = @"<script> var _hmt = _hmt || []; (function() { var hm = document.createElement('script'); hm.src = 'https://hm.baidu.com/hm.js?" + siteSeoSetting.Baidu + @"'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(hm, s); })(); </script> "; } if (!string.IsNullOrEmpty(siteSeoSetting.GTM)) { ViewBag.GTM_Head = @"<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','" + siteSeoSetting.GTM + @"');</script> <!-- End Google Tag Manager -->"; ViewBag.GTM_Body = "<noscript><iframe src=\"https://www.googletagmanager.com/ns.html?id=" + siteSeoSetting.GTM + "\" height=\"0\" width=\"0\" style = \"display:none;visibility:hidden\"></iframe></noscript>"; } if (siteSeoSetting.IsExtraCode) { ViewBag.ExtraCode = siteSeoSetting.ExtraCode; } } pageCache.SiteID = mSites.Id; pageCache.SiteName = mSites.Title; pageCache.SiteSN = mSites.SN; PagesModels mPages = PagesDAO.GetPageInfo(mSites.Id, PageSN); if (mPages != null) { pageCache.SiteID = mPages.SiteID; pageCache.MenuID = mPages.MenuID; pageCache.PageNO = mPages.No; pageCache.PageSN = mPages.SN; pageCache.SiteName = mSites.Title; pageCache.SiteSN = mSites.SN; MenusModels mMenus = MenusDAO.GetInfo(mPages.SiteID, mPages.MenuID); if (mMenus != null) { ShowStatus = mMenus.ShowStatus; } if (ShowStatus != 3) { ShowStatus = mPages.ShowStatus; } PageisExist = true; ViewBag.PageNo = mPages.No; ViewBag.Title = mPages.Title; ViewBag.MenuID = mPages.MenuID; ViewBag.SiteName = mSites.Title; ViewBag.FaviconPath = $"{WorkV3.Golbal.UpdFileInfo.GetVPathBySiteID(mSites.Id, "Header")}/{mSites.Favicon}"; #region 網頁SEO if (mPages != null) { string imgUrl = "", description = "", author = "", Title = ""; SEOModels pageSEO = null; if (PageSN == "RecruitDetail") //20190516 Nina 徵才需用ID取得SEO { long Id = 0; bool result = long.TryParse(Request.QueryString["ID"], out Id); if (result) { pageSEO = PagesDAO.GetPageSEO(mPages.SiteID, mPages.No, mPages.Title, Id); } } else { pageSEO = PagesDAO.GetPageSEO(mPages.SiteID, mPages.No, mPages.Title); } var siteSEO = Areas.Backend.Models.DataAccess.SiteSeoSettingDAO.GetItem(mPages.SiteID); var contentSEO = PagesDAO.GetContentSEO(mPages.SiteID, mPages.MenuID, mPages.No); string typeKeywords = contentSEO.Keywords;//PagesDAO.GetContentTypeKeyword(mPages.SiteID, mPages.MenuID, mPages.No); if (!string.IsNullOrEmpty(mPages.Title)) { ViewBag.SEO_Title = mPages.Title; // 以單頁的先給值 } //先設定頁面的 SEO //若PAGE SEO 存在, 則取代碼 => PAGE > SITE if (pageSEO != null) { string UploadUrl = UpdFileInfo.GetVPathByMenuID(mPages.SiteID, mPages.MenuID).TrimEnd('/') + "/"; if (!string.IsNullOrEmpty(pageSEO.Title)) { ViewBag.SEO_Title = pageSEO.Title; } if (!string.IsNullOrEmpty(pageSEO.Description)) { ViewBag.SEO_Description = pageSEO.Description; } if (!string.IsNullOrEmpty(pageSEO.Author)) { author = pageSEO.Author; } if (!string.IsNullOrEmpty(pageSEO.Copyright)) { ViewBag.SEO_Copyright = pageSEO.Copyright; } if (!string.IsNullOrEmpty(pageSEO.Keywords)) { ViewBag.SEO_Keywords = pageSEO.Keywords; } if (!string.IsNullOrEmpty(pageSEO.Image)) { ViewBag.SEO_Image = UploadUrl + pageSEO.Image; } description = ViewBag.SEO_Description; Title = ViewBag.SEO_Title; } if (contentSEO != null) { if (!string.IsNullOrEmpty(contentSEO.SocialImage)) { ViewBag.SEO_Image = contentSEO.SocialImage; } if (string.IsNullOrEmpty(description) && !string.IsNullOrEmpty(contentSEO.Description)) { ViewBag.SEO_Description = contentSEO.Description; } if (string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(contentSEO.Title)) { ViewBag.SEO_Title = contentSEO.Title; } if (contentSEO != null && !string.IsNullOrEmpty(contentSEO.Author)) { author = author.Trim(';') + ";" + contentSEO.Author; } } imgUrl = ViewBag.SEO_Image; ViewBag.SEO_Keywords = typeKeywords; //以SITE SEO 先給值, 若PAGE SEO 存在, 則取代碼 => PAGE > SITE if (siteSEO != null) { if (!string.IsNullOrEmpty(siteSEO.Title) && string.IsNullOrEmpty(ViewBag.SEO_Title)) { ViewBag.SEO_Title = siteSEO.Title; } if (!string.IsNullOrEmpty(siteSEO.Description) && string.IsNullOrEmpty(ViewBag.SEO_Description)) { ViewBag.SEO_Description = siteSEO.Description; } if (!string.IsNullOrEmpty(siteSEO.Author)) { author = author.Trim(';') + ";" + siteSEO.Author; } if (!string.IsNullOrEmpty(siteSEO.Copyright) && string.IsNullOrEmpty(ViewBag.SEO_Copyright)) { ViewBag.SEO_Copyright = siteSEO.Copyright; } if (!string.IsNullOrEmpty(siteSEO.Keywords)) { ViewBag.SEO_Keywords += (string.IsNullOrEmpty(ViewBag.SEO_Keywords) ? "" : ";") + siteSEO.Keywords; } WorkV3.Areas.Backend.Models.SocialSettingModels siteSocialSetting = WorkV3.Areas.Backend.Models.DataAccess.SocialSettingDAO.GetItem(mPages.SiteID); if (siteSocialSetting != null && !string.IsNullOrEmpty(siteSocialSetting.SocialDefaultImage)) { if (string.IsNullOrEmpty(imgUrl) && !string.IsNullOrEmpty(siteSocialSetting.SocialDefaultImage)) { string customImageFolder = "SocialImage"; WorkV3.Models.ImageModel imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <WorkV3.Models.ImageModel>(siteSocialSetting.SocialDefaultImage); string UploadUrl = UpdFileInfo.GetVPathBySiteID(mPages.SiteID, customImageFolder).TrimEnd('/') + "/"; ViewBag.SEO_Image = UploadUrl + imgModel.Img; } } } ViewBag.SEO_Author = author.Trim(';'); } #endregion } #region GA List <SitesModels.GAInfoCont> GA = new List <SitesModels.GAInfoCont>(); if (!string.IsNullOrEmpty(mSites.GAInfo)) { GA = JsonConvert.DeserializeObject <List <SitesModels.GAInfoCont> >(mSites.GAInfo); } ViewBag.GA = GA; #endregion } ViewBag.SiteSN = SiteSN; ViewBag.PageSN = PageSN; ViewBag.Id = id; PageCache.SetTempDataPageCache(TempData, pageCache); ViewBag.CustomCont = LoadCustomCont(pageCache); if (PageisExist == true) { if (ShowStatus == 3) { Response.Redirect(Url.Action("PageNotFound", "ErrorPages")); } else { #region 網頁點擊LOG long?memberID = null; WorkV3.Common.Member curUser = WorkV3.Common.Member.Current; if (curUser != null) { memberID = curUser.ID; } string referUrl = "", referUrlTitle = "", referrerUrlPageNo = ""; if (Request.UrlReferrer != null) { referUrl = Request.UrlReferrer.AbsoluteUri; if (referUrl.StartsWith(WorkLib.uUrl.GetURL())) { if (referUrl.Split('/').Length > 0) { string pageSN = referUrl.Split('/')[referUrl.Split('/').Length - 1]; Models.PagesModels pageInfo = Models.DataAccess.PagesDAO.GetPageInfo(pageCache.SiteID, pageSN); if (pageInfo != null) { referUrlTitle = pageInfo.Title; referrerUrlPageNo = pageInfo.No.ToString(); } else { Models.MenusModels menuInfo = Models.DataAccess.MenusDAO.GetInfo(pageCache.SiteID, pageSN); if (menuInfo != null) { referUrlTitle = menuInfo.Title; referrerUrlPageNo = menuInfo.Id.ToString(); } } } } } AddPageLog((long)pageCache.PageNO, mSites.Lang, 3, mSites.Id, getSessionID(), memberID, referUrl, referUrlTitle, referrerUrlPageNo); #endregion return(View()); } } else { //客製start string DefaultWebSite = Request.Url.AbsoluteUri; if (DefaultWebSite.Contains("webdemo") || DefaultWebSite.Contains("localhost")) { string DefaultSiteSN = GetItem.appSet("DefaultSiteSN").ToString(); if (DefaultSiteSN != null) { Response.Redirect("~/w/" + DefaultSiteSN + "/index"); } } else { DefaultWebSite = DefaultWebSite.Replace("www.", "").Replace("http://", "").Replace(".com.tw/", ""); if (DefaultWebSite == "nhmc") { DefaultWebSite = "NewHopeMarketing"; } else if (DefaultWebSite == "edec") { DefaultWebSite = "ELITEDREAM"; } Response.Redirect("~/w/" + DefaultWebSite + "/index"); } //客製end } return(View("EmptyPage")); }
public int Delete(PagesModels entity) { return DBCore.Deleteable(entity).With(SqlWith.RowLock).ExecuteCommand(); }
public int Update(PagesModels entity) { return DBCore.Updateable(entity).With(SqlWith.UpdLock).Where(true).ExecuteCommand(); }
public bool InsertBool(PagesModels entity) { return DBCore.Insertable(entity).With(SqlWith.UpdLock).ExecuteCommandIdentityIntoEntity(); }
public PagesModels InsertEntity(PagesModels entity) { return DBCore.Insertable(entity).With(SqlWith.UpdLock).ExecuteReturnEntity(); }
public long InsertLong(PagesModels entity) { return DBCore.Insertable(entity).With(SqlWith.UpdLock).ExecuteReturnBigIdentity(); }
public int InsertInt(PagesModels entity) { return DBCore.Insertable(entity).With(SqlWith.UpdLock).ExecuteCommand(); }
/// <summary> /// 添加/修改 /// </summary> /// <param name="entity"></param> /// <param name="message"></param> /// <returns></returns> public bool AddAndUpPages(PagesModels entity, out string message) { message = "系统错误"; entity.UTime = DateTime.Now; if (string.IsNullOrWhiteSpace(entity.PageTitle)) { message = "名称错误"; return(false); } if (entity.ParentLevel < 0) { message = "父级Id错误"; return(false); } if (string.IsNullOrWhiteSpace(entity.PagePathUrl)) { entity.PagePathUrl = string.Empty; } if (entity.PageSort < 0) { message = "排序码错误"; return(false); } if (entity.PageTypes < 0) { message = "类型错误"; return(false); } if (entity.PageIcon <= 0) { entity.PageIcon = 0; } if (string.IsNullOrWhiteSpace(entity.OpenId)) { entity.CTime = DateTime.Now; entity.IsDeleted = false; entity.OpenId = Guid.NewGuid().ToString(); entity.Remark = "页面数据"; if (IocRepository.IocPagesRepository.InsertBool(entity)) { message = "添加成功"; return(true); } return(false); } var upEntity = GetPagesModel(entity.OpenId) ?? new PagesModels(); if (!string.IsNullOrWhiteSpace(upEntity.OpenId)) { upEntity.PageIcon = entity.PageIcon; upEntity.PagePathUrl = entity.PagePathUrl; upEntity.PageSort = entity.PageSort; upEntity.PageTitle = entity.PageTitle; upEntity.PageTypes = entity.PageTypes; upEntity.ParentLevel = entity.ParentLevel; upEntity.UTime = entity.UTime; if (IocRepository.IocPagesRepository.Update(upEntity) > 0) { message = "修改成功"; return(true); } } return(false); }
/// <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); }