Ejemplo n.º 1
0
 public static void SendEvent(AuditEventBase auditEvent, World world)
 {
     auditEvent.WorldKey = world.WorldKey;
     auditEvent.AdvertisedPlayerCount = world.AdvertisedPlayerCount;
     auditEvent.GameID    = world.GameID;
     auditEvent.GameTime  = world.Time;
     auditEvent.Created   = DateTime.Now;
     auditEvent.PublicURL = world.GameConfiguration.PublicURL;
     auditEvent.Type      = auditEvent.GetType().Name;
     SendEvent(auditEvent);
 }
Ejemplo n.º 2
0
            protected async override Task ExecuteAsync()
            {
                var firestore = FirestoreDb.Create("daud-230416");

                CollectionReference eventsRef = firestore.Collection("events");
                Query         query           = eventsRef.Limit(100000);
                QuerySnapshot querySnapshot   = await query.GetSnapshotAsync();

                foreach (DocumentSnapshot documentSnapshot in querySnapshot.Documents)
                {
                    AuditEventBase auditEvent = null;
                    fields = documentSnapshot.ToDictionary();
                    var type = GetField("Type", null as string);
                    switch (type)
                    {
                    case "AuditEventSpawn":
                        auditEvent = new AuditEventSpawn()
                        {
                            Player = PlayerFrom("Player")
                        };
                        break;

                    case "AuditEventDeath":
                        auditEvent = new AuditEventDeath()
                        {
                            Killer = PlayerFrom("Killer"),
                            Victim = PlayerFrom("Victim")
                        };
                        break;
                    }
                    auditEvent.AdvertisedPlayerCount = (int)GetField("AdvertisedPlayerCount", 0L);
                    auditEvent.Created   = DateTimeOffset.UnixEpoch.AddSeconds(GetField("Created", 0L)).DateTime;
                    auditEvent.GameID    = GetField("GameID", null as string);
                    auditEvent.GameTime  = GetField("GameTime", 0L);
                    auditEvent.PublicURL = GetField("PublicURL", null as string);
                    auditEvent.Type      = GetField("Type", null as string);
                    auditEvent.WorldKey  = GetField("WorldKey", null as string);

                    Console.WriteLine(JsonConvert.SerializeObject(auditEvent, Formatting.Indented));

                    await RegistryAPI.Registry.PostEvents(new[] { auditEvent });
                }
            }