Example #1
0
        private Update GetBaseUpdateParticipantStatusesForItemQuery(ExitFromCampaignElement element)
        {
            var statusIdToSet = GetParticipantStatusToSet(element.IsCampaignGoal);
            var update        =
                new Update(UserConnection, CampaignParticipantTableName)
                .Set("StatusId", Column.Parameter(statusIdToSet))
                .Set("StepModifiedOn", Column.Parameter(DateTime.UtcNow));

            update.WithHints(new RowLockHint());
            return(update);
        }
Example #2
0
 private void ActualizeParticipantStatusesForItem(ExitFromCampaignElement element)
 {
     if (UseCampaignBatchedQueries)
     {
         BatchedUpdateParticipantStatusesForItem(element);
     }
     else
     {
         UpdateParticipantStatusesForItem(element);
     }
 }
Example #3
0
        private void UpdateParticipantStatusesForItem(ExitFromCampaignElement element)
        {
            var update           = GetBaseUpdateParticipantStatusesForItemQuery(element);
            var statusesToUpdate = GetParticipantStatusesToUpdate(element.IsCampaignGoal);

            update.Where("CampaignId").IsEqual(Column.Parameter(CampaignSchema.EntityId))
            .And("CampaignItemId").IsEqual(Column.Parameter(element.UId))
            .And("StepCompleted").IsEqual(Column.Const(true))
            .And("StatusId").In(Column.Parameters(statusesToUpdate));
            update.Execute();
        }
Example #4
0
        private Select GetParticipantIdsToUpdateSelectQuery(ExitFromCampaignElement element)
        {
            var statusesToUpdate = GetParticipantStatusesToUpdate(element.IsCampaignGoal);
            var select           = new Select(UserConnection)
                                   .Column("Id")
                                   .From(CampaignParticipantTableName)
                                   .Where("CampaignId").IsEqual(Column.Parameter(CampaignSchema.EntityId))
                                   .And("CampaignItemId").IsEqual(Column.Parameter(element.UId))
                                   .And("StepCompleted").IsEqual(Column.Const(true))
                                   .And("StatusId").In(Column.Parameters(statusesToUpdate)) as Select;

            select.SpecifyNoLockHints();
            return(select);
        }
Example #5
0
        private void BatchedUpdateParticipantStatusesForItem(ExitFromCampaignElement element)
        {
            var participantsSelect     = GetParticipantIdsToUpdateSelectQuery(element);
            var participantsCollection = participantsSelect
                                         .ExecuteEnumerable(r => r.GetColumnValue <Guid>("Id")).ToList();
            int participantsCount = participantsCollection.Count;
            int batchSize         = CampaignElementAudienceQueryBatchSize;
            int processedCount    = 0;

            while (processedCount < participantsCount)
            {
                var participantsBatch = participantsCollection.Skip(processedCount).Take(batchSize);
                var updateQuery       = GetBaseUpdateParticipantStatusesForItemQuery(element);
                updateQuery.Where("Id").In(Column.Parameters(participantsBatch));
                updateQuery.Execute();
                processedCount += batchSize;
                Task.Delay(10).Wait();
            }
        }
 /// <summary>
 /// Constructor for <see cref="ExitFromCampaignElement"/>.
 /// </summary>
 /// <param name="source">Instance of <see cref="ExitFromCampaignElement"/>.</param>
 /// <param name="dictToRebind">Dictionary to rebind schema elements' ids.</param>
 /// <param name="parentSchema">Parent campaign schema.</param>
 public ExitFromCampaignElement(ExitFromCampaignElement source, Dictionary <Guid, Guid> dictToRebind,
                                Core.Campaign.CampaignSchema parentSchema) : base(source, dictToRebind, parentSchema)
 {
     IsCampaignGoal = source.IsCampaignGoal;
 }
 /// <summary>
 /// Constructor for <see cref="ExitFromCampaignElement"/>.
 /// </summary>
 /// <param name="source">Instance of <see cref="ExitFromCampaignElement"/>.</param>
 public ExitFromCampaignElement(ExitFromCampaignElement source)
     : this(source, null, null)
 {
 }