public override string Check(int tenantId) { try { log.Debug("CheckFeedState"); var userGuid = new Guid(fakeUserId); CoreContext.TenantManager.SetCurrentTenant(tenantId); SecurityContext.AuthenticateMe(userGuid); var person = new Person { FirstName = "Homer", LastName = "Simpson", JobTitle = "Software engineer", About = "Cool dude" }; int personId; using (var scope = DIHelper.Resolve(tenantId)) { var dao = scope.Resolve <DaoFactory>().ContactDao; personId = dao.SaveContact(person); CRMSecurity.SetAccessTo(person, new List <Guid> { userGuid }); // waiting while service is collecting news var feedCfg = FeedConfigurationSection.GetFeedSection(); Thread.Sleep(feedCfg.AggregatePeriod + TimeSpan.FromSeconds(30)); var feedItemId = string.Format("person_{0}", personId); var feedItem = FeedAggregateDataProvider.GetFeedItem(feedItemId); if (feedItem == null) { log.ErrorFormat("Error! Feed Item is null, feedItemId = {0}", feedItemId); dao.DeleteContact(personId); FeedAggregateDataProvider.RemoveFeedItem(feedItemId); return(HealthCheckResource.FeedService_NewsGenerationError); } dao.DeleteContact(personId); FeedAggregateDataProvider.RemoveFeedItem(feedItemId); log.Debug("Feed is OK!"); return(string.Empty); } } catch (Exception ex) { log.ErrorFormat("Feed is failed! {0}, innerException = {1}", ex, ex.InnerException != null ? ex.InnerException.Message : string.Empty); return(HealthCheckResource.ServiceCheckFailed); } }
public void Start() { var cfg = FeedConfigurationSection.GetFeedSection(); isStopped = false; DbRegistry.Configure(); CommonLinkUtility.Initialize(cfg.ServerRoot); WebItemManager.Instance.LoadItems(); aggregateTimer = new Timer(AggregateFeeds, cfg.AggregateInterval, TimeSpan.Zero, cfg.AggregatePeriod); removeTimer = new Timer(RemoveFeeds, cfg.AggregateInterval, cfg.RemovePeriod, cfg.RemovePeriod); }