Celin.AIS - Get Started

CSharp · Console

/Program.cs

using System;
using System.Text.Json;
using System.Threading.Tasks;

// Use namespace Celin, which contains the AIS namespace
namespace Celin;
					
public class Program
{
	public static async Task Main()
	{
		// Initialise the E1 AIS Client
		var e1 = new AIS.Server("https://demo.steltix.com/jderest/v2/");
		// Set Credentials
		e1.AuthRequest.username = "demo";
		e1.AuthRequest.password = "demo";
		try
		{
			// Authenticate
			Console.WriteLine("Authenticate!");
			await e1.AuthenticateAsync();
			Console.WriteLine("{0}, Welcome to {1}", e1.AuthResponse.userInfo.alphaName, e1.AuthResponse.environment);
			// Create AB Form Request
			var ab = new AIS.FormRequest
			{
				// Form name to call
				formName = "P01012_W01012B",
				// Version
				version = "ZJDE0001",
				// Read-only
				formServiceAction = "R",
				// Return Maximum 10 rows
				maxPageSize = "10",
				// Return Form Field 54 and Grid Columns 19 and 20
				returnControlIDs = "54|1[19,20]"
			};
			// Create Form Action
			ab.formActions = new []
			{
				// Set the Search Type to "C"
				new AIS.FormAction { controlID = "54", command = AIS.FormAction.SetControlValue , value = "C" },
				// Press the Find Button
				new AIS.FormAction { controlID = "15", command = AIS.FormAction.DoAction }
			};
			// Submit the Form with a Json Response object
			var json = await e1.RequestAsync<JsonElement>(ab);
			// Dump the response
			Console.WriteLine(json);
			// Sign-out
			await e1.LogoutAsync();
			Console.WriteLine("Goodbye!");
		}
		catch (Exception ex)
		{
			Console.WriteLine(ex.Message);
		}
	}
}

;