Esempio n. 1
0
        public async Task<ActionResult> UpdateCacheFromGitHub()
        {
            string postedJson = string.Empty;

            try
            {
                using (var streamReader = new System.IO.StreamReader(Request.InputStream))
                {
                    postedJson = streamReader.ReadToEnd();
                }
                GitHubPostedCommit posted = JsonConvert.DeserializeObject<GitHubPostedCommit>(postedJson);
                IEnumerable<BlogPost> newposts = Enumerable.Empty<BlogPost>();
                //try
                //{
                    var gh = new Data.GitHub();
                    newposts = await gh.GetItemsForBranchCommit(posted);

                    var localFileCache = new LocalFileCache();

                    //delete items if any.
                    foreach (string blogUrlSlug in posted.RemovedPosts)
                    {
                        localFileCache.RemovePost(blogUrlSlug);
                    }
                //}
                //catch (Exception) { }
                
                try
                {
                    await SyncAzureIndex(newposts, posted.RemovedPosts);
                }
                catch (Exception) { }


                return new HttpStatusCodeResult(HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message);
            }

        }
Esempio n. 2
0
        public async Task CanProcessPostedWebhook()
        {

            GitHubPostedCommit posted = JsonConvert.DeserializeObject<GitHubPostedCommit>(GitHubJsonMessages.GitHubCommitValidMsg);

            var gh = new Thyme.Web.Data.GitHub();
            var newposts =  await gh.GetItemsForBranchCommit(posted);

            LocalFileCache lfc = new LocalFileCache();

            foreach (var blogPostSlug in posted.RemovedPosts)
            {
                lfc.RemovePost(blogPostSlug);
            }

            foreach (BlogPost blogPost in newposts)
            {
                lfc.SaveLocalItem(blogPost);
            }
            

        }