Пример #1
0
        static void Main(string[] args)
        {
            string certificatesFolder   = System.Configuration.ConfigurationManager.AppSettings["certificate_path"];
            string certificatesPassword = System.Configuration.ConfigurationManager.AppSettings["certificate_password"];

            InitFactories();

            using (var db = new NotificationsModel())
            {
                char input;
                do
                {
                    Product p0 = db.Products.Find(1);
                    p0.Price = 0.49;
                    db.SaveChanges();
                    PushService service = PushService.Instance;
                    service.Init(certificatesFolder, certificatesPassword, "", "", db.Notifications);
                    service.Push();

                    // Restore the normal state
                    p0.Price = 0.99;
                    db.SaveChanges();
                    input = Console.ReadKey().KeyChar;
                } while (input == 'c');
            }
        }
Пример #2
0
        /// <summary>
        /// StartAsync Service
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public override Task StartAsync(CancellationToken cancellationToken)
        {
            try
            {
                courseIds       = configService.Config.Learnweb.Courses;
                pushoverToken   = configService.Config.Pushover.Token;
                pushoverUser    = configService.Config.Pushover.Recipient;
                refreshDuration = configService.Config.Service.Refresh;

                ServiceStatus activityStatus = activityService.Init();
                ServiceStatus pushStatus     = pushService.Init();

                if (activityStatus == ServiceStatus.OK && pushStatus == ServiceStatus.OK)
                {
                    return(base.StartAsync(cancellationToken));
                }
                else
                {
                    logger.LogError("Could not initialize 'Learnweb Notifier Service'");
                    return(base.StopAsync(cancellationToken));
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
                return(base.StopAsync(cancellationToken));
            }
        }