示例#1
0
        /// <summary>
        /// Schedules multiple jobs extracted from file given via user input
        /// (in case of incorrect format, error message should be displyed in console)
        /// </summary>
        public static void ProcessBatchScheduleCommand(string lowerCaseInput)
        {
            string[] commandLine = lowerCaseInput.Split();
            int      length      = commandLine.Length;

            //try
            //{
            if (CheckInputData(commandLine, length))
            {
                using (StreamReader file = new StreamReader(Paths.BatchProcessJob(commandLine[1])))
                {
                    List <BaseJob> jobList = new List <BaseJob>();
                    string         line;

                    while ((line = file.ReadLine()) != null)
                    {
                        BaseJob job = ProcessScheduleCommand(line, false);

                        // what happens, if one of the items is not correct?
                        if (job != null)
                        {
                            jobList.Add(job);
                        }
                    }
                    JobScheduler.ScheduleJobs(jobList.ToArray());
                }
            }
            //}
            //catch (Exception)   // better exception handler
            //{
            //Console.WriteLine("File not found.");
            //}
        }
示例#2
0
        /// <summary>
        /// Schedules multiple jobs extracted from file given via user input
        /// (in case of incorrect format, error message should be displyed in console)
        /// </summary>
        public static void ProcessBatchScheduleCommand(string lowerCaseInput)
        {
            string fileName = ParseBatchScheduleInput(lowerCaseInput);

            using (var fileStream = File.Open(Paths.BatchProcessJob(fileName), FileMode.Open))
                using (var reader = new StreamReader(fileStream))
                {
                    while (!reader.EndOfStream)
                    {
                        string line = reader.ReadLine();
                        ProcessScheduleCommand(line);
                    }
                }
        }