Ejemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] NotificationJson NotificationMsg)
        {
            Microsoft.Azure.NotificationHubs.NotificationOutcome outcome = null;
            HttpStatusCode ret = HttpStatusCode.InternalServerError;

            int count = PlacesController.inProgress.Where(x => x.Name == NotificationMsg.Message).Count();

            if (count == 0)
            {
                PlacesController.inProgress.Add(places.GetFiltereBar(NotificationMsg.Message));
            }



            Dictionary <string, string> templateParams = new Dictionary <string, string>();

            templateParams["messageParam"] = "Breaking News!";

            GcmNotification notification = new GcmNotification("{ \"data\":{\"message\":\"" + NotificationMsg.Message + "\"} }");

            outcome = await Notification.Notification.Instance.Hub.SendNotificationAsync(notification);



            if (outcome != null)
            {
                if (!((outcome.State == Microsoft.Azure.NotificationHubs.NotificationOutcomeState.Abandoned) ||
                      (outcome.State == Microsoft.Azure.NotificationHubs.NotificationOutcomeState.Unknown)))
                {
                    ret = HttpStatusCode.OK;
                }
            }

            return(Ok("OK"));
        }
        public JsonResult GetAllCurrentNotifications()
        {
            List <NotificationJson> notifications = new List <NotificationJson>();

            //List<FootageStorage> videos = _FootageStorageService.GetAllCurrent();

            NotificationJson notification = new NotificationJson
            {
                DateTimeCaptureStartUtc = DateTime.UtcNow,
                DateTimeCaptureEndUtc   = DateTime.UtcNow,
                Tags = "tags",
                TriggerDescription       = "Type of Trigger",
                TriggerConfidencePercent = (decimal).50,
                FileLocation             = "FileLocation",
                FileName = "Sample File",

                APIResultTypeName = "Result Type",

                DeviceName = "Device Name 1",

                is_read = false,
            };

            notifications.Add(notification);
            notification = new NotificationJson
            {
                DateTimeCaptureStartUtc = DateTime.UtcNow,
                DateTimeCaptureEndUtc   = DateTime.UtcNow,
                Tags = "tags",
                TriggerDescription       = "Type of Trigger",
                TriggerConfidencePercent = (decimal).50,
                FileLocation             = "FileLocation",
                FileName = "Sample File",

                APIResultTypeName = "Result Type",

                DeviceName = "Device Name 2",

                is_read = false,
            };
            notifications.Add(notification);

            return(Json(notifications));
        }
        public JsonResult GetNotifications(string channel_id)
        {
            Guid channel_guid;

            if (Guid.TryParse(channel_id, out channel_guid))
            {
                List <FootageStorage>   storages      = _FootageStorageService.GetAllForChannel(channel_guid);
                List <NotificationJson> notifications = new List <NotificationJson>();
                foreach (FootageStorage storage in storages)
                {
                    NotificationJson notification = new NotificationJson
                    {
                        IdFootageStorage        = storage.IdFootageStorage.ToString(),
                        DateTimeCaptureStartUtc = storage.DateTimeCaptureStartUtc,
                        DateTimeCaptureEndUtc   = storage.DateTimeCaptureEndUtc,
                        Tags = storage.Tags,
                        TriggerDescription       = storage.TriggerDescription,
                        TriggerConfidencePercent = storage.TriggerConfidencePercent,
                        FileLocation             = storage.FileLocation,
                        FileName = storage.FileName,

                        //APIResultTypeName = storage.APIResultType.Name,

                        DeviceName = storage.FileName,

                        is_read = storage.IsReviewed,
                    };
                    notifications.Add(notification);
                }

                return(Json(notifications));
            }
            else
            {
                return(Json(new Result()
                {
                    result = "Failure",
                    result_description = "Invalid GUID format",
                    status_code = 406
                }));
            }
        }