Exemplo n.º 1
0
        public static void RunGetDeltasBatch()
        {
            var subscription = new Subscription(88L, String.Empty);
            var runId        = RunService.StartRun(subscription.SubscriptionDataSetId, "SET_DELTA");

            try {
                RunResultType <TesterEntity> result;
                using (var uow = new UnitOfWork(DatabaseUtil.GetConnection())) {
                    var x = Api.Publisher.PushEvent(EventCacheLockingStrategyType.BypassCacheLocking);

                    using var repoCache = new CacheEntryRepository <TesterEntity>(uow);
                    result = Api.Subscriber.PullBatchDeltas(
                        subscription,
                        runId,
                        Util.PullPublisherDataSet,
                        EmptyPublisherDataSetGetDeltasStrategyType.DefaultProcessingDeleteAll,
                        TesterEntity.IsEqual,
                        Api.Subscriber.CreateCacheOperationBatch <long, TesterEntity>(
                            repoCache.BeginTransaction,
                            repoCache.CommitTransaction,
                            repoCache.RollbackTransaction,
                            repoCache.GetRunIdMaxOfDataSet,

                            repoCache.Insert <long, TesterEntity>,
                            repoCache.Update <long, TesterEntity>,
                            repoCache.GetNewestById <long, TesterEntity>,
                            repoCache.GetDataSetRunExcludingDeltaState <long, TesterEntity>));

                    var messages = result.DeltaSnapshots.ToList();
                }
                Console.WriteLine("CONSUMER: " + (result.IsSuccess ? "SUCCESS" : "FAILURE") + " " + result.ErrorMsgs.FirstOrDefault()
                                  + $" RunId:{result.RunId} DataSetCount:{result.DataSetCount} DeltaCount:{result.DeltaCount}");

                RunService.CompleteRun(result.RunId, result.IsSuccess, result.IsSuccess ? null : result.ErrorMsgs.FirstOrDefault(), result.DataSetCount, result.DeltaCount);
            } catch (Exception ex) {
                Console.WriteLine($"CONSUMER: {ex.Message}");
                RunService.CompleteRun(runId, false, ex.Message, 0, 0);
            }
        }