コード例 #1
0
ファイル: ConsoleOutput.cs プロジェクト: xuchrist/duplicati
 public void BackendEvent(BackendActionType action, BackendEventType type, string path, long size)
 {
     lock (m_lock)
         if (type == BackendEventType.Started)
         {
             if (action == BackendActionType.Put)
             {
                 Console.WriteLine("  Uploading file ({0}) ...", Library.Utility.Utility.FormatSizeString(size));
             }
             else if (action == BackendActionType.Get)
             {
                 Console.WriteLine("  Downloading file ({0}) ...", size < 0 ? "unknown" : Library.Utility.Utility.FormatSizeString(size));
             }
             else if (action == BackendActionType.List)
             {
                 Console.WriteLine("  Listing remote folder ...");
             }
             else if (action == BackendActionType.CreateFolder)
             {
                 Console.WriteLine("  Creating remote folder ...");
             }
             else if (action == BackendActionType.Delete)
             {
                 Console.WriteLine("  Deleting file {0}{1} ...", path, size < 0 ? "" : (" (" + Library.Utility.Utility.FormatSizeString(size) + ")"));
             }
         }
 }
コード例 #2
0
 public void BackendEvent(BackendActionType action, BackendEventType type, string path, long size)
 {
     foreach (var s in m_sinks)
     {
         s.BackendEvent(action, type, path, size);
     }
 }
コード例 #3
0
        public void BackendEvent(BackendActionType action, BackendEventType type, string path, long size)
        {
            lock (m_lock)
                if (type == BackendEventType.Started)
                {
                    switch (action)
                    {
                    case BackendActionType.Put:
                        Output.WriteLine("  Uploading file ({0}) ...", Library.Utility.Utility.FormatSizeString(size));
                        break;

                    case BackendActionType.Get:
                        Output.WriteLine("  Downloading file ({0}) ...", size < 0 ? "unknown" : Library.Utility.Utility.FormatSizeString(size));
                        break;

                    case BackendActionType.List:
                        Output.WriteLine("  Listing remote folder ...");
                        break;

                    case BackendActionType.CreateFolder:
                        Output.WriteLine("  Creating remote folder ...");
                        break;

                    case BackendActionType.Delete:
                        Output.WriteLine("  Deleting file {0}{1} ...", path, size < 0 ? "" : (" (" + Library.Utility.Utility.FormatSizeString(size) + ")"));
                        break;
                    }
                }
        }
コード例 #4
0
 /// <summary>
 /// Register the start of a new action
 /// </summary>
 /// <param name="action">The action that is starting</param>
 /// <param name="path">The path being operated on</param>
 /// <param name="size">The size of the file being transferred</param>
 public void StartAction(BackendActionType action, string path, long size)
 {
     lock (m_lock)
     {
         m_action      = action;
         m_path        = path;
         m_size        = size;
         m_progress    = 0;
         m_actionStart = DateTime.Now;
     }
 }
コード例 #5
0
ファイル: ConsoleOutput.cs プロジェクト: admz/duplicati
 public void BackendEvent(BackendActionType action, BackendEventType type, string path, long size)
 {
     lock(m_lock)
         if (type == BackendEventType.Started)
         {
             if (action == BackendActionType.Put)
                 Console.WriteLine("  Uploading file ({0}) ...", Library.Utility.Utility.FormatSizeString(size));
             else if (action == BackendActionType.Get)
                 Console.WriteLine("  Downloading file ({0}) ...", size < 0 ? "unknown" : Library.Utility.Utility.FormatSizeString(size));
             else if (action == BackendActionType.List)
                 Console.WriteLine("  Listing remote folder ...");
             else if (action == BackendActionType.CreateFolder)
                 Console.WriteLine("  Creating remote folder ...");
             else if (action == BackendActionType.Delete)
                 Console.WriteLine("  Deleting file {0}{1} ...", path, size < 0 ? "" : (" (" + Library.Utility.Utility.FormatSizeString(size) + ")"));
         }
 }
コード例 #6
0
        public void AddBackendEvent(BackendActionType action, BackendEventType type, string path, long size)
        {
            if (m_parent != null)
            {
                m_parent.AddBackendEvent(action, type, path, size);
            }
            else
            {
                if (type == BackendEventType.Started)
                {
                    this.BackendProgressUpdater.StartAction(action, path, size);
                }

                Logging.Log.WriteMessage(string.Format("Backend event: {0} - {1}: {2} ({3})", action, type, path, size <= 0 ? "" : Library.Utility.Utility.FormatSizeString(size)), Duplicati.Library.Logging.LogMessageType.Information);

                if (MessageSink != null)
                {
                    MessageSink.BackendEvent(action, type, path, size);
                }
            }
        }
コード例 #7
0
ファイル: ProgressClasses.cs プロジェクト: zed9h/duplicati
        /// <summary>
        /// Update with the current action, path, size, progress and bytes_pr_second.
        /// </summary>
        /// <param name="action">The current action</param>
        /// <param name="path">The current path</param>
        /// <param name="size">The current size</param>
        /// <param name="progress">The current number of transferred bytes</param>
        /// <param name="bytes_pr_second">Transfer speed in bytes pr second, -1 for unknown</param>
        public void Update(out BackendActionType action, out string path, out long size, out long progress, out long bytes_pr_second)
        {
            lock (m_lock)
            {
                action   = m_action;
                path     = m_path;
                size     = m_size;
                progress = m_progress;

                //TODO: The speed should be more dynamic,
                // so we need a sample window instead of always
                // calculating from the beginning
                if (m_progress <= 0 || m_size <= 0 || m_actionStart.Ticks == 0)
                {
                    bytes_pr_second = -1;
                }
                else
                {
                    bytes_pr_second = (long)(m_progress / (DateTime.Now - m_actionStart).TotalSeconds);
                }
            }
        }
コード例 #8
0
        public void SendEvent(BackendActionType action, BackendEventType type, string path, long size)
        {
            if (type == BackendEventType.Started)
            {
                System.Threading.Interlocked.Increment(ref m_remoteCalls);
            }
            else if (type == BackendEventType.Retrying)
            {
                System.Threading.Interlocked.Increment(ref m_retryAttemptCount);
            }
            else if (type == BackendEventType.Completed)
            {
                switch (action)
                {
                case BackendActionType.CreateFolder:
                    System.Threading.Interlocked.Increment(ref m_foldersCreated);
                    break;

                case BackendActionType.List:
                    break;

                case BackendActionType.Delete:
                    System.Threading.Interlocked.Increment(ref m_filesDeleted);
                    break;

                case BackendActionType.Get:
                    System.Threading.Interlocked.Increment(ref m_filesDownloaded);
                    System.Threading.Interlocked.Add(ref m_bytesDownloaded, size);
                    break;

                case BackendActionType.Put:
                    System.Threading.Interlocked.Increment(ref m_filesUploaded);
                    System.Threading.Interlocked.Add(ref m_bytesUploaded, size);
                    break;
                }
            }

            base.AddBackendEvent(action, type, path, size);
        }
コード例 #9
0
        public void AddBackendEvent(BackendActionType action, BackendEventType type, string path, long size)
        {
            if (m_parent != null)
            {
                m_parent.AddBackendEvent(action, type, path, size);
            }
            else
            {
                lock (Logging.Log.Lock)
                {
                    if (m_is_reporting)
                    {
                        return;
                    }

                    try
                    {
                        m_is_reporting = true;
                        if (type == BackendEventType.Started)
                        {
                            this.BackendProgressUpdater.StartAction(action, path, size);
                        }

                        Logging.Log.WriteInformationMessage(LOGTAG, "BackendEvent", "Backend event: {0} - {1}: {2} ({3})", action, type, path, size <= 0 ? "" : Library.Utility.Utility.FormatSizeString(size));

                        if (MessageSink != null)
                        {
                            MessageSink.BackendEvent(action, type, path, size);
                        }
                    }
                    finally
                    {
                        m_is_reporting = false;
                    }
                }
            }
        }
コード例 #10
0
ファイル: ResultClasses.cs プロジェクト: AlexFRAN/duplicati
        public void AddBackendEvent(BackendActionType action, BackendEventType type, string path, long size)
        {
            if (m_parent != null)
            {
                m_parent.AddBackendEvent(action, type, path, size);
            }
            else
            {
                if (type == BackendEventType.Started)
                    this.BackendProgressUpdater.StartAction(action, path, size);

                Logging.Log.WriteMessage(string.Format("Backend event: {0} - {1}: {2} ({3})", action, type, path, size <= 0 ? "" : Library.Utility.Utility.FormatSizeString(size)), Duplicati.Library.Logging.LogMessageType.Information);

                if (MessageSink != null)
                    MessageSink.BackendEvent(action, type, path, size);
            }
                
        }
コード例 #11
0
ファイル: ResultClasses.cs プロジェクト: AlexFRAN/duplicati
 public void SendEvent(BackendActionType action, BackendEventType type, string path, long size)
 {
     if (type == BackendEventType.Started)
     {
         System.Threading.Interlocked.Increment(ref m_remoteCalls);
     }
     else if (type == BackendEventType.Retrying)
     {
         System.Threading.Interlocked.Increment(ref m_retryAttemptCount);
     }
     else if (type == BackendEventType.Completed)
     {
         switch (action)
         {
             case BackendActionType.CreateFolder:
                 System.Threading.Interlocked.Increment(ref m_foldersCreated);
                 break;
             case BackendActionType.List:
                 break;
             case BackendActionType.Delete:
                 System.Threading.Interlocked.Increment(ref m_filesDeleted);
                 break;
             case BackendActionType.Get:
                 System.Threading.Interlocked.Increment(ref m_filesDownloaded);
                 System.Threading.Interlocked.Add(ref m_bytesDownloaded, size);
                 break;
             case BackendActionType.Put:
                 System.Threading.Interlocked.Increment(ref m_filesUploaded);
                 System.Threading.Interlocked.Add(ref m_bytesUploaded, size);
                 break;
         }
     }
     
     base.AddBackendEvent(action, type, path, size);
 }
コード例 #12
0
 public FileEntryItem(BackendActionType operation, string remotefilename)
 {
     Operation      = operation;
     RemoteFilename = remotefilename;
     Size           = -1;
 }
コード例 #13
0
 /// <summary>
 /// Register the start of a new action
 /// </summary>
 /// <param name="action">The action that is starting</param>
 /// <param name="path">The path being operated on</param>
 /// <param name="size">The size of the file being transferred</param>
 public void StartAction(BackendActionType action, string path, long size)
 {
     lock(m_lock)
     {
         m_action = action;
         m_path = path;
         m_size = size;
         m_progress = 0;
         m_actionStart = DateTime.Now;                
     }
 }
コード例 #14
0
 public void UpdateBackendStart(BackendActionType action, string path, long size)
 {
     m_bw.BackendProgressUpdater.StartAction(action, path, size);
 }
コード例 #15
0
 public Task SendEventAsync(BackendActionType action, BackendEventType type, string path, long size, bool updateProgress = true)
 {
     return(RunOnMain(() => m_bw.SendEvent(action, type, path, size, updateProgress)));
 }
コード例 #16
0
 /// <summary>
 /// Update with the current action, path, size, progress and bytes_pr_second.
 /// </summary>
 /// <param name="action">The current action</param>
 /// <param name="path">The current path</param>
 /// <param name="size">The current size</param>
 /// <param name="progress">The current number of transferred bytes</param>
 /// <param name="bytes_pr_second">Transfer speed in bytes pr second, -1 for unknown</param>
 public void Update(out BackendActionType action, out string path, out long size, out long progress, out long bytes_pr_second)
 {
     lock(m_lock)
     {
         action = m_action;
         path = m_path;
         size = m_size;
         progress = m_progress;
         
         //TODO: The speed should be more dynamic,
         // so we need a sample window instead of always 
         // calculating from the beginning
         if (m_progress <= 0 || m_size <= 0 || m_actionStart.Ticks == 0)
             bytes_pr_second = -1;
         else
             bytes_pr_second = (long)(m_progress / (DateTime.Now - m_actionStart).TotalSeconds);
     }
 }
コード例 #17
0
 public FileEntryItem(BackendActionType operation, string remotefilename, long size, string hash)
     : this(operation, remotefilename)
 {
     Size = size;
     Hash = hash;
 }
コード例 #18
0
 public Task SendEventAsync(BackendActionType action, BackendEventType type, string path, long size)
 {
     return(RunOnMain(() => m_bw.SendEvent(action, type, path, size)));
 }