Celin.AIS - Submitting an UBE

CSharp · Console

/Program.cs

using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;

namespace Celin
{
	public class Program
	{
		public static async Task Main()
		{
			// Change below to 'if (false)' to submit the UBE
			if (true)
			{
				Console.WriteLine("Change the statement to \"if (false)\" to submit the UBE");
				return;
			}
			#region Set-up
			var loggerFactory = LoggerFactory.Create(builder => 
			{
				builder
					.SetMinimumLevel(LogLevel.Warning)
					.AddConsole();
			});
			var logger = loggerFactory.CreateLogger<Program>();
			var e1 = new AIS.Server("https://demo.steltix.com/jderest/v2/", loggerFactory.CreateLogger<AIS.Server>());
			e1.AuthRequest.username = "demo";
			e1.AuthRequest.password = "demo";
			#endregion
			
			try
			{
				logger.LogDebug("Authenticate");
				await e1.AuthenticateAsync();
				#region UBE Discovery
				Console.WriteLine("Submitting R01401...");
                var rs = await e1.RequestAsync(new AIS.LaunchUBERequest
                {
                    reportName = "R01401",
                    reportVersion = "ZJDE0001",
                    dataSelection = new AIS.DataSelection
                    {
                        criteria = new []
                        {
                            new AIS.Criteria
                            {
                                // Select with the F0101.AN8 field
                                subject = new AIS.Subject
                                {
                                    view = "V0101C",
                                    table = "F0101",
                                    dictItem = "AN8"
                                },
                                comparisonType = AIS.Condition.EQUAL,
                                // Where Equals 6002
                                predicate = new AIS.Predicate
                                {
                                    literalType = AIS.Predicate.SINGLE,
                                    values = new []
                                    {
                                        "6002"
                                    }
                                }
                            }
                        }
                    }
                });
                Console.WriteLine("Job {0} Completed Successfully", rs.jobNumber);
				#endregion
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.Message);
			}
			// Sign-out
			logger.LogDebug("Log out!");
			await e1.LogoutAsync();
			Console.WriteLine("Goodbye!");
		}
	}
}
;