public JsonResult PubArticle([FromBody] ArticleParam msg) { ReplyModel reply = new ReplyModel(); try { Users users = _userRepository.Get(msg.UserId); if (users != null) { msg.Password = MD5Encrypt.Encrypt(msg.Password); Article.Add(_articleRepository, msg); UserArticleEventExtend.TriggerAlterUserAritlceCountEvent(users, ServiceProvider); bool result = ServiceProvider.GetService <IUnitOfWork>().Commit(); if (result) { reply.Status = "002"; reply.Msg = "保存文章成功"; } else { reply.Msg = "保存文章失败"; } } else { reply.Msg = "未找到用户信息"; } } catch (Exception ex) { reply.Msg = "文章发布或保存草稿失败,请重试"; // _Logger.LogError($"文章发布或保存草稿失败,请重试{JsonConvert.SerializeObject(ex)}"); } return(Json(reply)); }
protected void CreateOrEditButton_Click(object sender, EventArgs e) { ErrorMessagePanel.Visible = false; SuccMessagePanel.Visible = false; if (Page.IsValid) { try { var user = Member.Current; string ImageURL = VideoImage.DescriptionUrl; string VideoURL = VideoURLHiddenLabel.Text; if (PageRequest == RequestType.Create && String.IsNullOrEmpty(ImageURL) && String.IsNullOrEmpty(VideoURL)) { throw new MsgException(U6012.MUSTUPLOADIMAGEORVIDEO); } string title = InputChecker.HtmlEncode(TitleTextBox.Text, Article.TitleMaxCharacters, L1.TITLE); string description = InputChecker.HtmlEncode(DescriptionTextBox.Text, 150, U6012.SUBTITLE); string text = InputChecker.HtmlEncode(Request.Form[TextCKEditor.UniqueID], 2000000000, L1.TEXT); List <string> keywords = KeywordsTextBox.Text.Replace(" ", string.Empty) .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(tag => InputChecker.HtmlEncode(tag, 20, U6002.TAG)) .ToList(); string keywordsString = InputChecker.HtmlEncode(String.Join(",", keywords.ToArray()), 5000, U6012.KEYWORDS); if (PageRequest == RequestType.Create) { Article.Add(title, text, description, keywordsString, Member.CurrentId, CountriesList.SelectedValue, Convert.ToInt32(CategoriesList.SelectedValue), ImageURL, VideoURL); SuccMessage.Text = U6012.ARTICLECREATED + ". " + L1.YOUWILLREDIRECT; } else { Article.Edit(Convert.ToInt32(ViewState["editid"]), title, text, description, keywordsString, Member.CurrentId, CountriesList.SelectedValue, Convert.ToInt32(CategoriesList.SelectedValue), ImageURL, VideoURL); SuccMessage.Text = U6013.ARTICLESAVEDANDSENT + " " + L1.YOUWILLREDIRECT; } SuccMessagePanel.Visible = true; ViewState["editid"] = null; Response.AddHeader("REFRESH", "3;URL=writing.aspx"); } catch (MsgException ex) { ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } catch (Exception ex) { ErrorLogger.Log(ex); } } }
public ActionResult ajouter(Article a) { Article.Add(a); //EntitiesContext.ajouter(a); string courriel = User.Identity.Name; Utilisateur u = Utilisateurs.FindByCourriel(courriel); int id = u.Id; Article.Update(a, id); return(RedirectToAction("afficher", new { Titre = a.accederTitre })); }
public override void Loaded() { TxtInput = string.Empty; Articles.Clear(); isInputEnabled = false; Index = 1; List <string> ls = new List <string>(); if (App.Model == TestModel.Exam) { IsBaseInfoVis = Visibility.Visible; IsExerciseModel = Visibility.Hidden; time = Exam.CR_F_TESTTIME * 60; string article = Exam.CR_F_ARTICLE; while (article.Length != 0) { var strTemp = string.Empty; if (article.Length < 30) { ls.Add(article); article = string.Empty; } else { ls.Add(article.Substring(0, 30)); strTemp = article.Remove(0, 30); article = strTemp; } } //ls = Exam.CR_F_ARTICLE.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries).ToList<string>(); } else { try { ExerciseTestTime = Convert.ToInt32(ConfigManager.GetInstance().GetConfigValue("SlitTextCnCharactersTypingDuration", ConfigType.Client)); } catch (Exception) { } Article.Clear(); IsBaseInfoVis = Visibility.Hidden; IsExerciseModel = Visibility.Visible; time = ExerciseTestTime * 60; doc.Load(@".\Source\TypeSlit.xml"); var xnl1 = doc.SelectNodes(@"Document/Article"); Dictionary <string, string> DicTemp = new Dictionary <string, string>(); foreach (var item in xnl1) { DicTemp.Add(((XmlElement)item).GetAttribute("Id").ToString(), ((XmlElement)item).GetAttribute("Name").ToString()); } Articles.Clear(); Articles = DicTemp; ArticleSelected = Articles.Keys.ToArray()[0]; for (int i = 0; i < xnl1.Count; i++) { if (((XmlElement)xnl1[i]).GetAttribute("Id") == Articles.Keys.First()) { foreach (XmlNode item in xnl1[i].ChildNodes) { ls.Add(item.InnerText); } } } } TimeSpan ts = new TimeSpan(0, 0, time); CountDown = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds); foreach (var item in ls) { Article.Add(new OneTypeInfo() { Index = ls.IndexOf(item) + 1, StrOri = item, }); } TxtOri = Article[Index - 1].StrOri; if (timer.Interval != new TimeSpan(0, 0, 1)) { timer.Interval = TimeSpan.FromMilliseconds(1000); timer.Tick += timer_Tick; //你的事件 } }
public void CreateParagraph() { _article.Add("Paragraph"); }
public override void Loaded() { TxtInput = string.Empty; Article.Clear(); Index = 1; isInputEnabled = false; if (App.Model == TestModel.Exam) { var dic = new Dictionary <int, float>(); string PercentOfNum = ConfigManager.GetInstance().GetConfigValue("PercentOfNum", ConfigType.Client); foreach (var item in PercentOfNum.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries)) { dic.Add(Convert.ToInt32(item.Split('|')[0]), Convert.ToSingle(item.Split('|')[1])); } var listStr = CommonFunction.CreateRandomNum(Exam.NI_F_NUMCOUNT, dic); while (listStr.Count > Exam.NI_F_NUMCOUNT) { listStr.RemoveAt(listStr.Count - 1); } //TODO: foreach (var item in listStr) { TestContent += item + "|"; } foreach (var item in listStr) { Article.Add(new OneTypeInfo() { Index = listStr.IndexOf(item) + 1, StrOri = item, }); } if (Article == null || Article.Count == 0) { Messenger.Default.Send("分条题目为空!"); return; } TxtOri = Article[Index - 1].StrOri; time = Exam.NI_F_TESTTIME * 60; IsBaseInfoVis = Visibility.Visible; IsExerciseModel = Visibility.Hidden; } else { try { ExerciseTestTime = Convert.ToInt32(ConfigManager.GetInstance().GetConfigValue("DigitalTypingDuration", ConfigType.Client)); ExerciseCriteria = Convert.ToInt32(ConfigManager.GetInstance().GetConfigValue("DigitalTypingCriteria", ConfigType.Client)); } catch (Exception) { } time = ExerciseTestTime * 60; IsBaseInfoVis = Visibility.Hidden; IsExerciseModel = Visibility.Visible; StreamReader sr = new StreamReader(@".\Source\TypeDigital.txt", Encoding.Default); String line = sr.ReadToEnd(); var listStr = line.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries).ToList <string>(); foreach (var item in listStr) { Article.Add(new OneTypeInfo() { Index = listStr.IndexOf(item) + 1, StrOri = item, }); } TxtOri = Article[Index - 1].StrOri; } if (timer.Interval != new TimeSpan(0, 0, 1)) { timer.Interval = TimeSpan.FromMilliseconds(1000); timer.Tick += Timer_Tick; //你的事件 } TimeSpan ts = new TimeSpan(0, 0, time); CountDown = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds); }