コード例 #1
0
ファイル: Program.cs プロジェクト: sanlonezhang/ql
        /// <summary>
        /// get the select jobs
        /// </summary>
        /// <returns></returns>
        private static List <string> SelectTheJobs()
        {
            //Store the select the jobs
            Console.WriteLine("pls select the job you want to test:");
            var jobNames = AbstractJobFactory.GetTheAllJobNameFromAssmeble();
            var index    = 1;

            //Show the names of the jobs
            jobNames.ForEach(x =>
            {
                Console.WriteLine("Job" + index + ": " + x);
                index++;
            });
            Console.WriteLine("Job" + index + ": All");
            Console.WriteLine();
            try
            {
                var numbers = Console.ReadLine().Split(new char[] { ' ' });
                if (numbers.Length > 0)
                {
                    var selectJobs = new List <string>();
                    foreach (var key in numbers)
                    {
                        selectJobs.Add(jobNames[Convert.ToInt32(key) - 1]);
                    }
                    return(selectJobs);
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Input error, pls re-select the jobs");
            }
            return(new List <string>());
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sanlonezhang/ql
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            ToDearLily();
            var selectJobs = SelectTheJobs();

            if (selectJobs.Count > 0)
            {
                var instances = new List <JobInstance>();
                selectJobs.ForEach(x =>
                {
                    instances.Add(AbstractJobFactory.GetJobInstance(x));
                });

                //Execute the jobs
                foreach (var job in instances)
                {
                    var context = new JobContext();
                    job.GetDescription();
                    job.Run(context);
                    Console.WriteLine(context.Message);
                }
            }

            Console.WriteLine();
            Console.WriteLine("---------------------");
            Console.WriteLine("The Job already done");
            Console.ReadLine();
        }