private bool AreThereActiveGroups(IEnumerable<CreativePackage> packages, GroupsAndIndividualDomainsSendingPolicies groupsAndIndividualDomainsSendingPolicies) { return GetActiveGroups(packages, groupsAndIndividualDomainsSendingPolicies).Any(); }
private void StartGroupSendingJobs(IEnumerable<CreativePackage> recipiens, GroupsAndIndividualDomainsSendingPolicies sendingPolicies) { var groups = GetActiveGroups(recipiens, sendingPolicies); foreach (var domainGroup in groups) { _logger.Info("Start sending to group {0} with interval {1}", domainGroup.Group, domainGroup.Interval); _framework.StartTasks(new SendCreativePackagesWithIntervalTask(x => { x.Group = domainGroup.Group; }, x => x.WithIntervalInSeconds(domainGroup.Interval).RepeatForever() )); } }
private static IEnumerable<PackageInfo> GetActiveGroups(IEnumerable<CreativePackage> recipiens, GroupsAndIndividualDomainsSendingPolicies andIndividualDomainsSendingPolicies) { return recipiens .GroupBy(x => x.Group) .Select(x => new PackageInfo { Group = x.Key, Interval = x.First().Interval, Count = x.Count() }) .Where(x => !andIndividualDomainsSendingPolicies .GroupSendingPolicies .EmptyIfNull() .ContainsKey(x.Group)) .ToList(); }