public static void SetItem(ArticleIntroModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("ArticleIntro"); item.Icon = item.Icon ?? string.Empty; item.RemarkText = item.RemarkText ?? string.Empty; tableObj.GetDataFromObject(item); string sql = "Select 1 From ArticleIntro Where ID = " + item.ID; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { long cardNo = WorkV3.Models.DataAccess.MenusDAO.GetFirstCardNo(item.MenuID, "ArticleIntro") ?? 0; tableObj.Add("CardNo", cardNo); tableObj.Insert(); } else { tableObj.Remove("ID"); tableObj.Remove("MenuID"); tableObj.Remove("Creator"); tableObj.Remove("CreateTime"); tableObj.Update(item.ID); } }
public ActionResult Edit(long siteId, long menuId, ArticleIntroModels item, IEnumerable <ParagraphModels> paragraphs, string deletedParagraphs) { if (!string.IsNullOrWhiteSpace(item.Icon)) { ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.Icon); if (imgModel.ID == 0) // 新上傳的圖片 { HttpPostedFileBase postedFile = Request.Files["fIcon"]; string fIconBase64 = Request.Form["fIconBase64"]; string fIconBase64_Resize = Request.Form["fIconBase64_Resize"]; if (postedFile == null || postedFile.ContentLength == 0) { item.Icon = string.Empty; } else { string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId, fIconBase64, fIconBase64_Resize); imgModel.ID = 1; imgModel.Img = saveName; item.Icon = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel); } } } item.MenuID = menuId; item.Creator = MemberDAO.SysCurrent.Id; item.CreateTime = DateTime.Now; item.Modifier = item.Creator; item.ModifyTime = item.CreateTime; ArticleIntroDAO.SetItem(item); if (paragraphs?.Count() > 0) { for (int i = 0, len = paragraphs.Count(); i < len; ++i) { ParagraphModels p = paragraphs.ElementAt(i); p.Sort = (byte)i; p.SourceNo = item.ID; ParagraphDAO.SetItem(p); } } if (!string.IsNullOrWhiteSpace(deletedParagraphs)) { IEnumerable <long> delParagraphIds = deletedParagraphs.Split(',').Select(p => long.Parse(p)); ParagraphDAO.Delete(delParagraphIds); } ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.Success = true; ViewBag.DateFmt = WebInfo.DateFmt; // View 中,WebInfo 會出現命名衝突 ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId); return(View(item)); }
public static string GetContentDesc(long SiteID, long MenuID, long PageNo) { List <ZonesModels> zoneList = ZonesDAO.GetPageData(SiteID, PageNo); string newUploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(SiteID, MenuID).TrimEnd('/') + "/"; if (zoneList != null && zoneList.Count > 0) { for (int i = 0; i < zoneList.Count; i++) { List <CardsModels> cardList = CardsDAO.GetZoneData(SiteID, zoneList[i].No); if (cardList != null && cardList.Count > 0) { switch (cardList[0].CardsType) { case "Article": ArticleModels articleModel = ArticleDAO.GetItemByCard(cardList[0].No); if (articleModel != null) { var paragraphs = ParagraphDAO.GetItems(articleModel.ID); if (paragraphs != null && paragraphs.Count() > 0) { foreach (ParagraphModels paragraph in paragraphs) { if (!string.IsNullOrWhiteSpace(paragraph.Contents)) { return(paragraph.Contents.TrimTags().Truncate(100)); } } } } break; case "ArticleIntro": ArticleIntroModels articleIntroModel = ArticleIntroDAO.GetItem(cardList[0].No); if (articleIntroModel != null) { var paragraphs = ParagraphDAO.GetItems(articleIntroModel.ID); if (paragraphs != null && paragraphs.Count() > 0) { foreach (ParagraphModels paragraph in paragraphs) { if (!string.IsNullOrWhiteSpace(paragraph.Contents)) { return(paragraph.Contents.TrimTags().Truncate(100)); } } } } break; } } } } return(""); }
public ActionResult Index(CardsModels model) { // 注意:CardsModels 中的 MenuID 是無效的 long menuId = CardsDAO.GetMenuID(model.No); ArticleIntroModels intro = ArticleIntroDAO.GetItem(model.No); ViewBag.SiteID = model.SiteID; ViewBag.MenuID = menuId; ViewBag.Style = model.StylesID == 0 ? 1 : model.StylesID; return(View(intro)); }
public ActionResult Edit(long siteId, long menuId) { ArticleIntroModels item = ArticleIntroDAO.GetItem(menuId); if (item == null) { item = new ArticleIntroModels { ID = WorkLib.GetItem.NewSN(), MenuID = menuId, IsIssue = true }; } ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.DateFmt = WebInfo.DateFmt; // View 中,WebInfo 會出現命名衝突 ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId); return(View(item)); }
/* * public static string GetContentTypeKeyword(long SiteID, long MenuID, long PageNo) * { * string type_keywords = ""; * List<ZonesModels> zoneList = ZonesDAO.GetPageData(SiteID, PageNo); * if (zoneList != null && zoneList.Count > 0) * { * for (int i = 0; i < zoneList.Count; i++) * { * List<CardsModels> cardList = CardsDAO.GetZoneData(SiteID, zoneList[i].No); * if (cardList != null && cardList.Count > 0) * { * switch (cardList[0].CardsType) * { * case "Article": * ArticleModels articleModel = ArticleDAO.GetItemByCard(cardList[0].No); * if (articleModel != null) * { * IEnumerable<ArticleTypesModels> types = articleModel.GetTypes(); * type_keywords = string.Join(";", types.Select(t => t.Name)); * } * break; * case "ArticleIntro": * ArticleIntroModels articleIntroModel = ArticleIntroDAO.GetItem(cardList[0].No); * if (articleIntroModel != null) * { * ArticleSettingModels setting = ArticleSettingDAO.GetItem(MenuID); * IEnumerable<ArticleTypesModels> types = ArticleTypesDAO.GetItems(MenuID); * if (setting.Types != "all") * { * IEnumerable<long> allowTypeIds = setting.GetTypes(); * types = types.Where(t => allowTypeIds.Contains(t.ID)); * type_keywords = string.Join(",", types.Select(t => t.Name)); * } * else * { * type_keywords = string.Join(",", types.Select(t => t.Name)); * } * } * break; * case "Event": * EventModels eventModel = EventDAO.GetItemByCard(cardList[0].No); * if (eventModel != null) * { * IEnumerable<EventTypesModels> types = eventModel.GetTypes(); * type_keywords = string.Join(";", types.Select(t => t.Name)); * } * break; * case "Questionnaire": * QuestionnaireModel questionnaireModel = QuestionnaireDAO.GetItemByCardNo(cardList[0].No); * if (questionnaireModel != null) * { * var selecttypes = questionnaireModel.GetTypes(); * var qTypes = QuestionnaireTypeDAO.GetItems(); * qTypes.Where(q => selecttypes.Contains(q.ID)); * type_keywords = string.Join(";", qTypes.Select(t => t.Name)); * } * break; * } * } * } * } * return type_keywords; * } */ public static string GetContentImage(long SiteID, long MenuID, long PageNo) { List <ZonesModels> zoneList = ZonesDAO.GetPageData(SiteID, PageNo); string newUploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(SiteID, MenuID).TrimEnd('/') + "/"; if (zoneList != null && zoneList.Count > 0) { for (int i = 0; i < zoneList.Count; i++) { List <CardsModels> cardList = CardsDAO.GetZoneData(SiteID, zoneList[i].No); if (cardList != null && cardList.Count > 0) { switch (cardList[0].CardsType) { case "Article": ArticleModels articleModel = ArticleDAO.GetItemByCard(cardList[0].No); if (articleModel != null) { if (!string.IsNullOrEmpty(articleModel.Icon)) // 取得[內文/頁面細節/自行設定代表圖] { ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleModel.Icon); return(newUploadUrl + imgModel.Img); } else { if (articleModel.CustomIcon) // 取得[內文 主影片 自行上傳圖片] { if (!string.IsNullOrEmpty(articleModel.VideoImg)) { ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleModel.VideoImg); return(newUploadUrl + imgModel.Img); } } else { if (!string.IsNullOrEmpty(articleModel.VideoImg)) { return(articleModel.VideoImg); //[ 內文 主影片 影片截圖] } } //都沒取到圖, 則繼續取段落的圖 var paragraphs = ParagraphDAO.GetItems(articleModel.ID); if (paragraphs != null && paragraphs.Count() > 0) { foreach (ParagraphModels paragraph in paragraphs) { if (paragraph.MatchType == "img") { IEnumerable <ResourceImagesModels> images = paragraph.GetImages().Where(m => m.IsShow); if (images != null && images.Count() > 0) { ResourceImagesModels imgModel = images.FirstOrDefault(); return(newUploadUrl + imgModel.Img); } } } } } } break; case "ArticleIntro": ArticleIntroModels articleIntroModel = ArticleIntroDAO.GetItem(cardList[0].No); if (articleIntroModel != null) { if (!string.IsNullOrEmpty(articleIntroModel.Icon)) // 取得[內文/頁面細節/自行設定代表圖] { ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleIntroModel.Icon); return(newUploadUrl + imgModel.Img); } else { //都沒取到圖, 則繼續取段落的圖 var paragraphs = ParagraphDAO.GetItems(articleIntroModel.ID); if (paragraphs != null && paragraphs.Count() > 0) { foreach (ParagraphModels paragraph in paragraphs) { if (paragraph.MatchType == "img") { IEnumerable <ResourceImagesModels> images = paragraph.GetImages().Where(m => m.IsShow); if (images != null && images.Count() > 0) { ResourceImagesModels imgModel = images.FirstOrDefault(); return(newUploadUrl + imgModel.Img); } } } } } //ArticleSettingModels newSetting = ArticleSettingDAO.GetItem(MenuID); //string img = articleIntroModel.GetFirstImg(newSetting); //if (!string.IsNullOrEmpty(img)) // return newUploadUrl + img; } break; } } } } return(""); }
public static ViewModels.SEORelationModel GetContentSEO(long SiteID, long MenuID, long PageNo) { ViewModels.SEORelationModel seoModel = new ViewModels.SEORelationModel(); string newUploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(SiteID, MenuID).TrimEnd('/') + "/"; //WorkLib.WriteLog.Write(true, MenuID.ToString()); List <ZonesModels> zoneList = ZonesDAO.GetPageData(SiteID, PageNo); if (zoneList != null && zoneList.Count > 0) { for (int i = 0; i < zoneList.Count; i++) { List <CardsModels> cardList = CardsDAO.GetZoneData(SiteID, zoneList[i].No); if (cardList != null && cardList.Count > 0) { switch (cardList[0].CardsType) { case "Article": ArticleModels articleModel = ArticleDAO.GetItemByCard(cardList[0].No); if (articleModel != null) { var authors = ArticleDAO.GetItemPosters(articleModel.ID); if (authors != null && authors.Count() > 0) { foreach (ArticlePosterModels auhtor in authors) { seoModel.Author += auhtor.Name + ";"; } seoModel.Author = seoModel.Author.Trim(';'); } IEnumerable <ArticleTypesModels> types = articleModel.GetTypes(); seoModel.Keywords = string.Join(";", types.Select(t => t.Name)); if (!string.IsNullOrEmpty(articleModel.Icon)) // 取得[內文/頁面細節/自行設定代表圖] { ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleModel.Icon); seoModel.SocialImage = newUploadUrl + imgModel.Img; } else { if (articleModel.CustomIcon) // 取得[內文 主影片 自行上傳圖片] { if (!string.IsNullOrEmpty(articleModel.VideoImg)) { ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleModel.VideoImg); seoModel.SocialImage = newUploadUrl + imgModel.Img; } } else { if (!string.IsNullOrEmpty(articleModel.VideoImg)) { seoModel.SocialImage = articleModel.VideoImg; //[ 內文 主影片 影片截圖] } } } var paragraphs = ParagraphDAO.GetItems(articleModel.ID); if (paragraphs != null && paragraphs.Count() > 0) { foreach (ParagraphModels paragraph in paragraphs) { //都沒取到圖, 則繼續取段落的圖 if (string.IsNullOrEmpty(seoModel.SocialImage)) { if (paragraph.MatchType == "img") { IEnumerable <ResourceImagesModels> images = paragraph.GetImages().Where(m => m.IsShow); if (images != null && images.Count() > 0) { ResourceImagesModels imgModel = images.FirstOrDefault(); seoModel.SocialImage = newUploadUrl + imgModel.Img; } } } if (!string.IsNullOrWhiteSpace(paragraph.Contents)) { if (string.IsNullOrEmpty(seoModel.Description)) { seoModel.Description = paragraph.Contents.TrimTags().Truncate(100); } } } } } break; case "ArticleIntro": ArticleIntroModels articleIntroModel = ArticleIntroDAO.GetItem(cardList[0].No); if (articleIntroModel != null) { ArticleSettingModels setting = ArticleSettingDAO.GetItem(MenuID); IEnumerable <ArticleTypesModels> types = ArticleTypesDAO.GetItems(MenuID); if (setting.Types != "all") { IEnumerable <long> allowTypeIds = setting.GetTypes(); types = types.Where(t => allowTypeIds.Contains(t.ID)); seoModel.Keywords = string.Join(",", types.Select(t => t.Name)); } else { seoModel.Keywords = string.Join(",", types.Select(t => t.Name)); } if (!string.IsNullOrEmpty(articleIntroModel.Icon)) // 取得[內文/頁面細節/自行設定代表圖] { ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleIntroModel.Icon); seoModel.SocialImage = newUploadUrl + imgModel.Img; } var paragraphs = ParagraphDAO.GetItems(articleIntroModel.ID); if (paragraphs != null && paragraphs.Count() > 0) { foreach (ParagraphModels paragraph in paragraphs) { //都沒取到圖, 則繼續取段落的圖 if (string.IsNullOrEmpty(seoModel.SocialImage)) { if (paragraph.MatchType == "img") { IEnumerable <ResourceImagesModels> images = paragraph.GetImages().Where(m => m.IsShow); if (images != null && images.Count() > 0) { ResourceImagesModels imgModel = images.FirstOrDefault(); seoModel.SocialImage = newUploadUrl + imgModel.Img; } } } if (!string.IsNullOrWhiteSpace(paragraph.Contents)) { if (string.IsNullOrEmpty(seoModel.Description)) { seoModel.Description = paragraph.Contents.TrimTags().Truncate(100); } } } } } break; } } } } return(seoModel); }