private void FileTransferredCallback( object sender, TransferEventArgs e, ICollection <BlobInfo> allFilesStream) { var source = (CloudBlockBlob)e.Source; var destination = (CloudBlockBlob)e.Destination; allFilesStream.Add( new BlobInfo( path: destination.Name, size: GetSize(source.Properties.Length), contentType: source.Properties.ContentType, contentLength: source.Properties.Length, meta: source.Metadata, created: source.Properties.Created, updated: source.Properties.LastModified ) ); _logger.LogInformation( "Transferred {0}/{1} -> {2}/{3}", source.Container.Name, source.Name, destination.Container.Name, destination.Name ); }
internal void TransferEventArgs_Instantiates_With_The_Given_Data(TransferDirection direction, string username, string filename, int token, TransferOptions options) { var dl = new Transfer(direction, username, filename, token, options); var d = new TransferEventArgs(dl); Assert.Equal(direction, d.Direction); Assert.Equal(0, d.AverageSpeed); Assert.Equal(0, d.BytesTransferred); Assert.Equal(0, d.BytesRemaining); Assert.Equal(default(TimeSpan), d.ElapsedTime); Assert.Equal(default(TimeSpan), d.RemainingTime); Assert.Null(d.StartTime); Assert.Null(d.EndTime); Assert.Null(d.IPAddress); Assert.Equal(0, d.PercentComplete); Assert.Null(d.Port); Assert.Equal(dl.RemoteToken, d.RemoteToken); Assert.Equal(0, d.Size); Assert.Equal(dl.Username, d.Username); Assert.Equal(dl.Filename, d.Filename); Assert.Equal(dl.Token, d.Token); Assert.Equal(dl.State, d.State); Assert.Equal(options, d.Options); Assert.Equal(dl.Data, d.Data); }
private static void InvokeTransfers(IWorkItemBase item, IWorkSheetBase sheet) { TransferEventArgs args = new TransferEventArgs(); //todo: check changes TransferEventPublisher.Invoke(args); }
private ConcurrentDictionary <string, Download> GetNewDictionary(TransferEventArgs args) { var r = new ConcurrentDictionary <string, Download>(); r.AddOrUpdate(args.Filename, new Download(args), (key, value) => new Download(args)); return(r); }
public void AddOrUpdate(TransferEventArgs args) { Downloads.AddOrUpdate(args.Username, GetNewDictionary(args), (user, dict) => { dict.AddOrUpdate(args.Filename, new Download(args), (file, download) => new Download(args)); return(dict); }); }
private void Context_FileTransferred(object sender, TransferEventArgs e) { if (Operation == OperationType.COPY && this.Direction == TransferDirection.UP && SourceFiles.Length == 1) { DestinationBlob = (CloudBlockBlob)e.Destination; } L.Info("Transfer of file {file} completed in {millisec} ms.", e.Source, (e.EndTime - e.StartTime).TotalMilliseconds); }
internal void TransferEventArgs_Instantiates_With_The_Given_Data(TransferDirection direction, string username, string filename, int token, TransferOptions options) { var dl = new TransferInternal(direction, username, filename, token, options); var xfer = new Transfer(dl); var d = new TransferEventArgs(xfer); Assert.Equal(xfer, d.Transfer); }
void trans_ProgressChanged(object sender, TransferEventArgs e) { var trans = (FileTransfer)sender; progressBar1.Value = e.Progress.ProgressPercentage; labprog.Text = string.Format("{0}KB/s {1}/{2}#{3}", e.Progress.GetSpeed(), e.Progress.BytesTransferred, e.Progress.ContentLength, e.Config.ChunkCount); }
private void FileTransferred(object sender, TransferEventArgs e) { if (e.Error == null) { this.LogTransfer($"Upload of {e.FileName} succeeded"); } else { this.LogTransfer($"Upload of {e.FileName} failed: {e.Error}"); } if (e.Chmod != null) { if (e.Chmod.Error == null) { this.LogTransfer($"Permissions of {e.Chmod.FileName} set to {e.Chmod.FilePermissions}"); } else { this.LogTransfer($"Setting permissions of {e.Chmod.FileName} failed: {e.Chmod.Error}"); } } else { this.LogTransfer($"Permissions of {e.Destination} kept with their defaults"); } if (e.Touch != null) { if (e.Touch.Error == null) { this.LogTransfer($"Timestamp of {e.Touch.FileName} set to {e.Touch.LastWriteTime}"); } else { this.LogTransfer($"Setting timestamp of {e.Touch.FileName} failed: {e.Touch.Error}"); } } else { // This should never happen during "local to remote" synchronization this.LogTransfer($"Timestamp of {e.Destination} kept with its default (current time)"); } if (e.Removal != null) { if (e.Removal.Error == null) { this.LogTransfer($"Removed of {e.Removal.FileName} succeeded."); } else { this.LogTransfer($"Removed of {e.Removal.FileName} failed: {e.Removal.Error}."); } } }
private void Context_FileFailed(object sender, TransferEventArgs e) { if (CT.IsCancellationRequested) { L.Warn("Transfer of file {file} was cancelled before completion by the user.", e.Source); } else { L.Warn("Transfer of file {file} failed.", e.Source); } }
/// <summary> /// FileTransferred event handler. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event arguments.</param> protected virtual void OnFileTransferred(object sender, TransferEventArgs e) { if (e.Error == null) { Logger.Log($"{e.FileName} have been uploaded"); } else { Logger.Log($"{e.FileName} failed: {e.Error}"); } }
private void OnFileTransferred(object sender, TransferEventArgs e) { if (e.Error == null) { this.logger.Information($"Upload of {e.FileName.ToShortFileName()} succeeded"); } else { this.logger.Error(e.Error, $"Error upload file {e.FileName.ToShortFileName()}"); } }
private void TransferManagerTransferAdded(object sender, TransferEventArgs e) { if (Settings.DumpTransferProtocolMessages) { e.Transfer.IncomingMessage += IncomingMessageHandler; e.Transfer.OutgoingMessage += OutgoingMessageHandler; } if (Settings.BackgroundSeedMode) { e.Transfer.UseBackgroundSeedMode = true; } }
private static void TransferContext_FileFailed(object sender, TransferEventArgs e) { // We need to trap transfer failures in this event handler rather than CopyDirectoryAsync() // Add the transfer error information from the FileFailed event into the List object // This will be written to the WebJobs log _failedFiles.Add(new TransferDetail { Source = e.Source, Destination = e.Destination, Error = e.Exception.Message }); }
private void Context_BlobFailed(object sender, TransferEventArgs e) { CloudBlob source = (CloudBlob)e.Source; if (CT.IsCancellationRequested) { L.Warn("Transfer of blob {blob} was cancelled before completion by the user.", source.Name); } else { L.Warn("Transfer of blob {blob} failed.", source.Name); } }
private void FileSkippedCallback(object?sender, TransferEventArgs e) { var source = (CloudBlockBlob)e.Source; var destination = (CloudBlockBlob)e.Destination; _logger.LogInformation( "Skipped transfer {0}/{1} -> {2}/{3}", source.Container.Name, source.Name, destination.Container.Name, destination.Name ); }
private void FileFailedCallback(object?sender, TransferEventArgs e) { var source = (CloudBlockBlob)e.Source; var destination = (CloudBlockBlob)e.Destination; _logger.LogInformation( "Failed to transfer {0}/{1} -> {2}/{3}. Error message: {4}", source.Container.Name, source.Name, destination.Container.Name, destination.Name, e.Exception.Message ); }
private static void TransferContext_FileSkipped(object sender, TransferEventArgs e) { // This is largely optional. Files can be skipped if the source and destination are the same for Incremental Copies // So this information does not always represent an error that occurred but is driven by the OverwriteCallback // Add the transfer error information from the FileSkipped event into the List object // This will be written to the WebJobs log _skippedFiles.Add(new TransferDetail { Source = e.Source, Destination = e.Destination, Error = e.Exception.Message }); }
private static void ResultHandler(object sender, TransferEventArgs e) { LogWriter logger = HostLogger.Get <Synchronizer>(); if (e.Error == null) { logger.Info(String.Format("Synchronization of file {0} from {1} directory is complete!", e.FileName, e.Side.ToString())); } else { logger.Error(String.Format("Upload of {0} failed: {1}", e.FileName, e.Error)); } }
/// <summary> /// WINSCP API function for logging /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FileTransferred(object sender, TransferEventArgs e) { if (e.Error == null) { Console.WriteLine("Upload of {0} succeeded", e.FileName); } else { Console.WriteLine("Upload of {0} failed: {1}", e.FileName, e.Error); } if (e.Chmod != null) { if (e.Chmod.Error == null) { Console.WriteLine( "Permissions of {0} set to {1}", e.Chmod.FileName, e.Chmod.FilePermissions); } else { Console.WriteLine( "Setting permissions of {0} failed: {1}", e.Chmod.FileName, e.Chmod.Error); } } else { Console.WriteLine("Permissions of {0} kept with their defaults", e.Destination); } if (e.Touch != null) { if (e.Touch.Error == null) { Console.WriteLine( "Timestamp of {0} set to {1}", e.Touch.FileName, e.Touch.LastWriteTime); } else { Console.WriteLine( "Setting timestamp of {0} failed: {1}", e.Touch.FileName, e.Touch.Error); } } else { // This should never happen during "local to remote" synchronization Console.WriteLine( "Timestamp of {0} kept with its default (current time)", e.Destination); } }
static void _transfer_Completed(object sender, TransferEventArgs e) { var trans = (FileTransfer)sender; var header = JsonConvert.DeserializeObject <JsonHeader>(e.Config.State.ToString()); string sourceFilePath = string.Format(@"{0}{1}\{2}{3}", InfrastructureRepository.RootPath, trans.DirectoryPath, header.FileKey, Path.GetExtension(e.Config.FileName)); if (header.FileKey != CryptoManaged.MD5HashFile(sourceFilePath).ToString()) { File.Delete(sourceFilePath); return; } var repository = new InfrastructureRepository(); repository.SaveFile(header.FileKey, e.Config.FileName, sourceFilePath); }
void _trans_Prepare(object sender, TransferEventArgs e) { if (MainForm.Confirm(string.Format("是否接收文件{0}?", e.Config.FileName), "文件传输")) { TaskHelper.Factory.StartNew(() => { var form = new TransferForm(); form.Start(_trans); form.Show(); }); } else { e.Cancel = true; } }
private void TransferManagerTransferRemoved(object sender, TransferEventArgs e) { lock (_speedSyncRoot) { _totalUploaded += e.Transfer.UploadSpeed.Total; _totalDownloaded += e.Transfer.DownloadSpeed.Total; } if (Settings.DumpTransferProtocolMessages) { e.Transfer.IncomingMessage -= IncomingMessageHandler; e.Transfer.OutgoingMessage -= OutgoingMessageHandler; } e.Transfer.Dispose(); }
private static void FileTransferred(object sender, TransferEventArgs e) { if (e.Error == null) { Console.WriteLine("\n" + @"Загружен {0} успешно", e.FileName); } else { Console.WriteLine("\n" + @"Не загружен {0} ошибка: {1}", e.FileName, e.Error); } if (e.Chmod != null) { if (e.Chmod.Error == null) { Console.WriteLine( "Разрешения {0} установить {1}", e.Chmod.FileName, e.Chmod.FilePermissions); } else { Console.WriteLine( "Установка разрешения {0} неудача: {1}", e.Chmod.FileName, e.Chmod.Error); } } else { Console.WriteLine("Разрешения {0} по умолчанию", e.Destination); } if (e.Touch != null) { if (e.Touch.Error == null) { Console.WriteLine( "Временная метка {0} установлена в {1}", e.Touch.FileName, e.Touch.LastWriteTime); } else { Console.WriteLine( "Временная метка {0} не установлена в {1}", e.Touch.FileName, e.Touch.Error); } } else { Console.WriteLine( "Временная метка {0} сохраняется по умолчанию (текущее время)", e.Destination); } }
/// <summary> /// 捕获文件传输过程中发生的事 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FileTransCatch(object sender, TransferEventArgs e) { if (e.Error == null) { build.AppendLine("Upload of " + e.FileName + " succeeded"); stringFileNames.Add(e.FileName); } else { build.AppendLine("Upload of " + e.FileName + " failed:" + e.Error); } if (e.Chmod != null) { if (e.Chmod.Error == null) { build.AppendLine("Permisions of " + e.Chmod.FileName + " set to " + e.Chmod.FilePermissions); } else { build.AppendLine("Setting permissions of " + e.Chmod.FileName + " failed: " + e.Chmod.Error); } } else { build.AppendLine("Permissions of " + e.Destination + " kept with their defaults"); } if (e.Touch != null) { if (e.Touch.Error == null) { build.AppendLine("Timestamp of " + e.Touch.FileName + " set to " + e.Touch.LastWriteTime); } else { build.AppendLine("Setting timestamp of " + e.Touch.FileName + " failed: " + e.Touch.Error); } } else { // This should never happen during "local to remote" synchronization build.AppendLine("Timestamp of " + e.Destination + " kept with its default (current time)"); } }
private void FileTransferred(object sender, TransferEventArgs e) { if (e.Error == null) { txtResult.AppendText(string.Format("Upload of {0} succeeded", e.FileName.ToString()) + Environment.NewLine); } else { txtResult.AppendText(string.Format("Upload of {0} failed: {1}", e.FileName.ToString(), e.Error.ToString()) + Environment.NewLine); } if (e.Chmod != null) { if (e.Chmod.Error == null) { txtResult.AppendText(string.Format("Permisions of {0} set to {1}", e.Chmod.FileName.ToString(), e.Chmod.FilePermissions.ToString()) + Environment.NewLine); } else { txtResult.AppendText(string.Format("Setting permissions of {0} failed: {1}", e.Chmod.FileName.ToString(), e.Chmod.Error.ToString()) + Environment.NewLine); } } else { txtResult.AppendText(string.Format("Permissions of {0} kept with their defaults", e.Destination.ToString()) + Environment.NewLine); } if (e.Touch != null) { if (e.Touch.Error == null) { txtResult.AppendText(string.Format("Timestamp of {0} set to {1}", e.Touch.FileName.ToString(), e.Touch.LastWriteTime.ToString()) + Environment.NewLine); } else { txtResult.AppendText(string.Format("Setting timestamp of {0} failed: {1}", e.Touch.FileName.ToString(), e.Touch.Error.ToString()) + Environment.NewLine); } } else { // This should never happen with Session.SynchronizeDirectories txtResult.AppendText(string.Format("Timestamp of {0} kept with its default (current time)", e.Destination.ToString()) + Environment.NewLine); //updateSyncLogs(String.Format("Timestamp of {0} kept with its default (current time)", e.Destination.ToString) } }
void session_FileTransferred(object sender, TransferEventArgs e) { if (e.Error == null) { log.Info(string.Format("檔案傳輸成功: {0} ", e.FileName)); } else { this.ErrorMsg = "檔案傳輸失敗: 檔案名稱:" + e.FileName + "\r錯誤訊息:" + e.Error.StackTrace; throw new Exception("Upload of " + e.FileName + " failded: " + e.Error.Message); } if (e.Chmod != null) { if (e.Chmod.Error == null) { log.Info("檔案權限: " + e.Chmod.FileName + "設定 \r 權限訊息:" + e.Chmod.FilePermissions); } else { this.ErrorMsg = "檔案權限錯誤: 檔案名稱:" + e.Chmod.FileName + "\r權限錯誤訊息:" + e.Chmod.Error.StackTrace; throw new Exception("Permision of " + e.Chmod.FileName + " failed" + e.Chmod.Error.Message); } } else { log.Info(string.Format("檔案權限: {0} 維持預設值", e.Destination)); } if (e.Touch != null) { if (e.Touch.Error == null) { log.Info(string.Format("時間戳設置: {0} set to {1}", e.Touch.FileName, e.Touch.LastWriteTime)); } else { this.ErrorMsg = string.Format("時間戳設置錯誤: {0} \r 錯誤訊息: {1}", e.Touch.FileName, e.Touch.Error.StackTrace); throw new Exception("Setting timestamp of " + e.Touch.FileName + " failed: " + e.Touch.Error.Message); } } else { log.Info(string.Format("時間戳設置: {0} 維持預設值(current time)", e.Destination)); } }
internal Download(TransferEventArgs e) { Filename = e.Filename; Username = e.Username; AverageSpeed = e.AverageSpeed; BytesTransferred = e.BytesTransferred; BytesRemaining = e.BytesRemaining; ElapsedTime = e.ElapsedTime; EndTime = e.EndTime; IPAddress = e.IPAddress; PercentComplete = e.PercentComplete; Port = e.Port; RemainingTime = e.RemainingTime; RemoteToken = e.RemoteToken; Size = e.Size; StartTime = e.StartTime; State = e.State; Token = e.Token; }
static void _transfer_Prepare(object sender, TransferEventArgs e) { var trans = (FileTransfer)sender; if (e.Config.State == null) { throw new InvalidOperationException("Config.State"); } var header = JsonConvert.DeserializeObject <JsonHeader>(e.Config.State.ToString()); trans.DirectoryPath = header.AppID.ToString("N"); var repository = new InfrastructureRepository(); e.Cancel = repository.ExistFile(new QueryFileParameter() { AppID = header.AppID, FileKey = header.FileKey }); }
/// <summary> /// Callback from the FTP client. This is called when a file has been downloaded /// We're just sending a message to the current window so it can update its view /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void Connection_TransferCompleteEx(object sender, TransferEventArgs e) { Log.Info("FTPConnection: Transfer completed: {0}->{1}", e.RemoteFilename, e.LocalFilePath); try { FTPClient ftpclient = sender as FTPClient; foreach (FtpConnection client in ftpConnections) { if (client.Connection == ftpclient) { GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_FILE_DOWNLOADED, 0, 0, 0, 0, 0, null); msg.Label = client.OriginalRemoteFileName; msg.Label2 = client.LocalFileName; GUIGraphicsContext.SendMessage(msg); return; } } } catch (Exception ex) { Log.Error(ex); } }
/// <summary> /// Deploys a structure recursively. Works in the current remote directory. /// </summary> /// <param name="structure"></param> private void DeployStructure(DeploymentStructure structure, string remoteBasePath) { // Deploy files string currentRemotePath = null; foreach(DeploymentFile file in structure.Files) { if(currentRemotePath != file.RemotePath) { ChangeRemoteDirectory(Path.Combine(remoteBasePath, file.RemotePath)); // Will create the directory if not existing currentRemotePath = file.RemotePath; } // // Get files in directory // string[] remoteFiles = _ftp.Dir(); // Signal that transfer started _currentTransferEventArgs = new TransferEventArgs(file.LocalPath); EventManager.OnTransferBegin(_currentTransferEventArgs); // Start transferring (FTPClient will raise events about the progress) _ftp.Put(file.LocalPath, file.Name); // Signal that transfer is complete EventManager.OnTransferComplete(_currentTransferEventArgs); } // Verify that directories exist // foreach(DeploymentStructure dir in structure.Directories) { // // Create directory? // if(Array.IndexOf(remoteFiles, dir.Name) == -1) // _ftp.MkDir(dir.Name); // } // Deploy each directory (will change the current remote directory) // foreach(DeploymentStructure dir in structure.Directories) { // DeployStructure(dir, string.Format("{0}/{1}", remotePath, dir.Name)); // } }