Ejemplo n.º 1
0
        private async void btnGenerate_Click(object sender, EventArgs e)
        {
            if (tbMaxRead.Text.Length == 0 || tbMaxProcess.Text.Length == 0 || tbMaxWrite.Text.Length == 0)
            {
                MessageBox.Show("Please, input initial parameters");
                return;
            }

            int maxReadFilesCount    = Convert.ToInt32(tbMaxRead.Text);
            int maxProcessTasksCount = Convert.ToInt32(tbMaxProcess.Text);
            int maxWriteFilesCount   = Convert.ToInt32(tbMaxWrite.Text);

            if (!(maxReadFilesCount > 0 && maxProcessTasksCount > 0 && maxWriteFilesCount > 0))
            {
                MessageBox.Show("Bad initial parameters");
                return;
            }

            if (files.Count == 0)
            {
                MessageBox.Show("List of files is empty. Choose minimum one class.");
                return;
            }

            TestsGenerator.TestGenerator generator = new TestsGenerator.TestGenerator(files, maxReadFilesCount, maxProcessTasksCount, maxWriteFilesCount);

            string folderPath;

            using (FolderBrowserDialog fbd = new FolderBrowserDialog())
            {
                fbd.SelectedPath = @"C:\Users\angel\OneDrive\Рабочий стол\BSUIR\5 сем\СПП\TestsGenerator\Output\";
                DialogResult result = fbd.ShowDialog();
                if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
                {
                    folderPath = fbd.SelectedPath;
                }
                else
                {
                    return;
                }
            }
            if (!string.IsNullOrEmpty(folderPath))
            {
                AsyncFileWriter asyncWriter = new AsyncFileWriter(folderPath);
                await generator.Generate(asyncWriter);
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string inputFile, outputFile;

            Console.Write("Write input file (with extension part): ");
            inputFile = Console.ReadLine();
            Console.Write("Write input file (with extension part): ");
            outputFile = Console.ReadLine();
            if (inputFile != string.Empty && outputFile != string.Empty && inputFile.Contains('.'))
            {
                TestGenerator generator = new TestGenerator(inputFile, outputFile);
                int           variants, questions;
                bool          mix;
                Console.Write("Write number of variants to generate: ");
                variants = Convert.ToInt32(Console.ReadLine());
                Console.Write("Write number of question per variant: ");
                questions = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Would you like to mix answers? (y/n) ");
                char c = Console.ReadKey().KeyChar;
                if (c == 'y' || c == 'Y')
                {
                    mix = true;
                }
                else if (c == 'n' || c == 'N')
                {
                    mix = false;
                }
                else
                {
                    throw new ArgumentException("I said you should say yes or no!");
                }

                generator.GenerateTest(variants, questions, mix);
                //Process.Start(generator.OutputFileName);
            }
            else
            {
                Console.WriteLine("Wrong put. Extension part is missed");
            }
        }