private void getNotificationButton_Click(object sender, EventArgs e) { if (notificationId == null) { throw new Exception("No notificationId known"); } using (Connection conn = NewConnection()) { SelectNotification result = conn.GetNotification(notificationId); AddLogLine(string.Format("ID of the place: {0}; message: {1}; data: {2}", result.ID, result.Message, result.Data)); } }
/// <summary> /// Fetch a single notification from the Plot back-end server /// </summary> /// <param name="notificationId">Id og the notification to fetch</param> /// <returns>Entity containing the notification data</returns> public SelectNotification GetNotification(string notificationId) { CheckNotAdmin(); const string Function = "notification"; HttpWebRequest webRequest = GetWebRequest("GET", Function, null, notificationId); GetNotificationResponse response = GetJSONresponse <GetNotificationResponse>(webRequest); if (response == null) { throw new Exception("No response."); } // check the result codes: response.Check(); SelectNotification ret = null; if (response.Result != null) { ret = new SelectNotification() { ID = response.Result.ID, StoreId = response.Result.PlaceId, State = response.Result.State.AsEnum <State>(), Message = response.Result.Message, Data = response.Result.Data, MatchRange = response.Result.MatchRange, Created = response.Result.Created.AsDateTime(true).Value, Timespans = response.Result.Timespans == null ? new Plot.Entities.SelectNotification.Timespan[] { } : response.Result.Timespans.Select(t => new Plot.Entities.SelectNotification.Timespan() { Start = t.Start.AsDateTime(), End = t.End.AsDateTime() }).ToArray() } } ; return(ret); }