Mobile Data StudioObject Model › Session

The Session class represents a session of a Project.

Sessions are a collection of point values, combined with metadata such as the UnitID of the mobile device that created them, timestamps, etc.

They are created and edited on mobile devices, or within the Mobile Data Studio server. They can be transferred in both directions according to the processes you establish. Within Mobile Data Studio server, they can be stored in the Database, which is accessible via the Database Window, and processed with Data Script and the Data Pathway.

To retrieve data from a session, use the indexer syntax with the point ID name of the point whose value you wish to retrieve:

retrievedValue = nameOfSessionVariable("PointIDName")

You can also modify session data by assigning a new value:

nameOfSessionVariable("PointIDName") = "newValue"

Enumerable

This class can be enumerated with a For Each loop.

Each enumerated item is a String of the form "PointIDName=PointValue".

If the value cannot be represented as a string, the "=" and everything after it will be omitted, leaving only the PointIDName. In that case you must retrieve the full Variant value by indexing using the PointIDName, see below.

Indexable

This class can be indexed, with either an Integer or a String index:

  • An Integer index must be between 1 and the Count property.
  • A String index is a point ID name of the value to retrieve.

This is a read/write indexer, so values can be both retrieved and stored.

Values are Variant, which may be Boolean, Integer, String, date, or binary (such as a file).

For working with embedded files, see Database.LoadFromFile and Database.SaveToFile.

Properties

Application

Returns the root Application.

Archived

A Boolean value that is True if the session has been stored in the Database.

Count

Returns the number of values stored in the session as an Integer.

Date

A Date value representing the creation date and time of the session. Read/write.

GUID

Returns a String value that is the GUID of the session.

Key()

This is a named indexer property, which takes one Integer parameter that must be between 1 and the Count property.

Returns a String that is the point ID name of that value.

LastSaved

A Date value representing the date and time the session was last saved (i.e. finished) on a mobile device or local session editor. Read/write.

Marked

A Boolean value indicating whether the session is "marked" for dispatch to a mobile device. Read/write.

Project

Returns the Project this session belongs to.

State

A String indicating the current state of the session as it is processed by Data Script and the Data Pathway. Read/write:

  • "none" - created locally
  • "send" - marked for send (the Marked property will be True)
  • "received" - newly received from mobile device, about to or currently processing through the Data Pathway for the first time
  • "failed-once" - Data Pathway failed processing once, about to or currently processing through the Data Pathway for the second time
  • "failed-twice" - Data Pathway failed processing twice, about to or currently processing through the Data Pathway for the third and last time
  • "gave-up" - Data Pathway failed processing three times, no further attempts will be made
  • "processed" - Data Pathway processing completed

UnitID

A String value indicating which mobile device created the session, or, to which mobile device the session should be dispatched, depending on the context. Read/write.

Value()

This is a named indexer property, which takes one Integer parameter that must be between 1 and the Count property.

Returns a String that is the indexed value. Does not support binary variant values.

Methods

Clone

Returns a new Session object that is a clone of this one in every way, except that the GUID property will be different.

Takes no parameters.

Delete

Deletes this session from the project's Database.

Takes no parameters.

Save

Saves this session in the project's Database.

Modifications to the session are not automatically saved in the database unless this method is called. Calling this method when Archived is False, i.e. the session has not yet been added to the database, will cause it to be added.

Takes no parameters.

SendToAll

Sends this session to all mobile devices that are currently connected.

Returns a Boolean that is True if the session was sent to at least one device.

Note that this does not guarantee that any devices successfully received the session. To track when mobile devices acknowledge receipt of sessions, handle the OnAcceptSession() event in Data Script.

Takes no parameters.

SendToClient

Takes one parameter:

  • UnitID - a String which is the UnitID of the mobile device the session should be sent to.

Returns a Boolean: True if the mobile device was connected and the session was sent to it, or False if it was not.

Note that a True return value does not mean that the mobile device successfully received the session, only that it was sent. To track when a mobile device acknowledges receipt of a session, handle the OnAcceptSession() event in Data Script.