Skip to content

Session

Sam Gerené edited this page Dec 8, 2017 · 24 revisions

Introduction

The Session class is the core class of the CDP4-SDK for API developers that wish to develop C# applications that need to interface with ECSS-E-TM-10-25A Annex C. It provides a layer of abstraction for the IDal interface that exposes the methods that can be used to Create, Read, Update and Delete objects from an Annex C data-source.

The ISession interface works with POCO instances, the IDal interface works with DTO instances.

Credentials

The Credentials class is used to capture information required to connect to a data-source. It carries the username, password and URI of the data-source. The Credentials are used to instantiate a Sesssion object and cannot be changed while the Session is active.

ISession interface

The Session class implements the ISession interface that exposes the following core methods:

method description async
Open Open a connection to a data-source y
Read Read Things from a data-source y
Write Write updates to Things to a data-source y
Refresh Update the Cache with updated Things from a data-source y
Reload Reload all Things from a data-source for all open TopContainers y
Close Close the connection to a data-source and clear the Cache n

The ISession interface exposes more convenience methods that are explained in the following sections.

Session Constructor

The Session class constructor expects 2 arguments, an instance of IDal and an instance of Credential. The IDal interface represents a Data Access Layer implementation used to perform operations on a ECSS-E-TM-10-25 Annex C data-source.

var uri = new Uri("https://cdp4services-public.rheagroup.com");
var credentrials = new Credentials("some-user-name", "some-password", uri);
var dal = new CdpServicesDal();

var session = new Session(dal, credentials);

Open

The Open method connects to the data-source and requests data from the SiteDirectory route provided by the Annex C data-source. The data-source returns an array of DTO instances that are processed by the Assembler, converted into POCO instances that are add to the Cache. Messages are produced for the objects that are added to the Cache by means of the CDP Message Bus.

try
{
    await session.Open();
}
catch(Exception ex)
{
    // handle the exception here and don't forget to do some logging
}

The Open method should be used in combination with await operator, await can only be used in an asynchronous method modified by the async keyword.

The data that is returned contains enough information for the current user to select an Iteration or a Reference Data Library to work with.

Read

Three distinct Read methods are provided by the ISession interface;

  1. Iteration: reads data from the data-source related to a specific Iteration.
  2. ReferenceDataLibrary: reads data from the data-source related to a specific ReferenceDataLibrary.
  3. Thing: reads any Thing from the data-source.

Write

more information coming soon

Refresh

more information coming soon

Reload

more information coming soon

Close

more information coming soon

Clone this wiki locally