public void DownloadTest_TC_Sw_GroundCore_Classes_0009_A2_A() { DownloadFolderRequest objDownloadFolderRequest = null; string res = PIS.Ground.Core.Utility.FtpUtility_Accessor.Download(ref objDownloadFolderRequest); Assert.AreNotEqual(string.Empty, res); }
/// <summary> /// Callback called when a download folder is published on the train (signaled by the T2G client) /// </summary> /// <param name="sender"></param> /// <param name="status"></param> private static void OnFilesPublished(object sender, FilePublishedNotificationArgs status) { LogManager.WriteLog(TraceType.INFO, "OnFilesPublished called, folderId=" + status.FolderId + " systemId=" + status.SystemId, "PIS.Ground.Infotainment.Journaling.JournalingService.OnFilesPublished", null, EventIdEnum.InfotainmentJournaling); try { string lGetFolderInformationError; IFolderInfo lFolderInfo = _t2gManager.T2GFileDistributionManager.GetRemoteFolderInformation(status.FolderId, status.SystemId, ConfigurationSettings.AppSettings["ApplicationId"], out lGetFolderInformationError); if (lFolderInfo != null) { List <RecipientId> lRecipientIdList = new List <RecipientId>(); RecipientId lRecipient = new RecipientId(); lRecipient.ApplicationId = ConfigurationSettings.AppSettings["ApplicationId"]; lRecipient.MissionId = string.Empty; lRecipient.SystemId = "ground"; lRecipientIdList.Add(lRecipient); DownloadFolderRequest objRequest = new DownloadFolderRequest( new Guid(lFolderInfo.FolderName), // The folder name should have the GUID-formatted name, this is our request ID lFolderInfo.ExpirationDate, // Set to the folder's expiration date lFolderInfo.FolderName, lRecipientIdList, DateTime.Now, //Start date: now "InfotainmentJournaling Service Transfer Task", FileTransferMode.AnyBandwidth, 16, //normal priority new EventHandler <FileDistributionStatusArgs>(OnFilesDistribution), status.FolderId); objRequest.SystemId = status.SystemId; objRequest.Compression = false; String lErrorMessage = _t2gManager.T2GFileDistributionManager.DownloadFolder(objRequest); if (!String.IsNullOrEmpty(lErrorMessage)) { LogManager.WriteLog(TraceType.ERROR, "T2G DownloadFolder failure, error " + lErrorMessage, "PIS.Ground.Infotainment.Journaling.JournalingService.OnFilesPublished", null, EventIdEnum.InfotainmentJournaling); } } else { LogManager.WriteLog(TraceType.ERROR, "Failure to retrieve folder info, error " + lGetFolderInformationError, "PIS.Ground.Infotainment.Journaling.JournalingService.OnFilesPublished", null, EventIdEnum.InfotainmentJournaling); } } catch (System.Exception e) { LogManager.WriteLog(TraceType.ERROR, "Exception thrown", "PIS.Ground.Infotainment.Journaling.JournalingService.OnFilesPublished", e, EventIdEnum.InfotainmentJournaling); } }
/// <summary>Downloads the given objDownloadFolderRequest.</summary> /// <param name="objDownloadFolderRequest">[in,out] The object download folder request.</param> /// <returns>.</returns> internal static string Download(ref DownloadFolderRequest objDownloadFolderRequest) { string error = string.Empty; if (objDownloadFolderRequest != null && objDownloadFolderRequest.Folderinfo != null && !string.IsNullOrEmpty(objDownloadFolderRequest.Folderinfo.FtpIP) && !string.IsNullOrEmpty(objDownloadFolderRequest.Folderinfo.Username) && !string.IsNullOrEmpty(objDownloadFolderRequest.Folderinfo.Pwd) && objDownloadFolderRequest.Folderinfo.FileList.Count > 0) { foreach (fileInfoStruct fileInfoStruct in objDownloadFolderRequest.Folderinfo.FileList) { DateTime dtCurrentTime = DateTime.Now; if (!string.IsNullOrEmpty(fileInfoStruct.path)) { bool downResp = false; while (DateTime.Now.Subtract(dtCurrentTime).TotalMinutes > TimeOut && !downResp) { FtpStatusCode ftpStatusCode; downResp = DownloadFile(objDownloadFolderRequest.DownloadFolderPath, fileInfoStruct.path, objDownloadFolderRequest.Folderinfo.FtpIP, objDownloadFolderRequest.Folderinfo.Username, objDownloadFolderRequest.Folderinfo.Pwd, out ftpStatusCode); if (!downResp && (ftpStatusCode == FtpStatusCode.ServiceNotAvailable || ftpStatusCode == FtpStatusCode.ServiceTemporarilyNotAvailable)) { Thread.Sleep(RetryPeriod); } if (!downResp && (ftpStatusCode == FtpStatusCode.ActionNotTakenFileUnavailable || ftpStatusCode == FtpStatusCode.ActionNotTakenFileUnavailableOrBusy)) { error = "File " + fileInfoStruct.path + " does not exist."; return(error); } } if (DateTime.Now.Subtract(dtCurrentTime).TotalMinutes > TimeOut && !downResp) { error = "T2G Ground Server not responding for " + TimeOut + " period downloading terminated"; return(error); } } else { error = "Invalid Input parameter"; return(error); } } } else { error = "Invalid Input parameter"; } return(error); }