public bool LaunchJob(PostLaunchJobRequest request) { ProcessBase process = IntegrationFactory.GetIntegrationProcess( request.CustomerId, request.AdmUserId, request.JobId); IProcessArguments pargs = new IntegrationJobArguments() { CustomerID = request.CustomerId, AdmIntegrationJobID = request.JobId, AdmUserID = request.AdmUserId, AdmIntegrationJobsFileID = request.FileId //IsImport = true }; var job = JobManager.Instance.DoJobAsync(a => process.Run(pargs)); process.OnStatusChanged += (sender, e) => { Trace.Write(e.StatusMessage); }; process.OnStepChanged += (sender, e) => { Trace.Write(e.StatusMessage); job.ReportProgress(e.PercentComplete, e.StatusMessage); }; process.OnComplete += (sender, result) => { job.OnSendResults(result); job.ReportComplete(); }; JobStorage.Instance.StoreGlobalJobId(job.Id); return(true); }
/// <summary> /// Starting point for the application. /// </summary> /// <param name="args"> /// The command-line arguments to the application. /// </param> private static void Main(string[] args) { // Parse the arguments into an options object. var options = new CliOptions(); string invokedVerb = null; object invokedOptions = null; var parser = new Parser( delegate(ParserSettings settings) { settings.CaseSensitive = true; settings.IgnoreUnknownArguments = false; }); bool successful = parser.ParseArguments( args, options, (verb, subOptions) => { // if parsing succeeds the verb name and correct instance // will be passed to onVerbCommand delegate (string,object) invokedVerb = verb; invokedOptions = subOptions; }); if (!successful) { Console.WriteLine("Cannot parse arguments."); Environment.Exit(1); } // If this is a process options, then configure it. var processOptions = invokedOptions as IProcessOptions; if (processOptions != null) { ProcessBase process = processOptions.GetProcess(); process.Run(); return; } // If we got this far, we have an invalid state. throw new Exception("Cannot identify resulting options."); }