//// GET: ShowItem //public ActionResult Index() //{ // string idstr = Request.QueryString["id"]; // int id = 0; // if (idstr == null || !Int32.TryParse(idstr, out id)) // { // return View("error"); // } // LayoutViewModel masterModel = new LayoutViewModel(db); // ArticleContent model = db.ArticleContents.Find(id); // // 根据不同的类型可以把title改下 // AcTypeEmun typeEnum = (AcTypeEmun)Enum.Parse((typeof(AcTypeEmun)), model.ACType); // string emumtext = RemarkAttribute.GetEnumRemark(typeEnum); // ViewBag.Title = "吉家尚" + emumtext + "详情页"; // ViewBag.Content = model.AContent; // masterModel.groupBuilds = db.ArticleContents // .Where(w => w.ACType == AcTypeEmun.GROUPBUILD.ToString().ToUpper()) // .Take(4).OrderBy(o => new { o.ACSortNum, o.InDateTime }) // .OrderBy(o => o.ACSortNum).ToList(); // return View(masterModel); //} /// <summary> /// 热门套餐,经典案例,团装,家居设计,环保装修详情页 /// </summary> /// <returns></returns> public ActionResult ArticleContent() { string idstr = Request.QueryString["id"]; int id = 0; if (idstr == null || !Int32.TryParse(idstr, out id)) { return(View("error")); } ArticleContent model = db.ArticleContents.Find(id); if (model == null) { return(View("error")); } // 根据不同的类型可以把title改下 AcTypeEmun typeEnum = (AcTypeEmun)Enum.Parse((typeof(AcTypeEmun)), model.ACType); string emumtext = RemarkAttribute.GetEnumRemark(typeEnum); ViewBag.Title = "吉家尚" + emumtext + "详情页"; ViewBag.Content = model.AContent; LayoutViewModel masterModel = new LayoutViewModel(db); masterModel.groupBuilds = db.ArticleContents .Where(w => w.ACType == AcTypeEmun.GROUPBUILD.ToString().ToUpper()) .Take(4).OrderBy(o => new { o.ACSortNum, o.InDateTime }) .OrderBy(o => o.ACSortNum).ToList(); return(View(masterModel)); }
public ActionResult Create([Bind(Include = "articlePreview,title,body")] Article article, HttpPostedFileBase imageData, List <string> paragraphs) { if (ModelState.IsValid) { // Configure Article metadata article.userId = User.Identity.GetUserId(); article.date = DateTime.Now; article.author = User.Identity.GetUserName(); if (imageData != null) { byte[] imageByteArray = ConvertToByte(imageData); article.image = new Image { imageDate = DateTime.Now, imageCaption = "Caption", imageData = imageByteArray }; } ArticleContent ac = new ArticleContent { paragraphs = paragraphs }; article.articleContent = JsonConvert.SerializeObject(ac); db.articles.Add(article); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(article)); }
public void UpdateArticleContentScoring() { var country = "EN-GB"; var articleContents = GetFeedArticle(country); var dataset = ArticleContent.Transform(articleContents); var model = ArticleContentPredictionModel.Train(); var rep = ArticleContentPredictionModel.Predict(model, dataset); model.WriteAsync(_modelpath); foreach (var item in rep) { var temp = articleContents.FirstOrDefault(x => x.ContentId.Equals(item.Item1.ContentId)); var keyValue = new KeyValuePair <string, float>("RelevantScoring", item.Item2.RelevantScoring); var filter = Builders <ArticleContent> .Filter.Eq("ContentId", item.Item1.ContentId); _repository.UpdateOneAsync(temp, keyValue, filter); } }
//============================== Controller Methods ============================== private void SaveToXML(ArticleContent article) { // Creating Xml Settings For Our XML File XmlWriterSettings settings = new XmlWriterSettings() { Async = true, Indent = true, IndentChars = (" "), CloseOutput = true, OmitXmlDeclaration = true }; // Writes Contents To The New XML File try { new System.Threading.Thread(() => { using (var stream = System.IO.File.Open(ARTICLE_FILE, FileMode.Create, FileAccess.Write, FileShare.Read)) { XmlWriter writer = XmlWriter.Create(stream, settings); writer.WriteStartElement("ArticleContent"); writer.WriteElementString("Title", article.Title); writer.WriteElementString("ParagraphTitle", article.ParagraphTitle); writer.WriteElementString("ParagraphContent", article.ParagraphContent); writer.WriteEndElement(); writer.Flush(); } }).Start(); } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception.Message); } }
/// <summary> /// PDF用 /// </summary> /// <param name="ArticleId"></param> /// <returns></returns> public ActionResult SimplePDF(string ArticleId) { if (string.IsNullOrEmpty(ArticleId)) { return(Redirect("/")); } var articlebody = ArticleListManager.GetArticleBodyById(ArticleId); if (articlebody == null) { return(Redirect("/")); } if (!articlebody.ArticleInfo.IsPrivate && articlebody.ArticleInfo.PublishStatus != ApproveStatus.Accept) { //公开文章,但是没有发布 return(Redirect("/")); } if (articlebody.ArticleInfo.IsPrivate) { if (Session[ConstHelper.Session_USERID] == null) { return(Redirect("/")); } if (!Session[ConstHelper.Session_USERID].ToString().Equals(articlebody.ArticleInfo.OwnerId)) { return(Redirect("/")); } } ViewBag.Html = ArticleContent.GetHtmlString(ArticleId); ViewData.Model = articlebody; return(View()); }
//文章内容 public ActionResult Content(string keyword1 = "", string keyword2 = "", int articleId = 1) { string menuKey = ""; if (keyword2 == "") { menuKey = keyword1; } else { menuKey = keyword1 + "/" + keyword2; } MyResult result = new MyResult(); ArticleDAL dal = new ArticleDAL(); result = dal.getArticleContent(menuKey, articleId); ArticleContent model = new ArticleContent(); //Article article = new Article(); //ArticleTag articleTag = new ArticleTag(); //PrevNext prevNext = new PrevNext(); model.article = ConvertHelper.FillModel <Article>(((DataTable)result.obj).Rows[0]); model.articleTag = ConvertHelper.FillModelList <ArticleTag>(((DataTable)result.obj2)); model.prevNext = ConvertHelper.FillModelList <PrevNext>(((DataTable)result.obj3)); ViewBag.menuKey = menuKey; return(View(model)); }
public Article(ArticleContent content, ArticleStatus status, ArticleSettings settings, uint ownerId) : this(content, status, settings) { this.Author = new ArticleUser() { Id = ownerId }; }
public PlainArticle(ArticleContent article) { Url = article.Permalink; Title = article.Title; Tags = article.Tags; PlainText = article.PlainText; Date = article.Date; }
public ArticleContent GetContentById(int id) { string sqlDetail = @"select ArticleId, Content from ArticleContents where ArticleId = @ArticleId"; var conn = GetOpenConnection(); ArticleContent articleContent = conn.Query <ArticleContent>(sqlDetail, new { ArticleId = id }).SingleOrDefault(); return(articleContent); }
void apiManager_RandomArticleHandler(ArticleContent ac) { Dispatcher.BeginInvoke(() => { apiManager.RandomArticleHandler -= apiManager_RandomArticleHandler; ImageStoryboard.Begin(); }); }
public ActionResult DeleteConfirmed(int id) { ArticleContent articleContent = db.ArticleContents.Find(id); db.ArticleContents.Remove(articleContent); db.SaveChanges(); int type = (int)Enum.Parse(typeof(AcTypeEmun), articleContent.ACType); return(RedirectToAction("Index", new { type = type })); }
public IActionResult Create(ArticleContent article) { if (ModelState.IsValid) { // Add The New Article Contents To SQLite Database company.Add(article); return(RedirectToActionPermanent("Dashboard")); } return(View()); }
public ActionResult Edit([Bind(Include = "Id,ACPhoto,ACTitle,ACSortNum,DId,AContent,ACEpitome,ACLink,ACType,InDateTime,EditDateTime,InUserName,EditUserName")] ArticleContent articleContent , HttpPostedFileBase ACPhoto) { string typestr = Request.QueryString["type"]; int type = 0; if (typestr == null || !Int32.TryParse(typestr, out type) || !Enum.IsDefined(typeof(AcTypeEmun), type)) { return(View("error")); } if (ModelState.IsValid) { if (type != (int)AcTypeEmun.OTHER) { if (ACPhoto != null) { var uploadResult = Helper.Upload(ACPhoto); if (uploadResult.code == "666") { articleContent.ACPhoto = uploadResult.url; } else { return(Content("上传异常 !", "text/plain")); } } else { articleContent.ACPhoto = Request.QueryString["oldphone"].ToString(); } } articleContent.ACType = ((AcTypeEmun)type).ToString(); articleContent.EditDateTime = DateTime.Now; db.Entry(articleContent).State = EntityState.Modified; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; return(RedirectToAction("Index", new { type = (int)Enum.Parse(typeof(AcTypeEmun), articleContent.ACType) })); } string pagenum = "_"; if (type == (int)AcTypeEmun.GROUPBUILD || type == (int)AcTypeEmun.HOMEDESIGN || type == (int)AcTypeEmun.ENVIRONMENTAL) { pagenum += "4"; } else { pagenum += type.ToString(); } return(View("Index" + pagenum)); }
public ArticleUpdateCommand(uint articleId, ArticleContent content, ArticleSettings settings, ArticleStatus status) { this.Id = articleId; this.Content = content; this.Settings = settings; this.Status = status; if (this.Status != null) { Status.ModifyTime = DateTime.UtcNow; } }
private Article(ArticleContent content, ArticleStatus status, ArticleSettings settings) { if (status.CreatedTime == null) { Status.CreatedTime = DateTime.UtcNow; Status.ModifyTime = DateTime.UtcNow; } this.Content = content; this.Status = status; this.Settings = settings; }
public string Transform(ArticleContent article, string htmlFromMarkdown) { var session = new Dictionary <string, object> { ["article"] = article, ["htmlFromMarkdown"] = htmlFromMarkdown, }; return(new ArticleContentTemplate { Session = session }.TransformText()); }
//============================== SAVE ============================== public IActionResult Save(int?id) { ArticleContent savedContent = company.GetReference(id); if (ModelState.IsValid) { // Save Article To The XML File SaveToXML(savedContent); return(RedirectToAction("Index", "Home")); } return(View("Edit")); }
private ArticleContent GetArticleFromResponse(WebResponse response) { ArticleContent ac = new ArticleContent(); DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(ArticleContent)); Stream stream = response.GetResponseStream(); ac = ds.ReadObject(stream) as ArticleContent; stream.Close(); response.Close(); return(ac); }
private void bind() { bindModel = ArticleManager.GetInstance().GetArticleList(CurrentPage, PageSize, SearchMode, SearchKeyword, true); RecordCount = bindModel.TotalCount; foreach (ArticleModel model in bindModel) { ArticleContent template = (ArticleContent)LoadControl(SnapManager.GetInstance().SnapCollection["Article"].ContentControl); template.ArticleNo = model.ArticleNo; phArticleList.Controls.Add(template); } }
private void CheckReadedList(ArticleContent article) { if (readedArticle != null) { readedArticle.Add(article.short_id); if (readedArticle.Count >= 50) { readedArticle.RemoveAt(0); } APIManager.readedArticle = APIManager.readedArticle; } }
// GET: ArticleContents/Details/5 public ActionResult Details() { string idnum = Request.QueryString["id"]; int id = 0; if (!Int32.TryParse(idnum, out id)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ArticleContent articleContent = db.ArticleContents.Find(id); if (articleContent == null) { return(HttpNotFound()); } AcTypeEmun typeEnum = AcTypeEmun.ROLL; typeEnum = (AcTypeEmun)Enum.Parse((typeof(AcTypeEmun)), articleContent.ACType); string emumtext = RemarkAttribute.GetEnumRemark(typeEnum); ViewBag.TypeText = emumtext; ViewBag.TypeNum = (int)typeEnum; ViewBag.Content = articleContent.AContent; articleContent.ACType = emumtext; string pagenum = "_"; if (typeEnum == AcTypeEmun.GROUPBUILD || typeEnum == AcTypeEmun.HOMEDESIGN || typeEnum == AcTypeEmun.ENVIRONMENTAL) { pagenum += "4"; } else { pagenum += ((int)typeEnum).ToString(); } if (typeEnum == AcTypeEmun.CLASSCASE) { foreach (var item in db.Designers) { if (articleContent.DId == item.Id) { ViewBag.DesignerName = item.DName + "_" + item.DUniversity + "_" + item.DDepartment; } } } return(View("Details" + pagenum, articleContent)); }
public async Task <ActionResult> Create([FromBody] ArticleContent model) { var resdata = await AutoException.Excute <long>(async (result) => { model.CreateBy = "admin"; model.CreateDt = DateTime.Now; result.Data = await ArticleContentDAL.InsertAsync(model); if (result.Data == 0) { throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model)); } }, false); return(Json(resdata)); }
public ArticleAddCommand(ArticleContent content, ArticleSettings settings, ArticleStatus status, uint authorId) { this.Content = content; this.Settings = settings; this.Status = status; this.AuthorId = authorId; if (this.Status != null) { Status.CreatedTime = DateTime.UtcNow; if (Status.IsPublished) { Status.PublishTime = DateTime.UtcNow; } } }
public async Task <ActionResult> Update([FromBody] ArticleContent model) { var resdata = await AutoException.Excute <ArticleContent>(async (result) => { model.UpdateBy = "admin"; model.UpdateDt = DateTime.Now; var res = await ArticleContentDAL.UpdateAsync(model); result.Data = model; if (!res) { throw new Exception("数据修改异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model)); } }, false); return(Json(resdata)); }
public Article GetArticleById(int id) { var article = _articleRepository.Table.SingleOrDefault(c => c.Id == id); if (article != null) { string sqlDetail = @"select ArticleId, Content from ArticleContents where ArticleId = @ArticleId"; var conn = GetOpenConnection(); ArticleContent articleContent = conn.Query <ArticleContent>(sqlDetail, new { ArticleId = id }).SingleOrDefault(); if (articleContent != null) { article.Content = articleContent.Content; } } return(article); }
/// <summary> /// 更新文章 /// </summary> /// <param name="request">文章信息</param> /// <returns></returns> public async Task <ResultModel <string> > UpdateAsync(UpdateArticleRequest request) { var response = new ResultModel <string>(); var article = new ArticleInfo() { Abstract = request.Abstract, Title = request.Title, Id = request.Id.ObjToInt(), Likes = request.Likes, Views = request.Views, Comments = request.Comments, IsPublished = request.IsPublished, ImageUrl = request.ImageUrl, ModifyTime = DateTime.Now }; var content = new ArticleContent() { Content = request.Content, ArticleId = article.Id, ModifyTime = DateTime.Now }; var result = await _articleRepository.UseTranAsync(async() => { await _articleRepository.UpdateAsync(article); await _articleContentRepository.UpdateAsync(content, it => it.ArticleId); ////先删除再添加 await _articleTagRepository.DeleteAsync(x => x.ArticleId == article.Id); await _articleCategoryRepository.DeleteAsync(x => x.ArticleId == article.Id); var articleTags = request.TagIds.Select(tagId => new ArticleTag() { TagId = tagId.ObjToInt(), ArticleId = article.Id, }).ToList(); await _articleTagRepository.InsertAsync(articleTags); var articleCategories = request.CategoryIds.Select(categoryId => new ArticleCategory() { ArticleId = article.Id, CategoryId = categoryId.ObjToInt() }).ToList(); await _articleCategoryRepository.InsertAsync(articleCategories); }); response.IsSuccess = result.IsSuccess; response.ResultInfo = result.ErrorMessage; return(response); }
/// <summary> /// 添加文章命令处理器 /// </summary> /// <param name="request"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task <bool> Handle(ArticleAddCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { return(Task.FromResult(false)); } var content = new ArticleContent(request.Content.Title, request.Content.CoverUrl, request.Content.Summary, request.Content.ContentHtml, request.Content.ContentMarkdown); var settings = new ArticleSettings(); var status = new ArticleStatus(); var newArticle = new Article(content, status, settings, request.AuthorId); _articleRepository.Add(newArticle); var commitResult = Commit(); return(Task.FromResult(commitResult)); }
public async Task <ActionResult> CreateModule(string id) { (List <ArticleType> list, long count)articles = await ArticleTypeDAL.QueryAsync(w => w.Status == 1); ViewBag.ArticleTypeList = articles.list.Select(s => new SelectListItem { Text = s.TypeName, Value = s.Id.ToString() }).ToList(); ArticleContent model = new ArticleContent() { OriginType = 0 }; if (!string.IsNullOrEmpty(id)) { model.TypeID = Convert.ToInt32(id); } return(View(model)); }
/// <summary> /// 编辑投稿 /// </summary> /// <param name="ArticleID"></param> /// <returns></returns> public ActionResult MarkDownEditor(string ArticleID) { Article article = Article.GetArticleBySn(ArticleID); if (Session[ConstHelper.Session_USERID] == null) { return(Redirect("/Home/Index")); } if (Session[ConstHelper.Session_USERID].ToString() != article.OwnerId) { return(Redirect("/Home/Index")); } ViewBag.IsPrivate = article.IsPrivate; ViewBag.FreeVolumn = UploadFile.GetFreeVolumnByAccountId(article.OwnerId); ViewData.Model = ArticleContent.GetMarkDown(ArticleID, RevisionType.Draft); ViewBag.Title = "编辑-" + article.Title; return(View()); }
// GET: ArticleContents/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ArticleContent articleContent = db.ArticleContents.Find(id); if (articleContent == null) { return(HttpNotFound()); } ViewBag.TypeText = RemarkAttribute.GetEnumRemark((AcTypeEmun)Enum.Parse(typeof(AcTypeEmun), articleContent.ACType)); int type = (int)Enum.Parse(typeof(AcTypeEmun), articleContent.ACType); ViewBag.TypeNum = type; ViewBag.TypeEmnu = articleContent.ACType.ToString(); string pagenum = "_"; if (type == (int)AcTypeEmun.GROUPBUILD || type == (int)AcTypeEmun.HOMEDESIGN || type == (int)AcTypeEmun.ENVIRONMENTAL) { pagenum += "4"; } else { pagenum += type.ToString(); } if (type == (int)AcTypeEmun.CLASSCASE) { foreach (var item in db.Designers) { if (articleContent.DId == item.Id) { ViewBag.DesignerName = item.DName + "_" + item.DUniversity + "_" + item.DDepartment; } } } return(View("Delete" + pagenum, articleContent)); }