public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string _file = "/Resources/Images/"; FileTransferType _transferType = (FileTransferType)values[0]; FileTransferStatus _status = (FileTransferStatus)values[1]; PausedBy _pausedBy = (PausedBy)values[2]; switch (_transferType) { case FileTransferType.Download: _file += "Download"; break; case FileTransferType.Upload: _file += "Upload"; break; } switch (_status) { case FileTransferStatus.Cancelled: _file += "Cancelled"; break; case FileTransferStatus.Error: _file += "Error"; break; case FileTransferStatus.Finished: _file += "Finished"; break; case FileTransferStatus.Paused: _file += "Paused"; switch (_pausedBy) { case PausedBy.User: _file += "ByUser"; break; case PausedBy.OtherPeer: _file += "ByOtherPeer"; break; case PausedBy.Both: _file += "ByBoth"; break; } break; case FileTransferStatus.Running: _file += "Running"; break; } _file += ".png"; return((new System.Windows.Media.ImageSourceConverter()).ConvertFromString("pack://application:,,," + _file)); }
public FileTransferOut(NetworkConnection recipient, FileTransferType fileType, string filePath) { connection = recipient; FileType = fileType; FilePath = filePath; FileName = Path.GetFileName(filePath); Acknowledged = false; SentOffset = 0; KnownReceivedOffset = 0; Status = FileTransferStatus.NotStarted; startingTime = DateTime.Now; int maxRetries = 4; for (int i = 0; i <= maxRetries; i++) { try { data = File.ReadAllBytes(filePath); } catch (System.IO.IOException e) { if (i >= maxRetries) { throw; } DebugConsole.NewMessage("Failed to initiate a file transfer {" + e.Message + "}, retrying in 250 ms...", Color.Red); Thread.Sleep(250); } } }
public FileTransferForm(FileTransferType fileTransferType, string RemoteAddress, string localPath, string serverFilePath, string downloadFileName) { InitializeComponent(); if (fileTransferType == FileTransferType.downloadFile) { DownloadFile(RemoteAddress, localPath, serverFilePath, downloadFileName); } }
public FileTransferIn(NetworkConnection connection, string filePath, FileTransferType fileType) { FilePath = filePath; FileName = Path.GetFileName(FilePath); FileType = fileType; Connection = connection; Status = FileTransferStatus.NotStarted; }
public DevicePage(MainPage mainPageForm) { TransferType = FileTransferType.Online; mainPage = mainPageForm; InitializeComponent(); CreateDragAndDropVisual(); CreateDeviceUploadUI(); ApiCommunication.FileUploadProgress += UploadProgress; }
public FileTransferIn(NetConnection connection, string filePath, FileTransferType fileType) { FilePath = filePath; FileName = Path.GetFileName(FilePath); FileType = fileType; Connection = connection; WriteStream = new FileStream(FilePath, FileMode.Create, FileAccess.Write, FileShare.None); TimeStarted = Environment.TickCount; Status = FileTransferStatus.NotStarted; }
public FileTransferForm(FileTransferType fileTransferType, string RemoteAddress, string localFullPath, string serverUploadPath) { InitializeComponent(); if (fileTransferType == FileTransferType.uploadDir) { UploadDir(RemoteAddress, localFullPath, serverUploadPath); } else { UploadFile(RemoteAddress, localFullPath, serverUploadPath); } }
public FileTransferConfigurationModel FindFileTransferConfigurationModel(int locationId, FileTransferType transferType, FileTransferDataType transferDataType) { var item = db.FindFileTransferConfigurations() .Where(ftc => ftc.LocationId == locationId && ftc.TransferType == (int)transferType && ftc.LOVItem_DataType.ItemValue1 == ((int)transferDataType).ToString() && ftc.Enabled == true) .FirstOrDefault(); return(MapToModel(item)); }
public FileTransferOut(NetConnection recipient, FileTransferType fileType, string filePath) { connection = recipient; FileType = fileType; FilePath = filePath; FileName = Path.GetFileName(filePath); Status = FileTransferStatus.NotStarted; startingTime = DateTime.Now; data = File.ReadAllBytes(filePath); }
public DevicePage(NetworkDevice device, MainPage mainPageForm) { _GUIState = GUIState.WaitingForInput; targetDevice = device; InitializeComponent(); mainPage = mainPageForm; CreateDragAndDropVisual(); DataProcessor.OutboundTransferFinished += Transferfinished; DataProcessor.OutboundTransferStarted += TransferStarted; MaxConcurrentTransfers = 4; TransferType = FileTransferType.Local; CreateDeviceUploadUI(); }
public FileTransferOut StartTransfer(NetworkConnection recipient, FileTransferType fileType, string filePath) { if (activeTransfers.Count >= MaxTransferCount) { return(null); } if (activeTransfers.Count(t => t.Connection == recipient) > MaxTransferCountPerRecipient) { return(null); } if (!File.Exists(filePath)) { DebugConsole.ThrowError("Failed to initiate file transfer (file \"" + filePath + "\" not found."); return(null); } FileTransferOut transfer = null; try { transfer = new FileTransferOut(recipient, fileType, filePath) { ID = 1 }; while (activeTransfers.Any(t => t.Connection == recipient && t.ID == transfer.ID)) { transfer.ID++; } activeTransfers.Add(transfer); } catch (Exception e) { DebugConsole.ThrowError("Failed to initiate file transfer", e); return(null); } OnStarted(transfer); return(transfer); }
/// <summary> /// Uploads the specified local file to the FTP server, saving it at a remote path and filename. <see cref="O:Nito.KitchenSink.WinInet.FtpConnection.Connect"/> must be called before invoking this method. /// </summary> /// <param name="localFile">The local file to upload.</param> /// <param name="remoteFile">The remote path and filename to which to save the file.</param> /// <param name="type">The type of file to transfer.</param> public void PutFile(string localFile, string remoteFile, FileTransferType type) { this.FtpHandle.PutFile(localFile, remoteFile, (FtpHandle.PutFileFlags)type); }
/// <summary> /// Downloads the specified remote file from the FTP server, saving it at a local path and filename. <see cref="O:Nito.KitchenSink.WinInet.FtpConnection.Connect"/> must be called before invoking this method. /// </summary> /// <param name="remoteFile">The remote file to download.</param> /// <param name="localFile">The local path and filename to which to save the file.</param> /// <param name="failIfExists">Whether to fail if the local file specified by <paramref name="localFile"/> already exists.</param> /// <param name="type">The type of file to transfer.</param> public void GetFile(string remoteFile, string localFile, bool failIfExists, FileTransferType type) { this.FtpHandle.GetFile(remoteFile, localFile, failIfExists, (FtpHandle.GetFileFlags)type); }
public static Int32 CountType(this IList <FileTransferBase> list, FileTransferType type) { return((from item in list where item.Discriminator == type select item).Count()); }