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 Para(long siteId, long menuId, string type) { ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.Type = type ?? "series"; ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId); IEnumerable <ArticleSeriesModels> series = ArticleSeriesDAO.GetItems(menuId); if (series == null) { series = new List <ArticleSeriesModels>(); } ViewBag.Series = series; IEnumerable <ArticleTypesModels> types = ArticleTypesDAO.GetItems(menuId); if (types == null) { types = new List <ArticleTypesModels>(); } ViewBag.Types = types; IEnumerable <ArticlePosterModels> posters = ArticlePosterDAO.GetItems(menuId); if (posters == null) { posters = new List <ArticlePosterModels>(); } ViewBag.Posters = posters; return(View()); }
public ActionResult TypeEdit(long siteId, long menuId, ArticleTypesModels item, HttpPostedFileBase fIcon, string fIconBase64, string fIconBase64_Resize) { ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.UploadVPath = UpdFileInfo.GetVPathByMenuID(siteId, menuId); ViewBag.Exit = true; if (string.IsNullOrEmpty(item.Icon)) { item.Icon = string.Empty; } else { WorkV3.Models.ImageModel imgModel = JsonConvert.DeserializeObject <WorkV3.Models.ImageModel>(item.Icon); if (imgModel.ID == 0) { if (fIcon == null || fIcon.ContentLength == 0) { item.Icon = string.Empty; } else { string fileName = Golbal.UpdFileInfo.SaveFilesByMenuID(fIcon, siteId, menuId, fIconBase64, fIconBase64_Resize); imgModel.ID = 1; imgModel.Img = fileName; item.Icon = JsonConvert.SerializeObject(imgModel); } } } ArticleTypesDAO.SetItem(item); 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)); }
private void SettingInit(long cardNo, SitePage page) { ViewBag.CardNo = cardNo; IEnumerable <IDValue> listCardMenus = WorkV3.Models.DataAccess.MenusDAO.GetListCards("Article"); Dictionary <long, IEnumerable <IDValue> > listCardTypes = new Dictionary <long, IEnumerable <IDValue> >(); foreach (IDValue menu in listCardMenus) { listCardTypes.Add(menu.ID, ArticleTypesDAO.GetItems(menu.ID).Select(t => new IDValue { ID = t.ID, Value = t.Name })); } ViewBag.ListCardMenus = listCardMenus; ViewBag.ListCardTypes = listCardTypes; ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(page.SiteID, page.MenuID).TrimEnd('/'); ViewBag.Page = page; }
public ActionResult TypeEdit(long siteId, long menuId, long?id) { ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.UploadVPath = UpdFileInfo.GetVPathByMenuID(siteId, menuId); ArticleTypesModels type = null; if (id != null) { type = ArticleTypesDAO.GetItem((long)id); } if (type == null) { type = new ArticleTypesModels { ID = WorkLib.GetItem.NewSN(), IsIssue = true, Sort = int.MaxValue } } ; return(View(type)); }
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 void TypeToggleIssue(long siteId, long menuId, long id) { ArticleTypesDAO.ToggleIssue(id); }
public void TypeDel(long siteId, long menuId, IEnumerable <long> ids) { ArticleTypesDAO.Delete(ids); }
public void TypeSort(long siteId, long menuId, IEnumerable <SortItem> items) { ArticleTypesDAO.Sort(menuId, items); }
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)); }
public int GetArticleCount() { return(ArticleTypesDAO.GetArticleCount(ID)); }
/// <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); }
public ActionResult Index(CardsModels model, string key, string type, long?typeId, int?index) { ViewBag.SiteID = model.SiteID; long menuId = CardsDAO.GetMenuID(model.No); ViewBag.Menu = MenusDAO.GetInfo(model.SiteID, menuId); ViewBag.SitePage = CardsDAO.GetPage((long)MenusDAO.GetFirstCardNo(menuId, "Article")); SitePage page = CardsDAO.GetPage(model.No); ArticleSettingModels setting = ArticleSettingDAO.GetItem(menuId); #region 文章列表是否限制會員觀看 if (setting.ReadMode == 1 && !string.IsNullOrWhiteSpace(setting.ReadModeSet)) { Member curUser = Member.Current; string IdentityName = ""; //限制身分的名稱 IEnumerable <Areas.Backend.Models.CategoryModels> listReadModeCategorie = Areas.Backend.Models.DataAccess.CategoryDAO.GetItems(IdentityType, setting.ReadModeSet); foreach (var readModeList in listReadModeCategorie) { IdentityName += readModeList.Title + "、"; } IdentityName = IdentityName.TrimEnd('、'); ViewBag.IdentityName = IdentityName; if (curUser == null) { ViewBag.CheckReadMode = false; ViewBag.IsLogin = false; } else { bool checkReadMode = ArticleDAO.ListCheckReadMode(curUser.ID, IdentityType, listReadModeCategorie); if (!checkReadMode) { ViewBag.CheckReadMode = false; } } } #endregion if (setting.PagingMode == "不分頁") { setting.PageSize = int.MaxValue; } IEnumerable <ArticleTypesModels> types = ArticleTypesDAO.GetItems(menuId); if (setting.Types != "all") { IEnumerable <long> allowTypeIds = setting.GetTypes(); types = types.Where(t => allowTypeIds.Contains(t.ID)); setting.Types = string.Join(",", types.Select(t => t.ID)); } ViewBag.Types = types; int pageIndex = index ?? 1; int totalRecord; IEnumerable <ArticleModels> items = ArticleDAO.GetItems(setting, key, type, typeId, pageIndex, out totalRecord); ViewBag.ItemTypes = ArticleDAO.GetItemTypes(items.Select(item => item.ID)); ViewBag.ItemPages = CardsDAO.GetPages(items.Select(item => item.CardNo)); ViewBag.UploadUrl = UpdFileInfo.GetVPathByMenuID(model.SiteID, menuId).TrimEnd('/') + "/"; ViewBag.Pagination = new Pagination { PageSize = setting.PageSize, PageIndex = pageIndex, TotalRecord = totalRecord }; ViewBag.Setting = setting; ViewBag.Type = type; int style = model.StylesID == 0 ? 1 : model.StylesID; // style = 6; return(View("ListStyle" + style, items)); }