Exemplo n.º 1
0
        /// <summary>
        /// Fetches updated posts
        /// </summary>
        /// <param name="taskInfo">info related to task, eg accessToken</param>
        /// <param name="sourceInfo">contains data source information</param>
        public async Task FetchUpdates(ConnectorTask taskInfo, SourceInfoFB sourceInfo, List <ItemMetadata> itemMetadata)
        {
            if (taskInfo.DirtyEntities != null && taskInfo.DirtyEntities?.Count != 0)
            {
                Trace.TraceInformation($"Number of dirty posts: {taskInfo.DirtyEntities?.Count}");

                string url = QueryFB.GetUpdatedPostsUrl(taskInfo);

                AuthenticationHeaderValue   header = new AuthenticationHeaderValue("Bearer", sourceInfo.AccessToken);
                Dictionary <string, PostFB> dict   = await this.downloader.GetWebContent <Dictionary <string, PostFB>, ErrorsFB>(url, header);

                foreach (KeyValuePair <string, PostFB> postEntry in dict)
                {
                    await HandlePost(postEntry.Value, header, sourceInfo.PageId, sourceInfo.PageName, taskInfo, itemMetadata);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fetches Posts wrt given time interval
        /// </summary>
        /// <param name="taskInfo">contains the time stamps for which data is to be fetched</param>
        /// <param name="sourceInfo">contains data source information</param>
        public async Task FetchPosts(ConnectorTask taskInfo, SourceInfoFB sourceInfo, List <ItemMetadata> itemMetadata)
        {
            string url = QueryFB.GetFeedUrl(taskInfo, sourceInfo);

            Trace.TraceInformation($"Fetching Data from Facebook, TenantId: {taskInfo.TenantId}, JobId: {taskInfo.JobId}, StartTime: {taskInfo.StartTime.ToString()}, EndTime: {taskInfo.EndTime.ToString()}");
            AuthenticationHeaderValue header = new AuthenticationHeaderValue("Bearer", sourceInfo.AccessToken);

            do
            {
                PostListFB list = await this.downloader.GetWebContent <PostListFB, ErrorsFB>(url, header);

                PostFB[] postList       = list.Data;
                PagingFB pagingPointers = list.Paging;
                if (postList.Count() == 0)
                {
                    break;
                }
                foreach (PostFB post in postList)
                {
                    await HandlePost(post, header, sourceInfo.PageId, sourceInfo.PageName, taskInfo, itemMetadata);
                }
                url = pagingPointers?.Next;
            } while (url != null);
        }