コード例 #1
0
 protected void OnQueueStarted(QueueStartedEventArgs e)
 {
     if (QueueStarted != null)
     {
         QueueStarted(this, e);
     }
 }
コード例 #2
0
        /// <summary>
        /// Copies file system items overwriting if necessary.
        /// </summary>
        /// <param name="items">List of <code>CopyPair</code> to copy.</param>
        public void Copy(IList <CopyPair> items)
        {
            try
            {
                if (items == null)
                {
                    throw new ArgumentNullException("items", "List of items to copy is null.");
                }
                else if (items.Count == 0)
                {
                    return;
                }

                InitializeQueue(items);

                if (QueueStarted != null)
                {
                    var args = new QueueStartedEventArgs(_queueInfo);
                    OnQueueStarted(args);
                    if (args.Cancel)
                    {
                        return;
                    }
                }

                foreach (var copyPair in items)
                {
                    CheckStopped();
                    try
                    {
                        CopyHelper(copyPair);
                        _queueInfo.ItemsCompleteCount += 1;
                        OnQueueProgressChanged(_queueInfo);
                    }
                    catch (Exception ex)
                    {
                        ReportError(copyPair, ex);
                        _log.ErrorFormat("Error copying {0} to {1}.", copyPair.SourceInfo.FullName, copyPair.TargetInfo.FullName);
                        _log.ErrorFormat(ex.Message, ex);
                    }
                    CheckStopped();
                }
                OnQueueComplete(_queueInfo);
            }
            catch (StoppedException)
            {
                _log.Debug("FileSystemCopier execution stopped.");
                StopInternal();
            }
        }