コード例 #1
0
        /// <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());
        }
コード例 #2
0
        /// <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");
            }

            TraceFactory.Logger.Debug("Starting Data Log service...");

            // Load the settings, either from the command line or the local cache
            SettingsLoader.LoadSystemConfiguration(args.GetParameterValue("database"));

            // Create the data log service implementation
            DataLogService singletonInstance;
            string         alternateDatabase = SettingsLoader.RetrieveSetting("DataLogDatabaseAlternate");

            if (!string.IsNullOrEmpty(alternateDatabase))
            {
                singletonInstance = new DataLogService(DbConnect.DataLogConnectionString, new DataLogConnectionString(alternateDatabase));
            }
            else
            {
                singletonInstance = new DataLogService(DbConnect.DataLogConnectionString);
            }

            // Set data log configuration
            singletonInstance.InitializeCache(new DirectoryInfo("Cache"), _cacheCheckFrequency);
            singletonInstance.CacheOperationsRetried += OnCacheOperationsRetried;
            singletonInstance.SessionDataExpired     += OnSessionDataExpired;

            // Start the service
            _dataLogService = new WcfHost <IDataLogService>(singletonInstance, DataLogServiceEndpoint.MessageTransferType, DataLogServiceEndpoint.BuildUri("localhost"));
            _dataLogService.Open();

            TraceFactory.Logger.Debug("Data Log service started.");
        }