コード例 #1
0
ファイル: AutoTx.cs プロジェクト: imcf/auto-tx
        /// <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();
            _status.SerializeHeartbeat();

            if (TimeUtils.SecondsSince(_lastUserDirCheck) >= 120)
            {
                _lastUserDirCheck = FsUtils.CreateIncomingDirectories(
                    _config.DestinationDirectory, _config.TmpTransferDir, _config.IncomingPath);
            }

            // 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();
            }
        }