Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataLogService" /> class.
        /// </summary>
        /// <param name="dataLogConnectionString">The <see cref="DataLogConnectionString" /> used to connect to the database.</param>
        /// <exception cref="ArgumentNullException"><paramref name="dataLogConnectionString" /> is null.</exception>
        public DataLogService(DataLogConnectionString dataLogConnectionString)
        {
            _dataLogConnectionString = dataLogConnectionString ?? throw new ArgumentNullException(nameof(dataLogConnectionString));
            _writer  = new DataLogDatabaseWriter(dataLogConnectionString);
            _cleanup = new DataLogCleanup(dataLogConnectionString);

            _cacheCheckTimer   = new Timer(RetryCacheEntries, null, Timeout.Infinite, Timeout.Infinite);
            _cleanupCheckTimer = new Timer(DeleteExpiredSessions, null, _cleanupCheckFrequency, _cleanupCheckFrequency);
        }
        /// <summary>
        /// Starts this service instance.
        /// </summary>
        /// <param name="args">The <see cref="CommandLineArguments" /> provided to the start command.</param>
        protected override void StartService(CommandLineArguments args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            // Load the settings, either from the command line or the local cache
            FrameworkServiceHelper.LoadSettings(args);

            ReservationExpirationManager expirationManager = new ReservationExpirationManager(DbConnect.AssetInventoryConnectionString);
            ExpirationNotifier expirationNotifier = new ExpirationNotifier(GlobalSettings.Items[Setting.AdminEmailServer]);
            _assetInventory = new AssetInventoryService(new[] { expirationManager }, expirationNotifier);

            Task.Factory.StartNew(() => _lock.Open());

            DataLogConnectionString connectionString = new DataLogConnectionString(GlobalSettings.Items[Setting.DataLogDatabase]);
            _dataLogService = new WcfHost<IDataLogService>(new DataLogService(connectionString), DataLogServiceEndpoint.MessageTransferType, DataLogServiceEndpoint.BuildUri("localhost"));
            Task.Factory.StartNew(() => _dataLogService.Open());
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataLogCleanup" /> class.
 /// </summary>
 /// <param name="connectionString">The <see cref="DataLogConnectionString" />.</param>
 public DataLogCleanup(DataLogConnectionString connectionString)
 {
     _connectionString = connectionString;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataLogService" /> class.
 /// </summary>
 /// <param name="dataLogConnectionString">The <see cref="DataLogConnectionString" /> used to connect to the database.</param>
 /// <param name="alternateConnectionString">A <see cref="DataLogConnectionString" /> used to connect to an alternate database if the primary operation fails.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="dataLogConnectionString" /> is null.
 /// <para>or</para>
 /// <paramref name="alternateConnectionString" /> is null.
 /// </exception>
 public DataLogService(DataLogConnectionString dataLogConnectionString, DataLogConnectionString alternateConnectionString)
     : this(dataLogConnectionString)
 {
     _alternateWriter = new DataLogDatabaseWriter(alternateConnectionString);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataLogDatabaseWriter" /> class.
 /// </summary>
 /// <param name="connectionString">The <see cref="DataLogConnectionString" /> used to connect to the database.</param>
 /// <exception cref="ArgumentNullException"><paramref name="connectionString" /> is null.</exception>
 public DataLogDatabaseWriter(DataLogConnectionString connectionString)
 {
     _connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString));
 }