private static void TransmitGetReportRequest(GetReportRequestContext request) { bool lTransmitted = false; ServiceInfo serviceInfo; T2GManagerErrorEnum lRqstResult = _t2gManager.GetAvailableServiceData(request.ElementId, (int)eServiceID.eSrvSIF_ReportExchangeServer, out serviceInfo); switch (lRqstResult) { case T2GManagerErrorEnum.eSuccess: { String lEndpoint = "http://" + serviceInfo.ServiceIPAddress + ":" + serviceInfo.ServicePortNumber; // Check if target element is online bool lIsElementOnline; lRqstResult = _t2gManager.IsElementOnline(request.ElementId, out lIsElementOnline); switch (lRqstResult) { case T2GManagerErrorEnum.eSuccess: if (true == lIsElementOnline) { // Call Report Exchange train service using (ReportExchange.ReportExchangeServiceClient client = new ReportExchange.ReportExchangeServiceClient("ReportExchangeEndpoint", lEndpoint)) { try { String requestIdStr = request.RequestId.ToString(); // Call onboard train Report Exchange Web service ReportExchange.ResultType result; client.GetInfotainmentJournal(ref requestIdStr, out result); // TODO (???) extract Folder ID from request - Check with Malik request.FolderId = result.folderId switch (result) { case ReportExchange.ResultType.ServiceInhibited: SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.InfotainmentDownloadInhibited, request.ElementId); break; case ReportExchange.ResultType.Failure: SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.Failed, request.ElementId); break; case ReportExchange.ResultType.NoEntryFound: SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.InfotainmentDownloadNoReportEntryFound, request.ElementId); lTransmitted = true; break; case ReportExchange.ResultType.Success: lTransmitted = true; break; default: LogManager.WriteLog(TraceType.ERROR, String.Format("Unexpected return value from WebService client: {0}", result), "PIS.Ground.Infotainment.Journaling.JournalingService.TransmitGetReportRequest", null, EventIdEnum.InfotainmentJournaling); break; } } catch (Exception ex) { LogManager.WriteLog(TraceType.ERROR, String.Format("Unexpected error from WebService client: {0}", ex.Message), "PIS.Ground.Infotainment.Journaling.JournalingService.TransmitGetReportRequest", ex, EventIdEnum.InfotainmentJournaling); } finally { if (client.State == CommunicationState.Faulted) { client.Abort(); } } } } break; case T2GManagerErrorEnum.eT2GServerOffline: SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.InfotainmentT2GServerOffline, ""); break; case T2GManagerErrorEnum.eElementNotFound: SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.InfotainmentDownloadElementNotFound, request.ElementId); break; default: break; } } break; case T2GManagerErrorEnum.eT2GServerOffline: SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.InfotainmentT2GServerOffline, ""); break; case T2GManagerErrorEnum.eElementNotFound: SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.InfotainmentDownloadElementNotFound, request.ElementId); break; case T2GManagerErrorEnum.eServiceInfoNotFound: SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.InfotainmentDownloadServiceNotFound, eServiceID.eSrvSIF_ReportExchangeServer.ToString()); break; default: LogManager.WriteLog(TraceType.INFO, "Failed to obtain service data from T2G", "PIS.Ground.Infotainment.Journaling.JournalingService.TransmitGetReportRequest", null, EventIdEnum.InfotainmentJournaling); break; } request.TransmissionStatus = lTransmitted; }
/// <summary> /// /// </summary> /// <param name="sessionId"></param> /// <param name="targetAddress"></param> /// <param name="requestTimeout"></param> /// <returns></returns> public GetReportResponse GetReport(Guid sessionId, TargetAddressType targetAddress, uint requestTimeout) { GetReportResponse result = new GetReportResponse(); result.RequestId = Guid.Empty; result.ResultCode = ResultCodeEnum.InternalError; if (requestTimeout <= MAX_REQUEST_TIMEOUT) { if (_sessionManager.IsSessionValid(sessionId)) { Guid requestId = Guid.Empty; _sessionManager.GenerateRequestID(sessionId, out requestId); if (requestId != Guid.Empty) // TODO requires modification to method GenerateRequestID { ElementList <AvailableElementData> elements; T2GManagerErrorEnum lRqstResult = _t2gManager.GetAvailableElementDataByTargetAddress(targetAddress, out elements); switch (lRqstResult) { case T2GManagerErrorEnum.eSuccess: // Queue to request list foreach (AvailableElementData element in elements) { SendNotificationToGroundApp(requestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.InfotainmentDownloadProcessing, element.ElementNumber); GetReportRequestContext request = new GetReportRequestContext(element.ElementNumber, requestId, sessionId, requestTimeout); lock (_lock) { _newRequests.Add(request); } } // Signal thread and start transmitting _transmitEvent.Set(); result.RequestId = requestId; result.ResultCode = ResultCodeEnum.RequestAccepted; break; case T2GManagerErrorEnum.eT2GServerOffline: result.ResultCode = ResultCodeEnum.T2GServerOffline; break; case T2GManagerErrorEnum.eElementNotFound: switch (targetAddress.Type) { case AddressTypeEnum.Element: result.ResultCode = ResultCodeEnum.UnknownElementId; break; case AddressTypeEnum.MissionCode: result.ResultCode = ResultCodeEnum.UnknownMissionId; break; case AddressTypeEnum.MissionOperatorCode: result.ResultCode = ResultCodeEnum.UnknownMissionId; break; } break; default: break; } } else { result.ResultCode = ResultCodeEnum.InvalidSessionId; } } else { result.ResultCode = ResultCodeEnum.InvalidSessionId; } } else { result.ResultCode = ResultCodeEnum.InvalidRequestTimeout; } return(result); }