示例#1
0
        // GET: Notification/Pull
        public ActionResult Pull()
        {
            var notification = _client.GetNotification();

            HandleNotification(notification);

            return(View(notification));
        }
        public void Execute(IJobExecutionContext context)
        {
            DpApi _client = new DpApi(AppSettings.ClientId, AppSettings.ClientSecret, (Locale)AppSettings.Locale);
            var   db      = new HospitalContext();
            NotificationHandler handler = new NotificationHandler(_client, db);

            while (true)
            {
                Notification notification = _client.GetNotification();
                string       json         = JsonConvert.SerializeObject(notification, new JsonSerializerSettings
                {
                    ContractResolver = new SnakeCaseContractResolver(),
                    Formatting       = Formatting.Indented
                });

                if (notification != null && notification.Message == null)
                {
                    try
                    {
                        log.Warn("Parsing notification:");
                        log.Warn(json);
                        handler.HandleNotification(notification);
                    }
                    catch (Exception ex)
                    {
                        var dpEx = new DPNotificationException("Couldn't process the notifiation data", ex);
                        dpEx.Data.Add("notificationData", json);
                        log.Error("Couldn't process the notifiation data", dpEx);
                    }
                }
                else
                {
                    break;
                }
            }
        }