//generators protected override List <SubscriberTopicSettings <ObjectId> > GenerateTopicsForDeliveryTypeSettings(GeneratorContext genContext, SpecsDeliveryTypeSettings dt, SubscriberWithMissingData subscriber) { EntityContext subscriberContext = genContext.EntityContexts[typeof(SubscriberWithMissingData)]; long subscriberNumber = subscriberContext.EntityProgress.CurrentCount; int subscribersPerTopic = 1000; long subscribersTopicGroup = subscriberNumber / subscribersPerTopic; string[] topics = new[] { "301" + subscribersTopicGroup, "302" + subscribersTopicGroup }; var categoryTopics = dt.SubscriberCategorySettings.SelectMany(category => topics.Select((topic, i) => new SubscriberTopicSettings <ObjectId> { SubscriberTopicSettingsId = ObjectId.GenerateNewId(), SubscriberId = dt.SubscriberId, DeliveryType = dt.DeliveryType, CategoryId = category.CategoryId, TopicId = topic, IsEnabled = true, AddDateUtc = DateTime.UtcNow, LastSendDateUtc = subscriber.HasTopicLastSendDate ? (DateTime?)DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(5)) : null }) ).ToList(); subscriber.Topics = subscriber.Topics ?? new List <SubscriberTopicSettings <ObjectId> >(); subscriber.Topics.AddRange(categoryTopics); return(categoryTopics); }
protected virtual List <SubscriberTopicSettings <ObjectId> > GenerateTopicsForDeliveryTypeSettings(GeneratorContext genContext, SpecsDeliveryTypeSettings dt, SubscriberWithMissingData subscriber) { string[] topics = new[] { "301a", "302a" }; var categoryTopics = dt.SubscriberCategorySettings.SelectMany(category => topics.Select((topic, i) => new SubscriberTopicSettings <ObjectId> { SubscriberTopicSettingsId = ObjectId.GenerateNewId(), SubscriberId = dt.SubscriberId, DeliveryType = dt.DeliveryType, CategoryId = category.CategoryId, TopicId = topic, IsEnabled = subscriber.HasTopicsSettingsEnabled, AddDateUtc = DateTime.UtcNow, LastSendDateUtc = subscriber.HasTopicLastSendDate ? (DateTime?)DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(5)) : null }) ).ToList(); subscriber.Topics = subscriber.Topics ?? new List <SubscriberTopicSettings <ObjectId> >(); subscriber.Topics.AddRange(categoryTopics); return(categoryTopics); }
protected virtual List <SubscriberCategorySettings <ObjectId> > GenerateCategories(GeneratorContext genContext, SpecsDeliveryTypeSettings deliverySettings, SubscriberWithMissingData subscriber) { int[] categories = new[] { 201, 202 }; var deliveryTypeCategories = categories .Select((category, i) => new SubscriberCategorySettings <ObjectId> { SubscriberCategorySettingsId = ObjectId.GenerateNewId(), SubscriberId = deliverySettings.SubscriberId, DeliveryType = deliverySettings.DeliveryType, CategoryId = category, IsEnabled = subscriber.HasCategorySettingsEnabled }) .ToList(); subscriber.Categories = subscriber.Categories ?? new List <SubscriberCategorySettings <ObjectId> >(); subscriber.Categories.AddRange(deliveryTypeCategories); deliverySettings.SubscriberCategorySettings = deliveryTypeCategories; return(deliveryTypeCategories); }