/// <summary> /// Creates new instance of <see cref="QuickIOTransferFileCopyProgressEventArgs"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="sourcePath">Source file path</param> /// <param name="targetPath">Target file path</param> /// <param name="totalBytes">Total bytes to transfer</param> /// <param name="transferStarted"></param> public QuickIOTransferFileCopyFinishedEventArgs( IQuickIOTransferJob job, string sourcePath, string targetPath, Int64 totalBytes, DateTime transferStarted ) : base(job, sourcePath, targetPath) { TotalBytes = ( UInt64 ) totalBytes; TransferStarted = transferStarted; TransferFinished = DateTime.Now; }
/// <summary> /// Creates new instance of <see cref="QuickIOTransferFileCopyProgressEventArgs"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="sourcePath">Source file path</param> /// <param name="targetPath">Target file path</param> /// <param name="totalBytes">Total bytes to transfer</param> /// <param name="bytesTransfered">Total bytes transfered</param> /// <param name="transferStarted"></param> public QuickIOTransferFileCopyProgressEventArgs( IQuickIOTransferJob job, string sourcePath, string targetPath, Int64 totalBytes, UInt64 bytesTransfered, DateTime transferStarted ) : base(job, sourcePath, targetPath) { TotalBytes = ( UInt64 ) totalBytes; BytesTransfered = bytesTransfered; TransferStartedTimestamp = transferStarted; ProgressTimestamp = DateTime.Now; }
/// <summary> /// Consuming - transfer file /// </summary> /// <param name="job">Queue Item</param> private void JobExecuteSwitch( IQuickIOTransferJob job ) { OnJobDequeued( job ); job.CurrentRetryCount++; try { job.Run( ); } catch ( Exception e ) { // Retry count reached?! if ( job.CurrentRetryCount >= _maxJobRetryAttempts ) { OnJobRetryMaxReached( job, e ); return; } // Increase retry count and re-add to the queue job.CurrentRetryCount++; lock ( _jobQueueLock ) { // on empty queue just add if ( _jobQueue.Count == 0 ) { _jobQueue.Add( job ); } // Check for cancellation token 'null' else if ( _jobQueue.Contains( null ) ) { // Queue has cancellation token at last position _jobQueue.Insert( _jobQueue.Count - 2, job ); } else { _jobQueue.Insert( _jobQueue.Count - 1, job ); } InternalReSortLockedQueue( ); // resort queue } OnJobRequeued( job, e ); } }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferWorkerWokeUpEventArgs"/> /// </summary> /// <param name="workerID">Affected Worker ID</param> /// <param name="job">Picked job</param> public QuickIOTransferWorkerPickedJobEventArgs( int workerID, IQuickIOTransferJob job ) { WorkerID = workerID; Job = job; }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferJobRunEventArgs"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="jobStart">Time of job start</param> public QuickIOTransferJobRunEventArgs( IQuickIOTransferJob job, DateTime jobStart ) : base( job ) { StartTime = jobStart; }
/// <summary> /// Fire <see cref="JobDequeued"/> /// </summary> /// <param name="job">Affected job</param> protected void OnJobDequeued( IQuickIOTransferJob job ) { QuickIOTransferJobDequeuedEventArgs args = null; if ( JobDequeued != null ) { args = new QuickIOTransferJobDequeuedEventArgs( job ); JobDequeued( this, args ); } if ( args == null ) { args = new QuickIOTransferJobDequeuedEventArgs( job ); } Observer.OnJobDequeued( args ); }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferJobWriteWithSourceEventArgs"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="sourcePath">Source path</param> /// <param name="targetPath">target path</param> protected QuickIOTransferJobWriteWithSourceEventArgs( IQuickIOTransferJob job, string sourcePath, string targetPath ) : base(job, targetPath) { SourcePath = sourcePath; }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferJobQueuedEventArgs"/>. Sets <see cref="AddedToQueue"/> to DateTime.Now /// </summary> /// <param name="job">Affected job</param> /// <param name="sourcePath">Source file path</param> /// <param name="targetPath">Target file path</param> public QuickIOTransferJobQueuedEventArgs( IQuickIOTransferJob job, string sourcePath, string targetPath ) : base(job, sourcePath, targetPath) { AddedToQueue = DateTime.Now; }
/// <summary> /// Creates new instance of <see cref="QuickIOTransferFileCreationStartedEventArgs"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="targetPath">Target file path</param> /// <param name="totalBytes">Total bytes to transfer</param> public QuickIOTransferFileCreationStartedEventArgs( IQuickIOTransferJob job, string targetPath, Int64 totalBytes ) : base(job, targetPath) { TotalBytes = ( UInt64 ) totalBytes; TransferStarted = DateTime.Now; }
/// <summary> /// Creates new instance of <see cref="QuickIOTransferFileCreationErrorEventArgs"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="targetPath">Target file path</param> /// <param name="e">Exception</param> public QuickIOTransferFileCreationErrorEventArgs( IQuickIOTransferJob job, string targetPath, Exception e ) : base(job, targetPath) { Exception = e; }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferJobWriteEventArgs"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="targetPath">Target file path</param> protected QuickIOTransferJobWriteEventArgs( IQuickIOTransferJob job, string targetPath ) : base(job) { TargetPath = targetPath; }
/// <summary> /// Creates new instance of <see cref="QuickIOTransferFileCopyErrorEventArgs"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="target">Target path</param> /// <param name="e">Exception</param> public QuickIOTransferDirectoryCreationErrorEventArgs( IQuickIOTransferJob job, string target, Exception e ) : base(job, target) { Exception = e; }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferDirectoryCreatingEventArgs"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="targetPath">Directory fullname to create</param> public QuickIOTransferDirectoryCreatingEventArgs( IQuickIOTransferJob job, string targetPath ) : base(job) { TargetPath = targetPath; }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferJobEventArgs"/> /// </summary> /// <param name="job">Affected job</param> protected QuickIOTransferJobEventArgs( IQuickIOTransferJob job ) { Job = job; }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferJobErrorEventArgs"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="e">Exception</param> public QuickIOTransferJobErrorEventArgs( IQuickIOTransferJob job, Exception e ) : base( job ) { Exception = e; }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferJobDequeuedEventArgs"/> /// </summary> /// <param name="job">Enqueued Job</param> public QuickIOTransferJobDequeuedEventArgs( IQuickIOTransferJob job ) { Job = job; }
/// <summary> /// Fire <see cref="JobRetryMaxReached"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="lastException">Last exception</param> protected void OnJobRetryMaxReached( IQuickIOTransferJob job, Exception lastException ) { QuickIOTransferJobReatryMaxReachedEventArgs args = null; if ( JobRetryMaxReached != null ) { args = new QuickIOTransferJobReatryMaxReachedEventArgs( job, lastException ); JobRetryMaxReached( this, args ); } if ( args == null ) { args = new QuickIOTransferJobReatryMaxReachedEventArgs( job, lastException ); } Observer.OnJobRetryMaxReached( args ); }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferJobRequeuedEventArgs"/> /// </summary> /// <param name="job">Enqueued Job</param> /// <param name="e">Exception of last error</param> public QuickIOTransferJobRequeuedEventArgs( IQuickIOTransferJob job, Exception e ) { Job = job; Exception = e; }
/// <summary> /// Fire <see cref="WorkerPickedJob"/> /// </summary> /// <param name="threadId">affcted Worker Thread ID</param> /// <param name="job">picked job</param> private void OnWorkerPickedJob( int threadId, IQuickIOTransferJob job ) { QuickIOTransferWorkerPickedJobEventArgs args = null; if ( WorkerPickedJob != null ) { args = new QuickIOTransferWorkerPickedJobEventArgs( threadId, job ); WorkerPickedJob( this, args ); } if ( args == null ) { args = new QuickIOTransferWorkerPickedJobEventArgs( threadId, job ); } Observer.OnWorkerPickedJob( args ); }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferJobEndEventArgs"/> /// </summary> /// <param name="job">Affected job</param> /// <param name="jobStart">Time of job start</param> /// <param name="jobEnd">Time of job end</param> public QuickIOTransferJobEndEventArgs( IQuickIOTransferJob job, DateTime jobStart, DateTime jobEnd ) : base(job) { StartTime = jobStart; EndTime = jobEnd; }
/// <summary> /// Creates a new instance of <see cref="QuickIOTransferJobReatryMaxReachedEventArgs"/> /// </summary> /// <param name="job">Enqueued Job</param> /// <param name="lastException">Last Exception occured</param> public QuickIOTransferJobReatryMaxReachedEventArgs( IQuickIOTransferJob job, Exception lastException ) { Job = job; LastException = lastException; }