Beispiel #1
0
 public EventEntryDTO(EventEntryId id, CustomerId customerid, DateTime receptiontime, string uuid, EventClientId client_id, string client_uuid, string client_name, DateTime eventtime, string action, string description, string url, EventActorId actor_id, string actor_uuid, string actor_name, string actor_email, string context_client_ip, string context_client_browseragent, string context_server_serverid, string context_server_version, string target_type, string target_uuid, string target_label, string target_url, EventActorId targetuser_id, string targetuser_uuid, string targetuser_name, string targetuser_email)
 {
     Id                          = id;
     CustomerId                  = customerid;
     ReceptionTime               = receptiontime;
     UUID                        = uuid;
     Client_Id                   = client_id;
     Client_UUID                 = client_uuid;
     Client_Name                 = client_name;
     EventTime                   = eventtime;
     Action                      = action;
     Description                 = description;
     URL                         = url;
     Actor_Id                    = actor_id;
     Actor_UUID                  = actor_uuid;
     Actor_Name                  = actor_name;
     Actor_Email                 = actor_email;
     Context_Client_IP           = context_client_ip;
     Context_Client_BrowserAgent = context_client_browseragent;
     Context_Server_ServerId     = context_server_serverid;
     Context_Server_Version      = context_server_version;
     Target_Type                 = target_type;
     Target_UUID                 = target_uuid;
     Target_Label                = target_label;
     Target_URL                  = target_url;
     TargetUser_Id               = targetuser_id;
     TargetUser_UUID             = targetuser_uuid;
     TargetUser_Name             = targetuser_name;
     TargetUser_Email            = targetuser_email;
 }
Beispiel #2
0
        public async Task <IActionResult> SubmitEventAsync([FromBody] EventEntry[] entries)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ApiError(400, ModelState)));
            }

            foreach (var entry in entries)
            {
                EnsureAllowedNullsAreRepresented(entry);
            }

            var customerId = _membership.GetCustomerId(User);
            var results    = new EventAcceptedResponse();

            foreach (var entry in entries)
            {
                var dto = new EventEntryDTO(null, customerId, DateTime.UtcNow,
                                            entry.UUID,
                                            null,
                                            entry.Client.UUID,
                                            entry.Client.Name,
                                            entry.Time.Value, // nullable - ModelBinding should catch this, as it's annotated as Required - convert to UTC
                                            entry.Action,
                                            entry.Description,
                                            entry.URL,
                                            null,
                                            entry.Actor.UUID,
                                            entry.Actor.Name,
                                            entry.Actor.Email,
                                            entry.Context.Client.IPAddress,
                                            entry.Context.Client.BrowserAgent,
                                            entry.Context.Server.ServerId,
                                            entry.Context.Server.Version,
                                            entry.Target.Type,
                                            entry.Target.UUID,
                                            entry.Target.Label,
                                            entry.Target.URL,
                                            null,
                                            entry.TargetUser.UUID,
                                            entry.TargetUser.Name,
                                            entry.TargetUser.Email);

                EventEntryId id = await _persistence.EventEntries.CreateAsync(dto);

                results.ReceivedEvents.Add(new ReceivedEventEntryId(id, entry.UUID));
            }

            return(Ok(results));
        }
Beispiel #3
0
        public async Task <EventEntryDTO> GetAsync(CustomerId customerId, EventEntryId entryId)
        {
            var sqlParams = new {
                CustomerId = customerId.RawValue,
                Id         = entryId.RawValue
            };

            string sql = @"
                SELECT EE.Id, 
                       EE.CustomerId, 
                       EE.ReceptionTime, 
                       EE.UUID, 
                       EE.EventClientId AS Client_Id,
                       EC.UUID AS Client_UUID, 
                       EC.Name AS Client_Name, 
                       EE.EventTime, 
                       EE.Action, 
                       EE.Description, 
                       EE.URL, 
                       EE.EventActorId AS Actor_Id, 
                       EA.UUID AS Actor_UUID,
                       EA.Name AS Actor_Name,
                       EA.Email AS Actor_Email,
                       EE.Context_Client_IP, 
                       EE.Context_Client_BrowserAgent, 
                       EE.Context_Server_ServerId, 
                       EE.Context_Server_Version, 
                       EE.Target_Type, 
                       EE.Target_UUID, 
                       EE.Target_Label, 
                       EE.Target_URL,
                       EE.TargetEventActorId AS TargetUser_Id,
                       TEA.UUID AS TargetUser_UUID,
                       TEA.Name AS TargetUser_Name,
                       TEA.Email AS TargetUser_Email
                FROM dbo.EventEntries EE   
                    INNER JOIN dbo.EventActors EA ON EA.Id = EE.EventActorId
                    INNER JOIN dbo.EventClients EC ON EC.Id = EE.EventClientId
                    LEFT JOIN dbo.EventActors TEA ON TEA.Id = EE.TargetEventActorId
                WHERE EE.CustomerId = @CustomerId
                    AND EE.Id = @Id;
            ";

            return(await _db.QuerySingleOrDefault(async (db) =>
            {
                return await db.FetchAsync <EventEntryDTO>(sql, sqlParams);
            }));
        }
        public async Task <IActionResult> GetEventAsync(string clientId, Guid entryId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ApiError(400, ModelState)));
            }

            var customerId   = _membership.GetCustomerId(User);
            var eventEntryId = new EventEntryId(entryId);
            var entry        = await _persistence.EventEntries.GetAsync(customerId, eventEntryId);

            if (entry == null)
            {
                return(NotFound(new ApiError(404, "Specified event not found")));
            }

            var recordedEntry = new RecordedEvent(entry, "/api/v1/entries/");

            return(Ok(recordedEntry));
        }
Beispiel #5
0
 public ReceivedEventEntryId(EventEntryId id, string uuid)
 {
     Id   = id.RawValue;
     UUID = uuid;
 }