Exemplo n.º 1
0
        /// <summary>
        /// Transafer a file
        /// </summary>
        /// <param name="lines"></param>
        /// <param name="fname"></param>
        /// <returns></returns>
        public bool Send(List <String> lines, string fname)
        {
            FileTransferLog ftLog = new FileTransferLog()
            {
                TransferType  = FileTransferType.PutFile,
                FileName      = fname,
                RemoteAddress = _ftpCredentials.Hostname
            };
            bool success;

            try
            {
                ftLog.Size   = PutFile(lines, fname);
                ftLog.Result = "Success";
                success      = true;
            }
            catch (Exception x)
            {
                StringBuilder xsb = new StringBuilder(x.Message);
                if (x.InnerException != null)
                {
                    xsb.Append(Environment.NewLine + x.InnerException.Message);
                }
                xsb.Append(Environment.NewLine + x.StackTrace);
                ftLog.Result = xsb.ToString();
                success      = false;
            }
            _logger.Log(_logName, ftLog.Json);
            return(success);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets a file from ftp server and stores it in a blob
        /// </summary>
        /// <param name="fname"></param>
        /// <param name="blobContainerName"></param>
        /// <param name="deleteFile"></param>
        /// <returns></returns>
        public FileTransferLog Get(string fname, string blobContainerName, bool deleteFile = true)
        {
            // prepare the log entry:
            FileTransferLog ftLog = new FileTransferLog()
            {
                TransferType  = FileTransferType.GetFile,
                FileName      = fname,
                RemoteAddress = _ftpCredentials.Hostname
            };

            try
            {
                // FTP transfer:
                byte[] bytes = GetFile(fname, deleteFile);
                ftLog.Result = "Success";
                ftLog.Size   = bytes.Length;
                // Blob Storage:
                string    blobId    = fname;
                BlobAgent blobAgent = new BlobAgent(_storageCredentials, blobContainerName);
                blobAgent.Add(blobId, bytes);
                ftLog.BlobId = string.Format("{0}/{1}", blobContainerName, blobId);
            }
            catch (Exception x)
            {
                StringBuilder xsb = new StringBuilder(x.Message);
                if (x.InnerException != null)
                {
                    xsb.Append(Environment.NewLine + x.InnerException.Message);
                }
                xsb.Append(Environment.NewLine + x.StackTrace);
                ftLog.Result = xsb.ToString();
            }
            _logger.Log(_logName, ftLog.Json);
            return(ftLog);
        }
Exemplo n.º 3
0
 private FileUploader(string srcPath, string destPath, AdlsClient client, int numThreads,
                      IfExists doOverwrite, IProgress <TransferStatus> progressTracker, bool notRecurse, bool resume, bool isBinary, CancellationToken cancelToken, bool ingressTest, long chunkSize) : base(srcPath, destPath, client, numThreads, doOverwrite, progressTracker, notRecurse, resume, ingressTest, chunkSize, Path.Combine(Path.GetTempPath(), ".adl", "Upload", GetTransferLogFileName(srcPath, destPath, Path.DirectorySeparatorChar, '/')), cancelToken, $"binary:{isBinary}")
 {
     // If not recurse then we will have one thread and ProducerFirstPass logic loop will run only once
     NumProducerThreads    = NotRecurse ? 1 : NumProducerThreadsFirstPass;
     UploaderProducerQueue = new QueueWrapper <DirectoryInfo>(NumProducerThreads);
     if (FileTransferLog.IsDebugEnabled)
     {
         FileTransferLog.Debug($"FileTransfer.Uploader, Src: {SourcePath}, Dest: {DestPath}, Threads: {NumConsumerThreads}, TrackingProgress: {ProgressTracker != null}, OverwriteIfExist: {DoOverwrite == IfExists.Overwrite}");
     }
     _isBinary   = isBinary;
     _encodeType = Encoding.UTF8;
 }
        private FileDownloader(string srcPath, string destPath, AdlsClient client, int numThreads,
                               IfExists doOverwrite, IProgress <TransferStatus> progressTracker, bool notRecurse, bool disableTransferLogging, bool resume, CancellationToken cancelToken, bool egressTest, int egressBufferCapacity, long chunkSize) : base(srcPath, destPath, client, numThreads, doOverwrite, progressTracker, notRecurse, disableTransferLogging, resume, egressTest, chunkSize, Path.Combine(Path.GetTempPath(), ".adl", "Download", GetTransferLogFileName(client.AccountFQDN, srcPath, destPath, '/', Path.DirectorySeparatorChar)), cancelToken)
        {
            EgressBufferCapacity = egressBufferCapacity;

            // If not recurse then we will have one thread and ProducerFirstPass logic loop will run only once
            NumProducerThreads      = notRecurse ? 1 : NumProducerThreadsFirstPass;
            DownloaderProducerQueue = new QueueWrapper <DirectoryEntry>(NumProducerThreads);
            DownloaderList          = new List <DirectoryEntry>(DownloaderListCapacity);
            if (FileTransferLog.IsDebugEnabled)
            {
                FileTransferLog.Debug($"FileTransfer.Downloader, Src: {SourcePath}, Dest: {DestPath}, Threads: {NumConsumerThreads}, TrackingProgress: {ProgressTracker != null}, OverwriteIfExist: {DoOverwrite == IfExists.Overwrite}");
            }
        }