예제 #1
0
 /// <summary>Raised when files after downloaded is finished.</summary>
 /// <param name="eventArgs">file recieved arguments.</param>
 /// <returns>true if it succeeds, false if it fails.</returns>
 public void RaiseOnFileReceivedNotificationEvent(FileReceivedArgs eventArgs)
 {
     lock (_subscriberLock)
     {
         NotifyEventHandlersAsync(eventArgs, _fileReceivedNotificationEventHandlers);
     }
 }
예제 #2
0
 /// <summary>Raises the on file received notification event.</summary>
 /// <param name="args">The arguments.</param>
 public void RaiseOnFileReceivedNotificationEvent(FileReceivedArgs args)
 {
     if (_t2gManager != null)
     {
         _t2gManager.RaiseOnFileReceivedNotificationEvent(args);
     }
 }
        /// <summary>Process Files Received Notification.</summary>
        /// <param name="folderId">folder id.</param>
        public void OnFilesReceivedNotification(int folderId)
        {
            lock (_lock)
            {
                FileReceivedArgs frArgs = new FileReceivedArgs();
                frArgs.FolderId  = folderId;
                frArgs.RequestId = new Guid();

                _notifierTarget.RaiseOnFileReceivedNotificationEvent(frArgs);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="status"></param>
        private static void OnFileReceived(object sender, FileReceivedArgs status)
        {
            LogManager.WriteLog(TraceType.INFO, "OnFileReceived called", "PIS.Ground.Infotainment.Journaling.JournalingService.OnFileReceived", null, EventIdEnum.InfotainmentJournaling);

            try
            {
                string      lGetFolderInformationError;
                IFolderInfo lFolderInfo = _t2gManager.T2GFileDistributionManager.GetFolderInformation(status.FolderId, out lGetFolderInformationError);
                if (lFolderInfo != null)
                {
                    Guid lRequestId = new Guid(lFolderInfo.FolderName);                     // The folder name should have the GUID-formatted name, this is our request ID

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

                    lParamMap.Add(NOTIFICATION_PARAMETER_ELEMENT_ID, lFolderInfo.SystemId);
                    lParamMap.Add(NOTIFICATION_PARAMETER_FOLDER_ID, lFolderInfo.FolderId.ToString());
                    lParamMap.Add(NOTIFICATION_PARAMETER_FTP_IP, lFolderInfo.FtpIP);
                    lParamMap.Add(NOTIFICATION_PARAMETER_FTP_PATH, lFolderInfo.FtpPath);
                    lParamMap.Add(NOTIFICATION_PARAMETER_FTP_PORT, lFolderInfo.FtpPort.ToString());
                    lParamMap.Add(NOTIFICATION_PARAMETER_FTP_USERNAME, lFolderInfo.Username);
                    lParamMap.Add(NOTIFICATION_PARAMETER_FTP_PASSWORD, lFolderInfo.Pwd);

                    SendNotificationToGroundApp(lRequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.InfotainmentDownloadCompleted, lParamMap);

                    Guid   lSessionId;
                    string lSessionMgrError = _sessionManager.GetSessionIdByRequestId(lRequestId, out lSessionId);

                    lock (_lock)
                    {
                        if (String.IsNullOrEmpty(lSessionMgrError))
                        {
                            _newRequests.Add(
                                new NotifyReportRetrievedRequestContext(
                                    lFolderInfo.SystemId,
                                    lRequestId,
                                    (uint)lFolderInfo.FolderId,
                                    lSessionId,
                                    MAX_REQUEST_TIMEOUT));
                        }
                        else
                        {
                            LogManager.WriteLog(TraceType.ERROR,
                                                "Failure to retrieve Session ID using Request ID. Error: " + lSessionMgrError,
                                                "PIS.Ground.Infotainment.Journaling.JournalingService.OnFileReceived",
                                                null, EventIdEnum.InfotainmentJournaling);
                        }

                        _requestCompletedEvents.Add(new RequestCompletedEvent(lFolderInfo.SystemId, lRequestId));
                    }

                    _transmitEvent.Set();
                }
                else
                {
                    LogManager.WriteLog(TraceType.ERROR, "Failure to retrieve folder info, error " + lGetFolderInformationError, "PIS.Ground.Infotainment.Journaling.JournalingService.OnFileReceived", null, EventIdEnum.InfotainmentJournaling);
                }
            }
            catch (System.Exception e)
            {
                LogManager.WriteLog(TraceType.ERROR, "Exception thrown", "PIS.Ground.Infotainment.Journaling.JournalingService.OnFileReceived", e, EventIdEnum.InfotainmentJournaling);
            }
        }