public virtual void ScheduleDispatch(Commit commit, string databaseName)
        {
            _dispatcher.Dispatch(commit);
            if (string.IsNullOrWhiteSpace(databaseName))
            {
                //using (var t = new TransactionScope(TransactionScopeOption.Suppress))
                //{
                _store.DatabaseCommands.Patch(commit.AggregateId.ToStringId <EventStream>(),
                                              new ScriptedPatchRequest
                {
                    Script = "this.Commits[CommitId].IsDispatched=true",
                    Values = { { "CommitId", RavenJValue.FromObject(commit.CommitId.ToString()) } }
                });
                //t.Complete();
                //}
            }
            else
            {
                //using (var t = new TransactionScope(TransactionScopeOption.Suppress))
                //{
                var db = _store.DatabaseCommands.ForDatabase(databaseName);
                db.Patch(commit.AggregateId.ToStringId <EventStream>(),
                         new ScriptedPatchRequest
                {
                    Script = "this.Commits[CommitId].IsDispatched=true",
                    Values = { { "CommitId", RavenJValue.FromObject(commit.CommitId.ToString()) } }
                });

                //t.Complete();
                //}
            }
        }
 private void DispatchImmediately(Commit commit)
 {
     try
     {
         Logger.Info(Resources.SchedulingDispatch, commit.CommitId);
         _dispatcher.Dispatch(commit);
     }
     catch
     {
         Logger.Error(Resources.UnableToDispatch, _dispatcher.GetType(), commit.CommitId);
         throw;
     }
 }
Ejemplo n.º 3
0
        public void Handle(CreateDocumentPartEvent documentPartEvent)
        {
            var serviceResult = _documentService.GetDocumentPartsNormalized(documentPartEvent.TranslationDocumentId,
                                                                            documentPartEvent.PartCount, documentPartEvent.CreatedBy);

            if (serviceResult.ServiceResultType != ServiceResultType.Success)
            {
                Console.WriteLine("Error occure while normalizing document parts");
            }
            else
            {
                var analyzedDocument = serviceResult.Data;

                var translationOperations = analyzedDocument.Select(a => new TranslationOperationDto {
                    TranslationDocumentPartId    = a.Id,
                    TranslationOperationStatusId = (int)TranslationOperationStatusEnum.Bid,
                    TranslationProgressStatusId  = (int)TranslationProgressStatusEnum.Open
                }).ToList();

                var translationOperationSaveResult = _translationService.SaveTranslationOperations(translationOperations);
                if (translationOperationSaveResult.ServiceResultType != ServiceResultType.Success)
                {
                    Console.WriteLine("Error Occured");
                    _logger.Error($"Unable to save translation operations");
                }
                else
                {
                    var operations = translationOperationSaveResult.Data;

                    var createOrderDetails = new CreateOrderDetailEvent {
                        Id                    = Guid.NewGuid(),
                        CreatedBy             = documentPartEvent.CreatedBy,
                        OrderId               = documentPartEvent.OrderId,
                        TranslationOperations = operations
                    };

                    _dispatcher.Dispatch(new List <EventMessage> {
                        createOrderDetails.ToEventMessage()
                    });
                }
            }
        }
 public void should_provide_the_commit_to_the_dispatcher()
 {
     A.CallTo(() => _dispatchCommits.Dispatch(_commit)).MustHaveHappened(Repeated.Exactly.Once);
 }
 public void should_provide_the_commits_to_the_dispatcher()
 {
     A.CallTo(() => _dispatcher.Dispatch(_firstCommit)).MustHaveHappened();
     A.CallTo(() => _dispatcher.Dispatch(_lastCommit)).MustHaveHappened();
 }
 public void OnNext(ICommit commit)
 {
     Contract.Requires <ArgumentNullException>(commit != null, "commit");
     dispatcher.Dispatch(commit);
     checkpointRepo.SaveCheckpoint(commit.CheckpointToken);
 }