Exemplo n.º 1
0
        public async Task CreateComment(Comment commentModel)
        {
            //向文章作者发送提示
            var _content = await ContentAccessor.OneAsync <ContentEntry>(x => x.Id == commentModel.ContentEntryId, "ContentEntryInfo");

            if (_content.ContentEntryInfo != null)
            {
                await sandBoxBusiness.SendAlertTo(new SandBoxMessage
                {
                    Content           = $"文章 : <a href='/Forum/PostList?Id={_content.Id}'>{_content.Title}</a> 有新的回复",
                    MessageType       = SandBoxMessageType.PostEntryComment,
                    CreateTime        = DateTime.Now,
                    FromUserAccountId = commentModel.UserAccountId.Value,
                    ToUserAccountId   = _content.ContentEntryInfo.UserAccountId
                });
            }

            //向引用回复作者发送提示
            if (commentModel.ParentComment != null)
            {
                await sandBoxBusiness.SendAlertTo(new SandBoxMessage
                {
                    Content           = $"文章 : <a href='/Forum/PostList?Id={_content.Id}'>{_content.Title}</a> 有新的回复",
                    MessageType       = SandBoxMessageType.PostEntryCommentSubComment,
                    CreateTime        = DateTime.Now,
                    FromUserAccountId = commentModel.UserAccountId.Value,
                    ToUserAccountId   = commentModel.ParentComment.UserAccountId.Value
                });
            }
            await ContentAccessor.Add <Comment>(commentModel);
        }
Exemplo n.º 2
0
        public async Task CreateContentCommentExtPostEntry(Comment comment)
        {
            var contentModel = await ContentAccessor.OneAsync <ContentEntry>(x => x.Id == comment.ContentEntry.Id, "Category");

            var topicTxt = contentModel.Category.Name + "|" + contentModel.Title;
            //设置话题为漫画名
            var topic = new PostEntryTopic()
            {
                CreateTime = DateTime.Now,
                Id         = Guid.NewGuid(),
                Text       = topicTxt,
                PosterId   = comment.UserAccount.Id
            };
            var topicExt = new ContentExtPostEntryTopic()
            {
                Id        = Guid.NewGuid(),
                TopicText = topicTxt,
                LinkId    = contentModel.Id,
                LinkType  = "category"
            };
            //评论
            var postentryModel = new PostEntry()
            {
                Id             = Guid.NewGuid(),
                CreateTime     = DateTime.Now,
                PostEntryTopic = topicTxt,
                UserId         = comment.UserAccount.Id,
                TimeStamp      = TimeStamp.Get(),
                TextContent    = comment.Content
            };

            //目前是一条漫画评论对应一个话题, 为防止以后出现多话题, 保留此表
            var contentPostentryMapping = new ContentPostEntryMapping()
            {
                Id          = Guid.NewGuid(),
                ContentId   = contentModel.Id,
                PostEntryId = postentryModel.Id,
                CreateTime  = DateTime.Now
            };

            await ContentAccessor.Add(topic);

            await ContentAccessor.Add(topicExt);

            await ContentAccessor.Add(postentryModel);

            await ContentAccessor.Add(contentPostentryMapping);
        }
Exemplo n.º 3
0
        //public Task CreateContentWithTag(ContentEntry contentEntry, string v1, string v2)
        //{
        //    throw new NotImplementedException();
        //}
        public async Task <ApiMessage> CreateContentWithTag(ContentEntry content, string tagName)
        {
            return(await ApiMessage.Wrap(async() =>
            {
                //var categoryEntity = await CategoryAccessor.OneAsync<Categories>(x => x.Name == tagName);
                //if (categoryEntity == null)
                //{
                //    categoryEntity = new Categories
                //    {
                //        Name = tagName,
                //        CreateTime = DateTime.Now,
                //        Id = Guid.NewGuid()
                //    };
                //    await CategoryAccessor.Add(categoryEntity);
                //}

                var contentEntry = await ContentAccessor.OneAsync <ContentEntry>(x => x.Id == content.Id);
                if (contentEntry == null)
                {
                    contentEntry = new ContentEntry
                    {
                        Id = Guid.NewGuid(),
                        CategoryId = content.CategoryId,
                        Content = content.Content,
                        CreateTime = DateTime.Now,
                        IsFaq = content.IsFaq,
                        IsTop = content.IsTop,
                        Title = content.Title,
                        Tags = new List <Tags> {
                            new Tags {
                                Name = tagName
                            }
                        }
                    };
                    await ContentAccessor.Add(contentEntry);
                }
                else
                {
                    contentEntry.CategoryId = content.CategoryId;
                    contentEntry.Content = content.Content;
                    contentEntry.IsFaq = content.IsFaq;
                    contentEntry.IsTop = content.IsTop;
                    contentEntry.Title = content.Title;
                    await ContentAccessor.Update(contentEntry);
                }
            }));
        }
Exemplo n.º 4
0
        public async Task <ApiMessage> CreateContentWithCategory(ContentEntry content, string categoryName)
        {
            return(await ApiMessage.Wrap(async() =>
            {
                var categoryEntity = await CategoryAccessor.OneAsync <Categories>(x => x.Name == categoryName);
                if (categoryEntity == null)
                {
                    categoryEntity = new Categories
                    {
                        Name = categoryName,
                        CreateTime = DateTime.Now,
                        Id = Guid.NewGuid()
                    };
                    await CategoryAccessor.Add(categoryEntity);
                }

                var contentEntry = await ContentAccessor.OneAsync <ContentEntry>(x => x.Id == content.Id);
                if (contentEntry == null)
                {
                    contentEntry = new ContentEntry
                    {
                        Id = Guid.NewGuid(),
                        Category = categoryEntity,
                        Content = content.Content,
                        CreateTime = DateTime.Now,
                        IsFaq = content.IsFaq,
                        IsTop = content.IsTop,
                        Title = content.Title
                    };
                    await ContentAccessor.Add(contentEntry);
                }
                else
                {
                    contentEntry.Category = categoryEntity;
                    contentEntry.Content = content.Content;
                    contentEntry.IsFaq = content.IsFaq;
                    contentEntry.IsTop = content.IsTop;
                    contentEntry.Title = content.Title;
                    await ContentAccessor.Update(contentEntry);
                }
            }));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 阅读时写入用户阅读记录
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="userId"></param>
        /// <param name="skipCount"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public async Task <ContentEntry> GetContentByIdSetLog(Guid Id, string userId, int skipCount = 0, int pageSize = 20)
        {
            return(await ApiMessage.WrapData(async() =>
            {
                var contentEntry = await ContentAccessor.OneAsync <ContentEntry>(x => x.Id == Id, "MediaResource", "Category", "Category.ContentList");

                if (!string.IsNullOrEmpty(userId))
                {
                    await ContentAccessor.Add(new ContentUserReadLog
                    {
                        CreateTime = DateTime.Now,
                        Id = Guid.NewGuid(),
                        Categories = contentEntry.Category,
                        UserId = Guid.Parse(userId),
                        ContentEntry = contentEntry
                    });
                }
                return contentEntry;
            }));
        }
Exemplo n.º 6
0
 public async Task CreateFaqArticle(ContentEntry contentEntry)
 {
     await ContentAccessor.Add(contentEntry);
 }
Exemplo n.º 7
0
        public async Task CreateCategoryCommentExtPostEntry(CategoryComment comment)
        {
            var categoryModel = await ContentAccessor.OneAsync <Categories>(x => x.Status != ContentStatus.Close && x.Id == comment.CategoryId);

            //设置话题为漫画名
            var topic = new PostEntryTopic()
            {
                CreateTime = DateTime.Now,
                Id         = Guid.NewGuid(),
                Text       = categoryModel.Name,
                PosterId   = comment.UserAccountId
            };
            var topicExt = new ContentExtPostEntryTopic()
            {
                Id        = Guid.NewGuid(),
                TopicText = categoryModel.Name,
                LinkId    = categoryModel.Id,
                LinkType  = "category"
            };
            //评论
            var postentryModel = new PostEntry()
            {
                Id             = Guid.NewGuid(),
                CreateTime     = DateTime.Now,
                PostEntryTopic = categoryModel.Name,
                UserId         = comment.UserAccountId,
                TimeStamp      = TimeStamp.Get(),
                TextContent    = comment.Content,
            };

            //目前是一条漫画评论对应一个话题, 为防止以后出现多话题, 保留此表
            var categoryPostentryMapping = new CategoryPostEntryMapping()
            {
                Id          = Guid.NewGuid(),
                CategoryId  = categoryModel.Id,
                PostEntryId = postentryModel.Id,
                CreateTime  = DateTime.Now
            };

            await ContentAccessor.Add(topic);

            await ContentAccessor.Add(topicExt);

            await ContentAccessor.Add(postentryModel);

            await ContentAccessor.Add(categoryPostentryMapping);

            var sandBoxMsg = new SandBoxMessage()
            {
                Content           = $"您在漫画{topic}的回复,收到了新的评论.",
                CreateTime        = DateTime.Now,
                FromUserAccountId = comment.UserAccountId,
                ToUserAccountId   = postentryModel.UserId,
                Id           = Guid.NewGuid(),
                IsRead       = false,
                MessageType  = SandBoxMessageType.PostEntryComment,
                TimeStamp    = TimeStamp.Get(),
                RecieveToken = ""
            };
            await sandBoxBusiness.SendAlertTo(sandBoxMsg);
        }
Exemplo n.º 8
0
        public async Task CreateCategoryComment(CategoryComment comment)
        {
            await ContentAccessor.Add(comment);

            await ContentAccessor.SaveAsync();
        }
Exemplo n.º 9
0
        public async Task <ContentEntry> CreateContentWithCategoryAndTag(ContentEntry content, string categoryName, string tag)
        {
            var categoryEntity = await CategoryAccessor.OneAsync <Categories>(x => x.Name == categoryName);

            if (categoryEntity == null)
            {
                categoryEntity = new Categories
                {
                    Name       = categoryName,
                    CreateTime = DateTime.Now,
                    Id         = Guid.NewGuid()
                };
                await CategoryAccessor.Add(categoryEntity);
            }

            var contentEntry = await ContentAccessor.OneAsync <ContentEntry>(x => x.Id == content.Id);



            if (contentEntry == null)
            {
                contentEntry = new ContentEntry
                {
                    Id         = Guid.NewGuid(),
                    Category   = categoryEntity,
                    Content    = content.Content,
                    CreateTime = DateTime.Now,
                    IsFaq      = content.IsFaq,
                    IsTop      = content.IsTop,
                    Title      = content.Title,
                    Tags       = new List <Tags> {
                        new Tags {
                            Name       = tag,
                            Id         = Guid.NewGuid(),
                            CreateTime = DateTime.Now
                        }
                    },
                    ContentEntryInfo = new ContentEntryInfo
                    {
                        Id            = content.ContentEntryInfo.Id,
                        Author        = content.ContentEntryInfo.Author,
                        Source        = content.ContentEntryInfo.Source,
                        Type          = content.ContentEntryInfo.Type,
                        UserAccountId = content.ContentEntryInfo.UserAccountId
                    }
                };
                await ContentAccessor.Add(contentEntry);

                //if (contentEntry.MediaResource == null)
                //{
                //    contentEntry.MediaResource = new List<FileEntry>();
                //}
                if (content.MediaResource != null)
                {
                    foreach (var item in content.MediaResource)
                    {
                        item.ContentEntryId = contentEntry.Id;
                    }

                    await ContentAccessor.UpdateRange(content.MediaResource);
                }

                ////var mediaResource = ContentAccessor.Entry(content.MediaResource);
                ////contentEntry.MediaResource = mediaResource;
                //await ContentAccessor.Update(contentEntry);
            }
            else
            {
                contentEntry.Category = categoryEntity;
                contentEntry.Content  = content.Content;
                contentEntry.IsFaq    = content.IsFaq;
                contentEntry.IsTop    = content.IsTop;
                contentEntry.Title    = content.Title;
                if (content.MediaResource != null)
                {
                    foreach (var item in content.MediaResource)
                    {
                        item.ContentEntryId = contentEntry.Id;
                    }

                    await ContentAccessor.UpdateRange(content.MediaResource);
                }
                //contentEntry.MediaResource = content.MediaResource;
                await ContentAccessor.Update(contentEntry);
            }

            return(contentEntry);
        }