public void AddTransferPacket(TransferPacket Packet) { Log("Adding file transfer: " + Packet.SourcePath + " -> " + Packet.TargetPath); if (client.IsConnected == false) { int connectCounter = 0; bool success = Reconnect(); while (success == false && connectCounter < Settings.MaxTransferErrorCount) { Log("Connection to " + loginData.Url + " not possible at this moment. Waiting for " + Settings.MinutesToSleepBeforeRetry + " minutes to try again..."); connectCounter += 1; Thread.Sleep(Convert.ToInt32(Math.Ceiling(1000 * 60 * Settings.MinutesToSleepBeforeRetry))); success = Reconnect(); } if (success == false) { if (Packet.Parent is Production) { (Packet.Parent as Production).ErrorStatus = ProductionErrorStatus.PES_UPLOAD; } else if (Packet.Parent is Motif) { if ((Packet.Parent as Motif).Job != null) { (Packet.Parent as Motif).Job.ErrorStatus = JobErrorStatus.JES_DOWNLOAD_MOTIFS; } } return; } } switch (Packet.Type) { case TransferType.DownloadAnimatedMotif: case TransferType.DownloadAudio: case TransferType.DownloadMotif: AddDownloadSingle(Packet); break; case TransferType.UploadFilmDirectory: case TransferType.UploadFilmPreviewDirectory: case TransferType.UploadProductDirectory: case TransferType.UploadProductPreviewDirectory: AddUploadDirectory(Packet); break; case TransferType.UploadMotifPreview: AddUploadSingle(Packet); break; } if (queue.State != TransferQueueState.Processing) { queue.Start(); } }
private _TransferQueueManager() { transferPacketList = new List <TransferPacket>(); loginData = Settings.MasterLogin; //initialize new Sftp connection client = new Sftp(); client.Timeout = -1; client.ReconnectionMaxRetries = Settings.MaxTransferErrorCount; client.ReconnectionFailureDelay = 5000; queue = new TransferQueue(3); queue.ReuseRemoteConnection = true; queue.ItemProcessed += Queue_ItemProcessed; queue.Start(); }