public void EnqueueSiteToCheck(SiteStatusCheckItem siteStatusCheckItem)
 {
     if (!_sitesToCheckQueue.IsAddingCompleted)
     {
         AddOrUpdateTrackedSiteConfigurationState(siteStatusCheckItem);
         EnqueueSiteToCheckInternal(siteStatusCheckItem);
     }
 }
        private void AddOrUpdateTrackedSiteConfigurationState(SiteStatusCheckItem siteStatusCheckItem)
        {
            _trackedSiteConfigurationStatesLock.EnterWriteLock();

            try
            {
                _trackedSiteConfigurationStates[siteStatusCheckItem.SiteConfigurationId] = siteStatusCheckItem.SiteConfigurationState;
            }
            finally
            {
                _trackedSiteConfigurationStatesLock.ExitWriteLock();
            }
        }
        private void ProcessQueueItem(SiteStatusCheckItem item)
        {
            var siteConfigurationState = GetSiteConfigurationState(item.SiteConfigurationId);

            if (siteConfigurationState == null ||
                item.EnqueueDateTime < siteConfigurationState.LastUpdated)
            {
                return;
            }

            var isSiteAvailable = _siteStatusCheckService
                                  .GetIsSiteAvailable(item.SiteConfigurationState.SiteUrl);

            Debug.WriteLine($"{DateTime.Now} - {item.SiteConfigurationState.SiteUrl}: {(isSiteAvailable ? "Available" : "Unavailable")}");

            UpdateSiteStatusIfValid(
                item.SiteConfigurationId,
                isSiteAvailable,
                DateTime.UtcNow);
        }
 private void EnqueueSiteToCheckInternal(SiteStatusCheckItem siteStatusCheckItem)
 {
     _sitesToCheckQueue.TryAdd(siteStatusCheckItem);
 }