Beispiel #1
0
 /// <summary>
 /// To Update Parameter
 /// </summary>
 /// <param name="ParameterBOobj"></param>
 /// <returns></returns>
 public string UpdateParameter(ParameterBO ParameterBOobj)
 {
     return((new ParameterDAL()).UpdateParameter(ParameterBOobj));
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.Title = "Loading..";

            var mainService   = CreateHostBuilder(args).Build().Services;
            var mainProcessor = mainService.GetService <ITasqR>();

            var clients = mainProcessor.Run(new GetClientsQr());

            mainProcessor.OnLog += (sender, proc, args) =>
            {
                Debug.WriteLine(args.Message);
            };

            if (clients.Count() > 1)
            {
                Console.ForegroundColor = commandColor;
                Console.Write("Enter ClientID: ");
                Console.ForegroundColor = inputColor;

                if (!short.TryParse(Console.ReadLine(), out ClientID))
                {
                    throw new AerishException("Invalid client ID parameter");
                }
            }
            else if (clients.Count() == 1)
            {
                ClientID = clients.Single().ClientID;
            }

            var client = clients.SingleOrDefault(a => a.ClientID == ClientID);

            short jobID;

            do
            {
                var scopeFactory = mainService.GetService <IServiceScopeFactory>();
                using (var scope = scopeFactory.CreateScope())
                {
                    var services  = scope.ServiceProvider;
                    var processor = services.GetService <ITasqR>();
                    Console.Clear();
                    jobID = -1;

                    processor.OnLog += (sender, proc, args) =>
                    {
                        Debug.WriteLine(args.Message);
                    };

                    Console.Title = client.Name;

                    Console.WriteLine($"Welcome to {client.Name} Test Payroll");
                    Console.WriteLine();

                    var jobList = processor.Run(new GetJobsQr());

                    foreach (var clientJob in jobList)
                    {
                        PrintJob(clientJob);
                    }

                    Console.WriteLine();

                    Console.ForegroundColor = commandColor;
                    Console.Write("Please enter Job ID (-1 to exit): ");
                    Console.ForegroundColor = inputColor;

                    Console.WriteLine();
                    Console.Write("> ");
                    string jobInputID = Console.ReadLine();

                    if (!short.TryParse(jobInputID, out jobID))
                    {
                        jobID = short.MaxValue;
                        continue;
                    }

                    if (jobID < 1)
                    {
                        continue;
                    }

                    var job = processor.Run(new FindJobQr(jobID));

                    if (job == null)
                    {
                        jobID = short.MaxValue;
                        continue;
                    }

                    Console.WriteLine();

                    Console.WriteLine($"Job: {job.LongDesc}");

                    var parameters = new ParameterDictionary();
                    if (job.JobParameters.Any())
                    {
                        Console.WriteLine("PARAMETERS");
                        Console.WriteLine();

                        foreach (var parameter in job.JobParameters)
                        {
                            var param = new ParameterBO
                            {
                                Name       = parameter.Name,
                                IsRequired = parameter.IsRequired,
                                DataType   = parameter.DataType,
                                MaxLength  = parameter.MaxLength
                            };

                            do
                            {
                                Console.ForegroundColor = commandColor;
                                Console.Write($"{(parameter.IsRequired ? "*" : "")}{parameter.Display} (");
                                Console.ForegroundColor = hintColor;
                                Console.Write($"{parameter.DataType}");
                                Console.ForegroundColor = commandColor;
                                Console.Write($"): ");
                                Console.ForegroundColor = inputColor;

                                if (!string.IsNullOrWhiteSpace(parameter.DefaultValue))
                                {
                                    param.Value = parameter.DefaultValue;

                                    Console.Write(parameter.DefaultValue);
                                }

                                Console.WriteLine("");
                                Console.Write("> ");

                                string newValue = Console.ReadLine();

                                if (!string.IsNullOrWhiteSpace(newValue))
                                {
                                    param.Value = newValue;
                                }

                                if (param.Value?.Length == 0)
                                {
                                    param.Value = null;
                                }
                            } while (!param.IsValid());

                            parameters[param.Name] = param;
                        }
                    }

                    var cmd = new MasterProcessCmd(jobID, parameters);

                    var jobTracker = (IProcessTracker)processor.Run(cmd);

                    Console.WriteLine();

                    if (jobTracker.JobErrors().Any())
                    {
                        var errors = jobTracker.JobErrors();

                        if (jobTracker.Aborted == true)
                        {
                            Console.WriteLine("Job aborted with errors.");
                        }
                        else
                        {
                            Console.WriteLine("Job done with errors.");
                        }

                        Console.WriteLine("----------------");
                        foreach (var error in errors)
                        {
                            Console.WriteLine(error.Message);
                        }
                        Console.WriteLine("----------------");
                    }
                    else
                    {
                        Console.WriteLine("Job done!");
                    }

                    Console.Write("Press any key to reset console.");

                    Console.ReadKey();
                }
            } while (jobID > 0);
        }
Beispiel #3
0
 /// <summary>
 /// To Add Parameter
 /// </summary>
 /// <param name="ParameterBOobj"></param>
 /// <returns></returns>
 public string AddParameter(ParameterBO ParameterBOobj)
 {
     return((new ParameterDAL()).AddParameter(ParameterBOobj));
 }