public static void SaveTimerEvent(Timerevent timerevent)
        {
            try
            {
                Timerevent te;

                using (fsbDB FSBDB = new fsbDB())
                {
                    te = (from x in FSBDB.Timerevent
                          where x.ID == timerevent.ID
                          select x).FirstOrDefault();

                    foreach (PropertyInfo pi in timerevent.GetType().GetProperties())
                    {
                        if (pi.CanWrite)
                        {
                            pi.SetValue(te, pi.GetValue(timerevent, null), null);
                        }
                    }

                    FSBDB.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                ClsError.CoreError(Name, MethodBase.GetCurrentMethod().ToString(), ex);
            }
        }
 public static int AddTimerEvent(Timerevent timerevent)
 {
     try
     {
         using (fsbDB FSBDB = new fsbDB())
         {
             long newID = (from x in FSBDB.Timerevent select x.ID).DefaultIfEmpty(0).Max() + 1;
             timerevent.ID = newID;
             FSBDB.Timerevent.Add(timerevent);
             FSBDB.SaveChanges();
             return((int)timerevent.ID);
         }
     }
     catch (Exception ex)
     {
         ClsError.CoreError(Name, MethodBase.GetCurrentMethod().ToString(), ex);
         return(0);
     }
 }
        private void ZeitAusloeser(object sender, ClsObjectEventArgs e)
        {
            Timerevent TimerEvent = (Timerevent)e.ObjectArgument;

            switch (TimerEvent.Eventtype)
            {
            case 0:
            {
                // Timer stoppen
                this.ClockStop(TimerEvent.TimerNr);
                GlobalServerEvents.SendMessage(null, new ClsStringEventArgs(ClsRequests.DataRequest(new ClsCommand(command: "TimerObjects"))));
                break;
            }

            case 1:
            {
                // anderen Timer starten
                if (TimerEvent.AndereTimerNr > 0)
                {
                    this.ClockStart(TimerEvent.AndereTimerNr);
                    GlobalServerEvents.SendMessage(null, new ClsStringEventArgs(ClsRequests.DataRequest(new ClsCommand(command: "TimerObjects"))));
                }

                break;
            }

            case 2:
            {
                // anderen Timer stoppen
                if (TimerEvent.AndereTimerNr > 0)
                {
                    this.ClockStop(TimerEvent.AndereTimerNr);
                    GlobalServerEvents.SendMessage(null, new ClsStringEventArgs(ClsRequests.DataRequest(new ClsCommand(command: "TimerObjects"))));
                }

                break;
            }

            case 3:
            {
                // Audio abspielen
                ClsSoundplayer.Instance.TPlay(TimerEvent.Soundfile + "|" + 75);
                break;
            }

            case 4:
            {
                // Layer wechsel
                if (!string.IsNullOrEmpty(TimerEvent.Layer))
                {
                    long id = Convert.ToInt64(TimerEvent.Layer);

                    DisplayPageSet ps = (from x in ClsDisplayControler.DisplayPageSets() where x.ID == ClsPageSets.ActivePageSet() select x).FirstOrDefault();

                    // prüfen ob ID tatsächlich noch existiert
                    long p = (from x in ClsDisplayControler.DisplayPagesForPageSet(ps.ID) where x.ID == id select x.ID).FirstOrDefault();

                    if (p != 0)
                    {
                        ClsDisplay.SetPage(ClsPageSets.ActivePageSet(), (int)p);

                        GlobalServerEvents.SendMessage(null, new ClsStringEventArgs(ClsRequests.DataRequest(new ClsCommand(command: "ActivePage"))));

                        GlobalServerEvents.SendMessage(null, new ClsStringEventArgs(ClsRequests.DataRequest(new ClsCommand(command: "DivsActivePage", pageSet: ps.PageSetName, page: p.ToString()))));
                    }
                }

                break;
            }
            }
        }