Beispiel #1
0
        /// <summary>
        /// Do the main tasks of the service, check system state, trigger transfers, ...
        /// </summary>
        private void RunMainTasks()
        {
            // Log.Error("test the email rate limiting for error messages...");
            // throw new Exception("just a test exception from RunMainTasks");

            // mandatory tasks, run on every call:
            SendLowSpaceMail(SystemChecks.CheckFreeDiskSpace(_config.SpaceMonitoring));
            UpdateServiceState();

            // update the status heartbeat at least once a minute:
            if (TimeUtils.SecondsSince(_status.LastStatusUpdate) >= 60)
            {
                _status.Serialize();
            }

            if (TimeUtils.SecondsSince(_lastUserDirCheck) >= 120)
            {
                CreateIncomingDirectories();
            }

            // tasks depending on the service state:
            if (_status.ServiceSuspended)
            {
                // make sure to pause any running transfer:
                PauseTransfer();
            }
            else
            {
                // always check the incoming dirs, independently of running transfers:
                CheckIncomingDirectories();
                // now trigger potential transfer tasks:
                RunTransferTasks();
            }
        }