Person |
Restores existing person by restore mode.
Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public void Restore( SimplePersonV1 person, RestoreMode restoreMode )
Parameters
- person SimplePersonV1
- The person.
- restoreMode RestoreMode
- The Restore mode
Implements
ISimpleClientPersonRepositoryV1.Restore(SimplePersonV1, RestoreMode)Example
The following example illustrates how the SimpleClient restores person with children.
The following example illustrates how the SimpleClient restores person with parents.
The following example illustrates how the SimpleClient restores single person.
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(); // Create new instance of SimplePerson as an Example Company var exampleCompany = new SimplePersonV1( Guid.NewGuid(), EntityRoot.Person, PersonCategory.Company); exampleCompany.Data["Surname"] = "exampleCompany"; // Create new instance of SimplePerson as an Example Department var exampleDepartment = new SimplePersonV1( Guid.NewGuid(), exampleCompany.Id, PersonCategory.Department); exampleDepartment.Data["Surname"] = "exampleDepartment"; // Create new Example Person var examplePerson = new SimplePersonV1( Guid.NewGuid(), exampleDepartment.Id, PersonCategory.Person); examplePerson.Data["Surname"] = "examplePerson"; client.Persons.Create(exampleCompany); client.Persons.Create(exampleDepartment); client.Persons.Create(examplePerson); // Archive company and its children client.Persons.Archive(exampleCompany); var archivedCompany = client.Persons.Get(exampleCompany.Id, Properties.All); var archivedDepartment = client.Persons.Get(exampleDepartment.Id, Properties.All); var archivedPerson = client.Persons.Get(examplePerson.Id, Properties.All); Console.WriteLine($"" + $"{archivedCompany.Name} -> {archivedCompany.Archived} \n" + $"{archivedDepartment.Name} -> {archivedDepartment.Archived} \n" + $"{archivedPerson.Name} -> {archivedPerson.Archived} \n"); // Restore Company with all its children client.Persons.Restore(exampleCompany, RestoreMode.WithChildren); var restoredCompany = client.Persons.Get(exampleCompany.Id, Properties.All); var restoredDepartment = client.Persons.Get(exampleDepartment.Id, Properties.All); var restoredPerson = client.Persons.Get(examplePerson.Id, Properties.All); Console.WriteLine($"" + $"{restoredCompany.Name} -> {restoredCompany.Archived}\n" + $"{restoredDepartment.Name} -> {restoredDepartment.Archived} \n" + $"{restoredPerson.Name} -> {restoredPerson.Archived}\n"); // 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(); // Create new instance of SimplePerson as an Example Company var exampleCompany = new SimplePersonV1( Guid.NewGuid(), EntityRoot.Person, PersonCategory.Company); exampleCompany.Data["Surname"] = "exampleCompany"; // Create new instance of SimplePerson as an Example Department var exampleDepartment = new SimplePersonV1( Guid.NewGuid(), exampleCompany.Id, PersonCategory.Department); exampleDepartment.Data["Surname"] = "exampleDepartment"; // Create new Example Person var examplePerson = new SimplePersonV1( Guid.NewGuid(), exampleDepartment.Id, PersonCategory.Person); examplePerson.Data["Surname"] = "examplePerson"; client.Persons.Create(exampleCompany); client.Persons.Create(exampleDepartment); client.Persons.Create(examplePerson); // Archive company and its children client.Persons.Archive(exampleCompany); var archivedCompany = client.Persons.Get(exampleCompany.Id, Properties.All); var archivedDepartment = client.Persons.Get(exampleDepartment.Id, Properties.All); var archivedPerson = client.Persons.Get(examplePerson.Id, Properties.All); Console.WriteLine($"" + $"{archivedCompany.Name} -> {archivedCompany.Archived} \n" + $"{archivedDepartment.Name} -> {archivedDepartment.Archived}\n" + $"{archivedPerson.Name} -> {archivedPerson.Archived} \n"); // Restore Company with all its children client.Persons.Restore(examplePerson, RestoreMode.WithParents); var restoredCompany = client.Persons.Get(exampleCompany.Id, Properties.All); var restoredDepartment = client.Persons.Get(exampleDepartment.Id, Properties.All); var restoredPerson = client.Persons.Get(examplePerson.Id, Properties.All); Console.WriteLine($"" + $"{restoredCompany.Name} -> {restoredCompany.Archived} \n" + $"{restoredDepartment.Name} -> {restoredDepartment.Archived} \n" + $"{restoredPerson.Name} -> {restoredPerson.Archived} \n"); // 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(); // Create new instance of SimplePerson as an Example Company var exampleCompany = new SimplePersonV1( Guid.NewGuid(), EntityRoot.Person, PersonCategory.Company); exampleCompany.Data["Surname"] = "exampleCompany"; // Create new instance of SimplePerson as an Example Department var exampleDepartment = new SimplePersonV1( Guid.NewGuid(), exampleCompany.Id, PersonCategory.Department); exampleDepartment.Data["Surname"] = "exampleDepartment"; // Create new Example Person var examplePerson = new SimplePersonV1( Guid.NewGuid(), exampleDepartment.Id, PersonCategory.Person); examplePerson.Data["Surname"] = "examplePerson"; client.Persons.Create(exampleCompany); client.Persons.Create(exampleDepartment); client.Persons.Create(examplePerson); // Archive company and its children client.Persons.Archive(exampleCompany); var archivedCompany = client.Persons.Get(exampleCompany.Id, Properties.All); var archivedDepartment = client.Persons.Get(exampleDepartment.Id, Properties.All); var archivedPerson = client.Persons.Get(examplePerson.Id, Properties.All); Console.WriteLine($"" + $"{archivedCompany.Name} -> {archivedCompany.Archived}\n" + $"{archivedDepartment.Name} -> {archivedDepartment.Archived}\n" + $"{archivedPerson.Name} -> {archivedPerson.Archived}\n"); // Restore Company with all its children client.Persons.Restore(exampleCompany, RestoreMode.Single); var restoredCompany = client.Persons.Get(exampleCompany.Id, Properties.All); var restoredDepartment = client.Persons.Get(exampleDepartment.Id, Properties.All); var restoredPerson = client.Persons.Get(examplePerson.Id, Properties.All); Console.WriteLine($"" + $"{restoredCompany.Name} -> {restoredCompany.Archived}\n" + $"{restoredDepartment.Name} -> {restoredDepartment.Archived}\n" + $"{restoredPerson.Name} -> {restoredPerson.Archived}\n"); // Disconnect from server client.Disconnect(); } }
See Also