Exemple #1
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="CmisSync.Lib.Events.TransmissionProgressEventArgs"/>.
        /// </summary>
        /// <param name='obj'>
        /// The <see cref="System.Object"/> to compare with the current <see cref="CmisSync.Lib.Events.TransmissionProgressEventArgs"/>.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="System.Object"/> is equal to the current
        /// <see cref="CmisSync.Lib.Events.TransmissionProgressEventArgs"/>; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            TransmissionProgressEventArgs e = obj as TransmissionProgressEventArgs;

            if ((object)e == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return((this.Length == e.Length) &&
                   (this.BitsPerSecond == e.BitsPerSecond || this.BitsPerSecond == null || e.BitsPerSecond == null) &&
                   (this.ActualPosition == e.ActualPosition) &&
                   (this.Paused == e.Paused) &&
                   (this.Resumed == e.Resumed) &&
                   (this.Aborting == e.Aborting) &&
                   (this.Aborted == e.Aborted) &&
                   (this.FailedException == e.FailedException));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CmisSync.Lib.Events.FileTransmissionEvent"/> class.
 /// </summary>
 /// <param name='type'>
 /// Type of the transmission.
 /// </param>
 /// <param name='path'>
 /// Path to the file of the transmission.
 /// </param>
 /// <param name='cachePath'>
 /// If a download runs and a cache file is used, this should be the path to the cache file
 /// </param>
 public FileTransmissionEvent(FileTransmissionType type, string path, string cachePath = null)
 {
     if(path == null) {
         throw new ArgumentNullException("Argument null in FSEvent Constructor","path");
     }
     Type = type;
     Path = path;
     status = new TransmissionProgressEventArgs();
     CachePath = cachePath;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CmisSync.Lib.Events.FileTransmissionEvent"/> class.
 /// </summary>
 /// <param name='type'>
 /// Type of the transmission.
 /// </param>
 /// <param name='path'>
 /// Path to the file of the transmission.
 /// </param>
 /// <param name='cachePath'>
 /// If a download runs and a cache file is used, this should be the path to the cache file
 /// </param>
 public FileTransmissionEvent(FileTransmissionType type, string path, string cachePath = null)
 {
     if (path == null)
     {
         throw new ArgumentNullException("Argument null in FSEvent Constructor", "path");
     }
     Type      = type;
     Path      = path;
     status    = new TransmissionProgressEventArgs();
     CachePath = cachePath;
 }
 /// <summary>
 /// Reports the progress. Every non null value will update the actual status.
 /// All other values will be taken from the last reported progress.
 /// </summary>
 /// <param name='status'>
 /// Status update.
 /// </param>
 public void ReportProgress(TransmissionProgressEventArgs status)
 {
     Status.Aborted        = (status.Aborted != null) ? status.Aborted : Status.Aborted;
     Status.ActualPosition = (status.ActualPosition != null) ? status.ActualPosition : Status.ActualPosition;
     Status.Length         = (status.Length != null) ? status.Length : Status.Length;
     Status.Completed      = (status.Completed != null) ? status.Completed : Status.Completed;
     Status.BitsPerSecond  = (status.BitsPerSecond != null && Status.BitsPerSecond != status.BitsPerSecond) ? status.BitsPerSecond : null;
     if (TransmissionStatus != null)
     {
         TransmissionStatus(this, Status);
     }
 }
Exemple #5
0
 /// <summary>
 /// Reports the progress. Every non null value will update the actual status.
 /// All other values will be taken from the last reported progress.
 /// </summary>
 /// <param name='status'>
 /// Status update.
 /// </param>
 public void ReportProgress(TransmissionProgressEventArgs status)
 {
     this.Status.Aborting        = (status.Aborting != null) ? status.Aborting : this.Status.Aborting;
     this.Status.Aborted         = (status.Aborted != null) ? status.Aborted : this.Status.Aborted;
     this.Status.ActualPosition  = (status.ActualPosition != null) ? status.ActualPosition : this.Status.ActualPosition;
     this.Status.Length          = (status.Length != null) ? status.Length : this.Status.Length;
     this.Status.Completed       = (status.Completed != null) ? status.Completed : this.Status.Completed;
     this.Status.Started         = (status.Started != null) ? status.Started : this.Status.Started;
     this.Status.BitsPerSecond   = (status.BitsPerSecond != null) ? status.BitsPerSecond : this.Status.BitsPerSecond;
     this.Status.FailedException = (status.FailedException != null) ? status.FailedException : this.Status.FailedException;
     if (this.TransmissionStatus != null)
     {
         this.TransmissionStatus(this, this.Status);
     }
 }
 /// <summary>
 /// If a transmission is reported as finished/aborted/failed, the transmission is removed from the collection
 /// </summary>
 /// <param name='sender'>
 /// The transmission event.
 /// </param>
 /// <param name='e'>
 /// The progress parameters of the transmission.
 /// </param>
 private void TransmissionFinished(object sender, TransmissionProgressEventArgs e)
 {
     if ((e.Aborted == true || e.Completed == true || e.FailedException != null))
     {
         lock (Lock)
         {
             FileTransmissionEvent transmission = sender as FileTransmissionEvent;
             if(transmission!=null && activeTransmissions.Contains(transmission)) {
                 activeTransmissions.Remove(transmission);
                 transmission.TransmissionStatus-=TransmissionFinished;
                 Logger.Debug("Transmission removed");
             }
         }
     }
 }
Exemple #7
0
 /// <summary>
 /// If a transmission is reported as finished/aborted/failed, the transmission is removed from the collection
 /// </summary>
 /// <param name='sender'>
 /// The transmission event.
 /// </param>
 /// <param name='e'>
 /// The progress parameters of the transmission.
 /// </param>
 private void TransmissionFinished(object sender, TransmissionProgressEventArgs e)
 {
     if ((e.Aborted == true || e.Completed == true || e.FailedException != null))
     {
         lock (Lock)
         {
             FileTransmissionEvent transmission = sender as FileTransmissionEvent;
             if (transmission != null && activeTransmissions.Contains(transmission))
             {
                 activeTransmissions.Remove(transmission);
                 transmission.TransmissionStatus -= TransmissionFinished;
                 Logger.Debug("Transmission removed");
             }
         }
     }
 }
 /// <summary>
 /// Reports the progress. Every non null value will update the actual status.
 /// All other values will be taken from the last reported progress.
 /// </summary>
 /// <param name='status'>
 /// Status update.
 /// </param>
 public void ReportProgress(TransmissionProgressEventArgs status)
 {
         Status.Aborted = (status.Aborted != null) ? status.Aborted : Status.Aborted;
         Status.ActualPosition = (status.ActualPosition != null) ? status.ActualPosition : Status.ActualPosition;
         Status.Length = (status.Length != null) ? status.Length : Status.Length;
         Status.Completed = (status.Completed != null) ? status.Completed : Status.Completed;
         Status.BitsPerSecond = (status.BitsPerSecond != null && Status.BitsPerSecond!=status.BitsPerSecond) ? status.BitsPerSecond : null;
     if (TransmissionStatus != null)
         TransmissionStatus(this, Status);
 }