Log |
Get all logs by source time.
Source Time is the time when the log was created.
Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public ISimpleCollection<SimpleLogV1> GetAllBySourceTime( DateTime from, DateTime to, int pageSize = -1 )
Parameters
- from DateTime
- The time from.
- to DateTime
- The time to.
- pageSize Int32 (Optional)
- Limits the number of the newest returned logs. If set to -1, no limit is applied
Return Value
ISimpleCollection<SimpleLogV1>All Logs filtered by Source time, returned in local time.
Implements
ISimpleClientLogRepositoryV1.GetAllBySourceTime(DateTime, DateTime, Int32)Example
The following example illustrates how SimpleClient provides all logs by Source Time.
The following example illustrates how SimpleClient provides all logs by Source Time and page size
C#
using System; using Gamanet.C4.SDK; using Gamanet.C4.SimpleInterfaces; public class Example { static void Main() { // Create instance of simple client var client = new SimpleClient(ConnectorConfiguration.HttpClient); ConnectionInfoV1 token; // Connect to local server var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support", out token); if (connectionResult != ConnectionResult.Successful) { Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult); return; } Console.WriteLine("Connection result: {0}", connectionResult); Console.WriteLine(); var exampleLog = new SimpleLogV1( Guid.NewGuid(), //log id "exampleLog", //log name Guid.Empty, // log parent id LogCategory.DoorOpened);//log category exampleLog.Data = new Dictionary<string, object> { ["DeviceId"] = door.Id, ["DeviceIdName"] = door.Name, ["SourceTime"] = sourceTime }; // create SimpleLog client.Logs.Create(exampleLog); // Get log by source time var logs = client.Logs.GetAllBySourceTime(timeFrom, timeTo); Console.WriteLine(logs.Count); // Disconnect from server client.Disconnect(); } }
C#
using System; using Gamanet.C4.SDK; using Gamanet.C4.SimpleInterfaces; public class Example { static void Main() { // Create instance of simple client var client = new SimpleClient(ConnectorConfiguration.HttpClient); ConnectionInfoV1 token; // Connect to local server var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support", out token); if (connectionResult != ConnectionResult.Successful) { Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult); return; } Console.WriteLine("Connection result: {0}", connectionResult); Console.WriteLine(); var exampleLog = new SimpleLogV1( Guid.NewGuid(), //log id "exampleLog", //log name Guid.Empty, // log parent id LogCategory.DoorOpened);//log category exampleLog.Data = new Dictionary<string, object> { ["DeviceId"] = door.Id, ["DeviceIdName"] = door.Name, ["SourceTime"] = sourceTime }; // create SimpleLog client.Logs.Create(exampleLog); // Get logs by source time with a page size set to var logs = SimpleClientV1.Logs.GetAllBySourceTime(timeFrom, timeTo, 4); foreach(var item in logs) { Console.WriteLine($"Log name: {item.Name}"); } // Disconnect from server client.Disconnect(); } }
See Also