public static KTA_JobServices.InputVariableCollection BuildInputVariableCollection(List <Tuple <string, object> > inputToService)
        {
            KTA_JobServices.InputVariableCollection inputVarCollection = new KTA_JobServices.InputVariableCollection();

            foreach (Tuple <string, object> oneInput in inputToService)
            {
                KTA_JobServices.InputVariable inputVariable = new KTA_JobServices.InputVariable();
                inputVariable.Id    = oneInput.Item1;
                inputVariable.Value = oneInput.Item2;
                inputVarCollection.Add(inputVariable);
            }

            return(inputVarCollection);
        }
        public static string CreateJob(string sessionId, string process_ID, long requestNumber, InputVariableCollection inputVarCollection = null)
        {
            // Set up the create new job method
            // Create a job service client so we call the methods in the job service e.g. createjob etc

            var jobSvc = new KTA_JobServices.JobServiceClient();

            // Set up variables for the CreateJob method. Create job requires sessionid, process identity, and process initialization variables (input variables)
            // CreateJob method returns the Job Identity (Job Id).
            var procIdentity = new KTA_JobServices.ProcessIdentity();
            var jobInit      = new KTA_JobServices.JobInitialization();

            // These variables are used for the return object (job identity)
            var jobIdentity = new KTA_JobServices.JobIdentity();

            // This is the process identity of the Loan Application API process. This Id was obtained by running a select * from the Business_Process table
            procIdentity.Id = process_ID;


            if (inputVarCollection == null)
            {
                inputVarCollection = new KTA_JobServices.InputVariableCollection();

                // Set up each inputvariable to job (process initialization variables)
                // Must use the ID of the variable in the process, not its display name
                KTA_JobServices.InputVariable id = new KTA_JobServices.InputVariable();
                id.Id    = "REQUESTID";
                id.Value = requestNumber;
                inputVarCollection.Add(id);
            }

            // Populate the InputVariables to the job
            jobInit.InputVariables = inputVarCollection;

            // Create the job, passing the session id, process identity and inputvariables. A job identity object containing the job id(string) is returned
            // from the method call
            jobIdentity = jobSvc.CreateJobAsync(sessionId, procIdentity, jobInit).GetAwaiter().GetResult();


            // Return the job id
            return(jobIdentity.Id);
        }