Пример #1
0
        // For information on handling configuration changes
        // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
        public override bool OnStart()
        {
            GGCharityInstance.InitializeLogging();

            Log = Logging.GetLongLivedLog(RoleEnvironment.CurrentRoleInstance.Id, "WebRole");
            WebKeepAliveTimer = new System.Threading.Timer(WebKeepaliveTimer, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10));

            Log.TraceInformation("New web role initializing");

            RoleEnvironment.Changing += RoleEnvironment_Changing;
            RoleEnvironment.Changed += RoleEnvironment_Changed;
            RoleEnvironment.Stopping += RoleEnvironment_Stopping;
            RoleEnvironment.StatusCheck += RoleEnvironment_StatusCheck;

            bool result = base.OnStart();
            if (!result)
            {
                Log.TraceEvent(TraceEventType.Critical, 0, "base.OnStart failed");
            }

            //BackgroundWorker = new WebRoleBackgroundWorker(RoleEnvironment.CurrentRoleInstance.Id);
            //BackgroundWorker.Start();

            if (Config.Get().RunBackgroundWorkFromWebRole)
            {
                // In debug configurations, only start the background workers by request.
                // In test configurations, always start them.
            #if !DEBUG || TEST
                Instance = new GGCharityInstance(RoleEnvironment.CurrentRoleInstance.Id, GGCharityInstance.InstanceType.Web);
                Instance.Start();
            #endif
            }

            isReady = result;
            return result;
        }
Пример #2
0
        public ScanCoordinator
        (
            IDistributedTaskManager taskManager, 
            IMatchHistoryStorageFactory storageFactory, 
            IMatchResultsProviderFactory resultsProviderFactory,
            TimeSpan pollRate, 
            string workerId,
            bool startTasksSuspended = false,
            IScannerConfiguration scannerConfig = null
        )
        {
            Log = Logging.GetLongLivedLog(workerId, "ScanCoordinator", "ScanCoordinator");

            _storageFactory = storageFactory;
            _taskManager = taskManager;
            _workerId = workerId;

            _monitor = new DistributedTaskMonitor(
                pollRate,
                DistributedTaskMonitor.AutoJoinMode.JoinIfHigherPriority,
                GetScanTaskType(),
                _taskManager,
                this,
                workerId
                );

            _startTasksSuspended = startTasksSuspended;
            _resultsProviderFactory = resultsProviderFactory;

            if (scannerConfig == null)
            {
                scannerConfig = new DefaultScannerConfig();
            }
            _scannerConfig = scannerConfig;
        }
Пример #3
0
 static ApiDispatcher()
 {
     Log = Logging.GetLongLivedLog("BattleNetApiDispatcher", "BattleNetApiDispatcher");
 }
 public StarCraftMatchResultsProvider(string appId)
 {
     _appId = appId;
     Log = Logging.GetLongLivedLog("StarCraftMatchResultsProvider", "MatchScanner");
 }
Пример #5
0
        internal MatchScanner(
            ScanCoordinator monitor, 
            IDistributedTaskParticipationHandle participationHandle, 
            IMatchHistoryStorage storage, 
            IMatchResultsProvider resultsProvider,
            ScanTraits traits,
            string workerId,
            IScannerConfiguration scannerConfig,
            bool suspended = false)
        {
            Log = Logging.GetLongLivedLog(workerId, "MatchScanner", "MatchScanner");

            _participationHandle = participationHandle;
            _matchHistory = storage;
            _resultsProvider = resultsProvider;
            _monitor = monitor;

            _scanTraits = traits;
            _workerId = workerId;

            _mainEvent = _matchHistory.GetEventAsync(_scanTraits.EventId).Result;
            _collection = _mainEvent.GetResultCollectionAsync(_scanTraits.ResultCollection).Result;

            _suspended = suspended;
            _scannerConfig = scannerConfig;
        }