示例#1
0
        /// <summary>
        /// Constructs a new instance of the LiveControl
        /// </summary>
        /// <param name="initialTimeout">The duration that the backups should be initially suspended</param>
        public LiveControls(Datamodel.ApplicationSettings settings)
        {
            m_state           = LiveControlState.Running;
            m_waitTimer       = new System.Windows.Forms.Timer();
            m_waitTimer.Tick += new EventHandler(m_waitTimer_Tick);
            if (!string.IsNullOrEmpty(settings.StartupDelayDuration) && settings.StartupDelayDuration != "0")
            {
                TimeSpan ts = Duplicati.Library.Utility.Timeparser.ParseTimeSpan(settings.StartupDelayDuration);
                m_waitTimer.Interval = (int)ts.TotalMilliseconds;
                m_waitTimer.Enabled  = true;
                m_waitTimeExpiration = DateTime.Now + ts;
                m_state = LiveControlState.Paused;
            }

            m_priority = settings.ThreadPriorityOverride;
            if (!string.IsNullOrEmpty(settings.DownloadSpeedLimit))
            {
                m_downloadLimit = Library.Utility.Sizeparser.ParseSize(settings.DownloadSpeedLimit, "kb");
            }
            if (!string.IsNullOrEmpty(settings.UploadSpeedLimit))
            {
                m_uploadLimit = Library.Utility.Sizeparser.ParseSize(settings.UploadSpeedLimit, "kb");
            }

            try
            {
                if (!Library.Utility.Utility.IsClientLinux)
                {
                    RegisterHibernateMonitor();
                }
            }
            catch { }
        }
示例#2
0
 /// <summary>
 /// Pauses the backups until resumed
 /// </summary>
 public void Pause()
 {
     if (m_state == LiveControlState.Running)
     {
         m_state = LiveControlState.Paused;
         if (StateChanged != null)
         {
             StateChanged(this, null);
         }
     }
 }
示例#3
0
        /// <summary>
        /// Constructs a new instance of the LiveControl
        /// </summary>
        public LiveControls(Database.ServerSettings settings)
        {
            m_state     = LiveControlState.Running;
            m_waitTimer = new System.Threading.Timer(m_waitTimer_Tick, this, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);

            if (!string.IsNullOrEmpty(settings.StartupDelayDuration) && settings.StartupDelayDuration != "0")
            {
                long milliseconds = 0;
                try { milliseconds = (long)Duplicati.Library.Utility.Timeparser.ParseTimeSpan(settings.StartupDelayDuration).TotalMilliseconds; }
                catch {}

                if (milliseconds > 0)
                {
                    m_waitTimeExpiration = DateTime.Now.AddMilliseconds(milliseconds);
                    m_waitTimer.Change(milliseconds, System.Threading.Timeout.Infinite);
                    m_state = LiveControlState.Paused;
                }
            }

            m_priority = settings.ThreadPriorityOverride;
            if (!string.IsNullOrEmpty(settings.DownloadSpeedLimit))
            {
                try
                {
                    m_downloadLimit = Library.Utility.Sizeparser.ParseSize(settings.DownloadSpeedLimit, "kb");
                }
                catch (Exception ex)
                {
                    Library.Logging.Log.WriteErrorMessage(LOGTAG, "ParseDownloadLimitError", ex, "Failed to parse download limit: {0}", settings.DownloadSpeedLimit);
                }
            }

            if (!string.IsNullOrEmpty(settings.UploadSpeedLimit))
            {
                try
                {
                    m_uploadLimit = Library.Utility.Sizeparser.ParseSize(settings.UploadSpeedLimit, "kb");
                }
                catch (Exception ex)
                {
                    Library.Logging.Log.WriteErrorMessage(LOGTAG, "ParseUploadLimitError", ex, "Failed to parse upload limit: {0}", settings.UploadSpeedLimit);
                }
            }

            try
            {
                if (!Library.Utility.Utility.IsClientLinux)
                {
                    RegisterHibernateMonitor();
                }
            }
            catch { }
        }
示例#4
0
 /// <summary>
 /// Internal helper to set the pause mode
 /// </summary>
 private void SetPauseMode()
 {
     lock (m_lock)
     {
         if (m_state == LiveControlState.Running)
         {
             m_state = LiveControlState.Paused;
             if (StateChanged != null)
                 StateChanged(this, null);
         }
     }
 }
示例#5
0
        /// <summary>
        /// Resumes a backups to the running state
        /// </summary>
        public void Resume()
        {
            if (m_state == LiveControlState.Paused)
            {
                //Make sure that the timer is cleared
                m_waitTimer.Enabled = false;

                m_state = LiveControlState.Running;
                if (StateChanged != null)
                {
                    StateChanged(this, null);
                }
            }
        }
示例#6
0
        /// <summary>
        /// Resumes a backups to the running state
        /// </summary>
        public void Resume()
        {
            lock (m_lock)
            {
                if (m_state == LiveControlState.Paused)
                {
                    //Make sure that the timer is cleared
                    ResetTimer(null);

                    m_state = LiveControlState.Running;
                    if (StateChanged != null)
                        StateChanged(this, null);
                }
            }
        }
示例#7
0
        /// <summary>
        /// Resumes a backups to the running state
        /// </summary>
        public void Resume()
        {
            lock (m_lock)
            {
                if (m_state == LiveControlState.Paused)
                {
                    //Make sure that the timer is cleared
                    m_waitTimeExpiration = new DateTime(0);
                    m_waitTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);

                    m_state = LiveControlState.Running;
                    if (StateChanged != null)
                    {
                        StateChanged(this, null);
                    }
                }
            }
        }
示例#8
0
        /// <summary>
        /// Constructs a new instance of the LiveControl
        /// </summary>
        /// <param name="initialTimeout">The duration that the backups should be initially suspended</param>
        public LiveControls(Database.ApplicationSettings settings)
        {
            m_state     = LiveControlState.Running;
            m_waitTimer = new System.Threading.Timer(m_waitTimer_Tick, this, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);

            if (!string.IsNullOrEmpty(settings.StartupDelayDuration) && settings.StartupDelayDuration != "0")
            {
                long milliseconds = 0;
                try { milliseconds = (long)Duplicati.Library.Utility.Timeparser.ParseTimeSpan(settings.StartupDelayDuration).TotalMilliseconds; }
                catch {}

                if (milliseconds > 0)
                {
                    m_waitTimeExpiration = DateTime.Now.AddMilliseconds(milliseconds);
                    m_waitTimer.Change(milliseconds, System.Threading.Timeout.Infinite);
                    m_state = LiveControlState.Paused;
                }
            }

            m_priority = settings.ThreadPriorityOverride;

            /*
             * if (!string.IsNullOrEmpty(settings.DownloadSpeedLimit))
             *  m_downloadLimit = Library.Utility.Sizeparser.ParseSize(settings.DownloadSpeedLimit, "kb");
             * if (!string.IsNullOrEmpty(settings.UploadSpeedLimit))
             *  m_uploadLimit = Library.Utility.Sizeparser.ParseSize(settings.UploadSpeedLimit, "kb");
             */

            try
            {
                if (!Library.Utility.Utility.IsClientLinux)
                {
                    RegisterHibernateMonitor();
                }
            }
            catch { }
        }
示例#9
0
        /// <summary>
        /// Constructs a new instance of the LiveControl
        /// </summary>
        /// <param name="initialTimeout">The duration that the backups should be initially suspended</param>
        public LiveControls(Datamodel.ApplicationSettings settings)
        {
            m_state = LiveControlState.Running;
            m_waitTimer = new System.Windows.Forms.Timer();
            m_waitTimer.Tick += new EventHandler(m_waitTimer_Tick);
            if (!string.IsNullOrEmpty(settings.StartupDelayDuration) && settings.StartupDelayDuration != "0")
            {
                TimeSpan ts = XervBackup.Library.Utility.Timeparser.ParseTimeSpan(settings.StartupDelayDuration);
                m_waitTimer.Interval = (int)ts.TotalMilliseconds;
                m_waitTimer.Enabled = true;
                m_waitTimeExpiration = DateTime.Now + ts;
                m_state = LiveControlState.Paused;
            }

            m_priority = settings.ThreadPriorityOverride;
            if (!string.IsNullOrEmpty(settings.DownloadSpeedLimit))
                m_downloadLimit = Library.Utility.Sizeparser.ParseSize(settings.DownloadSpeedLimit, "kb");
            if (!string.IsNullOrEmpty(settings.UploadSpeedLimit))
                m_uploadLimit = Library.Utility.Sizeparser.ParseSize(settings.UploadSpeedLimit, "kb");

            try
            {
                if (!Library.Utility.Utility.IsClientLinux)
                    RegisterHibernateMonitor();
            }
            catch { }
        }
示例#10
0
        /// <summary>
        /// Resumes a backups to the running state
        /// </summary>
        public void Resume()
        {
            if (m_state == LiveControlState.Paused)
            {
                //Make sure that the timer is cleared
                m_waitTimer.Enabled = false;

                m_state = LiveControlState.Running;
                if (StateChanged != null)
                    StateChanged(this, null);
            }
        }
示例#11
0
 /// <summary>
 /// Pauses the backups until resumed
 /// </summary>
 public void Pause()
 {
     if (m_state == LiveControlState.Running)
     {
         m_state = LiveControlState.Paused;
         if (StateChanged != null)
             StateChanged(this, null);
     }
 }
示例#12
0
        /// <summary>
        /// Resumes a backups to the running state
        /// </summary>
        public void Resume()
        {
            lock (m_lock)
            {
                if (m_state == LiveControlState.Paused)
                {
                    //Make sure that the timer is cleared
                    ResetTimer(null);

                    m_state = LiveControlState.Running;
                    if (StateChanged != null)
                        StateChanged(this, null);
                }
            }
        }
示例#13
0
 /// <summary>
 /// Internal helper to set the pause mode
 /// </summary>
 private void SetPauseMode()
 {
     lock (m_lock)
     {
         if (m_state == LiveControlState.Running)
         {
             m_state = LiveControlState.Paused;
             if (StateChanged != null)
                 StateChanged(this, null);
         }
     }
 }
示例#14
0
        /// <summary>
        /// Constructs a new instance of the LiveControl
        /// </summary>
        /// <param name="initialTimeout">The duration that the backups should be initially suspended</param>
        public LiveControls(Database.ApplicationSettings settings)
        {
            m_state = LiveControlState.Running;
            m_waitTimer = new System.Threading.Timer(m_waitTimer_Tick, this, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);

            if (!string.IsNullOrEmpty(settings.StartupDelayDuration) && settings.StartupDelayDuration != "0")
            {
                long milliseconds = 0;
                try { milliseconds = (long)Duplicati.Library.Utility.Timeparser.ParseTimeSpan(settings.StartupDelayDuration).TotalMilliseconds; }
                catch {}

                if (milliseconds > 0)
                {
                    m_waitTimeExpiration = DateTime.Now.AddMilliseconds(milliseconds);
                    m_waitTimer.Change(milliseconds, System.Threading.Timeout.Infinite);
                    m_state = LiveControlState.Paused;
                }
            }

            m_priority = settings.ThreadPriorityOverride;
            if (!string.IsNullOrEmpty(settings.DownloadSpeedLimit))
                m_downloadLimit = Library.Utility.Sizeparser.ParseSize(settings.DownloadSpeedLimit, "kb");
            if (!string.IsNullOrEmpty(settings.UploadSpeedLimit))
                m_uploadLimit = Library.Utility.Sizeparser.ParseSize(settings.UploadSpeedLimit, "kb");

            try
            {
                if (!Library.Utility.Utility.IsClientLinux)
                    RegisterHibernateMonitor();
            }
            catch { }
        }
示例#15
0
        /// <summary>
        /// Resumes a backups to the running state
        /// </summary>
        public void Resume()
        {
            lock (m_lock)
            {
                if (m_state == LiveControlState.Paused)
                {
                    //Make sure that the timer is cleared
                    m_waitTimeExpiration = new DateTime(0);
                    m_waitTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);

                    m_state = LiveControlState.Running;
                    if (StateChanged != null)
                        StateChanged(this, null);
                }
            }
        }