public void Insert() { if (udc.UserID == Constants.ANONYMOUS_USERID.ToGuid()) { throw new Exception("Access rights missing"); } if (State == ObjectState.Changed) { if (Text.Length == 0) { throw new MissingFieldException("Text is missing"); } else { Text = FilterEngine.FilterStringBadWords(Text, _4screen.CSB.DataAccess.Data.FilterObjectTypes.Comment, ObjectID.Value, udc.UserID); } if (!ObjectID.HasValue) { throw new MissingFieldException("ObjectID is missing"); } Data.Comment objData = new Data.Comment(); id = objData.Insert(ObjectID.Value, Text, udc.UserID); if (ID.HasValue) { enuState = ObjectState.Saved; Event.ReportEvent(EventIdentifier.Comment, udc.UserID, ObjectID); Business.UserActivities.InsertComment(udc, ObjectID.Value); } } }
public void Insert() { if (State == ObjectState.Changed) { if (Text.Length == 0) { throw new MissingFieldException("Text is missing"); } else { Text = FilterEngine.FilterStringBadWords(Text, _4screen.CSB.DataAccess.Data.FilterObjectTypes.Comment, ObjectID.Value, udc.UserID); } if (!ObjectID.HasValue) { throw new MissingFieldException("ObjectID is missing"); } Data.Comment objData = new Data.Comment(); id = objData.Insert(ObjectID.Value, Text, udc.UserID, BenutzeName, Email, Nickname, IpAddress, IsAnonymous); if (ID.HasValue) { enuState = ObjectState.Saved; Event.ReportEvent(EventIdentifier.Comment, udc.UserID, ObjectID); Business.UserActivities.InsertComment(udc, ObjectID.Value); } } }
public Comment(Data.Comment source) { this.ID = source.ID; this.Created = source.Created; this.Author = source.Author; this.Content = source.Content; }
public override IAnswer HandleDELETE() { Guid id = Data.Get.GetGuid("id"); Data.Comment comment = DB.Controller.DeleteComment(Server.DBSession, id); return(new CJE.Http.RequestAnswer.Json(comment)); }
public override IAnswer HandlePOST() { Form.Comment inputData = new Form.Comment(Data.Post.Input); Data.Comment inputMessage = inputData.ToData(); Data.Comment comment = DB.Controller.SaveComment(Server.DBSession, inputMessage); return(new CJE.Http.RequestAnswer.Json(comment)); }
public async Task <ActionResult <bool> > Save([FromBody] VMs.Comment comment) { try { var ticketUserID = -1; var tickerUser = await context.TicketUsers .Where(x => x.RowStatus == Base.enRowStatus.Active && x.TicketId == comment.TicketId && x.UserId == comment.User.Id) .FirstOrDefaultAsync(); if (tickerUser != null) { ticketUserID = tickerUser.Id; } else { // TICKET USER ticketUserID = context.TicketUsers .Max(x => x.Id); var ticketUser = new TicketUser { Id = ++ticketUserID, UserId = comment.User.Id, TicketId = comment.TicketId, RowStatus = Base.enRowStatus.Active, RowDate = DateTime.Now }; context.TicketUsers.Add(ticketUser); await context.SaveChangesAsync(); } // COMMENT var commentId = context.Comments .Max(x => x.Id); var dataComment = new Data.Comment { Id = ++commentId, Comments = comment.Description, TicketUserId = ticketUserID, RowStatus = Base.enRowStatus.Active, RowDate = DateTime.Now, }; context.Comments.Add(dataComment); await context.SaveChangesAsync(); return(OkResponse(true)); } catch (Exception ex) { return(BadRequestResponse(ex)); } finally { context.Dispose(); } }
public override IAnswer HandleGET() { Guid id = Data.Get.GetGuid("id"); if (id != Guid.Empty) { Data.Comment message = DB.Controller.LoadComment(Server.DBSession, id); return(new CJE.Http.RequestAnswer.Data(message)); } return(null); }
public JsonResult Add(string text, int feedId) { var comment = new Data.Comment(); comment.FeedID = feedId; comment.Text = text; _entities.Comments.Add(comment); _entities.SaveChanges(); return this.Json(true); }
public JsonResult Add(string text, int feedId) { var comment = new Data.Comment(); comment.FeedID = feedId; comment.Text = text; _entities.Comments.Add(comment); _entities.SaveChanges(); return(this.Json(true)); }
public Envelope <Comment> NewComment(string slug, [FromBody] Envelope <NewComment> comment) { EnsureModelValid(); var dbArticleId = _dbContext.Articles.AsNoTracking() .Where(x => x.Slug == slug) .Select(x => x.Id) .FirstOrDefault(); var dbUser = _dbContext.Users.AsNoTracking() .Where(x => x.Username == Username) .FirstOrDefault(); if (dbArticleId == 0 || dbUser == null) { throw NotFoundException(); } var dbComment = new Data.Comment { ArticleId = dbArticleId, AuthorId = dbUser.Id, Body = comment.Content.Body, CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow }; _dbContext.Comments.Add(dbComment); _dbContext.SaveChanges(); return(new Envelope <Comment> { EnvelopePropertyName = "comment", Content = new Comment { Author = new Profile { Bio = dbUser.Bio, Following = false, Image = dbUser.Image, Username = dbUser.Username }, Body = dbComment.Body, CreatedAt = dbComment.CreatedAt, Id = dbComment.CommentId, UpdatedAt = dbComment.UpdatedAt } }); }
/// <summary> /// 给工作项添加审批意见 /// </summary> /// <param name="item">工作项</param> /// <param name="approval">审批结果</param> /// <param name="commentText">审批意见</param> private void AppendComment(OThinker.H3.Instance.InstanceContext Instance, OThinker.H3.WorkItem.WorkItem item, OThinker.Data.BoolMatchValue approval, string commentText) { // 添加一个审批意见 WorkflowTemplate.PublishedWorkflowTemplate workflow = this.Engine.WorkflowManager.GetPublishedTemplate( item.WorkflowCode, item.WorkflowVersion); // 审批字段 string approvalDataItem = null; if (workflow != null) { OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(item.WorkflowCode); approvalDataItem = workflow.GetDefaultCommentDataItem(schema, item.ActivityCode); } if (approvalDataItem != null) { // 创建审批 OThinker.H3.Data.Comment comment = new Data.Comment(); comment.Activity = item.ActivityCode; comment.Approval = approval; comment.CreatedTime = System.DateTime.Now; comment.DataField = approvalDataItem; comment.InstanceId = item.InstanceId; comment.BizObjectId = Instance.BizObjectId; comment.BizObjectSchemaCode = Instance.BizObjectSchemaCode; comment.OUName = this.Engine.Organization.GetName(this.Engine.Organization.GetParent(item.Participant)); comment.Text = commentText; comment.TokenId = item.TokenId; comment.UserID = item.Participant; comment.UserName = item.ParticipantName; // 设置用户的默认签章 Organization.Signature[] signs = this.Engine.Organization.GetSignaturesByUnit(item.Participant); if (signs != null && signs.Length > 0) { foreach (Organization.Signature sign in signs) { if (sign.IsDefault) { comment.SignatureId = sign.ObjectID; break; } } } this.Engine.BizObjectManager.AddComment(comment); } }
public JsonResult AddComment(int areaId, int entityId, AddComment_Post_Req model) { var commentToAdd = new Data.Comment() { AreaId = areaId, EntityId = entityId, IsActive = true, Text = model.Comment.Text }; var userToAddCommentTo = new Data.User() { FBId = model.Comment.User.FBId, VKId = model.Comment.User.VKId, FirstName = model.Comment.User.FirstName, LastName = model.Comment.User.LastName, Thumbnail = model.Comment.User.Thumbnail }; CommentsService.Add(commentToAdd, userToAddCommentTo); return Json(string.Empty); }
public static Data.Comment SaveComment(IDBSession dbs, Data.Comment comment) { using (NHibernate.ITransaction transaction = dbs.Session.BeginTransaction()) { DB.Comment dbComment = null; if (comment.ID != Guid.Empty) { dbComment = dbs.Session.Get <DB.Comment>(comment.ID); } if (dbComment == null) { dbComment = new DB.Comment(comment); dbComment.Created = DateTime.UtcNow; } else { dbComment.Author = comment.Author; dbComment.Content = comment.Content; } DB.Message dbMessage = dbs.Session.QueryOver <DB.Message>().Fetch(x => x.Comments).Eager.Where(x => x.ID == comment.MessageID).SingleOrDefault <DB.Message>(); if (dbMessage != null) { dbMessage.Comments.Add(dbComment); dbs.Session.SaveOrUpdate(dbMessage); transaction.Commit(); comment = dbComment.ToData(false); } else { dbs.Session.SaveOrUpdate(dbComment); transaction.Commit(); comment = dbComment.ToData(false); } } return(comment); }
private async Task <VMs.Comment> ConvertVMComment(Data.Comment comment) { VMs.Comment result = new VMs.Comment(); try { result.Id = comment.Id; result.Description = comment.Comments; using (var user = new UserController(context)) { TicketUser ticketUserId = await context.TicketUsers .Where(x => x.RowStatus == Base.enRowStatus.Active && x.Id == comment.TicketUserId) .FirstOrDefaultAsync(); result.TicketId = ticketUserId.TicketId; result.User = await user.GetUserData(ticketUserId.UserId); } return(result); } catch (Exception ex) { throw ex; } finally { context.Dispose(); } }
private void AppendComment(WorkItem.WorkItem Item, OThinker.Data.BoolMatchValue Approval, string Comment) { WorkflowTemplate.PublishedWorkflowTemplate workflow = GetWorkflowTemplate(Item.WorkflowCode, Item.WorkflowVersion); // 审批字段 string approvalDataItem = null; if (workflow != null) { PublishedWorkflowTemplate workflowTemplate = this.Engine.WorkflowManager.GetPublishedTemplate(Item.WorkflowCode, Item.WorkflowVersion); OThinker.H3.DataModel.BizObjectSchema schema = GetSchema(workflowTemplate.BizObjectSchemaCode); approvalDataItem = workflow.GetDefaultCommentDataItem(schema, Item.ActivityCode); } if (approvalDataItem != null) { // 创建审批 //TODO:此处待修改,Item.BizObjectId不存在,通过 OT_InstanceContext获取 Instance.InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(Item.InstanceId); string BizObjectId = InstanceContext == null ? string.Empty : InstanceContext.BizObjectId; Data.Comment comment = new Data.Comment(); comment.Activity = Item.ActivityCode; comment.Approval = Approval; comment.CreatedTime = System.DateTime.Now; comment.DataField = approvalDataItem; comment.InstanceId = Item.InstanceId; comment.OUName = this.Engine.Organization.GetName(this.Engine.Organization.GetParent(Item.Participant)); comment.Text = Comment; comment.TokenId = Item.TokenId; comment.UserID = Item.Participant; comment.UserName = Item.ParticipantName; //comment.BizObjectId = Item.BizObjectId; comment.BizObjectId = BizObjectId; comment.BizObjectSchemaCode = Item.WorkflowCode; this.Engine.BizObjectManager.AddComment(comment); } }
public static Data.Comment LoadComment(IDBSession dbs, Guid id) { DB.Comment dbComment = dbs.Session.Get <DB.Comment>(id); Data.Comment comment = dbComment?.ToData(false); return(comment); }