public CommentsResponse FilterComment(int instanceId,
                                              FilterCommentViewModel filter = null)
        {
            var response = new CommentsResponse
            {
                CommentList = new List <CommentViewModel>()
            };

            filter = filter ?? new FilterCommentViewModel();
            var request = new CommentsRequest
            {
                InstanceId           = instanceId,
                CommentTypeCode      = filter.CommentTypeCode,
                DateFrom             = filter.DateFrom,
                DateTo               = filter.DateTo,
                OrderDesc            = filter.OrderBy,
                OrganizationalUnitId = filter.OrganizationalUnitId,
                TopicCommentId       = filter.TopicCommentId,
                UserName             = filter.UserName,
                MyComments           = filter.MyComments,
                IsCheckPublic        = filter.IsCheckPublic,
                IsOpcAgreement       = filter.IsOpcAgreement
            };

            var filterResponse = _commentService.FilterComments(request);

            if (filterResponse.IsValid)
            {
                response = filterResponse;
            }

            return(response);
        }
示例#2
0
        private async Task <bool> SendMail(CommentsRequest request)
        {
            string     fileName   = "";
            Attachment attachment = (Attachment)null;

            if (request.TempFileDirectory != null)
            {
                fileName = Path.Combine(AppConstants.TempFileDirectory, request.TempFileDirectory);
                if (File.Exists(fileName))
                {
                    attachment      = new Attachment(fileName, MediaTypeNames.Application.Octet);
                    attachment.Name = "request.csv";
                }
            }

            MailMessage message = new MailMessage(
                _AdminContact,
                request.Email,
                "Your Comment Request is Ready",
                "Find attached your comments as requested");

            // Add the file attachment to this e-mail message.
            if (attachment != null)
            {
                message.Attachments.Add(attachment);
            }
            else
            {
                message.Body = "Sorry, the website you submitted is not yet supported.";
            }
            await _smtpClient.SendMailAsync(message);

            return(true);
        }
示例#3
0
        public IEnumerable <ScrapedComment> Scrape(ScrapedPost post)
        {
            Debug.Assert(post != null);
            var      comments = new List <ScrapedComment>();
            DateTime now      = DateTime.Now;

            CommentsRequest graphRequest = new CommentsRequest(post.Id)
            {
                PaginationLimit = 100
            };
            PagedResponse <ScrapedComment> commentsResponse = GraphClient.GetComments <ScrapedComment>(graphRequest);

            // Could be null if the post doesn't exist anymore.
            if (commentsResponse != null)
            {
                foreach (ScrapedComment comment in commentsResponse.AllData())
                {
                    if (comment.FirstScraped == DateTime.MinValue)
                    {
                        comment.FirstScraped = now;
                    }
                    comment.LastScraped = now;
                    comment.Post        = post;

                    comments.Add(Save(comment, Refresh.False));
                }
            }

            return(comments);
        }
示例#4
0
        public void Ctor_ValidParentId_ReturnsExpected()
        {
            var commentsRequest = new CommentsRequest("ParentId");

            Assert.Equal("ParentId", commentsRequest.ParentId);
            Assert.Null(commentsRequest.Fields);
            Assert.Equal("/ParentId/comments?fields=id,message,from,like_count,comment_count,parent,created_time,updated_time&", commentsRequest.ToString());
        }
示例#5
0
        /// <summary>
        /// Calls https://graph.facebook.com/vX.Y/{request.ParentId/comments.
        /// </summary>
        /// <typeparam name="T">A constructable subclass of Comment to use. This allows deserializing data into custom subclasses that add extra metadata.</typeparam>
        /// <param name="request">The details of the request (ParentId, Since, Until, Limit) to send to the graph API.</param>
        /// <returns>The list of comments under request.ParentId, the id of a post or a comment, in the given range request.Since and request.Until if the parnet exists, else null.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="request"/> is null</exception>
        public async Task <PagedResponse <T> > GetComments <T>(CommentsRequest request) where T : Comment
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return(await GraphPagedResponse <T> .ExecuteRequest(ConstructRequest(request)));
        }
        public virtual async Task <string> FetchComments(CommentsRequest request)
        {
            var response = await _httpClient.GetAsync(request.RequestUrl);

            var fileName     = request.Id + "csv";
            var fullFilePath = Path.Combine(_path, fileName);
            await response.Content.ReadAsFileAsync(fullFilePath, true);

            _logger.LogInformation($"fetching successfull for {request.RequestUrl}, {response.StatusCode}");
            return(fullFilePath);
        }
示例#7
0
 public static CommentsRequestViewModel ToViewModel(this CommentsRequest model)
 {
     return(new CommentsRequestViewModel
     {
         Id = model.Id,
         RequestUrl = model.RequestUrl,
         Email = model.Email,
         MailSent = model.MailSent,
         CommentsFetched = model.CommentsFetched,
         FileName = model.TempFileDirectory
     });
 }
        public virtual ActionResult RemarksContent(int instanceId)
        {
            var remarksRequest = new CommentsRequest
            {
                InstanceId = instanceId
            };

            _viewModelMapperHelper.GetPagination();
            var remarksData = _vmrRemarksService.GetVmrRemarks(remarksRequest);
            var model       = remarksData.VmrCommentTab;

            return(PartialView("Partials/Tabs/TabRemarks", model));
        }
        public CommentsResponse GetFiltersComment(int instanceId, bool isOpcAgreement, FilterCommentViewModel filter)
        {
            CommentsRequest request = new CommentsRequest
            {
                InstanceId           = instanceId,
                IsOpcAgreement       = isOpcAgreement,
                TopicCommentId       = filter.TopicCommentId,
                CommentTypeId        = filter.CommentTypeId,
                MyComments           = filter.MyComments,
                OrganizationalUnitId = filter.OrganizationalUnitId,
                DateFrom             = filter.DateFrom,
                DateTo   = filter.DateTo,
                UserName = filter.UserName
            };

            return(_commentService.GetFiltersComment(request));
        }
示例#10
0
        public override async Task <string> FetchComments(CommentsRequest request)
        {
            #region initialize
            var videoId  = GetVideoId(request.RequestUrl);
            var query    = BuildQuery(videoId);
            var response = await _httpClient.GetAsync(query);

            #endregion

            #region needed params
            var    fileName        = request.Id + ".csv";
            var    currentResponse = new YouTubeCommentSet();
            bool   hasMore         = false;
            string nextPageToken   = "";
            var    refinedComments = new List <RefinedComment> ();
            #endregion

            do
            {
                if (hasMore)
                {
                    var newQuery = AddNextPageToken(query, nextPageToken);
                    response = await _httpClient.GetAsync(newQuery);
                }
                currentResponse = await response.Content.ReadAsAsync <YouTubeCommentSet> ();

                var snippets = currentResponse.Items.Select(e => GetRefinedComment(e, videoId));
                refinedComments.AddRange(snippets);
                nextPageToken = currentResponse.NextPageToken;
                hasMore       = !string.IsNullOrEmpty(nextPageToken);
            } while (hasMore);

            var fileSaved = SaveToFile(fileName, refinedComments);
            _logger.LogInformation($"fetching successfull for {request.RequestUrl}, {response.StatusCode}");
            return(fileSaved ? fileName : "");
        }
示例#11
0
 public CommentsResponse Get(CommentsRequest req)
 {
     return(Exec(req, r => r.CommentsResponse));
 }
示例#12
0
 /// <summary>
 /// Calls https://graph.facebook.com/vX.Y/{request.ParentId/comments.
 /// </summary>
 /// <param name="request">The details of the request (ParentId, Since, Until, Limit) to send to the graph API.</param>
 /// <returns>The list of comments under request.ParentId, the id of a post or a comment, in the given range request.Since and request.Until if the parnet exists, else null.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="request"/> is null</exception>
 public async Task <PagedResponse <Comment> > GetComments(CommentsRequest request) => await GetComments <Comment>(request);