public ActionResult Reply(int idProduct, string content, int idParent) { int id = UserHelper.GetUserByUserID(HttpContext.User.Identity.Name).ID; CommentHelper.AddComment(idProduct, id, content, idParent); return(Redirect("/Product/Detail/" + idProduct.ToString() + "#newComment")); }
private void CouponComment() { int cid = GetInt("couponid"); int uid = GetInt("uid"); string msg = GetString("message"); var coupon = CouponHelper.GetItem(cid); Comment c = new Comment(); c.SellerId = coupon.SellerId; c.TypeId = coupon.Id; c.UserId = uid; c.Content = msg; c.Type = CommentType.Coupons; //冗余两个字段 c.Img = coupon.ImgUrl; c.Title = coupon.Title; try { CommentHelper.Create(c); coupon.Commentnum += 1; CouponHelper.Update(coupon); } catch { ReturnErrorMsg("fail"); throw; } JsonTransfer jt = new JsonTransfer(); jt.AddSuccessParam(); Response.Write(DesEncrypt(jt).ToLower()); Response.End(); }
public List <Dictionary <string, object> > DisplayByTime() { mListOfCommentsByTime = new List <Dictionary <string, object> >(); mFirebaseHelper.CommentOnLocationRef().OrderByChild(StringValues.TIME_STAMP) .ValueChanged += (object sender, ValueChangedEventArgs args) => { if (args.DatabaseError != null) { Debug.LogError("Databse Error"); } else { if (args.Snapshot != null && args.Snapshot.ChildrenCount > 0) { foreach (var childSnapshot in args.Snapshot.Children) { mCommentHelper = new CommentHelper( childSnapshot.Child(StringValues.USER_NAME).Value.ToString(), childSnapshot.Child(StringValues.COMMENT).Value.ToString(), childSnapshot.Child(StringValues.TIME_STAMP).Value.ToString(), childSnapshot.Child(StringValues.LIKES).Value.ToString()); mListOfCommentsByTime.Add(mCommentHelper.CommentRS()); } } } }; Debug.Log("Displayed By Time"); return(mListOfCommentsByTime); }
/// <summary> /// Adds documentation header async. /// </summary> /// <param name="document">The document.</param> /// <param name="root">The root.</param> /// <param name="declarationSyntax">The declaration syntax.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>A Document.</returns> private async Task <Document> AddDocumentationHeaderAsync(Document document, SyntaxNode root, PropertyDeclarationSyntax declarationSyntax, CancellationToken cancellationToken) { SyntaxTriviaList leadingTrivia = declarationSyntax.GetLeadingTrivia(); bool isBoolean = false; if (declarationSyntax.Type is PredefinedTypeSyntax) { isBoolean = ((PredefinedTypeSyntax)declarationSyntax.Type).Keyword.Kind() == SyntaxKind.BoolKeyword; } bool hasSetter = false; if (declarationSyntax.AccessorList != null && declarationSyntax.AccessorList.Accessors.Any(o => o.Kind() == SyntaxKind.SetAccessorDeclaration)) { hasSetter = true; } string propertyComment = CommentHelper.CreatePropertyComment(declarationSyntax.Identifier.ValueText, isBoolean, hasSetter); DocumentationCommentTriviaSyntax commentTrivia = await Task.Run(() => DocumentationHeaderHelper.CreateOnlySummaryDocumentationCommentTrivia(propertyComment), cancellationToken); SyntaxTriviaList newLeadingTrivia = leadingTrivia.Insert(leadingTrivia.Count - 1, SyntaxFactory.Trivia(commentTrivia)); PropertyDeclarationSyntax newDeclaration = declarationSyntax.WithLeadingTrivia(newLeadingTrivia); SyntaxNode newRoot = root.ReplaceNode(declarationSyntax, newDeclaration); return(document.WithSyntaxRoot(newRoot)); }
/// <summary> /// Measures a cell created with this frame. /// </summary> /// <param name="measureContext">The context used to measure the cell.</param> /// <param name="cellView">The cell to measure.</param> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> /// <param name="size">The cell size upon return, padding included.</param> /// <param name="padding">The cell padding.</param> public virtual void Measure(ILayoutMeasureContext measureContext, ILayoutCellView cellView, ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength, out Size size, out Padding padding) { padding = Padding.Empty; ILayoutCommentCellView CommentCellView = cellView as ILayoutCommentCellView; Debug.Assert(CommentCellView != null); string Text = CommentHelper.Get(CommentCellView.Documentation); CommentDisplayModes DisplayMode = cellView.StateView.ControllerView.CommentDisplayMode; Debug.Assert(DisplayMode == CommentDisplayModes.OnFocus || DisplayMode == CommentDisplayModes.All); bool IsFocused = cellView.StateView.ControllerView.Focus.CellView == cellView; if (IsFocused && Text == null) { Text = string.Empty; } bool IsDisplayed = Text != null && ((DisplayMode == CommentDisplayModes.OnFocus && IsFocused) || DisplayMode == CommentDisplayModes.All); if (IsDisplayed) { size = measureContext.MeasureText(Text, TextStyles.Comment, Controller.Measure.Floating); } else { size = Size.Empty; } Debug.Assert(RegionHelper.IsValid(size)); }
public ActionResult UpdateComment(string commentId, CommentStatus status = CommentStatus.Disable) { var pageCommentStore = CommentHelper.GetCommentStoreName(); var id = EPiServer.Data.Identity.NewIdentity(new Guid(commentId)); var comment = CommentHelper.GetCommentById(pageCommentStore, id); if (comment != null) { if (status == CommentStatus.Enable || status == CommentStatus.Disable) { comment.IsDeleted = status == CommentStatus.Disable ? true : false; CommentHelper.UpdateComment(pageCommentStore, comment); } else { CommentHelper.Delete(pageCommentStore, id); } } else { return(Json(new { status = "error", message = "Not found" }, JsonRequestBehavior.AllowGet)); } return(Json(new { status = "ok", pageId = comment.PageId }, JsonRequestBehavior.AllowGet)); }
public void GetList() { int sellerid = GetInt("sellerid"); int start = GetInt("start"); int limit = GetInt("limit"); var result = CommentHelper.GetPagings(sellerid, CommentType.All, 0, start * limit, limit); var data = new PagResults <object>(); foreach (var item in result.Results) { var user = AccountHelper.GetUser(item.UserId); var feedbackStauts = item.Feedback != null && item.Feedback.Length > 0; var o = new { Id = item.Id, Title = item.Title, Content = item.Content, Feedback = item.Feedback, FeedbackStatus = feedbackStauts ? "已回复" : "未回复", CreateTime = item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), Type = EnumHelper.CommentTypeToName(item.Type), UserId = item.UserId, UserName = user.UserName, NickName = user.NickName }; data.Results.Add(o); } data.TotalCount = result.TotalCount; JsonTransfer jt = new JsonTransfer(); jt.AddSuccessParam(); jt.Add("data", data); Response.Write(DesEncrypt(jt).ToLower()); Response.End(); }
private void CutOrDelete(IDataObject dataObject, out bool isDeleted) { isDeleted = false; string Content = CommentHelper.Get(StateView.State.Node.Documentation); Debug.Assert(Content != null); Debug.Assert(Start <= End); Debug.Assert(End <= Content.Length); if (Start < End) { if (dataObject != null) { dataObject.SetData(typeof(string), Content.Substring(Start, End - Start)); } Content = Content.Substring(0, Start) + Content.Substring(End); FocusController Controller = StateView.ControllerView.Controller; int OldCaretPosition = StateView.ControllerView.CaretPosition; int NewCaretPosition = Start; Controller.ChangeCommentAndCaretPosition(StateView.State.ParentIndex, Content, OldCaretPosition, NewCaretPosition, true); StateView.ControllerView.ClearSelection(); isDeleted = true; } }
/// <summary> /// Analyzes node. /// </summary> /// <param name="context">The context.</param> private static void AnalyzeNode(SyntaxNodeAnalysisContext context) { FieldDeclarationSyntax node = context.Node as FieldDeclarationSyntax; // Only const field. if (!node.Modifiers.Any(SyntaxKind.ConstKeyword)) { return; } if (Configuration.IsEnabledForPublicMembersOnly && PrivateMemberChecker.IsPrivateMember(node)) { return; } DocumentationCommentTriviaSyntax commentTriviaSyntax = node .GetLeadingTrivia() .Select(o => o.GetStructure()) .OfType <DocumentationCommentTriviaSyntax>() .FirstOrDefault(); if (commentTriviaSyntax != null && CommentHelper.HasComment(commentTriviaSyntax)) { return; } VariableDeclaratorSyntax field = node.DescendantNodes().OfType <VariableDeclaratorSyntax>().First(); context.ReportDiagnostic(Diagnostic.Create(Rule, field.GetLocation())); }
private protected virtual string GetFocusedCommentText(IFocusCommentFocus commentFocus) { IFocusCommentCellView CellView = commentFocus.CellView; Document Documentation = CellView.StateView.State.Node.Documentation; return(CommentHelper.Get(Documentation)); }
//===================================================================================== // TODO - do spans always start on new lines? If not, we'll need an IsOpenLineComment private bool IsOpenBlockComment(NormalizedSnapshotSpanCollection sc) // are we starting with prior text that is already an opening comment block? { // return false; VerilogGlobals.PerfMon.VerilogTokenTagger_IsOpenBlockComment_Count++; bool isLocalBlockComment = false; // we'll assume there's no open block comment unless otherwise found bool isLocalLineComment = false; if (sc != null && sc[0].Snapshot != null && sc[0].Start.Position > 0) { int ToPosition = sc[0].Start.Position - 1; // we are only interested in text priot to our current location // SnapshotSpan PriorText = sc[0].Snapshot(0, ToPosition); foreach (ITextSnapshotLine thisLine in sc[0].Snapshot.Lines) { int pos = thisLine.Start.Position; if (pos > ToPosition) { break; // nothing to do if the starting position is beyond our starting point, as we are only interested in prior open block } CommentHelper commentHelper = new CommentHelper(thisLine.GetText(), isLocalLineComment, isLocalBlockComment); // we are starting at the beginning of a string, so there's of course no prior "//" continued line comment isLocalBlockComment = commentHelper.HasBlockStartComment; isLocalLineComment = false; // we are sending entire lines here, so we are never worried about continued line comments previously starting with "//" } // for each thisLine } // if sc is not blank return(isLocalBlockComment); }
/// <summary> /// Parses the specified notification element. /// </summary> /// <param name = "notificationElement">The notification element.</param> /// <returns></returns> public ConstantEntity Parse(TypedEntity typedEntity, XElement notificationElement) { ConstantEntity notificationEntity = new ConstantEntity(); notificationEntity.Type = "NSString"; // Get the name notificationEntity.Name = notificationElement.TrimAll(); this.Logger.WriteLine(" Notification '" + notificationEntity.Name + "'"); // Get the content and the discussion XElement summaryElement = (from el in notificationElement.ElementsAfterSelf("section") where (String)el.Attribute("class") == "spaceabove" select el).FirstOrDefault(); if (summaryElement != null) { foreach (XElement element in summaryElement.Elements()) { notificationEntity.Summary.Add(element.Value.TrimAll()); } } // Get the availability String minAvailability = (from el in notificationElement.ElementsAfterSelf("div").Elements("ul").Elements("li") where (String)el.Parent.Parent.Attribute("class") == "api availability" select el.Value).FirstOrDefault(); notificationEntity.MinAvailability = CommentHelper.ExtractAvailability(minAvailability.TrimAll()); return(notificationEntity); }
/// <summary> /// Appends the availability paragraph. /// </summary> /// <param name = "indent">The indent.</param> /// <param name = "entity">The entity.</param> protected void AppendAvailability(int indent, BaseEntity entity) { if (!String.IsNullOrEmpty(entity.MinAvailability)) { this.Writer.WriteLineFormat(indent, "/// <para>{0}</para>", CommentHelper.GetAvailability(entity.MinAvailability)); } }
public void TestCommentCurrentLine() { var editorTestToolset = new EditorTestToolset(); var view = editorTestToolset.CreatePythonTextView(@"print 'hello' print 'goodbye' "); editorTestToolset.UIThread.Invoke(() => { view.Caret.MoveTo(view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(0).Start); CommentHelper.CommentOrUncommentBlock(view, true); }); Assert.AreEqual(@"#print 'hello' print 'goodbye' ", view.GetText()); editorTestToolset.UIThread.Invoke(() => { view.Caret.MoveTo(view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1).Start); CommentHelper.CommentOrUncommentBlock(view, true); }); Assert.AreEqual(@"#print 'hello' #print 'goodbye' ", view.GetText()); }
/// <summary> /// 获取文章评论。 /// </summary> /// <param name="articleId">文章 Id。</param> /// <param name="pageIndex">第几页,从 1 开始。</param> /// <param name="pageSize">每页条数。</param> /// <returns>评论列表。</returns> /// <exception cref="ArgumentOutOfRangeException">文章 Id 错误。</exception> /// <exception cref="ArgumentOutOfRangeException">评论页数错误。</exception> /// <exception cref="ArgumentOutOfRangeException">评论条数错误。</exception> public static async Task <IEnumerable <ArticleComment> > CommentAsync(int articleId, int pageIndex, int pageSize) { if (articleId < 1) { throw new ArgumentOutOfRangeException(nameof(articleId)); } if (pageIndex < 1) { throw new ArgumentOutOfRangeException(nameof(pageIndex)); } if (pageSize < 1) { throw new ArgumentOutOfRangeException(nameof(pageSize)); } var url = string.Format(CultureInfo.InvariantCulture, CommentUrlTemplate, articleId, pageIndex, pageSize); url = url.WithCache(); var uri = new Uri(url, UriKind.Absolute); var request = WebRequest.Create(uri); using (var response = await request.GetResponseAsync()) { var document = XDocument.Load(response.GetResponseStream()); var comments = new List <ArticleComment>(CommentHelper.Deserialize <ArticleComment>(document)); for (var i = 0; i < comments.Count; i++) { comments[i].ArticleId = articleId; } return(comments); } }
/// <summary> /// Creates documentation comment trivia syntax. /// </summary> /// <param name="declarationSyntax">The declaration syntax.</param> /// <returns>A DocumentationCommentTriviaSyntax.</returns> private static DocumentationCommentTriviaSyntax CreateDocumentationCommentTriviaSyntax(MethodDeclarationSyntax declarationSyntax) { SyntaxList <SyntaxNode> list = SyntaxFactory.List <SyntaxNode>(); string methodComment = CommentHelper.CreateMethodComment(declarationSyntax.Identifier.ValueText); list = list.AddRange(DocumentationHeaderHelper.CreateSummaryPartNodes(methodComment)); if (declarationSyntax.ParameterList.Parameters.Any()) { foreach (ParameterSyntax parameter in declarationSyntax.ParameterList.Parameters) { string parameterComment = CommentHelper.CreateParameterComment(parameter); list = list.AddRange(DocumentationHeaderHelper.CreateParameterPartNodes(parameter.Identifier.ValueText, parameterComment)); } } string returnType = declarationSyntax.ReturnType.ToString(); if (returnType != "void") { string returnComment = new ReturnCommentConstruction(declarationSyntax.ReturnType).Comment; list = list.AddRange(DocumentationHeaderHelper.CreateReturnPartNodes(returnComment)); } return(SyntaxFactory.DocumentationCommentTrivia(SyntaxKind.SingleLineDocumentationCommentTrivia, list)); }
public ActionResult DeleteComment(int id, int newsPostId, bool detailsMode = true) { CommentHelper.DeleteComment(id, newsPostId); string action = detailsMode ? "Details" : "Preview"; return(RedirectToAction(action, new { id = newsPostId })); }
/// <summary> /// Generate python classes from declaration. /// </summary> public static string Build(TypeDecl decl) { // Determine if we are inside datacentric package // based on module name. This affects the imports // and namespace use. bool insideDc = PyExtensions.GetPackage(decl) == "datacentric"; // If not generating for DataCentric package, use dc. namespace // in front of datacentric types, otherwise use no prefix string dcNamespacePrefix = insideDc ? "" : "dc."; var writer = new CodeWriter(); writer.AppendLine("from abc import ABC"); string keyImport = insideDc ? "from datacentric.storage.key import Key" : "import datacentric as dc"; writer.AppendLine(keyImport); writer.AppendNewLineWithoutIndent(); writer.AppendNewLineWithoutIndent(); writer.AppendLine($"class {decl.Name}Key({dcNamespacePrefix}Key, ABC):"); writer.PushIndent(); writer.AppendLines(CommentHelper.PyComment(decl.Comment)); writer.AppendLine("pass"); writer.PopIndent(); return(writer.ToString()); }
public IActionResult NewComment(CommentHelper Comment) { if (ModelState.IsValid) { Comment newComment = new Comment { CommentContent = Comment.CommentContent, UserId = (int)HttpContext.Session.GetInt32("UserId"), MessageId = Comment.MessageId }; dbContext.Add(newComment); dbContext.SaveChanges(); return(RedirectToAction("Dashboard")); } else { ViewBag.User = dbContext.Users .FirstOrDefault(l => l.UserId == (int)HttpContext.Session.GetInt32("UserId")); ViewBag.Messages = dbContext.Messages .Include(l => l.CreatorOfMessage) .Include(l => l.CommentsPostedOnMessage) .ThenInclude(y => y.CreatorOfCommment) .ToList().OrderByDescending(t => t.CreatedAt); return(View("Dashboard")); } }
/// <summary> /// Create cells for the provided state view. /// </summary> /// <param name="context">Context used to build the cell view tree.</param> /// <param name="parentCellView">The parent cell view.</param> public virtual IFrameCellView BuildNodeCells(IFrameCellViewTreeContext context, IFrameCellViewCollection parentCellView) { IDocument Documentation = context.StateView.State.Node.Documentation; string Text = CommentHelper.Get(Documentation); if (IsDisplayed(context, Text)) { IFrameVisibleCellView CellView = CreateCommentCellView(context.StateView, parentCellView, context.StateView.State.Node.Documentation); ValidateVisibleCellView(context, CellView); if (context.StateView.State is IFrameOptionalNodeState AsOptionalNodeState) { Debug.Assert(AsOptionalNodeState.ParentInner.IsAssigned); } return(CellView); } else { IFrameEmptyCellView CellView = CreateEmptyCellView(context.StateView, parentCellView); ValidateEmptyCellView(context, CellView); return(CellView); } }
/// <summary> /// Generate python enum from declaration. /// </summary> public static string Build(EnumDecl decl) { var writer = new CodeWriter(); writer.AppendLine("from enum import IntEnum"); writer.AppendNewLineWithoutIndent(); writer.AppendNewLineWithoutIndent(); writer.AppendLine($"class {decl.Name}(IntEnum):"); writer.PushIndent(); writer.AppendLines(CommentHelper.PyComment(decl.Comment)); writer.AppendNewLineWithoutIndent(); var items = decl.Items; for (int index = 0; index < items.Count; index++) { EnumItem item = items[index]; writer.AppendLine($"{item.Name} = {index},"); writer.AppendLines(CommentHelper.PyComment(item.Comment)); // Do not add new line after last item if (index != items.Count - 1) { writer.AppendNewLineWithoutIndent(); } } writer.PopIndent(); return(writer.ToString()); }
private PropertyEntity ExtractProperty(PropertyDeclaration propertyDeclaration) { PropertyEntity propertyEntity = new PropertyEntity(); propertyEntity.Name = propertyDeclaration.Name; propertyEntity.Static = (propertyDeclaration.Modifier & Modifiers.Static) == Modifiers.Static; // Get the method's comment IEnumerable <Comment> comments = this.GetDocumentationCommentsBefore(propertyDeclaration); AppendComment(propertyEntity, comments); // Extract getter MethodEntity getterEntity = new MethodEntity(); propertyEntity.Getter = getterEntity; // Extract signature from comments Comment signatureComment = comments.FirstOrDefault(c => CommentHelper.IsSignature(c.CommentText.Trim())); if (signatureComment != null) { getterEntity.Signature = signatureComment.Trim("Original signature is", "'", ";", "private"); } // Extract selector MethodSelectorExtractor extractor = new MethodSelectorExtractor(getterEntity.Signature); getterEntity.Selector = extractor.Extract(); // Parse the signature for return type MethodSignatureEnumerator signatureEnumerator = new MethodSignatureEnumerator(getterEntity.Signature); if (signatureEnumerator.MoveNext()) { bool isOut, isByRef, isBlock; propertyEntity.Type = this.TypeManager.ConvertType(signatureEnumerator.Current.TrimAll(), out isOut, out isByRef, out isBlock, this.Logger); } else { propertyEntity.Type = "Id"; } if (propertyDeclaration.HasSetRegion) { MethodEntity setterEntity = new MethodEntity(); setterEntity.Selector = "MISSING"; MethodParameterEntity methodParameterEntity = new MethodParameterEntity(); methodParameterEntity.Name = "value"; methodParameterEntity.Type = propertyEntity.Type; setterEntity.Parameters.Add(methodParameterEntity); setterEntity.ReturnType = "void"; propertyEntity.Setter = setterEntity; } return(propertyEntity); }
public ActionResult LoadComment(int pageId = 0, CommentStatus status = CommentStatus.Enable) { var pageCommentStore = CommentHelper.GetCommentStoreName(); var condition = CreateCondition(pageId, status); var listComment = CommentHelper.GetCommentByPageCondition(condition); return(PartialView("_ListComment", listComment)); }
/// <summary> /// 上传附件 /// </summary> /// <returns></returns> public JsonResult UploadAttachment() { if (Request.Files == null || Request.Files.Count == 0) { return(Json(new { result = false, Message = "请选择要上传的文件!" }, JsonRequestBehavior.AllowGet)); } HttpPostedFileBase fileData = Request.Files[0]; UploadFileResult resultTemp = new UploadFileResult(); if (fileData != null) { try { int _limitedFileSize = 10000000; int.TryParse(ConfigurationManager.AppSettings["LimitedFileSize"], out _limitedFileSize); if (fileData.ContentLength > _limitedFileSize) { return(Json(new { result = false, Message = "上传的文件过大!" }, JsonRequestBehavior.AllowGet)); } // 文件上传后的保存路径 HttpContext context = System.Web.HttpContext.Current; string savePath = context.Server.MapPath("~"); string filePath = savePath + ConfigurationManager.AppSettings["UploadTmp"]; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fileName = Path.GetFileName(fileData.FileName); // 原始文件名称 string fileExtension = Path.GetExtension(fileName); // 文件扩展名 if (CommentHelper.IsAllowUploadFile(fileExtension)) { string saveName = Guid.NewGuid().ToString() + fileExtension; // TODO 保存文件名称 fileData.SaveAs(filePath + saveName); string baseDirectory = filePath.Substring(filePath.LastIndexOf('\\', filePath.Length - 2)).Trim('\\'); resultTemp.url = "/" + baseDirectory + saveName; //baseDirectory 以 /结尾 resultTemp.saveName = saveName; resultTemp.name = fileName; List <UploadFileResult> array = new List <UploadFileResult>(); array.Add(resultTemp); return(Json(new { result = true, files = array })); } else { return(Json(new { result = false, Message = "上传的文件类型不符合!" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { result = false, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { result = false, Message = "请选择要上传的文件!" }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Force the comment attached to the node with the focus to show, if empty, and move the focus to this comment. /// </summary> public virtual void ForceShowComment(out bool isMoved) { IFocusNodeState State = Focus.CellView.StateView.State; Document Documentation; if (State is IFocusOptionalNodeState AsOptionalNodeState) { Debug.Assert(AsOptionalNodeState.ParentInner.IsAssigned); Documentation = AsOptionalNodeState.Node.Documentation; } else { Documentation = State.Node.Documentation; } isMoved = false; ulong OldFocusHash = FocusHash; if (!(Focus is IFocusCommentFocus)) { string Text = CommentHelper.Get(Documentation); if (Text == null) { IFocusNodeStateView StateView = Focus.CellView.StateView; ForcedCommentStateView = StateView; Refresh(Controller.RootState); Debug.Assert(ForcedCommentStateView == null); for (int i = 0; i < FocusChain.Count; i++) { if (FocusChain[i] is IFocusCommentFocus AsCommentFocus && AsCommentFocus.CellView.StateView == StateView) { int OldFocusIndex = FocusChain.IndexOf(Focus); Debug.Assert(OldFocusIndex >= 0); // The old focus must have been preserved. int NewFocusIndex = i; ChangeFocus(NewFocusIndex - OldFocusIndex, OldFocusIndex, NewFocusIndex, true, out bool IsRefreshed); Debug.Assert(!IsRefreshed); // Refresh must not be done twice. isMoved = true; break; } } Debug.Assert(isMoved); } } if (isMoved) { ResetSelection(); } Debug.Assert(isMoved || OldFocusHash == FocusHash); }
private void Delete() { var ids = Utility.GetListint(GetString("ids")); foreach (var id in ids) { CommentHelper.Delete(id); } }
private void CouponComment() { int cid = GetInt("couponid"); int uid = GetInt("uid"); string msg = GetString("message"); var coupon = CouponHelper.GetItem(cid); Comment c = new Comment(); c.SellerId = coupon.SellerId; c.TypeId = coupon.Id; c.UserId = uid; c.Content = msg; c.Type = CommentType.Coupons; //冗余两个字段 c.Img = coupon.ImgUrl; c.Title = coupon.Title; try { CommentHelper.Create(c); coupon.Commentnum += 1; CouponHelper.Update(coupon); } catch { ReturnErrorMsg("fail"); throw; } var user = AccountHelper.GetUser(uid); ExtcreditLog log = new ExtcreditLog(); if (!ExtcreditLogHelper.JudgeExtcreditGet(ExtcreditSourceType.CommentCoupon, cid, uid)) { //积分获得 log.UserId = uid; log.SellerId = user.SellerId; log.SourceId = cid; var setting = SystemHelper.GetMerchantExtend(user.SellerId); log.Extcredit = setting != null ? setting.CommentIntegral : 0; log.Type = ExtcreditSourceType.CommentCoupon; log.CreateTime = DateTime.Now; ExtcreditLogHelper.AddExtcreditLog(log); user.Integral += log.Extcredit; AccountHelper.SaveAccount(user); } //ReturnCorrectMsg("评论成功"); JsonTransfer jt = new JsonTransfer(); jt.Add("data", new IntegralData(log.Extcredit)); jt.AddSuccessParam(); Response.Write(DesEncrypt(jt).ToLower()); Response.End(); }
private void ActiveComment(HttpContext context) { int aid = GetInt("newid"); int uid = GetInt("uid"); var user = AccountHelper.GetUser(uid); string msg = GetString("message"); var active = ActiveHelper.GetItem(aid); Comment c = new Comment(); c.SellerId = active.SellerId; c.TypeId = active.Id; c.UserId = uid; c.Content = msg; c.Type = CommentType.Avtive; //冗余两个字段 c.Img = active.CoverImgUrl; c.Title = active.Title; try { CommentHelper.Create(c); active.Commentnum += 1; ActiveHelper.Update(active); } catch { ReturnErrorMsg("fail"); throw; } ExtcreditLog log = new ExtcreditLog(); var merchantExtend = SystemHelper.GetMerchantExtend(user.SellerId); if (!ExtcreditLogHelper.JudgeExtcreditGet(ExtcreditSourceType.CommentActive, aid, uid)) { //积分获得 log.UserId = uid; log.SellerId = user.SellerId; log.SourceId = aid; log.Extcredit = merchantExtend != null ? merchantExtend.CommentIntegral : 0; log.Type = ExtcreditSourceType.CommentActive; log.CreateTime = DateTime.Now; ExtcreditLogHelper.AddExtcreditLog(log); user.Integral += log.Extcredit; AccountHelper.SaveAccount(user); } //ReturnCorrectMsg("评论成功"); JsonTransfer jt = new JsonTransfer(); jt.Add("data", new IntegralData(log.Extcredit)); jt.AddSuccessParam(); Response.Write(DesEncrypt(jt).ToLower()); Response.End(); }
public ActionResult CreateComment(CommentCreateModel model) { if (ModelState.IsValid) { var comment = model.ConvertToComment(); comment.Id = CommentHelper.CreateComment(comment); return(PartialView("_Comment", new CommentViewModel(comment))); } return(Json(new { error = CommentHelper.BuildErrorMessage(ModelState) })); }
private void Update() { var id = GetInt("id"); var item = CommentHelper.GetItem(id); item.Title = GetString("title"); item.Content = GetString("content"); item.Feedback = GetString("feedback"); CommentHelper.Update(item); }