Esempio n. 1
0
        private DCTemplateModel GetDcTemplateModel(Guid bulkEmailId,
                                                   DCRepositoryReadOptions <DCTemplateModel, DCReplicaModel> templateReadOptions)
        {
            var template = TemplateRepository.ReadByRecordId(bulkEmailId, templateReadOptions);

            return(template);
        }
        private void ResolveRecipientsReplica(Guid bulkEmailId)
        {
            var dcDataSource = _audienceDataSource as IDCAudienceDataSource;

            _audienceDataSource.PageNumber = 0;
            var dcStrategyResolver = new DCStrategyResolver(UserConnection);
            var templateRepository = new DCTemplateRepository <DCTemplateModel>(UserConnection);
            var repositoryOptions  = new DCRepositoryReadOptions <DCTemplateModel, DCReplicaModel> {
                TemplateReadOptions = DCTemplateReadOption.None
            };
            var template = templateRepository.ReadByRecordId(bulkEmailId, repositoryOptions);

            if (template == null)
            {
                throw new NullReferenceException($"Template for BulkEmail with id {bulkEmailId} not found");
            }
            while (true)
            {
                _audienceDataSource.PageNumber++;
                var audienceSelect        = dcDataSource.GetRecipientsIdsSelectQuery(Guid.Empty);
                var isAudienceSelectEmpty = IsRecipientsSelectQueryEmpty(audienceSelect);
                if (isAudienceSelectEmpty)
                {
                    break;
                }
                var segmentationContext = new DCSegmentationContext(UserConnection)
                {
                    Template              = template,
                    SourceAudience        = dcDataSource.GetRecipientsIdsSelectQuery(Guid.Empty),
                    SourceAlias           = "MandrillDeliveryPackage",
                    EntityIdSourceColumn  = "RecipientUId",
                    SourceColumnForFilter = "ContactId",
                    TargetTable           = "BulkEmailRecipientReplica",
                    EntityIdTargetColumn  = "RecipientId",
                    ReplicaIdTargetColumn = "DCReplicaId",
                    RecordIdTargetColumn  = "BulkEmailId"
                };
                dcStrategyResolver.SegmentAudience(segmentationContext);
            }
        }