All Classes Namespaces Functions Properties Pages
SessionId
Description
The following C# code shows how to retrieve a session id and use it to make calls to the TotalAgility SDK.
Please note that the corresponding App.Config file must be set up correctly for the methods to work. Please see here for more details.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace UserLogOn
{
class Program
{
static void Main(string[] args)
{
// Create the Session2 object to hold the return data
// Create the UserIdentity object and add the user we wish to logon
id.UserId = "<username>";
id.UnconditionalLogOn = true;
id.LogOnProtocol = 7;
// Set up a UserService object and call the Logon2 method
TotalAgility.Sdk.UserService userService = new TotalAgility.Sdk.UserService();
session2 = userService.LogOn2(id);
// make use of the session id by calling DoesResourceExist
TotalAgility.Sdk.ResourceService resourceService = new TotalAgility.Sdk.ResourceService();
resourceId.Name = "User2";
bool userExists = resourceService.DoesResourceExist(session2.SessionId, resourceId);
// Log the user off again
userService.LogOff(session2.SessionId);
}
}
}