public ActionResult EditLang(long SiteID, WorkV3.Models.SiteLangMenuModel item) { ViewBag.SiteID = SiteID; if (!Utility.CheckIsLogin()) { Response.Redirect(Url.Action("Login", "Home")); } if (item.ID == 0) { item.ID = WorkLib.GetItem.NewSN(); } if (item.LinkType == LangLinkType.CnTw) { item.Translate = true; } else { item.Translate = false; if (item.SelectSiteID.HasValue) { SitesModels siteModel = WorkV3.Models.DataAccess.SitesDAO.GetInfo(item.SelectSiteID.Value); item.Url = string.Format("~/w/{0}", siteModel.SN); } } AppendViewBags(); ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathBySiteID(SiteID, "Header"); WorkV3.Models.DataAccess.SiteLangMenuDAO.SetItem(item); ViewBag.Exit = true; return(View(item)); }
// GET: Footer public ActionResult Index(CardsModels card) { PageCache pageCache = PageCache.GetTempDataPageCache(TempData); ViewBag.SiteID = pageCache.SiteID; SitesModels Msites = SitesDAO.GetInfo(pageCache.SiteID); ViewBag.SitesInfo = Msites; if (Msites.FooterCustomized) { ViewBag.FooterCont = Msites.FooterCont; } else { ViewBag.FooterCont = ""; } ViewBag.Copyright = Msites.Copyright; List <MenusModels> Menus = MenusDAO.GetFrontMenus(pageCache.SiteID); var channel_models = Areas.Backend.Models.DataAccess.SocialSettingDAO.GetItem(pageCache.SiteID); if (channel_models != null && channel_models.IsFooterOpenChannel) { IEnumerable <Areas.Backend.Models.SocialRelationModels> itemList = Areas.Backend.Models.DataAccess.SocialSettingDAO.GetRelationItems(pageCache.SiteID, Areas.Backend.Models.RelationType.Channel); ViewBag.Channels = itemList; } return(View("Style" + card.StylesID, Menus)); }
public ActionResult ChangeIssue(string id, bool Issue) { SitesModels item = WorkV3.Models.DataAccess.SitesDAO.GetInfo(long.Parse(id)); item.Issue = Issue; WorkV3.Models.DataAccess.SitesDAO.SetItem(item); return(Json("success", JsonRequestBehavior.AllowGet)); }
public ActionResult Setting(long SiteID) { AppendViewBags(); ViewBag.SiteID = SiteID; ViewBag.Langs = WorkV3.Models.DataAccess.SiteLangMenuDAO.GetDatas(SiteID); ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathBySiteID(SiteID, "Header"); ViewBag.MailSetting = siteMailSettingRepository.GetItem(SiteID, "SiteID"); SitesModels item = WorkV3.Models.DataAccess.SitesDAO.GetInfo(SiteID); return(View(item)); }
public ActionResult Edit(long?id) { AppendViewBags(); SitesModels item = null; if (id != null) { item = WorkV3.Models.DataAccess.SitesDAO.GetInfo((long)id); } return(View(item)); }
public ActionResult Delete(string id) { SitesModels source_item = WorkV3.Models.DataAccess.SitesDAO.GetInfo(long.Parse(id)); string absFileSourcePath = Server.MapPath("~/Websites/" + source_item.SN); bool IsSuccess = WorkV3.Models.DataAccess.SitesDAO.Delete(long.Parse(id), absFileSourcePath); //SitesModels item = WorkV3.Models.DataAccess.SitesDAO.GetInfo(long.Parse(id)); //item.IsDelete = true; //WorkV3.Models.DataAccess.SitesDAO.SetItem(item); return(Json(IsSuccess ? "success" : "fail", JsonRequestBehavior.AllowGet)); }
// GET: Header public ActionResult Index(CardsModels model) { WorkV3.Common.SitePage curPage = WorkV3.Models.DataAccess.CardsDAO.GetPage(model.No); ViewBag.SiteID = curPage.SiteID; List <MenusModels> Menus = Models.DataAccess.MenusDAO.GetFrontMenus(curPage.SiteID); SitesModels SitesInfo = SitesDAO.GetInfo(curPage.SiteID); WorkV3.Areas.Backend.Models.DataAccess.KeywordDAO keywordDao = new Areas.Backend.Models.DataAccess.KeywordDAO(); // neil 20180331 新增關鍵字搜尋 ViewBag.SitesInfo = SitesInfo; #region WebLang List <SiteLangMenuModel> SiteLang = new List <SiteLangMenuModel>(); if (uCheck.IsNumeric(curPage.SiteID)) { if (SitesInfo.IsLang)//有開放再抓語言別資料 { SiteLang = SiteLangMenuDAO.GetDatas(curPage.SiteID); } } ViewBag.SiteLang = SiteLang; #endregion #region Socal List <SitesModels.socialSettingCont> social = new List <SitesModels.socialSettingCont>(); if (SitesInfo != null) { if (!string.IsNullOrEmpty(SitesInfo.socialSetting)) { social = JsonConvert.DeserializeObject <List <SitesModels.socialSettingCont> >(SitesInfo.socialSetting); } } ViewBag.social = social; #endregion #region 會員功能機制 Areas.Backend.Models.MemberShipRegSetModels MemberSetModel = Areas.Backend.Models.DataAccess.MemberShipRegSetDAO.GetItem(model.SiteID); bool IsEnabledMember = false; if (MemberSetModel != null) { IsEnabledMember = MemberSetModel.IsOpenReg; } ViewBag.IsEnabledMember = IsEnabledMember; #endregion ViewBag.SearchPage = SearchResultDAO.GetSearchPage(curPage.SiteID); ViewBag.VPath = WorkV3.Golbal.UpdFileInfo.GetVPathBySiteID(curPage.SiteID, "Header"); ViewBag.VMemberPath = WorkV3.Golbal.UpdFileInfo.GetVPathBySiteID(curPage.SiteID, "Member"); ViewBag.Keywords = keywordDao.GetAllKeywords(true); ViewBag.VMenuPath = Golbal.UpdFileInfo.GetVPathBySiteID(curPage.SiteID, "Menus"); int style = model.StylesID; return(View("Style" + style, Menus)); }
public string SendMail(long siteId, long menuId, FormMailModel mail, string[] fileList, string recipientIds, string recipientEmails, bool isTest, bool?isEvent = false) { if (mail == null || string.IsNullOrWhiteSpace(mail.MailBody)) { return("Mail 為 NULL"); } if (isTest && string.IsNullOrWhiteSpace(recipientEmails)) { return("測試郵件缺少收信人"); } if (!isTest && string.IsNullOrWhiteSpace(recipientIds)) { return("未選擇郵件發送用戶"); } SitesModels site = SitesDAO.GetInfo(siteId); System.Collections.ArrayList emailFiles = new System.Collections.ArrayList(); List <ResourceFilesModels> files = new List <ResourceFilesModels>(); if (fileList?.Length > 0) { string uploadPath = Golbal.UpdFileInfo.GetUPathByMenuID(siteId, menuId).TrimEnd('\\') + "\\"; foreach (string item in fileList) { ResourceFilesModels file = JsonConvert.DeserializeObject <ResourceFilesModels>(item); files.Add(file); emailFiles.Add(uploadPath + file.FileInfo); } } mail.Files = JsonConvert.SerializeObject(files); FormModel form = FormDAO.GetItem(mail.FormID); string mailSubject = mail.MailSubject.Replace("[WebsiteName]", site.Title).Replace("[SendDate]", DateTime.Now.ToString(WebInfo.DateFmt)); string mailBody = mail.MailBody.Replace("[WebsiteName]", site.Title).Replace("[SendDate]", DateTime.Now.ToString(WebInfo.DateFmt)); mailSubject = mailSubject.Replace("[FormName]", form.Title); mailBody = mailBody.Replace("[FormName]", form.Title); if (isTest) { SendMailTest(siteId, mail, mailSubject, mailBody, emailFiles, recipientEmails, isEvent); return("測試郵件發送成功"); } mail.ID = WorkLib.GetItem.NewSN(); FormMailDAO.SetItem(mail); MailSend(siteId, mail, mailSubject, mailBody, emailFiles, recipientIds); return("郵件發送成功"); }
public ActionResult Copy(long SourceID) { AppendViewBags(); ViewBag.IsCopy = true; SitesModels item = WorkV3.Models.DataAccess.SitesDAO.GetInfo(SourceID); item.Id = WorkLib.GetItem.NewSN(); item.Title += "(複製)"; item.SN += "Copy"; item.Issue = false; ViewBag.SourceID = SourceID; return(View("Edit", item)); }
/// <summary> /// 取得實體上傳目錄by SiteID /// </summary> /// <param name="SiteID"></param> /// <returns></returns> public static string GetUPathBySiteID(long SiteID, string CustomFolder = "") { string Path = GetItem.UpdPath(); SitesModels datas = SitesDAO.GetInfo(SiteID); if (datas != null) { Path += "\\" + datas.SN + "\\"; } if (CustomFolder != "") { Path += CustomFolder + "\\"; } return(Path); }
/// <summary> /// 取得瀏覽目錄by SiteID /// </summary> /// <param name="SiteID"></param> /// <returns></returns> public static string GetVPathBySiteID(long SiteID, string CustomFolder = "") { string Path = GetItem.ViewUpdUrl().TrimEnd('/'); SitesModels datas = SitesDAO.GetInfo(SiteID); if (datas != null) { Path += "/" + datas.SN + "/"; } if (CustomFolder != "") { Path += CustomFolder + "/"; } return(Path); }
private void SendEmail(long siteId, FormModel form, FormItem formItem) { if (!form.NotifyAdmin) { return; } IEnumerable <FormAdmin> formAdmins = form.GetAdmins(); if (formAdmins == null || formAdmins.Count() == 0) { return; } Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("表單名稱", form.Title); dic.Add("姓名", formItem.Name); dic.Add("行動電話", formItem.Mobile); dic.Add("email", formItem.Email); SitesModels site = SitesDAO.GetInfo(siteId); dic.Add("網站", site.Title); dic.Add("日期", DateTime.Now.ToString(WebInfo.DateFmt)); string mailContents = System.IO.File.ReadAllText(Server.MapPath("~/Data/MailContent/表單填寫通知管理員.html")); mailContents = System.Text.RegularExpressions.Regex.Replace(mailContents, @"\[([^\]]*)\]", match => { string key = match.Groups[1].Value; string val; if (dic.TryGetValue(key, out val)) { return(val); } return(null); }); foreach (FormAdmin admin in formAdmins) { emailService.SendEMail(siteId, admin.Email, admin.Name, form.Title + "填寫 通知信", mailContents); } }
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 ActionResult Edit(SitesModels item, string[] domains, string webType) { if (!Utility.CheckIsLogin()) { Response.Redirect(Url.Action("Login", "Home")); } bool IsNeedCreateBaseBackendMenus = false, IsNeedCreateHomePageInfo = false; AppendViewBags(); if (item.Id == 0) { item.Id = WorkLib.GetItem.NewSN(); IsNeedCreateBaseBackendMenus = true; IsNeedCreateHomePageInfo = true; } var orginalSiteInfo = WorkV3.Models.DataAccess.SitesDAO.GetInfo(item.Id); if (orginalSiteInfo != null) { item.Descriptions = orginalSiteInfo.Descriptions; item.Author = orginalSiteInfo.Author; item.Copyright = orginalSiteInfo.Copyright; item.ICO = orginalSiteInfo.ICO; item.Logo = orginalSiteInfo.Logo; item.FooterCont = orginalSiteInfo.FooterCont; item.GAInfo = orginalSiteInfo.GAInfo; item.Logoshrink = orginalSiteInfo.Logoshrink; item.socialSetting = orginalSiteInfo.socialSetting; item.LogoMobile = orginalSiteInfo.LogoMobile; item.HeaderCont = orginalSiteInfo.HeaderCont; item.HeaderCustomized = orginalSiteInfo.HeaderCustomized; item.FooterCustomized = orginalSiteInfo.FooterCustomized; item.IsLang = orginalSiteInfo.IsLang; item.IsSearchEnabled = orginalSiteInfo.IsSearchEnabled; item.IsPathBread = orginalSiteInfo.IsPathBread; } if (webType == "Indep") { item.ParentID = (long?)null; } List <ViewModels.SiteDomain> DomainList = new List <ViewModels.SiteDomain>(); long domainIndex = 0; if (domains != null) { foreach (string domain in domains) { if (!string.IsNullOrEmpty(domain)) { domainIndex++; ViewModels.SiteDomain domainModel = new ViewModels.SiteDomain() { ID = domainIndex, Domain = domain }; DomainList.Add(domainModel); } } } item.Domin = Newtonsoft.Json.JsonConvert.SerializeObject(DomainList); WorkV3.Models.DataAccess.SitesDAO.SetItem(item); if (IsNeedCreateBaseBackendMenus) { WorkV3.Models.DataAccess.SitesDAO.AddInitBackendStructure(item.Id, !item.ParentID.HasValue); } if (IsNeedCreateHomePageInfo) { WorkV3.Models.DataAccess.SitesDAO.AddInitHomePage(item.Id); WorkV3.Models.DataAccess.SitesDAO.AddInitSystemPages(item.Id); } ViewBag.Exit = true; return(View(item)); }
public ActionResult Setting(SitesModels item, string[] domains, string webType, SiteMailSettingModel mailSetting) { ViewBag.SiteID = item.Id; if (!Utility.CheckIsLogin()) { Response.Redirect(Url.Action("Login", "Home")); } AppendViewBags(); ViewBag.Langs = WorkV3.Models.DataAccess.SiteLangMenuDAO.GetDatas(item.Id); ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathBySiteID(item.Id, "Header"); if (webType == "Indep") { item.ParentID = (long?)null; } if (!string.IsNullOrEmpty(item.Logo)) { // 新上傳的圖片 HttpPostedFileBase postedFile = Request.Files["fLogo"]; string postedFileBase64 = Request.Form["fLogoBase64"]; string postedFileBase64_Resize = Request.Form["fLogoBase64_Resize"]; if (!string.IsNullOrEmpty(postedFileBase64)) { string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, item.Id, "Header", postedFileBase64, postedFileBase64_Resize); item.Logo = saveName; } else { ImageModel imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ImageModel>(item.Logo); if (!string.IsNullOrEmpty(imgModel.Img)) { item.Logo = System.IO.Path.GetFileName(imgModel.Img); } else { if (postedFile == null || postedFile.ContentLength == 0) { item.Logo = ""; } else { string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, item.Id, "Header", postedFileBase64, postedFileBase64_Resize); item.Logo = saveName; } } } } if (!string.IsNullOrEmpty(item.Favicon)) { // 新上傳的圖片 HttpPostedFileBase postedFile = Request.Files["fFavicon"]; string postedFileBase64 = Request.Form["fFaviconBase64"]; string postedFileBase64_Resize = Request.Form["fFaviconBase64_Resize"]; if (!string.IsNullOrEmpty(postedFileBase64)) { string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, item.Id, "Header", postedFileBase64, postedFileBase64_Resize); item.Favicon = saveName; } else { ImageModel imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ImageModel>(item.Favicon); if (!string.IsNullOrEmpty(imgModel.Img)) { item.Favicon = System.IO.Path.GetFileName(imgModel.Img); } else { if (postedFile == null || postedFile.ContentLength == 0) { item.Favicon = ""; } else { string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, item.Id, "Header", postedFileBase64, postedFileBase64_Resize); item.Favicon = saveName; } } } } if (!string.IsNullOrEmpty(item.Logoshrink)) { // 新上傳的圖片 HttpPostedFileBase postedFile = Request.Files["fLogoshrink"]; string postedFileBase64 = Request.Form["fLogoshrinkBase64"]; string postedFileBase64_Resize = Request.Form["fLogoshrinkBase64_Resize"]; if (!string.IsNullOrEmpty(postedFileBase64)) { string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, item.Id, "Header", postedFileBase64, postedFileBase64_Resize); item.Logoshrink = saveName; } else { ImageModel imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ImageModel>(item.Logoshrink); if (!string.IsNullOrEmpty(imgModel.Img)) { item.Logoshrink = System.IO.Path.GetFileName(imgModel.Img); } else { if (!string.IsNullOrEmpty(imgModel.Img)) { item.Logoshrink = System.IO.Path.GetFileName(imgModel.Img); } else { if (postedFile == null || postedFile.ContentLength == 0) { item.Logoshrink = ""; } else { string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, item.Id, "Header", postedFileBase64, postedFileBase64_Resize); item.Logoshrink = saveName; } } } } } if (!string.IsNullOrEmpty(item.LogoMobile)) { // 新上傳的圖片 HttpPostedFileBase postedFile = Request.Files["fLogoMobile"]; string postedFileBase64 = Request.Form["fLogoMobileBase64"]; string postedFileBase64_Resize = Request.Form["fLogoMobileBase64_Resize"]; if (!string.IsNullOrEmpty(postedFileBase64)) { string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, item.Id, "Header", postedFileBase64, postedFileBase64_Resize); item.LogoMobile = saveName; } else { ImageModel imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ImageModel>(item.LogoMobile); if (!string.IsNullOrEmpty(imgModel.Img)) { item.LogoMobile = System.IO.Path.GetFileName(imgModel.Img); } else { if (!string.IsNullOrEmpty(imgModel.Img)) { item.LogoMobile = System.IO.Path.GetFileName(imgModel.Img); } else { if (postedFile == null || postedFile.ContentLength == 0) { item.LogoMobile = ""; } else { string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, item.Id, "Header", postedFileBase64, postedFileBase64_Resize); item.LogoMobile = saveName; } } } } } List <ViewModels.SiteDomain> DomainList = new List <ViewModels.SiteDomain>(); long domainIndex = 0; if (domains != null) { foreach (string domain in domains) { if (!string.IsNullOrEmpty(domain)) { domainIndex++; ViewModels.SiteDomain domainModel = new ViewModels.SiteDomain() { ID = domainIndex, Domain = domain }; DomainList.Add(domainModel); } } } item.Domin = Newtonsoft.Json.JsonConvert.SerializeObject(DomainList); if (siteMailSettingRepository.GetItem(mailSetting.SiteID, "SiteID") == null) { siteMailSettingRepository.CreateItem(mailSetting); } else { siteMailSettingRepository.UpdateItemExcept(mailSetting, new string[] { }, "SiteID"); } MTSRepository.SetMailFromName(item.Title);//Joe 20190923設定寄件人為後台的網站設定之網站名稱 WorkV3.Models.DataAccess.SitesDAO.SetItem(item); ViewBag.Exit = true; return(View(item)); }
public ActionResult Copy(SitesModels item, string[] domains, string webType, long SourceID) { if (!Utility.CheckIsLogin()) { Response.Redirect(Url.Action("Login", "Home")); } AppendViewBags(); ViewBag.IsCopy = true; if (item.Id == 0) { item.Id = WorkLib.GetItem.NewSN(); } if (webType == "Indep") { item.ParentID = (long?)null; } List <ViewModels.SiteDomain> DomainList = new List <ViewModels.SiteDomain>(); long domainIndex = 0; if (domains != null) { foreach (string domain in domains) { if (!string.IsNullOrEmpty(domain)) { domainIndex++; ViewModels.SiteDomain domainModel = new ViewModels.SiteDomain() { ID = domainIndex, Domain = domain }; DomainList.Add(domainModel); } } item.Domin = Newtonsoft.Json.JsonConvert.SerializeObject(DomainList); } using (var scope = new TransactionScope()) { try { if (!WorkV3.Models.DataAccess.SitesDAO.CopyStructure(SourceID, item.Id)) { throw new Exception("結構複製失敗"); } if (!WorkV3.Models.DataAccess.SitesDAO.CopyBackendStructure(SourceID, item.Id)) { throw new Exception("後台選單結構複製失敗"); } SitesModels source_item = WorkV3.Models.DataAccess.SitesDAO.GetInfo(SourceID); string absFileSourcePath = Server.MapPath("~/Websites/" + source_item.SN); string absFileTargetPath = Server.MapPath("~/Websites/" + item.SN); WorkV3.Models.DataAccess.SitesDAO.SetItem(item); WorkV3.Models.DataAccess.SitesDAO.CopyWebsiteFiles(absFileSourcePath, absFileTargetPath); scope.Complete(); } catch (Exception ex) { ViewBag.Message = ex.Message; } } ViewBag.Exit = true; return(View("Edit", item)); }
public ActionResult ChangeStatus(long id) { SitesModels item = WorkV3.Models.DataAccess.SitesDAO.GetInfo(id); return(View(item)); }