Beispiel #1
0
        private async Task <ObservableCollectionCustomized <BroadcastModelGroup> > getSpotvDataAll(DateTime dateTime)
        {
            BroadcastModelGroup group = await getSpotvDataByChannel(dateTime, SpotvService.SPOTV_ONE);

            if (group.Count > 0)
            {
                broadcastModelList.Add(group);
            }

            group = await getSpotvDataByChannel(dateTime, SpotvService.SPOTV_TWO);

            if (group.Count > 0)
            {
                broadcastModelList.Add(group);
            }

            group = await getSpotvDataByChannel(dateTime, SpotvService.SPOTV_PLUS);

            if (group.Count > 0)
            {
                broadcastModelList.Add(group);
            }

            return(broadcastModelList);
        }
Beispiel #2
0
        private bool getIsAlreadyHas(BroadcastModelGroup group, SkySportsModel model)
        {
            SkySportsModel modelAlready;

            for (int i = 0; i < group.Count; ++i)
            {
                modelAlready = (Tnb.SkySportsModel)group[i];

                if (modelAlready.Time == model.Time || modelAlready.Title == model.Title)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #3
0
        public async void OnDateChanged(object sender, DateChangedEventArgs e)
        {
            HasNetworkProblem = false;

            IsBusy = true;

            BroadcastModelList.Clear();

            //await getDataTest( "http://m.sports.naver.com/basketball/schedule/index.nhn?category=nba&date=20170224" );
            await getSpotvDataAll(e.DateTimeTarget);

            BroadcastModelGroup group = await getSkySportsData(e.DateTimeTarget);

            if (group.Count > 0)
            {
                broadcastModelList.Add(group);
            }

            IsBusy = false;
        }
Beispiel #4
0
        private async Task <BroadcastModelGroup> getSpotvDataByChannel(DateTime dateTime, string strChannel)
        {
            BroadcastModelGroup group = new BroadcastModelGroup();

            group.Channel     = strChannel;
            group.ChannelShow = SpotvService.getChannelToDisplay(strChannel);

            // add yesterday midnight.
            ObservableCollectionCustomized <IBroadcastModel> gotModelList = await getSpotvData(dateTime.AddDays(-1), SpotvService.DAY_PART_NIGHT, strChannel, true);

            group.AddRange(gotModelList);

            gotModelList = await getSpotvData(dateTime, SpotvService.DAY_PART_MORNING, strChannel);

            group.AddRange(gotModelList);
            gotModelList = await getSpotvData(dateTime, SpotvService.DAY_PART_EVENING, strChannel);

            group.AddRange(gotModelList);
            gotModelList = await getSpotvData(dateTime, SpotvService.DAY_PART_NIGHT, strChannel);

            group.AddRange(gotModelList);

            return(group);
        }
Beispiel #5
0
        public BroadcastModelGroup MakeSkySportsData(string strHTML, DateTime dateTime)
        {
            BroadcastModelGroup group = new BroadcastModelGroup();

            group.Channel     = SkySportsService.CHANNEL;
            group.ChannelShow = group.Channel;

            int startIdx = strHTML.IndexOf("<html", System.StringComparison.Ordinal);

            if (startIdx > 0)
            {
                strHTML = strHTML.Substring(startIdx);
            }

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(strHTML);

            List <DateTime> dateTimeSkySports = getDateTimeSkySports(doc);

            if (!getHasDate(dateTime, dateTimeSkySports))
            {
                return(group);
            }

            SkySportsModel model;

            int nDayCurrent = (int)dateTime.DayOfWeek;

            //IEnumerable<HtmlNode> trNode = doc.DocumentNode.Descendants( "tr" ).Where(x => x.ParentNode.Name == "tbody");

            foreach (HtmlNode element in doc.DocumentNode.Descendants("tr"))
            {
                if (element.ParentNode.Name != "tbody")
                {
                    continue;
                }
                // 24 lines.

                int nSeq = 0;

                foreach (HtmlNode element2 in element.Descendants("td"))
                {
                    if (element2.ParentNode != element)
                    {
                        continue;
                    }

                    ++nSeq;

                    if (nSeq == 1)
                    {
                        continue;
                    }

                    int nDay = nSeq - 2;

                    bool isYesterday = nDay == nDayCurrent - 1;

                    if (!isYesterday && nDay != nDayCurrent)
                    {
                        continue;
                    }

                    if (element2.OuterHtml.IndexOf("NBA", StringComparison.Ordinal) == -1)
                    {
                        continue;
                    }

                    foreach (HtmlNode element3 in element2.Descendants("p"))
                    {
                        if (element3.OuterHtml.IndexOf("NBA", StringComparison.Ordinal) == -1)
                        {
                            continue;
                        }

                        model = new SkySportsModel();

                        string strTime = element2.Descendants("p").Where(x => x.GetAttributeValue("class", "") == "dateTxt mb10").First().InnerText;

                        model.Time    = strTime;
                        model.Channel = SkySportsService.CHANNEL;
                        model.Kind    = BroadcastStruct.RERUN;
                        model.Title   = element2.Descendants("span").First().InnerText;

                        model.DayPart = SkySportsService.getDayPartToDisplay(model.Time);

                        if (!getIsAlreadyHas(group, model))
                        {
                            group.Add(model);
                        }
                    }
                }
            }

            Debug.WriteLine(group.Count);

            return(group);
        }