private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != null) { Comment comment1 = new Comment(textBox1.Text, News.id, ID); comment1.Add(comment1); this.panel1.Controls.Clear(); comments = comment1.queryNewId(News.id); foreach (var item in comments) { commenf childform = new commenf(item); childform.TopLevel = false; childform.FormBorderStyle = FormBorderStyle.None; childform.Dock = DockStyle.Top; panel1.Controls.Add(childform); childform.BringToFront(); childform.Show(); } this.textBox1.Text = null; } }
public async Task <IActionResult> PostComment([FromBody] ListViewModel vm) { if (ModelState.IsValid) { try { var owner = await userManager.GetUserAsync(HttpContext.User); var idea = context.Ideas.Include(r => r.Stats).Include(r => r.Comments).Include(r => r.Owner).FirstOrDefault(r => r.Id == vm.IdeaId); if (idea.Owner != owner) { Notification.Add(NotificationType.Commented, idea.Owner, owner, idea, context); } Comment.Add(owner, idea, vm.Comment); UserStats.AddComment(owner, context); Stats.AddComments(idea); await context.SaveChangesAsync(); var ideaEx = IdeaEx.IdeaById(vm.IdeaId, owner, context); var JsonData = JsonConvert.SerializeObject(ideaEx, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); return(Json(JsonData)); } catch (Exception ex) { ex = ex; } } else { var JsonDataError = JsonConvert.SerializeObject(ModelState.Values, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); return(Json(JsonDataError)); } return(Json("")); }
private void AddComment() { int formInt = WebUtils.GetFormInt("cmtcontid", 0); ContentInfo contentById = Content.GetContentById(formInt); string formString = WebUtils.GetFormString("cmtusername"); string formString2 = WebUtils.GetFormString("cmtemail"); string formString3 = WebUtils.GetFormString("cmttitle"); string formString4 = WebUtils.GetFormString("cmtcontent"); string formString5 = WebUtils.GetFormString("ccode"); if (base.ValidateCode != formString5) { base.Response.Write("验证码不正确"); } else if (contentById == null) { base.Response.Write("没有找到相关内容"); } else if (string.IsNullOrEmpty(formString)) { base.Response.Write("用户名称不为空"); } else if (string.IsNullOrEmpty(formString3)) { base.Response.Write("标题不为空"); } else if (string.IsNullOrEmpty(formString4)) { base.Response.Write("评论内容不为空"); } else if (Comment.Add(new CommentInfo { Content = formString4, ContID = contentById.AutoID, ContName = contentById.Title, EnableAnonymous = true, IPAddress = IPUtils.GetIP(), IPArea = string.Empty, IsAudit = true, IsReply = false, Lang = base.cultureLang, ReplyID = 0, Title = formString3, UserID = 0, UserName = formString, AutoTimeStamp = System.DateTime.Now }) > 0) { base.Response.Write("发表评论成功"); } else { base.Response.Write("发表评论失败"); } }
protected void enterComment(object sender, KeyEventArgs e) { TextBox tbx = sender as TextBox; if (e.Key != System.Windows.Input.Key.Enter) { return; } e.Handled = true; Comment.Add(comment_tartalom.Text, Session.ProjektID, 0); megjegyzes_listBox.ItemsSource = Utility.Data_CommentProject(); tbx.Text = ""; }
protected void enterComment(object sender, KeyEventArgs e) { TextBox tbx = sender as TextBox; if (e.Key != System.Windows.Input.Key.Enter) { return; } e.Handled = true; Comment.Add(comment_tartalom.Text, Session.ProjektID, 0); listLoader(); tbx.Text = ""; }
protected void enterComment(object sender, KeyEventArgs e) { TextBox textbox = sender as TextBox; if (e.Key != System.Windows.Input.Key.Enter) { return; } e.Handled = true; Comment.Add(comment_tartalom.Text, 0, Session.ApplicantID); commentLoader(megjegyzes_listBox); textbox.Text = ""; }
public IHttpActionResult Create(decimal id_post, Comment comment) { comment.ID_POST = id_post; comment.Add(db); return(Created("", new { content = comment.CONTENT, approved_at = comment.APPROVED_AT, id_post = comment.ID_POST, id_user = comment.ID_USER } )); }
public void GetCommentData(BookingReceipt booking) { if (booking.Comment != null || booking.Star != null) { var data = new CommentModel { VehicleID = booking.VehicleID, VehicleName = booking.VehicleName, UserName = booking.AspNetUser.UserName, UserAvatarUrl = booking.AspNetUser.AvatarURL, Star = booking.Star }; Comment.Add(data); } }
public LacesResponse AddComment(AddCommentRequest request) { LacesResponse response = new LacesResponse(); try { if (request.SecurityString == ConfigurationManager.AppSettings[Constants.APP_SETTING_SECURITY_TOKEN]) { Comment comment = new Comment(); // Confirm user and product exist LacesDataModel.User.User user = new LacesDataModel.User.User(request.UserId); LacesDataModel.Product.Product product = new LacesDataModel.Product.Product(request.ProductId); comment.CreatedDate = DateTime.Now; comment.ProductId = product.ProductId; comment.Text = request.Text; comment.UpdatedDate = DateTime.Now; comment.UserId = user.UserId; if (comment.Add()) { response.Success = true; response.Message = "Comment added succesfully."; } else { response.Success = false; response.Message = "An error occurred when communicating with the database."; } } else { response.Success = false; response.Message = "Invalid security token."; } } catch { response = new LacesResponse(); response.Success = false; response.Message = "An unexpected error has occurred; please verify the format of your request."; } return(response); }
protected void BtnSubmit_Click(object sender, EventArgs e) { CommentInfo commentInfo = new CommentInfo(); commentInfo.GeneralId = BasePage.RequestInt32("ID"); commentInfo.TopicId = 1; commentInfo.NodeId = 0; commentInfo.CommentTitle = StringHelper.RemoveXss(this.TxtCommentTitle.Text); commentInfo.Content = StringHelper.RemoveXss(this.TxtCommentRestore.Text); commentInfo.UpdateDateTime = DateTime.Now; commentInfo.Score = this.ScoreControl.Score; commentInfo.Position = DataConverter.CLng(this.RadlPosition.SelectedValue); commentInfo.Status = true; commentInfo.IP = PEContext.Current.UserHostAddress; if (this.ChkIsPrivate.Checked) { commentInfo.IsPrivate = true; } else { commentInfo.IsPrivate = false; } if (!string.IsNullOrEmpty(PEContext.Current.User.UserName)) { commentInfo.UserName = PEContext.Current.User.UserName; commentInfo.ReplyUserName = this.TxtUserName.Text; } else { commentInfo.UserName = "******"; commentInfo.ReplyUserName = this.TxtUserName.Text; } commentInfo.Face = ""; if (Comment.Add(commentInfo)) { DynamicPage.WriteSuccessMsg("<li>添加评论成功!</li>", base.BasePath + "Item/" + BasePage.RequestInt32("ID").ToString() + ".aspx"); } else { DynamicPage.WriteErrMsg("<li>添加评论失败,请返回!</li>"); } }
public string AddComment(Comment value) { try { value.DateAdded = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); value.Add(); return("success"); } catch (Exception ex) { var resp = new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { ReasonPhrase = ex.Message }; throw new HttpResponseException(resp); } }
protected void BtnSubmit_Click(object sender, EventArgs e) { CommentInfo commentInfo = new CommentInfo(); commentInfo.CommentTitle = this.TxtCommentTitle.Text.Trim(); commentInfo.GeneralId = BasePage.RequestInt32("GeneralId"); commentInfo.TopicId = 1; commentInfo.NodeId = 0; commentInfo.Content = this.TxtCommentRestore.Text; commentInfo.UpdateDateTime = DateTime.Now; commentInfo.Score = this.ScoreControl.Score; commentInfo.Position = DataConverter.CLng(this.RadlPosition.SelectedValue); commentInfo.Status = true; commentInfo.IP = PEContext.Current.UserHostAddress; if (this.ChkIsPrivate.Checked) { commentInfo.IsPrivate = true; } else { commentInfo.IsPrivate = false; } if (!string.IsNullOrEmpty(PEContext.Current.Admin.UserName)) { commentInfo.UserName = PEContext.Current.Admin.UserName; } else { commentInfo.UserName = "******"; } commentInfo.Face = ""; if (Comment.Add(commentInfo)) { AdminPage.WriteSuccessMsg("<li>添加评论成功!</li>", "ContentView.aspx?GeneralId=" + BasePage.RequestInt32("GeneralId").ToString()); } else { AdminPage.WriteErrMsg("<li>添加评论失败,请返回!</li>"); } }
private void AddComment(XmlDocument xmlDoc) { CommentInfo commentInfo = new CommentInfo(); commentInfo.CommentTitle = GetNodeInnerText(xmlDoc, "//commenttitle"); if (!HttpContext.Current.User.Identity.IsAuthenticated) { commentInfo.UserName = "******"; } else { commentInfo.UserName = PEContext.Current.User.UserName; } commentInfo.Content = GetNodeInnerText(xmlDoc, "//content"); commentInfo.Email = GetNodeInnerText(xmlDoc, "//email"); commentInfo.Face = GetNodeInnerText(xmlDoc, "//face"); commentInfo.GeneralId = DataConverter.CLng(GetNodeInnerText(xmlDoc, "//gid")); commentInfo.NodeId = DataConverter.CLng(GetNodeInnerText(xmlDoc, "//nid")); commentInfo.TopicId = DataConverter.CLng(GetNodeInnerText(xmlDoc, "//tid")); commentInfo.IsPrivate = DataConverter.CBoolean(GetNodeInnerText(xmlDoc, "//private", "true")); commentInfo.Position = DataConverter.CLng(GetNodeInnerText(xmlDoc, "//position")); commentInfo.Score = DataConverter.CLng(GetNodeInnerText(xmlDoc, "//score", "3")); commentInfo.IP = this.GetClientIP(); commentInfo.UpdateDateTime = DateTime.Now.ToLocalTime(); commentInfo.ReplyUserName = GetNodeInnerText(xmlDoc, "//username", "游客"); int num = string.Compare(commentInfo.UserName, "游客", StringComparison.OrdinalIgnoreCase); string str = ""; NodeInfo cacheNodeById = Nodes.GetCacheNodeById(ContentManage.GetCommonModelInfoById(commentInfo.GeneralId).NodeId); commentInfo.Status = cacheNodeById.Settings.CommentNeedCheck; UserPurviewInfo userPurview = null; if (num != 0) { userPurview = PEContext.Current.User.UserInfo.UserPurview; if (userPurview.CommentNeedCheck) { commentInfo.Status = true; } else { commentInfo.Status = !cacheNodeById.Settings.CommentNeedCheck; } } else if (!cacheNodeById.Settings.EnableTouristsComment) { str = "noTourists"; } else { commentInfo.Status = !cacheNodeById.Settings.CommentNeedCheck; } bool enableComment = false; bool commentNeedCheck = false; if (userPurview != null) { enableComment = userPurview.EnableComment; commentNeedCheck = userPurview.CommentNeedCheck; } if (string.IsNullOrEmpty(str)) { if (cacheNodeById.Settings.EnableComment || enableComment) { if (Comment.Add(commentInfo)) { if (commentInfo.Status || commentNeedCheck) { str = "ok"; } else { str = "check"; } } else { str = "err"; } } else { str = "nopurview"; } } this.XmlResponseWriter.WriteElementString("status", str); }
protected void BtnSubmit_Click(object sender, EventArgs e) { int num = BasePage.RequestInt32("NodeId"); if (num < 1) { DynamicPage.WriteErrMsg("<li>请选择隶属栏目!</li>"); } CommentInfo commentInfo = new CommentInfo(); if (!HttpContext.Current.User.Identity.IsAuthenticated) { commentInfo.UserName = "******"; } else { commentInfo.UserName = PEContext.Current.User.UserName; } commentInfo.GeneralId = BasePage.RequestInt32("ID"); commentInfo.TopicId = 1; commentInfo.NodeId = num; commentInfo.CommentTitle = StringHelper.RemoveXss(this.TxtCommentTitle.Text); commentInfo.Content = StringHelper.RemoveXss(this.TxtCommentRestore.Text); commentInfo.UpdateDateTime = DateTime.Now; commentInfo.Score = DataConverter.CLng(this.RadlScore.SelectedValue); commentInfo.Position = DataConverter.CLng(this.RadlPosition.SelectedValue); commentInfo.IP = PEContext.Current.UserHostAddress; commentInfo.IsPrivate = this.ChkIsPrivate.Checked; int num2 = string.Compare(commentInfo.UserName, "游客", StringComparison.CurrentCultureIgnoreCase); CommonModelInfo commonModelInfoById = ContentManage.GetCommonModelInfoById(commentInfo.GeneralId); if (commonModelInfoById.IsNull) { DynamicPage.WriteErrMsg("<li>评论不存在,请检查评论是否被删除!</li>"); } NodeInfo cacheNodeById = Nodes.GetCacheNodeById(commonModelInfoById.NodeId); if (cacheNodeById.IsNull) { DynamicPage.WriteErrMsg("<li>栏目不存在,请检查栏目!</li>"); } commentInfo.Status = cacheNodeById.Settings.CommentNeedCheck; UserPurviewInfo userPurview = null; if (num2 != 0) { userPurview = PEContext.Current.User.UserInfo.UserPurview; if (userPurview.CommentNeedCheck) { commentInfo.Status = true; } else { commentInfo.Status = !cacheNodeById.Settings.CommentNeedCheck; } } else if (!cacheNodeById.Settings.EnableTouristsComment) { DynamicPage.WriteErrMsg("<li>此栏目已禁止游客发表评论!</li>"); } else { commentInfo.Status = !cacheNodeById.Settings.CommentNeedCheck; } bool enableComment = false; bool commentNeedCheck = false; if (userPurview != null) { enableComment = userPurview.EnableComment; commentNeedCheck = userPurview.CommentNeedCheck; } if (cacheNodeById.Settings.EnableComment || enableComment) { if (Comment.Add(commentInfo)) { string returnurl = "../Item/" + BasePage.RequestInt32("ID").ToString() + ".aspx"; if (commentInfo.Status || commentNeedCheck) { DynamicPage.WriteSuccessMsg("<li>添加评论成功!</li>", returnurl); } else { DynamicPage.WriteSuccessMsg("<li>发表评论成功,请等待管理员审核。</li>", returnurl); } } else { DynamicPage.WriteErrMsg("<li>添加评论失败,请返回!</li>"); } } else { DynamicPage.WriteErrMsg("<li>此栏目已禁止发表评论!</li>"); } }
protected override async void OnAppearing() { Url = "http://192.168.1.111:8081/etm_log/api/project/log/" + posts.LogId + "/remark"; String content = await _client.GetStringAsync(Url); //Sends a GET request to the specified Uri and returns the response body as a string in an asynchronous operation CommentPost commentPosts = JsonConvert.DeserializeObject <CommentPost>(content); //Deserializes or converts JSON String into a collection of Post Comment.Clear(); Attachment.Clear(); CommentDetail.Clear(); AttachmentDetail.Clear(); for (int i = 0; i < commentPosts.returnValue.Count; i++) { Comment.Add(new TextCell { Text = commentPosts.returnValue[i].title, Detail = commentPosts.returnValue[i].remark }); CommentDetail.Add(new TextCell { Text = commentPosts.returnValue[i].title, Detail = commentPosts.returnValue[i].remark }); } ; CommentSwitch = new SwitchCell(); CommentSwitch.OnChanged += addComment_Clicked; CommentSwitch.Text = "Add Comment"; Comment.Add(CommentSwitch); CommentSwitchDetail = new SwitchCell(); CommentSwitchDetail.OnChanged += addComment_Clicked; CommentSwitchDetail.Text = "Add Comment"; CommentDetail.Add(CommentSwitchDetail); AttachmentSwitch = new SwitchCell(); AttachmentSwitch.OnChanged += attachmentManagement_Clicked; AttachmentSwitch.Text = "Attachment Download"; Attachment.Add(AttachmentSwitch); AttachmentSwitchDetail = new SwitchCell(); AttachmentSwitchDetail.OnChanged += attachmentManagement_Clicked; AttachmentSwitchDetail.Text = "Attachment Download"; AttachmentDetail.Add(AttachmentSwitchDetail); _LogNo.Text = posts.LogId; LogNo.Text = posts.LogId; _LogTitle.Text = posts.Title; LogTitle.Text = posts.Title; _Priority.Text = posts.codePriority; Priority.Text = posts.codePriority; _AssignTo.Text = posts.codeUserAction; AssignTo.Text = posts.codeUserAction; _Status.Text = posts.Status; Status.Text = posts.Status; ParentLog.Text = posts.parentIdLog; Organization.Text = posts.codeOrg; Project.Text = posts.codeProject; Ver.Text = posts.versionNo; FunctionCode.Text = posts.codeFunc; IssuedBy.Text = posts.codeUserIssued; IssuedDate.Text = posts.issueDate; LogType.Text = posts.codeLogType; LogEnvironment.Text = posts.codeEnvironment; IncidentType.Text = posts.codeIncidentType; UserRef.Text = posts.userLogRef; base.OnAppearing(); }