コード例 #1
0
        //generators
        protected override List <SubscriberTopicSettings <ObjectId> > GenerateTopics(GeneratorContext genContext,
                                                                                     SubscriberCategorySettings <ObjectId> category, SubscriberWithMissingData subscriber)
        {
            EntityContext subscriberContext     = genContext.EntityContexts[typeof(SubscriberWithMissingData)];
            long          subscriberNumber      = subscriberContext.EntityProgress.CurrentCount;
            int           subscribersPerTopic   = 1000;
            long          subscribersTopicGroup = subscriberNumber / subscribersPerTopic;

            string[] topics = new[]
            {
                "3011" + subscribersTopicGroup,
                "3012" + subscribersTopicGroup
            };

            var categoryTopics = topics
                                 .Select((topic, i) => new SubscriberTopicSettings <ObjectId>
            {
                SubscriberTopicSettingsId = ObjectId.GenerateNewId(),
                SubscriberId    = category.SubscriberId,
                DeliveryType    = category.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);
        }
コード例 #2
0
        protected virtual List <SubscriberTopicSettings <ObjectId> > GenerateTopics(GeneratorContext genContext,
                                                                                    SubscriberCategorySettings <ObjectId> category, SubscriberWithMissingData subscriber)
        {
            string[] topics = new[]
            {
                "301a",
                "302a"
            };

            var categoryTopics = topics
                                 .Select((topic, i) => new SubscriberTopicSettings <ObjectId>
            {
                SubscriberTopicSettingsId = ObjectId.GenerateNewId(),
                SubscriberId    = category.SubscriberId,
                DeliveryType    = category.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);
        }