public ActionResult Setting(long siteId, long menuId) { ViewBag.Menu = MenusDAO.GetInfo(siteId, menuId); IEnumerable <ArticleTypesModels> types = ArticleTypesDAO.GetIssueItems(menuId); ViewBag.Types = types; //ViewBag.ListCards = WorkV3.Models.DataAccess.MenusDAO.GetListCards("Article").Where(c => c.ID != menuId); ViewBag.ListCards = WorkV3.Models.DataAccess.MenusDAO.GetListCards("Article"); // shan 20180102 依 CC 要求修改為本單元亦列入, 且預設勾選 ViewBag.ListCards2 = WorkV3.Models.DataAccess.MenusDAO.GetListCards("Article"); // shan 20180102 依 CC 要求修改為本單元亦列入, 且預設勾選 ViewBag.ListIdentity = CategoryDAO.GetIssueItems(IdentityType); ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/') + "/"; ViewBag.MemberRegSet = MemberShipRegSetDAO.GetItem(siteId); List <WorkV3.ViewModels.CommentType> ReplyItemList = WorkV3.ViewModels.CommentTypeLibs.GetCommitTypeList(); ViewBag.ReplyItemList = ReplyItemList; WorkV3.Models.ArticleSettingModels item = WorkV3.Models.DataAccess.ArticleSettingDAO.GetItem(menuId); if (item.Types == "all") { item.Types = string.Join(",", types.Select(t => t.ID)); } return(View(item)); }
public ActionResult List(long siteId, long menuId, int?index, ArticleSearchModels search) { ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.Types = ArticleTypesDAO.GetIssueItems(menuId); ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/') + "/"; if (Request.HttpMethod == "GET") { if (index == null) { WorkV3.Common.Utility.ClearSearchValue(); } else { ArticleSearchModels prevSearch = WorkV3.Common.Utility.GetSearchValue <ArticleSearchModels>(); if (prevSearch != null) { search = prevSearch; } } } else if (Request.HttpMethod == "POST") { WorkV3.Common.Utility.SetSearchValue(search); } ViewBag.Search = search; Pagination pagination = new Pagination { PageIndex = index ?? 1, PageSize = WebInfo.PageSize }; int totalRecord; IEnumerable <ArticleModels> items = ArticleDAO.GetItems(search, pagination.PageSize, pagination.PageIndex, out totalRecord); pagination.TotalRecord = totalRecord; ViewBag.SitePages = WorkV3.Models.DataAccess.CardsDAO.GetPages(items.Select(item => item.CardNo)); ViewBag.ItemTypes = ArticleDAO.GetItemTypes(items.Select(item => item.ID)); ViewBag.Pagination = pagination; return(View(items)); }
public ActionResult Setting(long siteId, WorkV3.Models.ArticleSettingModels item, string[] ExtendReadMenus, string[] ExtendReadMenus2, string[] ReadModeSet) { long menuId = item.MenuID; ViewBag.Menu = MenusDAO.GetInfo(siteId, menuId); ViewBag.Types = ArticleTypesDAO.GetIssueItems(menuId); //ViewBag.ListCards = WorkV3.Models.DataAccess.MenusDAO.GetListCards("Article").Where(c => c.ID != menuId); ViewBag.ListCards = WorkV3.Models.DataAccess.MenusDAO.GetListCards("Article"); // shan 20180102 依 CC 要求修改為本單元亦列入, 且預設勾選 ViewBag.ListCards2 = WorkV3.Models.DataAccess.MenusDAO.GetListCards("Article"); // shan 20180102 依 CC 要求修改為本單元亦列入, 且預設勾選 ViewBag.ListIdentity = CategoryDAO.GetIssueItems(IdentityType); ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/'); ViewBag.MemberRegSet = MemberShipRegSetDAO.GetItem(siteId); List <WorkV3.ViewModels.CommentType> ReplyItemList = WorkV3.ViewModels.CommentTypeLibs.GetCommitTypeList(); ViewBag.ReplyItemList = ReplyItemList; if (item.SortMode == "隨機排序") { item.SortField = "NewID()"; } if (ExtendReadMenus != null) { string eMenus = ""; foreach (string ExtendReadMenu in ExtendReadMenus) { if (!string.IsNullOrEmpty(ExtendReadMenu)) { eMenus += ExtendReadMenu + ","; } } eMenus = eMenus.Trim(','); item.ExtendReadMenus = eMenus; } else { item.ExtendReadMenus = string.Empty; } if (ExtendReadMenus2 != null) { string eMenus = ""; foreach (string ExtendReadMenu in ExtendReadMenus2) { if (!string.IsNullOrEmpty(ExtendReadMenu)) { eMenus += ExtendReadMenu + ","; } } eMenus = eMenus.Trim(','); item.ExtendReadMenus2 = eMenus; } else { item.ExtendReadMenus2 = string.Empty; } if (ReadModeSet != null) { string readModeSetStr = ""; foreach (string readModeSet in ReadModeSet) { if (!string.IsNullOrEmpty(readModeSet)) { readModeSetStr += readModeSet + ","; } } readModeSetStr = readModeSetStr.Trim(','); item.ReadModeSet = readModeSetStr; } else { item.ReadModeSet = string.Empty; } if (!string.IsNullOrWhiteSpace(item.DefaultImg)) { ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.DefaultImg); if (imgModel.ID == 0) { // 新上傳的圖片 HttpPostedFileBase postedFile = Request.Files["fDefaultImg"]; string fDefaultImgBase64 = Request.Form["fDefaultImgBase64"]; string fDefaultImgBase64_Resize = Request.Form["fDefaultImgBase64_Resize"]; if (postedFile == null || postedFile.ContentLength == 0) { item.DefaultImg = string.Empty; } else { string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId, fDefaultImgBase64, fDefaultImgBase64_Resize); imgModel.ID = 1; imgModel.Img = saveName; item.DefaultImg = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel); } } } WorkV3.Models.DataAccess.ArticleSettingDAO.SetItem(item); ViewBag.Success = true; return(View(item)); }
public ActionResult Edit(long siteId, long menuId, string type, long?id, long?templateId) { ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.Types = ArticleTypesDAO.GetIssueItems(menuId); ViewBag.Series = ArticleSeriesDAO.GetIssueItems(menuId); ViewBag.Categories = CategoryDAO.GetItems(FavorityType); ViewBag.Sites = WorkV3.Models.DataAccess.SitesDAO.GetDatas(); ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId); ViewBag.ListIdentity = CategoryDAO.GetIssueItems(IdentityType); int cardStyleID = 1; List <CardsModels> cardItem = CardsDAO.GetPageData(siteId, menuId); foreach (var cards in cardItem) { if (cards.CardsType == "Article") { cardStyleID = cards.StylesID; break; } } ArticleModels item = null; if (id != null) { item = ArticleDAO.GetItem((long)id); SetLinkDetailViewBag(item.LinkDetail); } if (item == null && templateId != null) { MenusModels menu = MenusDAO.GetInfo(siteId, menuId); long newArticleId = WorkLib.GetItem.NewSN(); long cardNo = WorkV3.Golbal.PubFunc.AddPage(siteId, menuId, menu.SN, "Article", "Content", true, CardStyleId: cardStyleID); ArticleDAO.Copy((long)templateId, newArticleId, cardNo, menuId, siteId, true); item = ArticleDAO.GetItem(newArticleId); item.VideoType = "youtube"; ViewBag.FromTemplate = true; } if (item == null) { item = new ArticleModels { ID = WorkLib.GetItem.NewSN(), Type = type, IsIssue = true }; ViewBag.ArticleTypes = new long[] { }; ViewBag.ArticleSeries = new long[] { }; ViewBag.ArticleCategories = new long[] { }; ViewBag.ArticlePosters = new ArticlePosterModels[] { }; } else { ViewBag.ArticleTypes = ArticleDAO.GetItemTypes(item.ID); ViewBag.ArticleSeries = ArticleDAO.GetItemSeries(item.ID); ViewBag.ArticleCategories = ArticleDAO.GetItemCategories(item.ID); IEnumerable <ArticlePosterModels> posters = ArticleDAO.GetItemPosters(item.ID); foreach (ArticlePosterModels p in posters) { if (!string.IsNullOrWhiteSpace(p.Photo)) { ResourceImagesModels photo = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(p.Photo); if (photo.Img != string.Empty) { p.Photo = photo.Img; } } } ViewBag.ArticlePosters = posters; } ViewBag.showMainVideo = false; if (item.VideoID != "") { ViewBag.showMainVideo = true; } return(View(item)); }
public ActionResult Edit(long siteId, long menuId, ArticleModels item, long[] types, long[] series, long[] categories, long[] sites, string posters, IEnumerable <ParagraphModels> paragraphs, string deletedParagraphs, bool saveTemplate, HttpPostedFileBase fVideoImg, string fVideoImgBase64, string fVideoImgBase64_Resize, string customVideo, string LinkSites, string[] Pages, string PageDetailID, long[] readModeCategories) { if (!Utility.CheckIsLogin()) { Response.Redirect(Url.Action("Login", "Home")); } ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.Types = ArticleTypesDAO.GetIssueItems(menuId); ViewBag.Series = ArticleSeriesDAO.GetIssueItems(menuId); ViewBag.Categories = CategoryDAO.GetItems(FavorityType); ViewBag.Sites = WorkV3.Models.DataAccess.SitesDAO.GetDatas(); ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/'); SaveIconAndArchive(siteId, menuId, item); item.MenuID = menuId; if (sites?.Length > 0) { item.IsIssue = true; } if (item.VideoType == "custom") { item.VideoID = customVideo; } #region 影片截圖 if (!string.IsNullOrWhiteSpace(item.VideoImg) && item.VideoImgIsCustom) { if (item.VideoImg[0] == '{') { WorkV3.Models.ImageModel imgModel = JsonConvert.DeserializeObject <WorkV3.Models.ImageModel>(item.VideoImg); if (imgModel.ID == 0) { if (fVideoImg == null || fVideoImg.ContentLength == 0) { item.VideoImg = string.Empty; } else { string fileName = Golbal.UpdFileInfo.SaveFilesByMenuID(fVideoImg, siteId, menuId, fVideoImgBase64, fVideoImgBase64_Resize); imgModel.ID = 1; imgModel.Img = fileName; item.VideoImg = JsonConvert.SerializeObject(imgModel); } } } else { item.VideoImg = string.Empty; } } #endregion int cardStyleID = 1; List <CardsModels> cardItem = CardsDAO.GetPageData(siteId, menuId); foreach (var cards in cardItem) { if (cards.CardsType == "Article") { cardStyleID = cards.StylesID; break; } } if (Request["LinkType"].Contains("true")) { item.LinkType = ResourceLinkType.inLink; if (!string.IsNullOrEmpty(PageDetailID)) { item.LinkDetail = 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); item.Link = 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])) { item.LinkDetail = Pages[i]; } } if (!string.IsNullOrEmpty(item.LinkDetail)) { var pageInfo = WorkV3.Areas.Backend.Models.DataAccess.PagesDAO.GetPageInfo(long.Parse(item.LinkDetail)); if (pageInfo != null) { var siteInfo = WorkV3.Models.DataAccess.SitesDAO.GetInfo(pageInfo.SiteID); item.Link = Url.RouteUrl("FrontSitePage", new { SiteSN = siteInfo.SN, PageSN = pageInfo.SN }); } } } item.Link = item.Link; } else { item.LinkType = ResourceLinkType.outLink; } ArticleDAO.SetItem(item, cardStyleID); SysLog.SaveArticleEditLog(item.ID); ArticleDAO.SetItemTypes(item.ID, types); ArticleDAO.SetItemSeries(item.ID, series); ArticleDAO.SetItemCategories(item.ID, FavorityType, categories); ArticleDAO.SetItemCategories(item.ID, IdentityType, readModeCategories); ArticleDAO.SetItemPosters(item.ID, Newtonsoft.Json.JsonConvert.DeserializeObject <long[]>(posters)); ArticleDAO.SetItemSites(item.ID, sites); SaveParagraph(item, paragraphs, deletedParagraphs); ViewBag.ArticleTypes = types ?? (new long[] { }); ViewBag.ArticleSeries = series ?? (new long[] { }); ViewBag.ArticlePosters = GetPoster(item, posters); ViewBag.ArticleCategories = categories ?? (new long[] { }); SetLinkDetailViewBag(item.LinkDetail); if (saveTemplate) { long tmplId = WorkLib.GetItem.NewSN(); ArticleDAO.Copy(item.ID, tmplId, 0, -menuId, null, true); ViewBag.TemplateID = tmplId; } else { ViewBag.Exit = true; } return(View(item)); }
/// <summary> /// 文章模組類別,需傳入token /// </summary> /// <param name="data"></param> /// <returns></returns> public ApiResult <List <ArticlesTypeListResult> > Post([FromBody] ArticleModuleRequest data) { ApiResult <List <ArticlesTypeListResult> > result = new ApiResult <List <ArticlesTypeListResult> >(); try { ResultCode rcode = ResultCode.Success; bool isSuccess = true; if (string.IsNullOrEmpty(data.SiteSN)) { rcode = ResultCode.SiteNull; isSuccess = false; goto Result; } if (string.IsNullOrEmpty(data.SN)) { rcode = ResultCode.ModuleSNNull; isSuccess = false; goto Result; } long SiteID = GetSiteID(data.SiteSN); if (SiteID <= 0) { rcode = ResultCode.SiteNull; isSuccess = false; goto Result; } var menuItem = Models.DataAccess.MenusDAO.GetInfo(SiteID, data.SN); if (menuItem == null || menuItem.Id <= 0) { rcode = ResultCode.MenuNull; result.Success = false; result.Code = (int)rcode; result.Message = rcode.GetMessage(); return(result); } var types = ArticleTypesDAO.GetIssueItems(menuItem.Id); result.Content = new List <ArticlesTypeListResult>(); foreach (var item in types) { result.Content.Add(new ArticlesTypeListResult() { ID = item.ID, Name = item.Name }); } Result: result.Code = (int)rcode; result.Success = isSuccess; result.Message = rcode.GetMessage(); } catch (Exception ex) { result.Code = (int)ResultCode.Exception; result.Success = false; result.Message = ex.ToString(); } return(result); }