Пример #1
0
        private void ConvertThroughProto(CreatedEvent source)
        {
            Com.DigitalAsset.Ledger.Api.V1.CreatedEvent protoValue = source.ToProto();
            var target = CreatedEvent.FromProto(protoValue);

            Assert.IsTrue(source == target);
        }
Пример #2
0
        public async Task WHEN_afterAsynchronousSagaRun_THEN_sagaShouldBeCompleted()
        {
            // given
            ISagaEvent startEvent = new CreatedEvent();

            ISaga saga = await sagaCoordinator.
                         Publish(startEvent);

            // when
            await sagaCoordinator.
            WaitForIdle(saga.Data.ID);

            // then
            ISaga persistedSaga = await sagaPersistance.
                                  Get(saga.Data.ID);

            persistedSaga.ShouldNotBeNull();
            persistedSaga.ExecutionState.CurrentStep.ShouldBe(new SagaFinishState().Name);
            persistedSaga.ExecutionState.CurrentState.ShouldBe(new SagaFinishState().Name);
            persistedSaga.Data.ID.ShouldBe(saga.Data.ID);
            persistedSaga.ExecutionState.History.ShouldContain(step => step.StepName == "CreatedEventStep0" && step.CompensationData == null && step.HasSucceeded());
            persistedSaga.ExecutionState.History.ShouldContain(step => step.StepName == "CreatedEventStep1" && step.CompensationData == null && step.HasSucceeded());
            persistedSaga.ExecutionState.History.ShouldContain(step => step.StepName == "CreatedEventStep2" && step.CompensationData == null && step.HasSucceeded());
            persistedSaga.ExecutionState.History.Count.ShouldBe(4);
        }
Пример #3
0
        public RedirectToActionResult Join(CreatedEvent ce)
        {
            var entity = repository.CreatedEvents
                         .Where(e => e.ID == ce.ID)
                         .FirstOrDefault();

            if (entity != null)
            {
                if (p_rope.participations.Where(p => p.CreatedEvent == entity)
                    .Where(c => c.Username == User.Identity.Name).Count() == 0)
                {
                    var participate = new Participation()
                    {
                        CreatedEvent  = entity,
                        Title         = entity.Title,
                        StudentNumber = User.Identity.Name,
                        Date          = entity.Date,
                        Username      = User.Identity.Name,
                        Location      = entity.Location
                    };
                    p_rope.SaveEvent(participate);
                    var dbEntity = repository.CreatedEvents.Where(e => e.ID == ce.ID).FirstOrDefault();
                    dbEntity.CountOfParticipation += 1;
                    repository.SaveEvent(dbEntity);
                }
                else
                {
                    // ViewBag.Message = string.Format("You have joined this activity!");
                    // TempData["message_join"]="You have joined this activity!";
                    TempData["ID"] = entity.ID.ToString();
                }
            }
            return(RedirectToAction("Index"));
        }
Пример #4
0
        private CreatedEvent GetCreatedEvent()
        {
            var _event = new CreatedEvent();

            _event.SetOccuredAtToNow();
            return(_event);
        }
Пример #5
0
        static public Link Create(Link source, Link linker, Link target)
        {
            if (!MemoryManagerIsReady)
            {
                throw new Exception("Менеджер памяти ещё не готов.");
            }
            if (LinkWasDeleted(source))
            {
                throw new ArgumentException("Удалённая связь не может использоваться в качестве значения.", "source");
            }
            if (LinkWasDeleted(linker))
            {
                throw new ArgumentException("Удалённая связь не может использоваться в качестве значения.", "linker");
            }
            if (LinkWasDeleted(target))
            {
                throw new ArgumentException("Удалённая связь не может использоваться в качестве значения.", "target");
            }
            __link *link = CreateLink(source, linker, target);

            if (link == null)
            {
                throw new OutOfMemoryException();
            }

            Parallel.Invoke(() => CreatedEvent.Invoke(new LinkDefinition(source, linker, target)));

            return(link);
        }
Пример #6
0
        private void ConvertThroughProtoUsingEventHelper(CreatedEvent source)
        {
            Com.DigitalAsset.Ledger.Api.V1.Event protoValue = EventHelper.ToProtoEvent(source);
            var target = EventHelper.FromProtoEvent(protoValue);

            Assert.IsTrue(target is CreatedEvent);
            Assert.IsTrue(source == (CreatedEvent)target);
        }
Пример #7
0
        public void Test()
        {
            var event1 = new CreatedEvent();

            _sut.HandleAsync(event1).RunSynchronously();

            // assert any post invokations made
        }
Пример #8
0
        private void ConvertThroughProtoUsingEventHelper(CreatedEvent source)
        {
            Com.Daml.Ledger.Api.V1.Event protoValue = EventHelper.ToProtoEvent(source);
            var target = EventHelper.FromProtoEvent(protoValue);

            target.Should().BeOfType <CreatedEvent>();
            Assert.True(source == (CreatedEvent)target);
        }
Пример #9
0
        public IActionResult Delete(int id)
        {
            CreatedEvent deletedProduct = ceRepository.DeleteCrCreatedEvent(id);

            if (deletedProduct != null)
            {
                TempData["message"] = $"{deletedProduct.Title} was deleted";
            }
            return(RedirectToAction("CreatedEvents"));
        }
Пример #10
0
        public void AddTodo(Todo todo)
        {
            CreatedEvent newEvent = new CreatedEvent()
            {
                Data      = todo,
                TimeStamp = DateTime.Now,
                Type      = EventType.Created,
            };

            SaveToEventStore(newEvent);
            hanlder.Handle(newEvent);
        }
Пример #11
0
        /// <summary>
        /// Creates an entity by appending a <see cref="CreatedEvent"/> and the necessary
        /// <see cref="PropertyChangedEvent"/>s to the event stream.
        /// </summary>
        /// <typeparam name="T">Type of the entity</typeparam>
        /// <param name="service">EventStoreService</param>
        /// <param name="obj">Object which contains the values</param>
        /// <param name="resourceType">Resource type of the object</param>
        /// <param name="id">Id of the object</param>
        /// <param name="userId">Id of the user</param>
        /// <returns></returns>
        public static async Task CreateEntityAsync <T>(EventStoreService service, T obj, ResourceType resourceType, int id, string userId) where T : new()
        {
            if (obj == null)
            {
                throw new ArgumentException("The object to store cannot be null", nameof(obj));
            }

            var emptyObject  = Activator.CreateInstance <T>();
            var createdEvent = new CreatedEvent(resourceType.Name, id, userId);
            await service.AppendEventAsync(createdEvent);

            await UpdateEntityAsync(service, emptyObject, obj, resourceType, id, userId);
        }
Пример #12
0
    public void RegisterCreation(ShipCreatedDto shipDto)
    {
        var shipCreatedEvent = new CreatedEvent
        {
            X = shipDto.x,
            Y = shipDto.y,
            Rotation = shipDto.rot,
            Team = shipDto.team,
            TimeStamp = shipDto.timestamp
        };

        this.InsertInHistory(shipCreatedEvent);
    }
        public async Task WHEN_runSagaAsynchronous_THEN_sagaShouldBeLocked()
        {
            // given
            ISagaEvent startEvent = new CreatedEvent();

            // when
            ISaga saga = await sagaCoordinator.
                         Publish(startEvent);

            // then
            (await sagaLocking.
             IsAcquired(saga.Data.ID)).
            ShouldBeTrue();
        }
Пример #14
0
        /// <summary>
        /// 创建对象
        /// </summary>
        /// <param name="data">模块对象信息</param>
        /// <param name="userInfo">创建人</param>
        /// <exception cref="Exception.ActionForbiddenException">当不允许被创建时抛出</exception>
        public void Create(IUploadFile data, IUserInfo userInfo)
        {
            var result = PrepareCreatedEvent?.Invoke(data, userInfo);

            if (!(result?.Success ?? true))
            {
                throw new ActionForbiddenException(result.Message);
            }

            OracleDB.ExeSql(
                @"insert into UploadFiles
                    (fileId,
                     fileName,
                     fileSize,
                     fileSuffix,
                     localPath,
                     fromModule,
                     creator,
                     creatorName,
                     organizId,
                     organizTable,
                     organizName)
                  values
                    (:fileId,
                     :fileName,
                     :fileSize,
                     :fileSuffix,
                     :localPath,
                     :fromModule,
                     :creator,
                     :creatorName,
                     :organizId,
                     :organizTable,
                     :organizName)",
                new OracleParameter("fileId", data.FileId),
                new OracleParameter("fileName", data.FileName),
                new OracleParameter("fileSize", data.FileSize),
                new OracleParameter("fileSuffix", data.FileSuffix),
                new OracleParameter("localPath", data.LocalPath),
                new OracleParameter("fromModule", data.FromModule),
                new OracleParameter("creator", userInfo.UserId),
                new OracleParameter("creatorName", userInfo.UserName),
                new OracleParameter("organizId", userInfo.OrganizId),
                new OracleParameter("organizTable", userInfo.OrganizTable),
                new OracleParameter("organizName", userInfo.OrganizName));

            CreatedEvent?.Invoke(data, userInfo);
        }
Пример #15
0
 private void Apply(CreatedEvent e)
 {
     _activated = true;
     Id         = e.Id;
     TableId    = e.TableId;
     foreach (var item in e.OrderItems)
     {
         _orderItems.Add(new OrderItem()
         {
             OrderItemGuid = item.Guid,
             ProductId     = item.ProductId,
             Quantity      = item.Quantity,
             State         = 0
         });
     }
 }
Пример #16
0
        public async Task WHEN_runSagaAsynchronous_THEN_sagaShouldBeInIntermediateState()
        {
            // given
            ISagaEvent startEvent = new CreatedEvent();

            // when
            ISaga saga = await sagaCoordinator.
                         Publish(startEvent);

            // then
            ISaga persistedSaga = await sagaPersistance.
                                  Get(saga.Data.ID);

            persistedSaga.ShouldNotBeNull();
            persistedSaga.ExecutionState.CurrentStep.ShouldStartWith("CreatedEventStep");
            persistedSaga.ExecutionState.CurrentState.ShouldBe(new SagaStartState().Name);
            persistedSaga.Data.ID.ShouldBe(saga.Data.ID);
            persistedSaga.ExecutionState.History.ShouldContain(step => step.StepName == "CreatedEventStep0" && step.CompensationData == null);
        }
Пример #17
0
        /// <summary>
        /// Handle CREATE commands
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <CommandResult <Guid> > Handle(CreateCommand <T> request, CancellationToken cancellationToken)
        {
            // Validate input
            if (string.IsNullOrWhiteSpace(request.EventData))
            {
                return(new CommandResult <Guid>(ResultType.BadRequest));
            }

            // Call extension point to get the action authorised for the user in question, and the specific resource
            var authResult = await this.AuthoriseCreate(request.EventData);

            if (authResult.ResultType == ResultType.AccessDenied)
            {
                // TODO: Move the Access Denied audit log creation to here, from the child classes?
                return(new CommandResult <Guid>(authResult.ResultType));
            }
            else
            {
                // This is a Create event (and thus starts a new event stream) so we need to create the Event Stream Id
                Guid eventStreamId = Guid.NewGuid();

                // Save the domain event record to the database
                DomainEventType eventType   = (DomainEventType)Enum.Parse(typeof(DomainEventType), string.Format("Create{0}Event", typeof(T).Name));
                DomainEvent     domainEvent = new DomainEvent(request.EventData, _currentUser.UserName, eventType, eventStreamId);

                _dc.DomainEvents.Add(domainEvent);
                await _dc.SaveChangesAsync();

                // Now publish events to signal the domain model to be updated, and to update the audit log
                CreatedEvent <T> eventNotification = new CreatedEvent <T>(request.EventData, _currentUser.UserName, domainEvent.EventStreamId, domainEvent.Id);
                await _mediator.Publish(eventNotification);

                // Drop an AuditLogEvent onto the mediator, to dispatch a request to update the system audit log. Again, we're not going to wait for the outcome of this event. Just fire and forget.
                AuditLogEvent auditLogNotification = new AuditLogEvent(eventNotification.DomainEventType, _currentUser.UserName, domainEvent.EventStreamId, domainEvent.Id);
                await _mediator.Publish(auditLogNotification);

                // If the response was not 201 CREATED (or it is, and we have errors) then we need to ensure that we pass the correct response code back, along with any "error" messages

                //return new CommandResult<Guid>(eventStreamId);
                return(new CommandResult <Guid>(authResult.ResultType, eventStreamId, authResult.Errors));
            }
        }
Пример #18
0
        public override Task ExecuteAsync(string receiver, WebHookHandlerContext context)
        {
            if (receiver.ToLower() == Properties.Settings.Default.WebhookRecieverClient.ToLower())
            {
                JObject       content           = context.GetDataOrDefault <JObject>();
                var           serializedContent = JsonConvert.SerializeObject(content);
                var           util           = new JsonUtilities();
                var           action         = util.GetFirstInstance <string>("action", serializedContent);
                var           actionUser     = content["sender"]["login"].Value <string>(); //Get the user performing the action
                var           owner          = content["repository"]["owner"]["login"].Value <string>();
                var           repositoryName = util.GetFirstInstance <string>("name", serializedContent);
                var           taggedUser     = ConfigurationManager.AppSettings["Assignees"];
                IWebhookEvent webhookEvent   = null;

                switch (action.ToLower())
                {
                case "deleted":
                    webhookEvent = new DeleteEvent(repositoryName, actionUser, action, taggedUser);
                    break;

                case "created":
                    webhookEvent = new CreatedEvent(repositoryName, actionUser, action, taggedUser);
                    break;

                case "added":
                    webhookEvent = new RemovedEvent(repositoryName, actionUser, action, taggedUser);
                    webhookEvent.EditRepository(repositoryName, owner, actionUser);
                    break;

                default:
                    break;
                }

                if (webhookEvent != null)
                {
                    return(webhookEvent.CreateRepositoryIssue());
                }
            }

            return(Task.FromResult(true));
        }
Пример #19
0
 public IActionResult Edit(CreatedEvent e)
 {
     e.StudentNameber       = User.Identity.Name;
     e.Username             = User.Identity.Name;
     e.CountOfParticipation = e.CountOfParticipation;
     Convert.ToDateTime(e.Date);
     if (ModelState.IsValid)
     {
         ceRepository.SaveEvent(e);
         // Session
         TempData["message"] = $"{e.Title} has been saved";
         return(RedirectToAction("CreatedEvents"));
     }
     else
     {
         var erros = ModelState.Values.SelectMany(v => v.Errors);
         // TempData["message"]= erros.FirstOrDefault().ErrorMessage + " "+ erros.Last().ErrorMessage;
         // there is something wrong with the data values
         return(View(e));
     }
 }
Пример #20
0
        public override void OnEvent(CqEvent <TKey, TResult> ev)
        {
            Debug.WriteLine("CqListener::OnEvent called");
            var  val = ev.getNewValue() as Position;
            TKey key = ev.getKey();

            switch (ev.getQueryOperation())
            {
            case CqOperation.OP_TYPE_REGION_CLEAR:
                RegionClearEvent.Set();
                break;

            case CqOperation.OP_TYPE_CREATE:
                CreatedEvent.Set();
                break;

            case CqOperation.OP_TYPE_UPDATE:
                UpdatedEvent.Set();
                break;

            case CqOperation.OP_TYPE_INVALIDATE:
                InvalidatedEvent.Set();
                break;

            case CqOperation.OP_TYPE_DESTROY:
                if (val == null)
                {
                    DestroyedNullEvent.Set();
                }
                else
                {
                    DestroyedNonNullEvent.Set();
                }
                break;

            default:
                ReceivedUnknownEventType = true;
                break;
            }
        }
Пример #21
0
        /// <summary>
        /// For each CreatedEvent where the receiver is
        /// the current party, exercise the Pong choice of Ping contracts, or the Ping
        /// choice of Pong contracts.
        /// </summary>
        /// <param name="workflowId">the workflow the event is part of</param>
        /// <param name="createdEvent">the CreatedEvent to process</param>
        /// <returns>null if this event doesn't trigger any action for this PingPongProcessor's party</returns>
        private Command ProcessEvent(string workflowId, CreatedEvent createdEvent)
        {
            Identifier template = createdEvent.TemplateId;

            bool isPingPongModule = template.ModuleName == _pingIdentifier.ModuleName;

            bool isPing = template.EntityName == _pingIdentifier.EntityName;
            bool isPong = template.EntityName == _pongIdentifier.EntityName;

            if (!isPingPongModule || !isPing && !isPong)
            {
                return(null);
            }

            var fields = new Dictionary <string, Value>(from f in createdEvent.CreateArguments.Fields select KeyValuePair.Create(f.Label, f.Value));

            // check that this party is set as the receiver of the contract
            bool thisPartyIsReceiver = fields["receiver"].Party == _party;

            if (!thisPartyIsReceiver)
            {
                return(null);
            }

            string contractId = createdEvent.ContractId;
            string choice     = isPing ? "RespondPong" : "RespondPing";

            long count = fields["count"].Int64;

            Console.WriteLine($"{_party} is exercising {choice} on {contractId} in workflow {workflowId} at count {count}");

            // assemble the exercise command
            return(new Command {
                Exercise = new ExerciseCommand {
                    TemplateId = template, ContractId = contractId, Choice = choice, ChoiceArgument = new Value {
                        Record = new Record()
                    }
                }
            });
        }
Пример #22
0
        /**********************************************************/

        public void processCreatedEvent(CreatedEvent createdEvent, Dictionary <string, OadrEventWrapper> activeEvents, string requestID)
        {
            // update list of active events
            // this must be called before ucEvents1.updateOptType(createdEvent.request);
            // updateOptType will lookup event by ID and, well, update the optType
            // new events won't be in the list of updateEvents isn't called first
            ucEvents1.updateEvents(activeEvents, requestID);

            // createdEvent will be null if the VTN sent an empty distributeEvent message,
            // clearing all events for this ven
            // createdEvent is NULL because there's no response to send when distributeEvent
            // is empty
            // it can also be NULL if the message contained only updates to event status
            if (createdEvent != null)
            {
                ucLog1.addOadrMessage(createdEvent);

                ucEvents1.updateOptType(createdEvent.request);

                updateError(createdEvent);
            }
        }
Пример #23
0
 public static SyncProjection Create(CreatedEvent @event)
 {
     return(new SyncProjection(@event.Key, @event.Value));
 }
Пример #24
0
        public async Task Handle(CreatedEvent message, CancellationToken cancellationToken)
        {
            var player = message.Player;

            await _queueHandler.SendQueueMessage(new CheckPlayerNewbieQuestQueue(player.Id));
        }
Пример #25
0
        /**********************************************************/

        public void processEvents(oadrDistributeEventType distributeEvent, string requestID, eOptType optType, VEN2b ven)
        {
            List <string> eventIDs = new List <string>();     // track list of valid events from distributeEvent object

            // will use to match against our list of active events

            // validate the VTN id
            if (distributeEvent.vtnID != ven.VTNID)
            {
                // the VTN ID was invalid; remove all events and send an error message
                checkForRemovedEvents(eventIDs);

                m_callbacks.logSystemMessage("Invalid VTN ID: " + distributeEvent.vtnID, UserControls.Log.WebLogView.eWebLogMessageStatus.WARNING);

                CreatedEvent createdEvent = ven.createdEvent(requestID, 452, "Invalid ID");

                m_callbacks.processCreatedEvent(createdEvent, m_idToEvent, requestID);

                return;
            }

            // the VTN didn't send any events; clear all events we have stored
            if (distributeEvent.oadrEvent == null)
            {
                checkForRemovedEvents(eventIDs);
                m_callbacks.processCreatedEvent(null, m_idToEvent, requestID);
                return;
            }

            OptTypeType oadrOptType = (optType == eOptType.OptIn ? OptTypeType.optIn : OptTypeType.optOut);

            // send a createdEvent with an opt type of the incoming optType for all new events
            // that aren't canceled or completed.  optIn/out of cancelled and completed events as appropriate
            CreatedEventHelper createdEventHelper = new CreatedEventHelper();

            foreach (oadrDistributeEventTypeOadrEvent evt in distributeEvent.oadrEvent)
            {
                string eventID = evt.eiEvent.eventDescriptor.eventID;

                // validate that the event is for this VEN and MarketContext
                if (!eventValid(evt, ven, requestID, createdEventHelper))
                {
                    continue;
                }

                eventIDs.Add(eventID);

                if (!m_idToEvent.ContainsKey(eventID))
                {
                    processNewEvent(requestID, oadrOptType, createdEventHelper, evt);
                }
                else
                {
                    processExistingEvent(requestID, createdEventHelper, evt);
                }

                OadrEventWrapper eventWrapper = m_idToEvent[eventID];

                if (eventWrapper.RandomizedMinutes != 0)
                {
                    m_callbacks.logSystemMessage(string.Format("Event start time delayed due to start after parameter: event ID={0}, start after={1}, randomized minutes={2}",
                                                               eventWrapper.OadrEvent.eiEvent.eventDescriptor.eventID, eventWrapper.OadrEvent.eiEvent.eiActivePeriod.properties.tolerance.tolerate.startafter,
                                                               eventWrapper.RandomizedMinutes), UserControls.Log.WebLogView.eWebLogMessageStatus.INFO);
                }
            }

            // events in m_idToEvent but not in the incoming distributeEvent message must be
            // implicitly canceled
            checkForRemovedEvents(eventIDs);

            if (createdEventHelper.EventResponses.Count > 0)
            {
                CreatedEvent createdEvent = ven.createdEvent(createdEventHelper);

                m_callbacks.processCreatedEvent(createdEvent, m_idToEvent, requestID);
            }
            else
            {
                // still need to call this function to ensure the UI is updated with any event status changes
                m_callbacks.processCreatedEvent(null, m_idToEvent, requestID);
            }
        }
Пример #26
0
#pragma warning disable IDE0051 // Remove unused private members
#pragma warning disable CC0068  // Unused Method

        private void Handle(CreatedEvent @event)
        {
            Id       = @event.Id;
            MyString = StringValue.FromString(@event.MyString);
            MyBool   = BoolValue.FromBool(@event.MyBool);
        }
Пример #27
0
 public void Apply(CreatedEvent @event)
 {
     this.AggregateId = @event.AggregateId;
 }
Пример #28
0
 public void Apply(CreatedEvent aggregateEvent)
 {
     _model.Id          = aggregateEvent.ProjectId;
     _model.ProjectName = aggregateEvent.Name;
 }
Пример #29
0
 public void Apply(CreatedEvent e)
 {
 }
Пример #30
0
 private void Apply(CreatedEvent e)
 {
     _activated = true;
 }
Пример #31
0
 private void OnCreated(CreatedEvent @event)
 {
     this.Id    = @event.Id;
     this.Title = @event.Title;
 }
Пример #32
0
 private void Awake()
 {
     Disabled = new DisabledEvent();
     Created  = new CreatedEvent();
 }