示例#1
0
        private void RefreshJobAds()
        {
            const string method = "RefreshJobAds";

            EventSource.Raise(Event.Information, method, "Refreshing job ads");

            var ids   = _jobAdsQuery.GetJobAdIdsRequiringRefresh(DateTime.Now.Date.AddDays(-7));
            var count = 0;

            foreach (var id in ids)
            {
                try
                {
                    var jobAd = _jobAdsQuery.GetJobAd <JobAd>(id);
                    if (jobAd != null)
                    {
                        _jobAdsCommand.RefreshJobAd(jobAd);
                        ++count;
                    }
                }
                catch (Exception ex)
                {
                    EventSource.Raise(Event.Error, method, string.Format("Could not refresh the '{0}' job ad.", id), ex);
                }
            }

            EventSource.Raise(Event.Information, method, string.Format("{0} job ads were refreshed.", count));
        }