private void SendToAmssService(string message, string dataId, string amssEndpoint, Identity identity) { var paramList = new List <KeyValuePair <string, string> >(); var p1 = new KeyValuePair <string, string>("dataId", dataId); paramList.Add(p1); p1 = new KeyValuePair <string, string>("amssEndpoint", amssEndpoint); paramList.Add(p1); var requestObj = new CallServiceRequestObj { Body = message, EndpointMethod = WebRequestHelper.CombineUrl(amssEndpoint, "/amss/state_update"), Headers = null, RequestType = "POST", }; try { var headers = new List <Header> { new Header("content-type", "application/xml") }; requestObj.Headers = headers; _logEventService.LogInfo(EventNumber.SPIS_amss_request, EventDataType.PCM, paramList, JsonConvert.SerializeObject(requestObj, Newtonsoft.Json.Formatting.Indented)); var client = new SSC.Internal.SccPrivateService(); var queueResult = client.CallService(requestObj); if (queueResult.StatusCode < 200 || queueResult.StatusCode >= 300) { throw new Exception("Unable to send state update. " + queueResult.StatusCode + " " + queueResult.Body); } _logEventService.LogSuccess(EventNumber.SPIS_amss_response, EventDataType.Other, paramList, JsonConvert.SerializeObject(queueResult, Newtonsoft.Json.Formatting.Indented)); } catch (Exception ex) { log.Error(ex.Message, ex); _logEventService.LogError(EventNumber.SPIS_amss_request, EventType.Error_internal, paramList, JsonConvert.SerializeObject(requestObj, Newtonsoft.Json.Formatting.Indented)); // Send notification var notification = new Interfaces.Notification(); notification.FromOrgName = identity.Name; notification.FromOrgId = identity.UID; notification.FromServiceId = InstanceContext.CallerServiceId; notification.NotificationType = EnumNotificationType.ERROR_MESSAGE; notification.Subject = "Unable to send message"; notification.Body = string.Format("Unable to send message with id {0} to identity {1}, {2}. {3}", dataId, identity.Name, identity.UID, ex.Message); notification.NotificationSource = EnumNotificationSource.SPIS; _notificationService.Notify(notification); } }
/// <summary> /// /// </summary> /// <param name="message"></param> /// <param name="dataId"></param> /// <param name="endpoint"></param> /// <param name="identity"></param> public void SendMessage(string message, string dataId, string endpoint, Identity identity) { var client = new SSC.Internal.SccPrivateService(); string msg = string.Format("Voyageplan with uvid {0} sent to subscriber {1}", dataId, identity.Name); //Add event logging var paramList = new List <KeyValuePair <string, string> >(); var param = new KeyValuePair <string, string>("Message", msg); paramList.Add(param); try { var result = client.CallService(new CallServiceRequestObj { Body = message, EndpointMethod = WebRequestHelper.CombineUrl(endpoint, "voyagePlans?uvid=" + dataId), Headers = new List <Header> { new Header("content-type", "text/xml; charset=utf-8") }, RequestType = "POST", }); if (result.StatusCode != 200) { throw new Exception(result.Body); } log.Info(msg); _logEventService.LogSuccess(EventNumber.VIS_publishMessage, EventDataType.RTZ, paramList, message); } catch (Exception ex) { log.Error(ex.Message, ex); //logg event _logEventService.LogError(EventNumber.VIS_publishMessage, EventType.Error_internal, paramList, ex.Message); // Send notification var notification = new Interfaces.Notification(); notification.FromOrgName = identity.Name; notification.FromOrgId = identity.UID; notification.FromServiceId = InstanceContext.CallerServiceId; notification.NotificationType = EnumNotificationType.ERROR_MESSAGE; notification.Subject = "Unable to send message to subscriber"; notification.Body = string.Format("Voyageplan with UVID {0} could not be sent to subscriber {1}, {2}", dataId, identity.Name, identity.UID); notification.NotificationSource = EnumNotificationSource.VIS; _notificationService.Notify(notification); } }