public async Task Upload()
        {
            CloudBlobDirectory destDir = await GetCloudBlobDirectoryAsync(TargetFolder);

            UploadDirectoryOptions options = new UploadDirectoryOptions {
                SearchPattern = "*",
                Recursive     = true,
                BlobType      = BlobType.BlockBlob,
            };

            using (MemoryStream journalStream = new MemoryStream()) {
                // Store the transfer context in a streamed journal.
                DirectoryTransferContext context = new DirectoryTransferContext(journalStream);

                // Register for transfer event.
                context.FileTransferred += FileTransferredCallback;
                context.FileFailed      += FileFailedCallback;
                context.FileSkipped     += FileSkippedCallback;

                context.SetAttributesCallback = (destination) => {
                    CloudBlob destBlob = destination as CloudBlob;
                    switch (Path.GetExtension(destBlob.Name).ToLowerInvariant())
                    {
                    case "html":
                    case ".html":
                        destBlob.Properties.ContentType = "text/html";
                        break;

                    default:
                        destBlob.Properties.ContentType = "text/plain";
                        break;
                    }
                    Console.WriteLine($"Setting attributes for {destination}");
                };

                context.ShouldTransferCallback = (source, destination) => {
                    // Can add more logic here to evaluate whether really need to transfer the target.
                    Console.WriteLine($"Should transfer from {source} to {destination}? YES");
                    return(true);
                };

                // Create CancellationTokenSource used to cancel the transfer
                CancellationTokenSource cancellationSource = new CancellationTokenSource();

                TransferStatus transferStatus = null;

                StartCancelThread(cancellationSource);

                try {
                    // Start the upload
                    Task <TransferStatus> task = TransferManager.UploadDirectoryAsync(InputDirectory, destDir, options, context, cancellationSource.Token);
                    transferStatus = await task;
                } catch (Exception e) {
                    Console.WriteLine("The transfer failed: {0}", e.Message);
                }

                Console.WriteLine("Final transfer state: {0}", TransferStatusToString(transferStatus));
                Console.WriteLine("Files in directory {0} uploading to {1} is finished.", InputDirectory, destDir.Uri);
            }
        }
Example #2
0
        /// <summary>
        /// Updates the <see cref="TransferStatus"/> of an existing transfer object on the Sql DB
        /// </summary>
        /// <param name="transferId">The ID of the transfer to update</param>
        /// <param name="newStatus">The new <see cref="TransferStatus"/></param>
        /// <returns>A <see cref="Transfer"/> Object with the updated properties as it exists on the Sql DB</returns>
        public Transfer UpdateTransferStatus(int transferId, TransferStatus newStatus)
        {
            Transfer updatedTransfer = null;

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(SQL_UPDATE_TRANSFER_STATUS_BY_ID, conn);
                    cmd.Parameters.AddWithValue("@statusDescription", Enum.GetName(typeof(TransferStatus), newStatus));
                    cmd.Parameters.AddWithValue("@transferId", transferId);

                    int rowsAffected = cmd.ExecuteNonQuery();
                    if (rowsAffected > 0)
                    {
                        updatedTransfer = GetTransferById(transferId);
                    }
                }
                return(updatedTransfer);
            }
            catch (SqlException)
            {
                throw;
            }
        }
Example #3
0
 public bool prompt(TransferItem item, TransferStatus status, BackgroundException failure, int pending)
 {
     if (_supressed)
     {
         return(_option);
     }
     if (_controller.Visible)
     {
         AtomicBoolean c = new AtomicBoolean(true);
         _controller.Invoke(delegate
         {
             TaskDialogResult result = _controller.View.CommandBox(LocaleFactory.localizedString("Error"),
                                                                   failure.getMessage() ?? LocaleFactory.localizedString("Unknown"),
                                                                   failure.getDetail() ?? LocaleFactory.localizedString("Unknown"), null, null,
                                                                   LocaleFactory.localizedString("Always"),
                                                                   LocaleFactory.localizedString("Continue", "Credentials"), true, TaskDialogIcon.Warning,
                                                                   TaskDialogIcon.Information, delegate(int opt, bool verificationChecked)
             {
                 if (verificationChecked)
                 {
                     _supressed = true;
                     _option    = c.Value;
                 }
             });
             if (result.Result == TaskDialogSimpleResult.Cancel)
             {
                 c.SetValue(false);
             }
         }, true);
         return(c.Value);
     }
     // Abort
     return(false);
 }
Example #4
0
        protected void SetSendFileStatus(TransferStatus fss)
        {
            if (SendFileChangeEvent != null)
            {
                _transferStatus = fss;
                SendFileChangeEvent(this, new SendFileEvent(fss));
            }

            if (fss == TransferStatus.CONFIRM_RECIVE &&
                ConfirmReciveEvent != null)
            {
                ConfirmReciveEvent(this, new EventArgs());
            }
            else if ((fss == TransferStatus.START_RECIVE || fss == TransferStatus.START_SEND) &&
                     StartTransferEvent != null)
            {
                StartTransferEvent(this, new EventArgs());
            }
            else if ((fss == TransferStatus.SEND_OK || fss == TransferStatus.RECIVE_OK) &&
                     TransferCompleteEvent != null)
            {
                TransferCompleteEvent(this, new EventArgs());
            }
            else if ((fss == TransferStatus.ERROR || fss == TransferStatus.FILE_ERROR ||
                      fss == TransferStatus.SOCKET_EXCEPTION) &&
                     TransferErrorEvent != null)
            {
                TransferErrorEvent(this, new EventArgs());
            }
        }
Example #5
0
 public FileTransfer()
 {
     timer           = new Timer();
     timer.Interval  = 50;
     timer.Tick     += new EventHandler(timer_Tick);
     _transferStatus = TransferStatus.WAITING;
 }
        private static void CopyContainer(CloudBlobDirectory sourceDirectory, CloudBlobDirectory destDirectory)
        {
            // This function copies an entire Storage container using the data movement library.
            // See https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.storage.datamovement.copydirectoryoptions?view=azure-dotnet for the API
            // and https://docs.microsoft.com/en-us/azure/storage/common/storage-use-data-movement-library for a general overview.

            ProgressRecorder recorder  = new ProgressRecorder();
            Stopwatch        stopWatch = Stopwatch.StartNew();

            CopyDirectoryOptions copyDirectoryOptions = new CopyDirectoryOptions
            {
                // Needs to be true to copy the contents of the directory / container.  If this is false the contents will
                // not be copied.
                Recursive = true
            };
            // Copy all files under root folder
            DirectoryTransferContext context = new DirectoryTransferContext
            {
                ProgressHandler = recorder
            };

            TransferStatus copyStatus = TransferManager.CopyDirectoryAsync(sourceDirectory, destDirectory, CopyMethod.ServiceSideAsyncCopy, copyDirectoryOptions, context).Result;

            stopWatch.Stop();
            // Get the elapsed time as a TimeSpan value.
            TimeSpan ts = stopWatch.Elapsed;

            // Format and display the TimeSpan value.
            string elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                               ts.Hours, ts.Minutes, ts.Seconds,
                                               ts.Milliseconds / 10);

            Console.WriteLine($"Elapsed:{elapsedTime} T File transferred: {copyStatus.NumberOfFilesTransferred} total bytes:{copyStatus.BytesTransferred}, failed: {copyStatus.NumberOfFilesFailed}, skipped:{copyStatus.NumberOfFilesSkipped}");
        }
Example #7
0
        /// <summary>
        /// Closes a given transfer, and frees resources that were associated with the
        /// transfer (by invoking the <see cref="FinalizeTransfer"/> method).
        /// </summary>
        /// <returns>The suggested <param name="status" /> if the transfer was found, or
        /// <see cref="TransferStatus.UnknownTransfer"/> if no matching transfer was found.</returns>
        protected virtual TransferStatus CloseTransferInternal(string transferId, TransferStatus status, AbortReason?abortReason, FileSystemTask context, AuditEvent eventId)
        {
            //try to get the transfer
            TTransfer transfer = GetCachedTransfer(transferId, false, context);

            //if we don't have this one (anymore), return corresponding flag
            if (transfer == null)
            {
                return(TransferStatus.UnknownTransfer);
            }

            lock (transfer.SyncRoot)
            {
                CloseTransferImpl(transfer, status, abortReason);

                transfer.Status      = status;
                transfer.AbortReason = abortReason;

                FinalizeTransfer(transfer);
            }

            //audit status change
            AuditHelper.AuditChangedTransferStatus(Auditor, transfer, context, eventId);

            return(status);
        }
Example #8
0
        public void CreateTransfer_test(string senderUsername, string receiverUsername, int transferType, double amount)
        {
            //todo this should be in the TransferController test. If we knew how to test controllers that is...
            //arrange
            AccountSqlDAO  accountDao        = new AccountSqlDAO(connectionString);
            UserSqlDAO     userDao           = new UserSqlDAO(connectionString);
            int            senderAccountId   = (int)accountDao.GetDefaultAccountIdForUserId(userDao.GetApiUser(senderUsername).UserId);
            int            receiverAccountId = (int)accountDao.GetDefaultAccountIdForUserId(userDao.GetApiUser(receiverUsername).UserId);
            TransferStatus transferStatus    = transferType == (int)TransferType.Send ? TransferStatus.Approved : TransferStatus.Pending;
            Transfer       transferToCreate  = new Transfer()
            {
                AccountFromId  = senderAccountId,
                AccountToId    = receiverAccountId,
                TransferType   = (TransferType)transferType,
                TransferStatus = transferStatus,
                Amount         = (decimal)amount
            };


            //act
            Transfer actualTransfer = dao.CreateTransfer(transferToCreate);

            //assert
            Assert.IsNotNull(actualTransfer);
            Assert.AreEqual(transferToCreate.AccountFromId, actualTransfer.AccountFromId);
            Assert.AreEqual(senderUsername, actualTransfer.UsernameFrom);
            Assert.AreEqual(transferToCreate.AccountToId, actualTransfer.AccountToId);
            Assert.AreEqual(receiverUsername, actualTransfer.UsernameTo);
            Assert.AreEqual(transferToCreate.TransferType, actualTransfer.TransferType);
            Assert.AreEqual(transferToCreate.TransferStatus, actualTransfer.TransferStatus);
            Assert.AreEqual(transferToCreate.Amount, actualTransfer.Amount);
        }
Example #9
0
 public void Execute()
 {
     TransferStatus = TransferStatus.InProgress;
     Thread.Sleep(5000);
     DelayedJob();
     TransferStatus = TransferStatus.Finished;
 }
        public async void GetsTransferInfoAsync()
        {
            Guid           tokenAddressTransferUID = Guid.NewGuid();
            Guid           UID             = Guid.NewGuid();
            TransferStatus status          = TransferStatus.Complete;
            string         transactionHash = "asdujasd32409892345893485";

            var testHttpClient = StartTestHostWithFixedResponse(GetPath("tokens", "transfer/info"), 200, new TransferInfoResponse
            {
                UID             = UID,
                Status          = status,
                TransactionHash = transactionHash
            });

            var mobius   = new Mobius(testHttpClient, GetConnectionInfo());
            var response = await mobius.Tokens.GetTransferInfoAsync(new TransferInfoRequest
            {
                TokenAddressTransferUID = tokenAddressTransferUID
            });

            Assert.NotNull(response);
            Assert.Equal(UID, response.UID);
            Assert.Equal(status, response.Status);
            Assert.Equal(transactionHash, response.TransactionHash);
        }
 /// <summary>
 /// 实例化一个新的转账记录
 /// </summary>
 /// <param name="comeFrom">来源银行</param>
 /// <param name="serialNumber">流水号</param>
 /// <param name="sum">金额</param>
 public TransferRecord(Bank comeFrom, string serialNumber, double sum)
 {
     this.ComeFrom = comeFrom;
     this.SerialNumber = serialNumber;
     this.Sum = sum;
     this.Status = TransferStatus.用户已经支付;
 }
Example #12
0
        //NEED TO CAST TO TransferType/Status when we read the transfers in



        public bool LogTransfers(TransferType transfer_type_id, TransferStatus transfer_status_id, int accountID_from, int accountID_to, decimal amount)
        {
            string sql = "insert transfers (transfer_type_id, transfer_status_id, account_from, account_to,amount) values(@transfer_type_id, @transfer_status_id, @account_from, @account_to, @amount)";

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand(sql, conn);

                    cmd.Parameters.AddWithValue("@transfer_type_Id", transfer_type_id);
                    cmd.Parameters.AddWithValue("@transfer_status_Id", transfer_status_id);
                    cmd.Parameters.AddWithValue("@account_from", accountID_from);
                    cmd.Parameters.AddWithValue("@account_to", accountID_to);
                    cmd.Parameters.AddWithValue("@amount", amount);

                    int rowsAffected = cmd.ExecuteNonQuery();

                    return(rowsAffected > 0);
                }
            }
            catch (SqlException)
            {
                return(false);
            }
        }
Example #13
0
 public void When(TransferStarted e)
 {
     FromAccount = e.FromAccount;
     ToAccount   = e.ToAccount;
     Amount      = e.Amount;
     Status      = TransferStatus.Started;
 }
Example #14
0
        public void Writing_Last_Buffered_Block_Should_Complete_Transfer()
        {
            using (var fs = SourceFile.OpenRead())
            {
                fs.WriteTo(Token, SourceFile.Length, 2048, b =>
                {
                    b.IsLastBlock = false;
                    Uploads.WriteBlockStreamed(b);
                });
            }

            Assert.AreEqual(TransferStatus.Running, Uploads.GetTransferStatus(Token.TransferId));

            //write an empty last block
            BufferedDataBlock db = new BufferedDataBlock
            {
                TransferTokenId = Token.TransferId,
                BlockLength     = 0,
                Offset          = SourceFile.Length,
                Data            = new byte[0],
                BlockNumber     = 0,
                IsLastBlock     = true
            };

            Uploads.WriteBlock(db);

            CompareUploadToSourceFile();

            TransferStatus status = Uploads.GetTransferStatus(Token.TransferId);

            Assert.IsTrue(status.Is(TransferStatus.Completed, TransferStatus.UnknownTransfer));
        }
        /// <summary>
        /// Converts a <see cref="MonoUsbTansferStatus"/> enum to a <see cref="Error"/> enum.
        /// </summary>
        /// <param name="status">the <see cref="MonoUsbTansferStatus"/> to convert.</param>
        /// <returns>A <see cref="Error"/> that represents <paramref name="status"/>.</returns>
        public static Error MonoLibUsbErrorFromTransferStatus(TransferStatus status)
        {
            switch (status)
            {
            case TransferStatus.Completed:
                return(Error.Success);

            case TransferStatus.Error:
                return(Error.Pipe);

            case TransferStatus.TimedOut:
                return(Error.Timeout);

            case TransferStatus.Cancelled:
                return(Error.Io);

            case TransferStatus.Stall:
                return(Error.Pipe);

            case TransferStatus.NoDevice:
                return(Error.NoDevice);

            case TransferStatus.Overflow:
                return(Error.Overflow);

            default:
                return(Error.Other);
            }
        }
Example #16
0
        public async Task doDownload(string containerName, DirectoryInfo localDir, string storageConnectionString)
        {
            try
            {
                // Connect to Azure Storage to download a container
                CloudStorageAccount account    = CloudStorageAccount.Parse(storageConnectionString);
                CloudBlobClient     blobClient = account.CreateCloudBlobClient();

                // Get the container and root directory reference
                CloudBlobContainer blobContainer = blobClient.GetContainerReference(containerName);
                CloudBlobDirectory rootDir       = blobContainer.GetDirectoryReference("");

                // Log
                Console.WriteLine("Directory to be downloaded is {0} and {1}", rootDir.Container.Name, rootDir.StorageUri);

                // Parallel Operations
                TransferManager.Configurations.ParallelOperations = 32;

                // Setup the transfer context and track the upoload progress
                DirectoryTransferContext context = new DirectoryTransferContext();
                context.FileFailed += Program.FileFailedCallback;

                context.ProgressHandler = new Progress <TransferStatus>((progress) =>
                {
                    Console.WriteLine("{0} MB downloaded", progress.BytesTransferred / (1024 * 1024));
                });

                // Download recursively
                DownloadDirectoryOptions options = new DownloadDirectoryOptions()
                {
                    Recursive = true
                };

                // Start the counter
                Stopwatch s = Stopwatch.StartNew();

                // Initiate the download from DMLib
                TransferStatus transferStatus = await TransferManager.DownloadDirectoryAsync(rootDir, localDir.ToString(), options, context);

                s.Stop();

                if (transferStatus.NumberOfFilesFailed > 0)
                {
                    Console.WriteLine("{0} files failed to transfer", transferStatus.NumberOfFilesFailed);
                }

                // Log the result
                Console.WriteLine("Download has been completed in {0} seconds", s.Elapsed.TotalSeconds);
            }
            catch (StorageException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                ex = (ex.InnerException != null) ? ex.InnerException.GetBaseException() : ex;
                Console.WriteLine(ex.Message);
            }
        }
 private void View_ChangedSelectionEvent()
 {
     if (View.SelectedItem != null)
     {
         TransferItem selected = View.SelectedItem;
         if (null != selected)
         {
             if (null != selected.local)
             {
                 View.LocalFileUrl = selected.local.getAbsolute();
                 if (selected.local.attributes().getSize() == -1)
                 {
                     View.LocalFileSize = UnknownString;
                 }
                 else
                 {
                     View.LocalFileSize = SizeFormatterFactory.get().format(selected.local.attributes().getSize());
                 }
                 if (selected.local.attributes().getModificationDate() == -1)
                 {
                     View.LocalFileModificationDate = UnknownString;
                 }
                 else
                 {
                     View.LocalFileModificationDate =
                         UserDateFormatterFactory.get().getLongFormat(selected.local.attributes().getModificationDate());
                 }
             }
             View.RemoteFileUrl =
                 new DefaultUrlProvider(Transfer.getSource()).toUrl(selected.remote)
                 .find(DescriptiveUrl.Type.provider)
                 .getUrl();
             TransferStatus status = TransferPromptModel.GetStatus(selected);
             if (status.getRemote().getSize() == -1)
             {
                 View.RemoteFileSize = UnknownString;
             }
             else
             {
                 View.RemoteFileSize = SizeFormatterFactory.get().format(status.getRemote().getSize());
             }
             if (status.getRemote().getModificationDate() == -1)
             {
                 View.RemoteFileModificationDate = UnknownString;
             }
             else
             {
                 View.RemoteFileModificationDate =
                     UserDateFormatterFactory.get().getLongFormat(status.getRemote().getModificationDate());
             }
         }
         else
         {
             View.LocalFileUrl              = String.Empty;
             View.LocalFileSize             = String.Empty;
             View.LocalFileModificationDate = String.Empty;
         }
     }
 }
 public void StatusUpdate(TransferStatus status)
 {
     SetStatus(ProgressStatus.Running);
     currentStatus            = status;
     TotalProgressBar.Maximum = currentStatus.TotalFileCount;
     TotalProgressBar.Value   = currentStatus.CurrentFileIdx;
     StatusLabel.Text         = currentStatus.DestinationFileName;
 }
Example #19
0
 public Transfer()
 {
     startedOn  = DateTime.Now;
     progress   = 0;
     status     = TransferStatus.Idle;
     hostName   = file1 = file2 = "???";
     remoteHost = null;
 }
Example #20
0
 /// <summary>
 /// Format the TransferStatus of DMlib to printable string
 /// </summary>
 public static string TransferStatusToString(TransferStatus status)
 {
     return(string.Format("Transferred bytes: {0}; Transfered: {1}; Skipped: {2}, Failed: {3}",
                          status.BytesTransferred,
                          status.NumberOfFilesTransferred,
                          status.NumberOfFilesSkipped,
                          status.NumberOfFilesFailed));
 }
        public async Task doCopy(DirectoryInfo source, string storageConnectionString)
        {
            try
            {
                // Connect to Azure Storage to create a container for this backup
                CloudStorageAccount account    = CloudStorageAccount.Parse(storageConnectionString);
                CloudBlobClient     blobClient = account.CreateCloudBlobClient();

                // Unique container name with timestamp
                string             container     = source.Name + DateTime.Now.ToString("MMddyyyy-HHmmss");
                CloudBlobContainer blobContainer = blobClient.GetContainerReference(container);

                await blobContainer.CreateIfNotExistsAsync();

                Console.WriteLine("Container {0} has been created.", container);

                // Get root directory reference for the container
                CloudBlobDirectory destBlob = blobContainer.GetDirectoryReference("");

                // Parallel Operations
                TransferManager.Configurations.ParallelOperations = 32;

                // Setup the transfer context and track the upload progress
                TransferContext context = new TransferContext();
                context.FileFailed += Program.FileFailedCallback;

                context.ProgressHandler = new Progress <TransferStatus>((progress) =>
                {
                    Console.WriteLine("{0} MB uploaded", progress.BytesTransferred / (1024 * 1024));
                });

                // Upload recursively
                UploadDirectoryOptions options = new UploadDirectoryOptions()
                {
                    Recursive = true
                };

                // Start the counter
                Stopwatch s = Stopwatch.StartNew();

                // Initiate the Upload from DMLib
                TransferStatus transferStatus = await TransferManager.UploadDirectoryAsync(source.FullName, destBlob, options, context);

                s.Stop();

                if (transferStatus.NumberOfFilesFailed > 0)
                {
                    Console.WriteLine("{0} files failed to transfer", transferStatus.NumberOfFilesFailed);
                }

                // Log the result
                Console.WriteLine("Upload has been completed in {0} seconds.", s.Elapsed.TotalSeconds);
            }
            catch (StorageException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #22
0
        private void PurgeListFrom(ObservableCollection <FileTransfer> list, TransferStatus status)
        {
            List <FileTransfer> itemsToRemove = list.Where(x => x.Status == status).ToList();

            foreach (var item in itemsToRemove)
            {
                list.Remove(item);
            }
        }
 public void AddFileSliceSender(FileSliceSender fileSliceSender)
 {
     TransferStatus.Add(fileSliceSender.UniqueKey, new FileTransferStatus
     {
         NextSlice     = 0,
         SlicesCount   = fileSliceSender.SlicesCount,
         LastSliceSize = fileSliceSender.LastSliceSize,
         SliceMaxSize  = sliceMaxSize,
     });
 }
        /// <summary>
        /// Perform the status updates required when a batch is completed
        /// </summary>
        public void BatchCompleted()
        {
            ++TotalBatchesCompleted;
            TransferStatus.PerformStep();

            if (TableCompleted != null)
            {
                TableCompleted(this, null);
            }
        }
Example #25
0
        public TransferStatus GetStatus(TransferItem path)
        {
            if (!_status.ContainsKey(path))
            {
                // Transfer filter background task has not yet finished
                return(new TransferStatus());
            }
            TransferStatus status = _status[path];

            return(status);
        }
Example #26
0
        public CheckState GetCheckState(Object i)
        {
            TransferItem   item   = (TransferItem)i;
            TransferStatus status = GetStatus(item);

            if (status.isRejected())
            {
                return(CheckState.Unchecked);
            }
            return(IsSelected(item) ? CheckState.Checked : CheckState.Unchecked);
        }
Example #27
0
 private void WorkerDoWork(object sender, DoWorkEventArgs e)
 {
     if (TransferSettings.IsDataTransferAllowed)
     {
         _operationStatus = _dataTransferer.PerformDataTransfer(_sourceFilePath, _targetFilePath, ProgressBar.Step, _worker, _locker);
     }
     else
     {
         MessageBox.Show("All threads are busy at the moment");
     }
 }
Example #28
0
        public static string ToUserString(this TransferStatus progress, long?intialBytesTransferred, Stopwatch stopwatch)
        {
            var result = $"{progress.NumberOfFilesTransferred} transferred, {progress.NumberOfFilesSkipped} skipped, {progress.NumberOfFilesFailed} failed, {progress.BytesTransferred.ToSizeSuffix(0)} ({progress.BytesTransferred:N0})";

            if (intialBytesTransferred.HasValue && (progress.BytesTransferred > intialBytesTransferred))
            {
                result += $" {(progress.BytesTransferred - intialBytesTransferred).ToBitsPerSecond(stopwatch.ElapsedMilliseconds)}";
            }

            return(result);
        }
Example #29
0
 public override void TransferEnd()
 {
     lock (_lock)
     {
         timer?.Dispose();
         DateTime       now    = DateTime.Now;
         TransferStatus status = new TransferStatus(Interlocked.Read(ref newlyTransferredBytes),
                                                    Interlocked.Read(ref transferredBytes), totalBytes, (now - lastCheckpoint).TotalSeconds, (now - startCheckpoint).TotalSeconds);
         handler(sender, status);
     }
 }
        public void Writing_All_Blocks_Should_Create_Clean_Copy()
        {
            foreach (var block in CreateBufferedBlocks())
            {
                UploadHandler.WriteBlock(block);
            }

            TransferStatus status = UploadHandler.CompleteTransfer(Token.TransferId);

            FileAssert.AreEqual(SourceFile, TargetFile);
            Assert.AreEqual(TransferStatus.Completed, status);
        }
        /// <summary>
        /// Cleans up the temporary file and the local <see cref="FileCache"/>
        /// before invoking finalization on the base class. This method also
        /// invokes the <see cref="CommitCompletedFile"/> method in case of a
        /// successful transfer.
        /// </summary>
        /// <param name="status">The transfer status.</param>
        /// <param name="abortReason">Indicates why the transfer was aborted, in case the
        /// <paramref name="status"/> is <see cref="TransferStatus.Aborted"/>.</param>
        /// <param name="transfer">The closed transfer.</param>
        protected override void CloseTransferImpl(TTransfer transfer, TransferStatus status, AbortReason?abortReason)
        {
            using (var fileData = GetCachedTempData(transfer, null))
            {
                FileCache.Remove(transfer.TransferId);

                if (status == TransferStatus.Completed)
                {
                    CommitCompletedFile(transfer, fileData);
                }
            }
        }
 protected void HandleEvent(PokemonData pokemon, TransferStatus status)
 {
     if (status == TransferStatus.Success)
     {
         OnTransferSuccess(pokemon);
     }
     else if (status == TransferStatus.Fail)
     {
         OnTransferFailed(pokemon);
     }
     else if(status == TransferStatus.Ignored)
     {
         OnTransferIgnored(pokemon);
     }
 }
 public abstract void GetTransferProgressCore(uint transferID, out TransferStatus transferStatus, out string transferLength, out string transferTotal);
Example #34
0
 public FileTransfer()
 {
     timer = new Timer();
     timer.Interval = 50;
     timer.Tick += new EventHandler(timer_Tick);
     _transferStatus = TransferStatus.WAITING;
 }
Example #35
0
        protected void SetSendFileStatus(TransferStatus fss)
        {
            if(SendFileChangeEvent != null)
            {
                _transferStatus = fss;
                SendFileChangeEvent(this, new SendFileEvent(fss));
            }

            if(	fss == TransferStatus.CONFIRM_RECIVE &&
                ConfirmReciveEvent != null)
            {
                ConfirmReciveEvent(this, new EventArgs());
            }
            else if((fss == TransferStatus.START_RECIVE || fss == TransferStatus.START_SEND) &&
                StartTransferEvent != null)
            {
                StartTransferEvent(this, new EventArgs());
            }
            else if((fss == TransferStatus.SEND_OK || fss == TransferStatus.RECIVE_OK) &&
                TransferCompleteEvent != null)
            {
                TransferCompleteEvent(this, new EventArgs());
            }
            else if((fss == TransferStatus.ERROR || fss == TransferStatus.FILE_ERROR ||
                fss == TransferStatus.SOCKET_EXCEPTION) &&
                TransferErrorEvent != null)
            {
                TransferErrorEvent(this, new EventArgs());
            }
        }
 public static void ChangeTransferStatus(Guid pkTransferId, TransferStatus newStatus, String ApiToken, String ApiServer)
 {
     Factory.GetResponse("WarehouseTransfer/ChangeTransferStatus", "pkTransferId=" + pkTransferId + "&newStatus=" + newStatus + "", ApiToken, ApiServer);
 }
Example #37
0
 public static Transfer[] GetTransfersByStatus(TransferStatus status)
 {
     return Array.ConvertAll<DataRow, Transfer>(BillingSystemDataAdapter.GetTransfersByStatus((int)status)
        , delegate(DataRow dr) { return new Transfer().Load<Transfer>(dr); });
 }
Example #38
0
 public SendFileEvent(TransferStatus init)
 {
     fileSendStatus = init;
 }
Example #39
0
 public PositionTransferDetails(IPositionTransfer transfer)
 {
     this.AIsInternal = transfer.AIsInternal;
     this.BIsInternal = transfer.BIsInternal;
     if (transfer.AccountA != null) this.AccountAID = transfer.AccountA.Key;
     if (transfer.AccountB != null) this.AccountBID = transfer.AccountB.Key;
     this.TransferDate = transfer.TransferDate;
     this.TypeOfTransfer = transfer.TypeOfTransfer;
     this.TransferAmount = transfer.TransferAmount == null ? 0 : transfer.TransferAmount.Quantity;
     this.Status = transfer.TransferStatus;
     this.IsInitialised = transfer.IsInitialised;
     this.IsEditable = transfer.IsEditable;
 }
 public RunbookTransferProgress(RunbookTransferJob rtj)
 {
     this.Job = rtj;
     this.Status = TransferStatus.Starting;
 }