Example #1
0
 public static Tracker GetModel(TrackerDo trackerDo, string lang, string game)
 {
     Tracker tracker = new Tracker()
     {
         LanguageAbbrev = lang.ToLower(),
         RealItemCount = trackerDo.TotalItems,
         PageTitle = trackerDo.PageTitle,
         CurrentPage = trackerDo.CurrentPage,
         SecondaryTitle1 = trackerDo.SecondaryTitle1,
         SecondaryTitle2 = trackerDo.SecondaryTitle2,
         GameAbbrev = game.ToLower(),
         UserLanguageAbbrev = lang
     };
     Tracker tracker1 = tracker;
     foreach (TrackerItemDo trackerItem in trackerDo.TrackerItems)
     {
         TrackerItem trackerItem1 = new TrackerItem()
         {
             BlueReplyCount = trackerItem.NoReplies,
             BoardNumber = trackerItem.SubForumBlizzId,
             EntryType = (ItemType)trackerItem.EntryType,
             Game = trackerItem.GameAbbrev.ToLower(),
             Id = trackerItem.EntryId,
             LastBlue = trackerItem.LastBluePoster,
             OpSummaryRaw = trackerItem.OpSummary,
             Region = trackerItem.RegionAbbrev.ToLower(),
             SubForum = trackerItem.SubForumName,
             ThreadAuthor = trackerItem.Author,
             TimeOfLatestPost = trackerItem.LastUpdateTime,
             Title = trackerItem.ThreadTitle,
             Lang = trackerItem.LanguageAbbrev.ToLower()
         };
         tracker1.TrackerItems.Add(trackerItem1);
     }
     return tracker1;
 }
Example #2
0
        public TrackerDo GetTrackerByBlog(string game, string lang, string region, int page)
        {
            if (game == null)
                throw new ArgumentNullException("game");
            if (lang == null)
                throw new ArgumentNullException("lang");
            if (region == null)
                throw new ArgumentNullException("region");

            game = game.ToUpper();
            lang = lang.ToUpper();
            region = region.ToUpper();

            TrackerDo tracker = new TrackerDo();

            var db = new TrackerDataContext(DbConnectionString.Value);

            tracker.CurrentPage = page;

            var trackerQuery = from t in db.TrackerTableListItems
                               where t.Game == game
                                && t.Lang == lang
                                && t.Region == region
                                && t.EntryType == 1
                               orderby t.TimeOfLatestPost descending
                               select t;

            List<TrackerTableListItem> trackerListItems = (trackerQuery).Skip((page - 1) * 50).Take(50).ToList();

            //TODO: This should be detected in the frontend, and appropriate action taken.
            tracker.PageTitle = "{REPLACE WITH GAME}";

            tracker.TotalItems = trackerQuery.Count();
            tracker.TrackerItems = GetItemsDomainObjects(trackerListItems);

            if (tracker.TotalItems > 0)
            {
                tracker.SecondaryTitle1 = tracker.TrackerItems[0].SubForumName;
            }

            return tracker;
        }
Example #3
0
        public TrackerDo GetTrackerByPosterName(string posterName, int page)
        {
            if (posterName == null)
                throw new ArgumentNullException("posterName");

            TrackerDo tracker = new TrackerDo();
            var dbTracker = new TrackerDataContext(DbConnectionString.Value);
            var dbForumBlogs = new ForumBlogsDataContext(DbConnectionString.Value);

            var threadQuery = (from p in dbForumBlogs.Posts
                               where p.PosterName == posterName
                               && p.PosterType == 2
                               select p.Topic).Distinct().OrderByDescending(x => x.LastPostDate);

            List<int> threadsPostedIn = threadQuery.Skip((page - 1) * 50).Take(50).Select(x => x.Id).ToList();

            var trackerQuery = from t in dbTracker.TrackerTableListItems
                               where threadsPostedIn.Contains(t.BlogOrTopicId)
                               && t.EntryType == 0
                               orderby t.TimeOfLatestPost descending
                               select t;

            List<TrackerTableListItem> trackerListItems = (trackerQuery).ToList();

            tracker.TrackerItems = GetItemsDomainObjects(trackerListItems);
            tracker.PageTitle = posterName;
            tracker.TotalItems = threadQuery.Count();

            return tracker;
        }
Example #4
0
        public TrackerDo GetTwitterConversations(int page, string gameAbbrev)
        {
            if (gameAbbrev == null)
                throw new ArgumentNullException("gameAbbrev");

            gameAbbrev = gameAbbrev.ToUpper();

            TrackerDo tracker = new TrackerDo();
            var db = new TwitterDataContext(DbConnectionString.Value);

            List<TwitterConversation> conversations = new List<TwitterConversation>();
            int itemCount = 0;

            if (gameAbbrev == "ALL")
            {
                var query = (from c in db.TwitterConversations
                             orderby c.LastDevResponseDate descending
                             select c);
                itemCount = query.Count();
                conversations = query.Skip((page - 1) * 50).Take(50).ToList();
            }
            else
            {
                var query = (from c in db.TwitterConversations
                             where c.BlizzArea.Game.GameAbbreviation == gameAbbrev
                             orderby c.LastDevResponseDate descending
                             select c);
                itemCount = query.Count();
                conversations = query.Skip((page - 1) * 50).Take(50).ToList();
            }
            List<TrackerTableListItem> trackerListItems = new List<TrackerTableListItem>();
            foreach (var conversation in conversations)
            {
                TrackerTableListItem item = new TrackerTableListItem
                {
                    BlogOrTopicId = conversation.Id,
                    BoardNumber = 0,
                    EntryNumber = 0,
                    EntryType = 2,
                    Game = conversation.BlizzArea.Game.GameAbbreviation,
                    Id = 0,
                    Lang = conversation.BlizzArea.Language.LanguageAbbreviation,
                    LastBlue = conversation.LastBlueResponder,
                    //LastPoster = "",
                    NoReplies = conversation.Tweets.Count,
                    //OpSummary = conversation.Tweets[0].TweetContentNonHtml,
                    Region = conversation.BlizzArea.Region.RegionAbbreviation,
                    SubForum = "Twitter",
                    ThreadAuthor = conversation.Tweets[0].TwitterUserName,
                    TimeOfLatestPost = conversation.LastDevResponseDate,
                    Title = conversation.TwitterConvTitle
                };

                trackerListItems.Add(item);
            }

            tracker.TrackerItems = GetItemsDomainObjects(trackerListItems);
            tracker.PageTitle = "Twitter";
            tracker.TotalItems = itemCount;

            return tracker;
        }
Example #5
0
        public TrackerDo GetTracker(string game, string lang, string p, bool includeBlogs, bool includeThreads, bool includeTwitter)
        {
            if (String.IsNullOrEmpty(game))
                throw new ArgumentNullException("game");
            if (String.IsNullOrEmpty(lang))
                throw new ArgumentNullException("lang");

            List<short> rawIncludes = new List<short>();
            if (includeThreads)
                rawIncludes.Add(0);
            if (includeBlogs)
                rawIncludes.Add(1);
            if (includeTwitter)
                rawIncludes.Add(2);

            int page = 1;
            if (!String.IsNullOrEmpty(p))
            {
                if (!(int.TryParse(p, out page)))
                {
                    throw new ArgumentException("p");
                }
            }

            game = game.ToUpper();
            lang = lang.ToUpper();

            TrackerDo tracker = new TrackerDo();
            tracker.CurrentPage = page;

            List<TrackerTableListItem> trackerListItems = null;

            var db = new TrackerDataContext(DbConnectionString.Value);

            if (game == "ALL")
            {
                trackerListItems = (from t in db.TrackerTableListItems
                                    where t.Lang == lang
                                    && rawIncludes.Contains(t.EntryType)
                                    orderby t.TimeOfLatestPost descending
                                    select t).Skip((page - 1) * 50).Take(50).ToList();

                tracker.TotalItems = (from t in db.TrackerTableListItems
                                      where t.Lang == lang
                                      && rawIncludes.Contains(t.EntryType)
                                      select t).Count();

            }
            else
            {
                trackerListItems = (from t in db.TrackerTableListItems
                                    where t.Lang == lang
                                    && t.Game == game
                                    && rawIncludes.Contains(t.EntryType)
                                    orderby t.TimeOfLatestPost descending
                                    select t).Skip((page - 1) * 50).Take(50).ToList();

                tracker.TotalItems = (from t in db.TrackerTableListItems
                                      where t.Lang == lang
                                      && t.Game == game
                                      && rawIncludes.Contains(t.EntryType)
                                      select t).Count();
            }

            tracker.TrackerItems = GetItemsDomainObjects(trackerListItems);

            if (game == "ALL")
            {
                tracker.PageTitle = "Home"; //this would be the home page.
                tracker.TotalItems = (from t in db.TrackerTableListItems
                                      where t.Lang == lang
                                      && rawIncludes.Contains(t.EntryType)
                                      select t).Count();
            }
            else
            {
                //TODO: This should be detected in the frontend, and appropriate action taken.
                tracker.PageTitle = "{REPLACE WITH GAME}";
            }

            return tracker;
        }