Device |
Import the list of devices.
If a device already exists, it will be updated and if it does not exist, it will be created.
Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public void Import( ISimpleCollection<SimpleDeviceV1> devices )
Parameters
- devices ISimpleCollection<SimpleDeviceV1>
- The devices.
Implements
ISimpleClientDeviceRepositoryV1.Import(ISimpleCollection<SimpleDeviceV1>)Example
The following example illustrates how the SimpleClient imports devices.
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(); //If a device already exists, it will be updated and if it does not exist, it will be created. // Create the Example Device var exampleDeviceForUpdate = new SimpleDeviceV1( Guid.NewGuid(), "BUS", EntityRoot.Device, Guid.Parse("9c2246aa-5d43-414f-85d4-8c3b4e657236") ); // Create device under device root in db client.Devices.Create(exampleDeviceForUpdate); exampleDeviceForUpdate.Name = "UPDATE BUS"; // Create the Example Device var exampleDeviceForCreate = new SimpleDeviceV1( Guid.NewGuid(), "BUS", EntityRoot.Device, Guid.Parse("9c2246aa-5d43-414f-85d4-8c3b4e657236") ); // Listing of all devices var allDevices = client.Devices.GetAll(); Console.WriteLine("Following listing contains all existing devices\n"); foreach ( var device in allDevices) { Console.WriteLine(device.Name); } var devicesExampleForImport = new SimpleCollection<SimpleDeviceV1> { exampleDeviceForUpdate, // this device already exists, however we are changing its name from 'BUS' to 'UPDATE BUS' exampleDeviceForCreate // this device doesnt exist yet, and will be created during import }; // import device client.Devices.Import(devicesExampleForImport); var result = client.Devices.GetAll(); Console.WriteLine("Following listing contains all existing devices\n"); foreach (var device in result) { Console.WriteLine(device.Name); } // Disconnect from server client.Disconnect(); } }
See Also