示例#1
0
文件: RDB.cs 项目: keyanmca/_Signage
        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;
        }
示例#2
0
文件: RDB.cs 项目: keyanmca/_Signage
 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;
 }
示例#3
0
文件: RDB.cs 项目: keyanmca/_Signage
 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;
 }
示例#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()");
        }
示例#5
0
文件: RDB.cs 项目: keyanmca/_Signage
 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 "";
 }