示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool GetTumblrStats()
        {
            var url = TumblrApiHelper.GeneratePostTypeQueryUrl(TumblrDomain, TumblrPostType.All, 0, 1);

            if (url.TumblrExists())

            {
                DocumentManager.GetRemoteDocument(url);
                TotalPostsOverall = DocumentManager.GetTotalPostCount();

                var postTypes = Enum.GetValues(typeof(TumblrPostType)).Cast <TumblrPostType>().ToHashSet();
                postTypes.RemoveWhere(type => type == TumblrPostType.All || type == TumblrPostType.Regular || type == TumblrPostType.Conversation);

                foreach (TumblrPostType type in postTypes)
                {
                    int TotalPostsForType = 0;
                    url = TumblrApiHelper.GeneratePostTypeQueryUrl(TumblrDomain, type, 0, 1);

                    if (url.TumblrExists())
                    {
                        DocumentManager.GetRemoteDocument(url);
                        TotalPostsForType = DocumentManager.GetTotalPostCount();

                        switch (type)
                        {
                        case TumblrPostType.Photo:
                            TotalPhotoPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Text:
                            TotalTextPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Video:
                            TotalVideoPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Audio:
                            TotalAudioPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Link:
                            TotalLinkPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Quote:
                            TotalQuotePosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Chat:
                            TotalChatPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Answer:
                            TotalAnswerPosts = TotalPostsForType;
                            break;
                        }

                        PostTypesProcessedCount++;

                        ProcessingStatusCode = ProcessingCode.Ok;
                    }
                    else
                    {
                        ProcessingStatusCode = ProcessingCode.InvalidUrl;
                    }
                }
            }

            return(true);
        }