Ejemplo n.º 1
0
        public Boolean UpdateScheduleForScreens(ObservableCollection<Schedule> scheduleCollection)
        {
            InitDB();

            using (var session = documentStore.OpenSession())
            {
                var currentSchedule = from x in session.Query<Schedule>()
                                      where x.Screenname != ""
                                      select x;

                ObservableCollection<Schedule> newSchedule = new ObservableCollection<Schedule>();
                //ScheduleCollection newSchedule = new ScheduleCollection();

                if (scheduleCollection.Count > 0)
                {
                    session.Delete(currentSchedule);
                    session.SaveChanges();
                }

                foreach (Schedule schedule in scheduleCollection)
                {
                    Schedule newSch = new Schedule();
                    newSch.Loopname = schedule.Loopname;
                    newSch.Screenname = schedule.Screenname;
                    newSch.Groupname = schedule.Groupname;
                    newSch.Loopstart = schedule.Loopstart;
                    newSch.Loopend = schedule.Loopend;
                    session.Store(newSch);
                }
                session.SaveChanges();
            }

            //SerializeScheduleCollection();
            //SerializeLoopCollection();
            //SerializeLoopContentCollection();
            //SerializeContentCollection();
            //SerializeTemplateCollection();

            return true;
        }
Ejemplo n.º 2
0
 public Boolean InsertScheduleItem(Schedule schedule)
 {
     InitDB();
     using (var session = documentStore.OpenSession())
     {
         Schedule newSchedule = new Schedule();
         newSchedule.Loopid = schedule.Loopid;
         newSchedule.Loopname = schedule.Loopname;
         newSchedule.Screenid = schedule.Screenid;
         newSchedule.Screenname = schedule.Screenname;
         newSchedule.Groupid = schedule.Groupid;
         newSchedule.Groupname = schedule.Groupname;
         newSchedule.Loopstart = schedule.Loopstart;
         newSchedule.Loopend = schedule.Loopend;
         newSchedule.Createdon = schedule.Createdon;
         session.Store(newSchedule);
         session.SaveChanges();
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 public Boolean UpdateScheduleForScreen(Schedule _schedule, string _id)
 {
     InitDB();
     using (var session = documentStore.OpenSession())
     {
         Schedule newSch = new Schedule();
         newSch = session.Load<Schedule>(_id);
         newSch.Loopname = _schedule.Loopname;
         newSch.Screenname = _schedule.Screenname;
         newSch.Groupname = _schedule.Groupname;
         newSch.Loopstart = _schedule.Loopstart;
         newSch.Loopend = _schedule.Loopend;
         session.Store(newSch);
         session.SaveChanges();
     }
     return true;
 }
Ejemplo n.º 4
0
        private void SelectNewCurrentScheduleAndFireIfRequired()
        {
            //Decide if current schedule is valid, if not collect,media and templates & fire new schedule
            si.sie("SelectNewCurrentScheduleAndFireIfRequired()");
            Boolean foundSchedule = false;
            try
            {
                //Display
                foreach (DAL.Schedule schedule in scheduleCollection)
                {   DateTime dtStart = new DateTime();
                    DateTime dtEnd = new DateTime();
                    dtStart = (DateTime)schedule.Loopstart;
                    dtEnd = (DateTime)schedule.Loopend;
                    dtEnd.AddSeconds(-7);
                    long scheduleFrom = dtStart.Ticks;
                    long scheduleTo = dtEnd.Ticks;
                    DateTime dtnow = new DateTime();
                    dtnow = DateTime.Now.AddSeconds(10);
                    long schedulenow= dtnow.Ticks;
                    if (schedulenow>=scheduleFrom && schedulenow<=scheduleTo && schedule.Screenname == Properties.Settings.Default.ClientID)
                    {
                        foundSchedule = true;
                        si.sii("Found Schedule = True");
                        if (currentSchedule.Id != schedule.Id)
                        {
                            windupDisplay();
                            currentSchedule = schedule;
                            ConfigureAndTriggerSchedule(currentSchedule);
                            si.sii("Firing:" + schedule.Loopname);
                        }
                    }
                }

                //Group
                if (foundSchedule == false)
                {
                    foreach (DAL.Schedule schedule in scheduleCollection)
                    {
                        DateTime dtStart = new DateTime();
                        DateTime dtEnd = new DateTime();
                        dtStart = (DateTime)schedule.Loopstart;
                        dtEnd = (DateTime)schedule.Loopend;
                        dtEnd.AddSeconds(-7);
                        long scheduleFrom = dtStart.Ticks;
                        long scheduleTo = dtEnd.Ticks;
                        DateTime dtnow = new DateTime();
                        dtnow = DateTime.Now.AddSeconds(10);
                        long schedulenow = dtnow.Ticks;
                        if (schedulenow >= scheduleFrom && schedulenow <= scheduleTo && schedule.Groupname == _GROUPID)
                        {
                            si.sii("Firing:" + schedule.Loopname);
                            foundSchedule = true;
                            if (currentSchedule.Id != schedule.Id)
                            {
                                windupDisplay();
                                currentSchedule = schedule;
                                ConfigureAndTriggerSchedule(currentSchedule);
                                si.sii("Firing:" + schedule.Loopname);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                si.sii("SELECT NEW CURRENT AND FIRE IF REQUIRED EXCEPTION:"+ex.Message);
            }
            si.sil("SelectNewCurrentScheduleAndFireIfRequired()");
        }
Ejemplo n.º 5
0
 public string InsertNewScheduleForScreen(Schedule _schedule)
 {
     InitDB();
     using (var session = documentStore.OpenSession())
     {
         Schedule newSch = new Schedule();
         newSch.Loopname = _schedule.Loopname;
         newSch.Screenname = _schedule.Screenname;
         newSch.Groupname = _schedule.Groupname;
         newSch.Loopstart = _schedule.Loopstart;
         newSch.Loopend = _schedule.Loopend;
         session.Store(newSch);
         session.SaveChanges();
         return newSch.Id;
     }
     return "";
 }