当前位置: 首页>>代码示例>>C#>>正文


C# Services.ProgrammesUrl方法代码示例

本文整理汇总了C#中Services.ProgrammesUrl方法的典型用法代码示例。如果您正苦于以下问题:C# Services.ProgrammesUrl方法的具体用法?C# Services.ProgrammesUrl怎么用?C# Services.ProgrammesUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Services的用法示例。


在下文中一共展示了Services.ProgrammesUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScanWholeDay

        private void ScanWholeDay(DateTime date)
        {
            reduxItems = new ReduxItems();
            Dispatcher.Invoke((MyDelegate)delegate { dateScanning.Content = date.ToString("dd/MM/yyyy"); });
            Services services = new Services();
            DateTime dayStart = date.Date;
            DateTime dayEnd = dayStart.AddDays(1);
            //if (reduxItems.Scanned.Any(p => p.DateScanned == dayStart) == false)
            //{
                Dispatcher.Invoke((MyDelegate)delegate { working.Content = "Working..."; });
                List<XElement> programmeElements = new List<XElement>();
                //var dayItems = from item in reduxItems.Items
                //               where item.Aired >= dayStart && item.Aired < dayEnd
                //               select item;
                foreach (var sid in services.Select(s=>s.Id))
                {
                    Dispatcher.Invoke((MyDelegate)delegate { working.Content = "Working... " + services[sid].Name; });
                    string url = services.ProgrammesUrl(sid, dayStart);
                    XElement schedule = XElement.Load(url);
                    var items = from element in schedule.Element("day").Element("broadcasts").Elements("broadcast")
                                select new XElement("programme", new XAttribute("serviceid", sid), element);
                    XElement previous = null;
                    foreach (var item in items)
                    {
                        if (previous != null)
                        {
                            var st = previous.Element("broadcast").GetElementDate("end");
                            var en = item.Element("broadcast").GetElementDate("start");
                            if (st < en)
                            {
                                if ((sid == 1 || sid == 6) && en.Hour == 19 && en.Minute == 0)
                                {
                                }
                                else
                                {

                                }
                            }
                        }
                        previous = item;
                    }
                    programmeElements.AddRange(items);
                }

                var programmes = from element in programmeElements
                                 let broadcast = element.Element("broadcast")
                                 let episode = broadcast.Elements("programme").First(e => e.Attribute("type").Value == "episode")
                                 select new PipsProgramme()
                                 {
                                     service_id = element.GetAttributeInt("serviceid"),
                                     service_name = services[element.GetAttributeInt("serviceid")].Name,
                                     start_time = broadcast.GetElementDate("start"),
                                     end_time = broadcast.GetElementDate("end"),
                                     duration = broadcast.GetElementInt("duration"),
                                     programme_name = episode.Element("title").Value,
                                     display_title = episode.Element("display_titles").Element("title").Value,
                                     display_subtitle = episode.Element("display_titles").Element("subtitle").Value,
                                     pid = episode.Element("pid").Value,
                                     description = episode.Element("short_synopsis").Value,
                                     rawdata = element.ToString()
                                 };

                //foreach (var item in dayItems)
                //{
                //    var matched = (from programme in programmeElements
                //                   where programme.GetAttributeInt("serviceid") == item.ServiceId
                //                   && programme.Element("broadcast").GetElementDate("start").ToUniversalTime() == item.Aired
                //                   select programme).FirstOrDefault();
                //    if (matched != null)
                //    {
                //        var broadcast = matched.Element("broadcast");
                //        item.IsStartTimeMatched = true;
                //        int duration = broadcast.GetElementInt("duration");
                //        item.IsDurationMatched = duration == item.DurationSecs;
                //        var episode = (from ep in broadcast.Elements("programme")
                //                       where ep.Attribute("type").Value == "episode"
                //                       select ep).First();
                //        //item.PipsName = episode.Element("display_titles").Element("title").Value;
                //        //item.TitleMatch = item.PipsName == item.ProgrammeName;
                //        //item.Pid = episode.Element("pid").Value;
                //        //item.PipsDurationSecs = broadcast.GetElementInt("duration");
                //    }

                //    item.IsChecked = true;
                //}
                DateTime timerstart = DateTime.Now;
                var already = (from p in reduxItems.pips_programmes
                               where p.start_time >= dayStart && p.start_time < dayEnd
                               select p).ToList();
                foreach (var prog in programmes)
                {
                    if (already.Any(p => p.service_id == prog.service_id && p.start_time == prog.start_time) == false)
                    {
                        reduxItems.pips_programmes.Add(prog);
                    }
                }
                //reduxItems.Scanned.Add(new Scanned() { DateScanned = dayStart });
                //reduxItems.SaveChanges();
                DateTime timerend = DateTime.Now;
                Dispatcher.Invoke((MyDelegate)delegate { working.Content = "took " + (timerend - timerstart).ToString(); });
//.........这里部分代码省略.........
开发者ID:JimLynn,项目名称:MatchRedux,代码行数:101,代码来源:DayScan.xaml.cs


注:本文中的Services.ProgrammesUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。