Ejemplo n.º 1
0
        // This is a quick(ish) way to scan all the programmes in pips_programmes
        // and find all gaps in the schedule.
        // Note that this process will find all actual gaps where
        // the channel is not transmitting
        private void ScanGaps_Click(object sender, RoutedEventArgs e)
        {
            List <Gap> gaps = new List <Gap>();

            Task.Factory.StartNew(() =>
            {
                StringBuilder sql = new StringBuilder();
                sql.AppendLine("insert into gaps (programme_id, service_id, gapstart,gapend)");                        // VALUES(1234,1,"2007-06-28 03:00","2007-06-28 06:00")
                using (var data = new ReduxItems())
                {
                    var programmes = (from prog in data.pips_programmes
                                      //orderby prog.ServiceId, prog.StartTime
                                      select prog).ToList();
                    programmes = (from prog in programmes
                                  orderby prog.service_id, prog.start_gmt
                                  select prog).ToList();
                    PipsProgramme prev = null;
                    using (var newdata = new ReduxItems())
                    {
                        foreach (var prog in programmes)
                        {
                            if (prev != null && prev.service_id == prog.service_id && prev.end_gmt < prog.start_gmt)
                            {
                                Gap gap = new Gap
                                {
                                    pips_id    = prog.id,
                                    service_id = prog.service_id,
                                    gapstart   = prev.end_gmt,
                                    gapend     = prog.start_gmt
                                };
                                newdata.gaps.Add(gap);
                                Dispatcher.Invoke((MyDelegate) delegate { gapLabel.Content = string.Format("{0}", gap.gapstart); });
                            }
                            if (prev == null || prog.service_id != prev.service_id || prog.end_gmt > prev.end_gmt)
                            {
                                prev = prog;
                            }
                        }
                        newdata.SaveChanges();
                    }
                    Dispatcher.Invoke((MyDelegate) delegate { gapGrid.ItemsSource = data.gaps; });
                }
            });
        }
Ejemplo n.º 2
0
 private void NewProgramme(object sender, RoutedEventArgs e)
 {
     //programmesEntities entities = new programmesEntities();
     //var result = from item in entities.pips_programmes select item;
     //result.First().
     using (var items = new ReduxItems())
     {
         var newProgramme = new PipsProgramme()
         {
             start_time     = new DateTime(2007, 9, 27, 10, 0, 0),
             end_time       = new DateTime(2007, 9, 27, 10, 30, 0),
             duration       = 30 * 60,
             service_id     = 1,
             service_name   = "bbcfour",
             programme_name = "Life on Mars",
             description    = "Cop Show in the 70s",
             pid            = "b00b8989",
             matched        = true
         };
         items.pips_programmes.Add(newProgramme);
         items.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public ReduxViewModel(ReduxItem redux, PipsProgramme pips, ReduxToPips join)
 {
     ReduxItem        = redux;
     Programme        = pips;
     ReduxToProgramme = join;
 }