/// <summary> /// BarPost转换成<see cref="Lucene.Net.Documents.Document"/> /// </summary> /// <param name="BarPost">回帖实体</param> /// <returns>Lucene.Net.Documents.Document</returns> public static Document Convert(BarPost barPost) { Document doc = new Document(); //索引回帖基本信息 doc.Add(new Field(BarIndexDocument.SectionId, barPost.SectionId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(BarIndexDocument.ThreadId, "0", Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(BarIndexDocument.PostId, barPost.PostId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); //如果回帖没有主题存储其主贴的主题 if (string.IsNullOrEmpty(barPost.Subject)) { string subject = barThreadService.Get(barPostService.Get(barPost.PostId).ThreadId).Subject.ToLower(); doc.Add(new Field(BarIndexDocument.Subject, subject, Field.Store.YES, Field.Index.ANALYZED)); } else { doc.Add(new Field(BarIndexDocument.Subject, barPost.Subject, Field.Store.YES, Field.Index.ANALYZED)); } doc.Add(new Field(BarIndexDocument.Body, HtmlUtility.TrimHtml(barPost.GetBody(), 0).ToLower(), Field.Store.NO, Field.Index.ANALYZED)); doc.Add(new Field(BarIndexDocument.Author, barPost.Author, Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field(BarIndexDocument.IsPost, "1", Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(BarIndexDocument.DateCreated, DateTools.DateToString(barPost.DateCreated, DateTools.Resolution.DAY), Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(BarIndexDocument.TenantTypeId, barPost.TenantTypeId, Field.Store.YES, Field.Index.NOT_ANALYZED)); return(doc); }
/// <summary> /// BarPost转换成<see cref="Lucene.Net.Documents.Document"/> /// </summary> /// <param name="BarPost">回帖实体</param> /// <returns>Lucene.Net.Documents.Document</returns> public static Document Convert(BarPost barPost) { Document doc = new Document(); //索引回帖基本信息 doc.Add(new Field(BarIndexDocument.SectionId, barPost.SectionId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(BarIndexDocument.ThreadId, "0", Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(BarIndexDocument.PostId, barPost.PostId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); //如果回帖没有主题存储其主贴的主题 if (string.IsNullOrEmpty(barPost.Subject)) { string subject = barThreadService.Get(barPostService.Get(barPost.PostId).ThreadId).Subject.ToLower(); doc.Add(new Field(BarIndexDocument.Subject, subject, Field.Store.YES, Field.Index.ANALYZED)); } else { doc.Add(new Field(BarIndexDocument.Subject, barPost.Subject, Field.Store.YES, Field.Index.ANALYZED)); } doc.Add(new Field(BarIndexDocument.Body, HtmlUtility.TrimHtml(barPost.GetBody(), 0).ToLower(), Field.Store.NO, Field.Index.ANALYZED)); doc.Add(new Field(BarIndexDocument.Author, barPost.Author, Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field(BarIndexDocument.IsPost, "1", Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(BarIndexDocument.DateCreated, DateTools.DateToString(barPost.DateCreated, DateTools.Resolution.DAY), Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(BarIndexDocument.TenantTypeId, barPost.TenantTypeId, Field.Store.YES, Field.Index.NOT_ANALYZED)); return doc; }
/// <summary> /// 积分处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void BarPostPointModule_After(BarPost sender, AuditEventArgs eventArgs) { AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); string pointItemKey = string.Empty; string eventOperationType = string.Empty; if (auditDirection == true) //加积分 { pointItemKey = PointItemKeys.Instance().CreateComment(); if (eventArgs.OldAuditStatus == null) eventOperationType = EventOperationType.Instance().Create(); else eventOperationType = EventOperationType.Instance().Approved(); } else if (auditDirection == false) //减积分 { pointItemKey = PointItemKeys.Instance().DeleteComment(); if (eventArgs.NewAuditStatus == null) eventOperationType = EventOperationType.Instance().Delete(); else eventOperationType = EventOperationType.Instance().Disapproved(); } if (!string.IsNullOrEmpty(pointItemKey)) { PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "回帖", HtmlUtility.TrimHtml(sender.GetBody(), 32)); pointService.GenerateByRole(sender.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == sender.UserId); } }
/// <summary> /// 积分处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void BarPostPointModule_After(BarPost sender, AuditEventArgs eventArgs) { AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); string pointItemKey = string.Empty; string eventOperationType = string.Empty; if (auditDirection == true) //加积分 { pointItemKey = PointItemKeys.Instance().CreateComment(); if (eventArgs.OldAuditStatus == null) { eventOperationType = EventOperationType.Instance().Create(); } else { eventOperationType = EventOperationType.Instance().Approved(); } } else if (auditDirection == false) //减积分 { pointItemKey = PointItemKeys.Instance().DeleteComment(); if (eventArgs.NewAuditStatus == null) { eventOperationType = EventOperationType.Instance().Delete(); } else { eventOperationType = EventOperationType.Instance().Disapproved(); } } if (!string.IsNullOrEmpty(pointItemKey)) { PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "回帖", HtmlUtility.TrimHtml(sender.GetBody(), 32)); pointService.GenerateByRole(sender.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == sender.UserId); } }