Beispiel #1
0
        private void tm_Tick(object sender, ElapsedEventArgs e)
        {
            //EndTimer();


            //&& DateTime.Now.ToString("HH:mm tt") == "00:00"
            if (DateTime.Now.DayOfWeek == DayOfWeek.Thursday && DateTime.Now.ToString("HH") == "17")
            {
                //Console.Beep(300, 1000);
                DBservices     db = new DBservices();
                List <Trainee> tl = db.GetLazyTrainees();

                for (int i = 0; i < tl.Count; i++)
                {
                    PushNotification pn = new PushNotification();
                    pn.To    = tl[i].Token;
                    pn.Title = "benefit";
                    pn.Body  = "hi " + tl[i].FirstName + " we've missed you!";
                    pn.Badge = 1;
                    this.PushNotification(pn);
                }


                List <Trainer> trl = db.GetLazyTrainers();
                for (int i = 0; i < tl.Count; i++)
                {
                    PushNotification pn = new PushNotification();
                    pn.To    = trl[i].Token;
                    pn.Title = "benefit";
                    pn.Body  = "hi " + trl[i].FirstName + " we've missed you!";
                    pn.Badge = 1;
                    this.PushNotification(pn);
                }
            }

            // if (DateTime.Now.ToString("HH") == "00" || DateTime.Now.ToString("HH") == "04")
            {
                DBservices db = new DBservices();

                db.DeleteNotActive();  // delets : current trainer/trainee and active groups
                db.UpdateSuggestionsStatus();
                db.UpdateTrainingsStatus();
                List <User> ul = db.CheckMinParticipants_AllGroups();

                for (int i = 0; i < ul.Count; i++)
                {
                    PushNotification pn = new PushNotification();
                    pn.To    = ul[i].Token;
                    pn.Title = "Benefit";
                    pn.Body  = "Your group is canceled :(";
                    pn.Badge = 1;
                    this.PushNotification(pn);
                }
            }
        }