dotnetCLI to set up a new console app project. Run the following commands from a terminal window:
quickStartService.csprojin the root of your project folder. *Note that the version number may be different than at the time of the writing of this guide:
Program.csfile. We’ll start off by importing some libraries. Make sure you’re importing the following libraries:
Managerobject that will let us access functionality from the Skylight Integration API. Modify the body of
Program.csto reflect the following code, replacing the default “Hello World” functionality.
myDomainin the above with your own credentials. While we’re passing these in as hard-coded values in this example for the sake of expediency, you’d never want to build a production service that stored your credentials in this manner. Instead consider using something such as the
.NET ConfigurationManagerto manage your config and credentials. The code we’ve written to scaffold our service is pretty self explanatory. We’ve specified that our class should implement the
ISessionEventListenerinterface so that we can create methods that handle the various events we’ll receive from Skylight. We’ve also created a new Manager object and set its credentials and log configuration. Afterwards we connect and keep the connection alive indefinitely.
ISessionEventListeneryet. So let’s do that. Add the following method implementations to your
OnSessionCreatedevent handler that adds some data to our session. Before we do that, we’re going to have to create a POCO (Plain Old CLR Object) that contains the object classes we’ll use to model our data. If you’ll remember from Part 3, we saved the following data in application data and used it to bind our UX on the client:
AssemblySessionData.cscontaining the following classes:
stepStatusin our object. If you’ll remember from Part 4, this is the dictionary style object we store in session data to track which pieces of the process have been done. Since we’ll be adapting our application to read all of its data from sessions as opposed to application data, we’ll want to be able to work with this as well.
OnSessionDataUpdatedevent that would inform that system of the status of each step in the process. Since we don’t have a system of record to integrate this example with, we’re going to just leave the
Console.WriteLine()calls in place that we added to our scaffolding so that you can observe the changes to the data as you use your application.
Quick Startapplication from the current tutorials and go to the
openStepsListevent script associated with that card. Go ahead and open it up and comment the code indicated below (you can also just remove it if you like):
stepsListview and select the card that you data bound to represent each step in the collection. We’re going to change that card’s context from
session.data.stepsbecause we’re now populating the steps for this process through the API instead of hard-coding them in the application data. When you’re done, the properties panel should look like this:
stepscollection from the JSON (leaving
dotnet runand watch for console messages as you use the app from the web client or your device! You can also still use session inspector to view the data updates as they’re made.