protected void SubmitButton_Click(object sender, EventArgs e)
    {
        TextBox commentCtrl = (TextBox)CommentsLoginView.FindControl("CommentTextBox");
        if (commentCtrl != null && commentCtrl.Text.Length > 0)
        {
            using (DataClassesDataContext dtx = new DataClassesDataContext())
            {
                int aid = 0;
                MembershipUser mu = Membership.GetUser(HttpContext.Current.User.Identity.Name);
                if (int.TryParse(Context.Request["aid"], out aid))
                {
                    var comment = new Comment()
                    {
                        ArticleId = aid,
                        UserId = (Guid)mu.ProviderUserKey,
                        Body = commentCtrl.Text,
                        Created = System.DateTime.Now
                    };
                    dtx.Comments.InsertOnSubmit(comment);
                    dtx.SubmitChanges();

                    CommentService c = new CommentService();
                    CommentsDataList.DataSource = c.GetComments(aid);
                    CommentsDataList.DataBind();
                }
                commentCtrl.Text = "";
            }
        }
    }
Пример #2
0
 public LayoutController()
 {
     blogService = new BlogService();
     postService = new BlogPostService();
     categoryService = new BlogCategoryService();
     rollService = new BlogrollService();
     commentService = new CommentService<BlogPostComment>();
 }
Пример #3
0
		public void Initialize()
		{
			_commentService = new CommentService
			{
				Token = TestSettings.Token,
				ApiKey = TestSettings.ApiKey,
				UserAgent = TestSettings.UserAgent
			};
		}
 protected void Page_Load(object sender, EventArgs e)
 {
     int aid = 0;
     if (int.TryParse(Context.Request["aid"], out aid))
     {
         if (!IsPostBack)
         {
             CommentService c = new CommentService();
             CommentsDataList.DataSource = c.GetComments(aid);
             CommentsDataList.DataBind();
         }
     }
 }
    protected void btnPostComment_Click(object sender, EventArgs e)
    {
        CommentService cs = new CommentService();

            string deviceId = Request.QueryString["id"];
            string nickname = txtNickname.Text;
            string pros = txtPros.Text;
            string cons = txtCons.Text;

            string result = cs.PostComment(deviceId, nickname, pros, cons);

            //lblPostCommentResult.Text = result;

            Response.Redirect(Request.RawUrl);
    }
Пример #6
0
        public void ShouldGetRightNoOfCommentsWithMaxCommentsSet()
        {
            var commentRepository = MockRepository.GenerateStub<ICommentRepository>();

            ICommentService commentService = new CommentService(commentRepository);
            const int personId = 1;
            var currentPerson = new Person();
            var listOfComments = new List<CommentDto> { new CommentDto(), new CommentDto(), new CommentDto(), new CommentDto() };
            commentRepository
                .Expect(c => c.GetListOfComments(currentPerson, personId))
                .Return(listOfComments);

            var sut = commentService.GetListOfComments(currentPerson, personId, 2);

            Assert.That(sut.Count(), Is.EqualTo(2));
        }
Пример #7
0
        public void CanSaveNewComment()
        {
            var commentRepository = MockRepository.GenerateStub<ICommentRepository>();

            ICommentService commentService = new CommentService(commentRepository);
            var currentPerson = new Person();
            var newCommentDto = new CommentDto();
            const int commentId = 1;
            commentRepository
                .Expect(c => c.SaveItem(currentPerson, newCommentDto))
                .Return(commentId);

            var sut = commentService.SaveComment(currentPerson, newCommentDto);

            Assert.That(sut, Is.EqualTo(commentId));
        }
Пример #8
0
        public void ShouldBeErrorIfNoKeyUpdate()
        {
            string encryptionKey = null;
            DBResult <UserProfile> profileDBResult = new DBResult <UserProfile>
            {
                Payload = new UserProfile()
                {
                    EncryptionKey = encryptionKey
                }
            };

            Mock <IUserProfileDelegate> profileDelegateMock = new Mock <IUserProfileDelegate>();

            profileDelegateMock.Setup(s => s.GetUserProfile(hdid)).Returns(profileDBResult);

            UserComment userComment = new UserComment()
            {
                UserProfileId   = hdid,
                ParentEntryId   = parentEntryId,
                Text            = "Deleted Comment",
                EntryTypeCode   = Database.Constants.CommentEntryType.Medication,
                CreatedDateTime = new DateTime(2020, 1, 1)
            };

            ICommentService service = new CommentService(
                new Mock <ILogger <CommentService> >().Object,
                new Mock <ICommentDelegate>().Object,
                profileDelegateMock.Object,
                new Mock <ICryptoDelegate>().Object
                );


            RequestResult <UserComment> actualResult = service.Update(userComment);

            Assert.Equal(ResultType.Error, actualResult.ResultStatus);
        }
Пример #9
0
        /// <summary>
        /// 删除ContentItem
        /// </summary>
        /// <param name="contentItem"></param>
        public void Delete(ContentItem contentItem)
        {
            if (contentItem != null)
            {
                //执行事件
                EventBus <ContentItem> .Instance().OnBefore(contentItem, new CommonEventArgs(EventOperationType.Instance().Delete()));

                contentItemRepository.Delete(contentItem);
                //用户投稿计数-1
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(contentItem.UserId, OwnerDataKeys.Instance().ContributeCount(), -1);

                //删除标签关联
                TagService tagService = new TagService(TenantTypeIds.Instance().ContentItem());
                tagService.ClearTagsFromItem(contentItem.ContentItemId, contentItem.UserId);
                //删除评论
                CommentService commentService = new CommentService();
                commentService.DeleteCommentedObjectComments(contentItem.ContentItemId);
                //执行事件
                EventBus <ContentItem> .Instance().OnAfter(contentItem, new CommonEventArgs(EventOperationType.Instance().Delete(), ApplicationIds.Instance().CMS()));

                EventBus <ContentItem, AuditEventArgs> .Instance().OnAfter(contentItem, new AuditEventArgs(contentItem.AuditStatus, null));
            }
        }
Пример #10
0
        public async Task RemoveByIdAsyncShoulWorkCorrectlyWithValidParameters()
        {
            //Arange
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            //Act
            var db     = new ApplicationDbContext(options);
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <ApplicationProfile>();
            });
            var mapper         = new Mapper(config);
            var commentService = new CommentService(db, mapper);
            var comment        = new Comment();
            await db.Comments.AddAsync(comment);

            await db.SaveChangesAsync();

            await commentService.RemoveByIdAsync(comment.Id);

            //asssert
            Assert.True(await db.Comments.CountAsync() == 0);
        }
Пример #11
0
        public async Task RemoveCommentShouldReduceCount()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "MyTestDb5")
                          .Options;
            var dbContext = new ApplicationDbContext(options);
            var comment1  = new Comment {
                Id = 1
            };
            var comment2 = new Comment {
                Id = 2
            };

            dbContext.Comments.Add(comment1);
            dbContext.Comments.Add(comment2);
            await dbContext.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <Comment>(dbContext);
            var service    = new CommentService(repository);
            int existingId = 2;
            await service.RemoveComment(existingId);

            Assert.Equal(1, repository.All().Count());
        }
Пример #12
0
        public async void Update_ErrorsOccurred_ShouldReturnErrorResponse()
        {
            var mock          = new ServiceMockFacade <ICommentService, ICommentRepository>();
            var model         = new ApiCommentServerRequestModel();
            var validatorMock = new Mock <IApiCommentServerRequestModelValidator>();

            validatorMock.Setup(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiCommentServerRequestModel>())).Returns(Task.FromResult(new ValidationResult(new List <ValidationFailure>()
            {
                new ValidationFailure("text", "test")
            })));
            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Comment()));
            var service = new CommentService(mock.LoggerMock.Object,
                                             mock.MediatorMock.Object,
                                             mock.RepositoryMock.Object,
                                             validatorMock.Object,
                                             mock.DALMapperMockFactory.DALCommentMapperMock);

            UpdateResponse <ApiCommentServerResponseModel> response = await service.Update(default(int), model);

            response.Should().NotBeNull();
            response.Success.Should().BeFalse();
            validatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <int>(), It.IsAny <ApiCommentServerRequestModel>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <CommentUpdatedNotification>(), It.IsAny <CancellationToken>()), Times.Never());
        }
Пример #13
0
 public TaskController(TaskService tService, SubTaskService stService, ProjectService projectService, AccountService accountService, CommentService commentService)
 {
     this.taskService    = tService;
     this.subTaskService = stService;
     this.projectService = projectService;
     this.accountService = accountService;
     this.commentService = commentService;
 }
 public TimeLineController()
 {
     appUserService = new AppUserService();
     commentService = new CommentService();
     tweetService   = new TweetService();
 }
Пример #15
0
        public async Task <ActionResult> Submit(CommentCommand dto)
        {
            var match = Regex.Match(dto.NickName + dto.Content.RemoveHtmlTag(), CommonHelper.BanRegex);

            if (match.Success)
            {
                LogManager.Info($"提交内容:{dto.NickName}/{dto.Content},敏感词:{match.Value}");
                return(ResultData(null, false, "您提交的内容包含敏感词,被禁止发表,请检查您的内容后尝试重新提交!"));
            }

            Post post = await PostService.GetByIdAsync(dto.PostId) ?? throw new NotFoundException("评论失败,文章未找到");

            if (post.DisableComment)
            {
                return(ResultData(null, false, "本文已禁用评论功能,不允许任何人回复!"));
            }

            dto.Content = dto.Content.Trim().Replace("<p><br></p>", string.Empty);
            if (CommentFeq.GetOrAdd("Comments:" + ClientIP, 1) > 2)
            {
                CommentFeq.Expire("Comments:" + ClientIP, TimeSpan.FromMinutes(1));
                return(ResultData(null, false, "您的发言频率过快,请稍后再发表吧!"));
            }

            var comment = dto.Mapper <Comment>();

            if (Regex.Match(dto.NickName + dto.Content, CommonHelper.ModRegex).Length <= 0)
            {
                comment.Status = Status.Published;
            }

            comment.CommentDate = DateTime.Now;
            var user = HttpContext.Session.Get <UserInfoDto>(SessionKey.UserInfo);

            if (user != null)
            {
                comment.NickName   = user.NickName;
                comment.QQorWechat = user.QQorWechat;
                comment.Email      = user.Email;
                if (user.IsAdmin)
                {
                    comment.Status   = Status.Published;
                    comment.IsMaster = true;
                }
            }
            comment.Content  = dto.Content.HtmlSantinizerStandard().ClearImgAttributes();
            comment.Browser  = dto.Browser ?? Request.Headers[HeaderNames.UserAgent];
            comment.IP       = ClientIP;
            comment.Location = comment.IP.GetIPLocation();
            comment          = CommentService.AddEntitySaved(comment);
            if (comment == null)
            {
                return(ResultData(null, false, "评论失败"));
            }

            CommentFeq.AddOrUpdate("Comments:" + ClientIP, 1, i => i + 1, 5);
            CommentFeq.Expire("Comments:" + ClientIP, TimeSpan.FromMinutes(1));
            var emails = new HashSet <string>();
            var email  = CommonHelper.SystemSettings["ReceiveEmail"]; //站长邮箱

            emails.Add(email);
            var content = new Template(await System.IO.File.ReadAllTextAsync(HostEnvironment.WebRootPath + "/template/notify.html"))
                          .Set("title", post.Title)
                          .Set("time", DateTime.Now.ToTimeZoneF(HttpContext.Session.Get <string>(SessionKey.TimeZone)))
                          .Set("nickname", comment.NickName)
                          .Set("content", comment.Content);

            if (comment.Status == Status.Published)
            {
                if (!comment.IsMaster)
                {
                    await MessageService.AddEntitySavedAsync(new InternalMessage()
                    {
                        Title   = $"来自【{comment.NickName}】的新文章评论",
                        Content = comment.Content,
                        Link    = Url.Action("Details", "Post", new { id = comment.PostId, cid = comment.Id }, Request.Scheme) + "#comment"
                    });
                }
                if (comment.ParentId == 0)
                {
                    emails.Add(post.Email);
                    emails.Add(post.ModifierEmail);
                    //新评论,只通知博主和楼主
                    foreach (var s in emails)
                    {
                        BackgroundJob.Enqueue(() => CommonHelper.SendMail(Request.Host + "|博客文章新评论:", content.Set("link", Url.Action("Details", "Post", new { id = comment.PostId, cid = comment.Id }, Request.Scheme) + "#comment").Render(false), s, ClientIP));
                    }
                }
                else
                {
                    //通知博主和上层所有关联的评论访客
                    var pid = CommentService.GetParentCommentIdByChildId(comment.Id);
                    emails.AddRange(CommentService.GetSelfAndAllChildrenCommentsByParentId(pid).Select(c => c.Email).ToArray());
                    emails.AddRange(post.Email, post.ModifierEmail);
                    emails.Remove(comment.Email);
                    string link = Url.Action("Details", "Post", new { id = comment.PostId, cid = comment.Id }, Request.Scheme) + "#comment";
                    foreach (var s in emails)
                    {
                        BackgroundJob.Enqueue(() => CommonHelper.SendMail($"{Request.Host}{CommonHelper.SystemSettings["Title"]}文章评论回复:", content.Set("link", link).Render(false), s, ClientIP));
                    }
                }
                return(ResultData(null, true, "评论发表成功,服务器正在后台处理中,这会有一定的延迟,稍后将显示到评论列表中"));
            }

            foreach (var s in emails)
            {
                BackgroundJob.Enqueue(() => CommonHelper.SendMail(Request.Host + "|博客文章新评论(待审核):", content.Set("link", Url.Action("Details", "Post", new { id = comment.PostId, cid = comment.Id }, Request.Scheme) + "#comment").Render(false) + "<p style='color:red;'>(待审核)</p>", s, ClientIP));
            }

            return(ResultData(null, true, "评论成功,待站长审核通过以后将显示"));
        }
Пример #16
0
 public NewsController(NewsService newsService, CommentService commentService)
 {
     this._newsService    = newsService;
     this._commentService = commentService;
 }
Пример #17
0
 public ProductController()
 {
     _productService = new ProductService();
     _commentService = new CommentService();
 }
Пример #18
0
 public CommentController()
 {
     commentService = new CommentService(new SouqContext());
 }
Пример #19
0
 public CommentController(CommentService commentService)
 {
     _commentService = commentService;
 }
Пример #20
0
        public int ApproveMember(int id)
        {
            if (Members.IsAdmin() == false)
            {
                throw new Exception("You cannot approve this member");
            }

            var memberService = UmbracoContext.Application.Services.MemberService;
            var member        = memberService.GetById(id);

            if (member == null)
            {
                throw new Exception("Member not found");
            }

            var minimumKarma = 71;

            if (member.GetValue <int>("reputationCurrent") < minimumKarma)
            {
                member.SetValue("reputationCurrent", minimumKarma);
                member.SetValue("reputationTotal", minimumKarma);
                memberService.Save(member);
            }

            var rolesForUser = Roles.GetRolesForUser(member.Username);

            if (rolesForUser.Contains("potentialspam"))
            {
                memberService.DissociateRole(member.Id, "potentialspam");
            }
            if (rolesForUser.Contains("newaccount"))
            {
                memberService.DissociateRole(member.Id, "newaccount");
            }

            var topicService   = new TopicService(ApplicationContext.Current.DatabaseContext);
            var commentService = new CommentService(ApplicationContext.Current.DatabaseContext, topicService);
            var comments       = commentService.GetAllCommentsForMember(member.Id);

            foreach (var comment in comments)
            {
                if (comment.IsSpam)
                {
                    comment.IsSpam = false;
                    commentService.Save(comment);
                    var topic      = topicService.GetById(comment.TopicId);
                    var topicUrl   = topic.GetUrl();
                    var commentUrl = string.Format("{0}#comment-{1}", topicUrl, comment.Id);
                    var memberName = member.Name;
                    commentService.SendNotifications(comment, memberName, commentUrl);
                }
            }

            var topics = topicService.GetLatestTopicsForMember(member.Id, false, 100);

            foreach (var topic in topics)
            {
                if (topic.IsSpam)
                {
                    topic.IsSpam = false;
                    topicService.Save(topic);
                    topicService.SendNotifications(topic, member.Name, topic.GetUrl());
                }
            }

            var newForumTopicNotification = new NotificationsCore.Notifications.AccountApproved();

            newForumTopicNotification.SendNotification(member.Email);

            SendSlackNotification(BuildBlockedNotifactionPost(Members.GetCurrentMember().Name, member.Id, false));

            return(minimumKarma);
        }
Пример #21
0
        public CommentsController(CommentService cs, ResourceService rs)
        {
            _commentService = cs;

            _rService = rs;
        }
Пример #22
0
 public DailyController(UserManager <ApplicationUser> userManager, CommentService commentService)
 {
     _userManager    = userManager;
     _commentService = commentService;
 }
 public CommentsController(CommentService service)
 {
     _service = service;
 }
Пример #24
0
 public Creating(ApplicationContext applicationContext, ProviderService providerService, RoleService roleService, UserService userService, ProductService productService, AssessmentService assessmentService, CommentService commentService, OrderService orderService, BasketService basketService)
 {
     _applicationContext = applicationContext;
     _providerService    = providerService;
     _roleService        = roleService;
     _userService        = userService;
     _productService     = productService;
     _assessmentService  = assessmentService;
     _commentService     = commentService;
     _orderService       = orderService;
     _basketService      = basketService;
 }
Пример #25
0
        public LayoutController()
        {
            albumService = new PhotoAlbumService();

            commentService = new CommentService<PhotoPostComment>();
        }
Пример #26
0
 public PostController(PostService postService, ILogger <PostController> logger, CommentService commentService)
 {
     this.postService    = postService;
     this.logger         = logger;
     this.commentService = commentService;
 }
Пример #27
0
 public CommentsController(CommentService commentService, LikeCommentService likeCommentService, DislikeCommentService dislikeCommentService)
 {
     _commentService        = commentService;
     _likeCommentService    = likeCommentService;
     _dislikeCommentService = dislikeCommentService;
 }
Пример #28
0
 public NewsController(NewsService newsService, CommentService commentService)
 {
     _newsService    = newsService;
     _commentService = commentService;
 }
Пример #29
0
 public QuickActionController(CommentService commentService, TopicService topicService)
 {
     this.CommentService = commentService;
     this.TopicService   = topicService;
 }
Пример #30
0
 public Comment_Controller(CommentService commentService, PostService postService)
 {
     _commentService = commentService;
     _postService    = postService;
 }
Пример #31
0
 public CommentController(IConfiguration configuration)
 {
     _connectionString = configuration["ConnectionStrings:DefaultConnection"];
     _commentService   = new CommentService(_connectionString);
 }
Пример #32
0
 public ArticleController()
 {
     commentService = new CommentService();
     articleService = new ArticleService();
 }
Пример #33
0
        public async System.Threading.Tasks.Task CreateTaskLists(ILambdaContext context, Podio podio, Item check, RoutedPodioEvent e, DriveService service, GetIds ids, GoogleIntegration google, PreSurvAndExp pre)
        {
            string commentText;
            var    TlStatusId  = ids.GetFieldId("Admin|Hidden Status");
            var    startDateId = ids.GetFieldId("Admin|Program Start Date");
            //var packageId = ids.GetFieldId("Admin|Curriculum Package");
            //string packageName = check.Field<CategoryItemField>(packageId).Options.First().Text;
            var fieldId = 0;

            context.Logger.LogLine("Satisfied conditions, Task List Function");
            var viewServ = new ViewService(podio);

            context.Logger.LogLine("Got View Service");
            var views = await viewServ.GetViews(21310276);            //VC Admin Master Schedule App

            var view = from v in views
                       where v.Name == "Package" // ------------- >> where v.Name == packageName
                       select v;
            //context.Logger.LogLine($"Got View '{packageName}'");
            var op = new FilterOptions {
                Filters = view.First().Filters
            };

            if (check.Field <CategoryItemField>(TlStatusId).Options.First().Text == "1")
            {
                context.Logger.LogLine("Grabbing items 1-30");
                op.Offset = 0;
                op.Limit  = 30;
                filter    = await podio.FilterItems(21310276, op);

                commentText = "Batch 1 finished";
            }
            else if (check.Field <CategoryItemField>(TlStatusId).Options.First().Text == "2")
            {
                context.Logger.LogLine("Grabbing items 31-60");
                op.Offset = 30;
                op.Limit  = 30;
                filter    = await podio.FilterItems(21310276, op);

                commentText = "Batch 2 finished";
            }
            else if (check.Field <CategoryItemField>(TlStatusId).Options.First().Text == "3")
            {
                context.Logger.LogLine("Grabbing items 61-90");
                op.Offset = 60;
                op.Limit  = 30;
                filter    = await podio.FilterItems(21310276, op);

                commentText = "Batch 3 finished";
            }
            else if (check.Field <CategoryItemField>(TlStatusId).Options.First().Text == "4")
            {
                context.Logger.LogLine("Grabbing items 91-120 with links");
                op.Offset = 90;
                op.Limit  = 30;
                filter    = await podio.FilterItems(21310276, op);

                commentText = "Batch 4 finished";
            }
            else if (check.Field <CategoryItemField>(TlStatusId).Options.First().Text == "5")
            {
                context.Logger.LogLine("Grabbing items 121-150 with links");
                op.Offset = 120;
                op.Limit  = 30;
                filter    = await podio.FilterItems(21310276, op);

                commentText = "Batch 5 finished";
            }
            else if (check.Field <CategoryItemField>(TlStatusId).Options.First().Text == "6")
            {
                context.Logger.LogLine("Grabbing items 151-180 with links");
                op.Offset = 150;
                op.Limit  = 30;
                filter    = await podio.FilterItems(21310276, op);

                commentText = "Batch 6 finished";
            }
            else if (check.Field <CategoryItemField>(TlStatusId).Options.First().Text == "7")
            {
                context.Logger.LogLine("Grabbing items 181-210 with links");
                op.Offset = 180;
                op.Limit  = 30;
                filter    = await podio.FilterItems(21310276, op);

                commentText = "Batch 7 finished";
            }
            else if (check.Field <CategoryItemField>(TlStatusId).Options.First().Text == "8")
            {
                context.Logger.LogLine("Grabbing items 211-240 with links");
                op.Offset = 210;
                op.Limit  = 30;
                filter    = await podio.FilterItems(21310276, op);

                commentText = "Batch 8 finished";
            }
            else
            {
                context.Logger.LogLine("Grabbing nothing --- undefined input");
                commentText = "";
            }
            context.Logger.LogLine($"Items in filter:{filter.Items.Count()}");
            var count = 0;

            foreach (var masterItem in filter.Items)
            {
                count += 1;
                context.Logger.LogLine($"On item #: {count}");
                var child = new Item();


                //--- Assign Fields ---//
                fieldId = ids.GetFieldId("VC Administration|Master Schedule|Task Name");
                var nameMaster = masterItem.Field <TextItemField>(fieldId);
                if (nameMaster.Value != null)
                {
                    fieldId = ids.GetFieldId("Task List|Title");
                    var nameChild = child.Field <TextItemField>(fieldId);
                    nameChild.Value = nameMaster.Value;
                }
                context.Logger.LogLine($"Added field:{nameMaster.Label}");
                fieldId = ids.GetFieldId("VC Administration|Master Schedule|Desciption");
                var descrMaster = masterItem.Field <TextItemField>(fieldId);
                if (descrMaster.Value != null)
                {
                    fieldId = ids.GetFieldId("Task List|Description");
                    var descrChild = child.Field <TextItemField>(fieldId);
                    //descrChild.Value = StripHTML(descrMaster.Value);
                    descrChild.Value = descrMaster.Value;
                }
                context.Logger.LogLine($"Added field:{descrMaster.Label}");

                fieldId = ids.GetFieldId("VC Administration|Master Schedule|Phase");
                var phaseMaster = masterItem.Field <CategoryItemField>(fieldId);
                if (phaseMaster.Options.Any())
                {
                    fieldId = ids.GetFieldId("Task List|Phase");
                    var phaseChild = child.Field <CategoryItemField>(fieldId);
                    phaseChild.OptionText = phaseMaster.Options.First().Text;
                    if (phaseMaster.Options.First().Text == "Dependent Task")
                    {
                        continue;
                    }
                }

                context.Logger.LogLine($"Added field:{phaseMaster.Label}");
                fieldId = ids.GetFieldId("VC Administration|Master Schedule|ESO Member Role");
                var esoMaster = masterItem.Field <CategoryItemField>(fieldId);
                if (esoMaster.Options.Any())
                {
                    fieldId = ids.GetFieldId("Task List|ESO Member Role");
                    var esoChild = child.Field <CategoryItemField>(fieldId);
                    esoChild.OptionText = esoMaster.Options.First().Text;
                }
                context.Logger.LogLine($"Added field:{esoMaster.Label}");
                fieldId = ids.GetFieldId("VC Administration|Master Schedule|Project");
                var projectMaster = masterItem.Field <CategoryItemField>(fieldId);
                if (projectMaster.Options.Any())
                {
                    fieldId = ids.GetFieldId("Task List|Project");
                    var projectChild = child.Field <CategoryItemField>(fieldId);
                    projectChild.OptionText = projectMaster.Options.First().Text;
                }
                context.Logger.LogLine($"Added field:{projectMaster.Label}");

                fieldId = ids.GetFieldId("VC Administration|Master Schedule|Base Workshop Association");
                var wsMaster = masterItem.Field <CategoryItemField>(fieldId);
                if (wsMaster.Options.Any())
                {
                    fieldId = ids.GetFieldId("Task List|WS Association");
                    var wsChild = child.Field <TextItemField>(fieldId);
                    wsChild.Value = wsMaster.Options.First().Text;
                    fieldId       = ids.GetFieldId("Task List|Parent WS");
                    var parentChild = child.Field <CategoryItemField>(fieldId);
                    parentChild.OptionText = wsMaster.Options.First().Text;
                }
                context.Logger.LogLine($"Added field:{wsMaster.Label}");
                fieldId = ids.GetFieldId("VC Administration|Master Schedule|Weeks Off-Set");
                var offsetMaster = masterItem.Field <NumericItemField>(fieldId);
                if (offsetMaster.Value.HasValue)
                {
                    fieldId = ids.GetFieldId("Task List|Week Offset");
                    var offsetChild = child.Field <NumericItemField>(fieldId);
                    offsetChild.Value = offsetMaster.Value;
                    fieldId           = ids.GetFieldId("Task List|Weeks Before WS");
                    var weeksChild = child.Field <NumericItemField>(fieldId);
                    weeksChild.Value = offsetMaster.Value;
                }
                context.Logger.LogLine($"Added field:{offsetMaster.Label}");
                fieldId = ids.GetFieldId("Task List|Completetion");
                var comChild = child.Field <CategoryItemField>(fieldId);
                comChild.OptionText = "Incomplete";
                context.Logger.LogLine($"Added field: Completion");

                fieldId = ids.GetFieldId("VC Administration|Master Schedule|Duration (Days)");
                var durMaster = masterItem.Field <NumericItemField>(fieldId);
                if (durMaster.Value.HasValue)
                {
                    fieldId = ids.GetFieldId("Task List|Duration (days)");
                    var durChild = child.Field <NumericItemField>(fieldId);
                    durChild.Value = durMaster.Value;
                }
                context.Logger.LogLine($"Added field:{durMaster.Label}");
                fieldId = ids.GetFieldId("VC Administration|Master Schedule|Dependancy");
                var depMaster = masterItem.Field <TextItemField>(fieldId);
                if (depMaster.Value != null)
                {
                    fieldId = ids.GetFieldId("Task List|Additional Dependencies");
                    var depChild = child.Field <TextItemField>(fieldId);
                    depChild.Value = depMaster.Value;
                }
                context.Logger.LogLine($"Added field:{depMaster.Label}");
                fieldId = ids.GetFieldId("VC Administration|Master Schedule|Gdrive Link");
                var embedMaster = masterItem.Field <EmbedItemField>(fieldId);
                fieldId = ids.GetFieldId("Task List|Linked Files");
                var embedChild     = child.Field <EmbedItemField>(fieldId);
                var embeds         = new List <Embed>();
                var parentFolderId = Environment.GetEnvironmentVariable("GOOGLE_PARENT_FOLDER_ID");
                var cloneFolderId  = google.GetSubfolderId(service, podio, e, parentFolderId);               //TODO:
                foreach (var em in embedMaster.Embeds)
                {
                    if (em.OriginalUrl.Contains(".google."))
                    {
                        await google.UpdateOneEmbed(service, em, embeds, cloneFolderId, podio, e);
                    }
                    //else          // Hold for 2.0 //
                    //{
                    //	NonGdriveLinks nonG = new NonGdriveLinks();
                    //	await nonG.NonGDriveCopy(em, embeds, podio, e);
                    //}
                }
                foreach (var embed in embeds)
                {
                    embedChild.AddEmbed(embed.EmbedId);
                }
                context.Logger.LogLine($"Added field:{embedMaster.Label}");
                var taskListAppId = ids.GetFieldId("Task List");
                var waitSeconds   = 5;
CallPodio:
                try
                {
                    await podio.CreateItem(child, taskListAppId, true);                    //child task list appId
                }
                catch (PodioUnavailableException ex)
                {
                    context.Logger.LogLine($"{ex.Message}");
                    context.Logger.LogLine($"Trying again in {waitSeconds} seconds.");
                    for (var i = 0; i < waitSeconds; i++)
                    {
                        System.Threading.Thread.Sleep(1000);
                        context.Logger.LogLine(".");
                    }
                    waitSeconds = waitSeconds * 2;
                    goto CallPodio;
                }
                context.Logger.LogLine($"Created item #{count}");
            }
            var comm = new CommentService(podio);

            if (check.Field <CategoryItemField>(TlStatusId).Options.First().Text == "1")
            {
                await pre.CreateExpendituresAndPreWSSurvs(context, podio, viewServ, check, e, service, ids, google);
            }
            await comm.AddCommentToObject("item", check.ItemId, commentText, hook : true);
        }
Пример #34
0
        public ActionResult Delete(int id)
        {
            var b = CommentService.DeleteEntitiesSaved(CommentService.GetSelfAndAllChildrenCommentsByParentId(id).ToList());

            return(ResultData(null, b, b ? "删除成功!" : "删除失败!"));
        }
Пример #35
0
 protected async override Task OnInitializedAsync()
 {
     Comments = await CommentService.GetComments(Id);
 }
Пример #36
0
 public CommentsController(UserManager <ApplicationUser> manager, CommentService commentService)
 {
     _manager        = manager;
     _commentService = commentService;
 }
Пример #37
0
 public NewsController(NewsService newsService, BannerService bannerService, CommentService commentService)
 {
     this._bannerService  = bannerService;
     this._newService     = newsService;
     this._commentService = commentService;
 }
Пример #38
0
 public CommentsController(CommentService commentService)
 {
     this._commentService = commentService;
 }
Пример #39
0
 public ActionResult Comment(long id, string content)
 {
     var username = MembershipHelper.GetUserName();
     var res = new CommentService().AddComment(username, content, new KEYID("Question", id), "0");
     return RedirectToAction("Details", new { id = id });
 }