private void Queue_ItemProcessed(object sender, TransferQueueItemProcessedEventArgs e) { TransferPacket currentPacket; if (transferPacketList.Any(item => item.FileItem == e.Item)) { currentPacket = transferPacketList.First(item => item.FileItem == e.Item); if (e.Item.Error == null) { if (currentPacket.Type == TransferType.UploadSubPacket) { TransferPacket parentPacket = currentPacket.Parent as TransferPacket; parentPacket.RemainingSubPackets -= 1; if (parentPacket.RemainingSubPackets == 0) { parentPacket.FireSuccessEvent(); } } else { currentPacket.FireSuccessEvent(); } } else { currentPacket.FireFailureEvent(e.Item.Error); } transferPacketList.Remove(currentPacket); } else { } }
private void HandleFileTransferCompleted(Exception e) { client.ConnectCompleted -= Client_ConnectCompleted; client.AuthenticateCompleted -= Client_AuthenticateCompleted; if (client.IsConnected) { client.Disconnect(); } client = null; if (e == null) { Log("Transfer SUCCESS: " + Packet.Parent + " " + Packet.SourcePath + " -> " + Packet.TargetPath); Packet.FireSuccessEvent(); } else { Log("Transfer ERROR: " + Packet.Parent + " " + Packet.SourcePath + " -> " + Packet.TargetPath); Log(e.Message); Packet.FireFailureEvent(e); } }