Ejemplo n.º 1
0
        private IList <FileInfo> ProcessTtfFonts(Config config, IList <FileInfo> fonts, ProgressBar pb)
        {
            var failureList = new List <FileInfo>();

            if (!fonts.Any())
            {
                return(failureList);
            }

            pb.StartProcessingTtf();

            foreach (var font in fonts)
            {
                pb.StartProcessingTtf(font.Name);
                // X: & cd "{TtxExeDirectory}" & ttx.exe -o "{OutputDirectory}\{fontName}" -m "{InputDirectory}\{fontName}" GaspHack.ttx
                var exitCode = CmdExecutor.ExecuteCommand(
                    $"{config.TtxExeDirectory.Substring(0, 2)} & cd \"{config.TtxExeDirectory}\" & ttx.exe -o \"{Path.Combine(config.OutputDirectory, font.Name)}\" -m \"{font.FullName}\" GaspHack.ttx");
                if (exitCode != 0)
                {
                    failureList.Add(font);
                }

                pb.DoneProcessingTtf(font.Name);
            }

            // # {InputDirectory}\*.ttf should == # {OutputDirectory}\*.ttf + # failure fonts
            Debug.Assert(fonts.Count ==
                         Directory.EnumerateFiles(config.OutputDirectory, "*.*").Count(it => it.ToLowerInvariant().EndsWith(".ttf")) +
                         failureList.Count);

            pb.DoneProcessingTtf();

            return(failureList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Run command when derived class override this method.
        /// </summary>
        /// <returns>
        /// Return value of the whole application.
        /// </returns>
        public override int Run()
        {
            string output = CmdExecutor.ExecuteCmd("dotnet --info");

            _console.WriteLine(output);
            return(0);
        }
Ejemplo n.º 3
0
 public override void Execute(Cmdline cmd)
 {
     try
     {
         var exec = new CmdExecutor();
         if (exec.IsConfiguration(cmd.Parameters))
         {
             exec.Configure(cmd.Parameters);
         }
         if (exec.IsList(cmd.Parameters))
         {
             var resul = exec.List();
         }
         else
         {
             exec.Execute(cmd);
             Notifyer.NotifyInfo($"Evernote: note created.");
         }
     }
     catch (Exception ex)
     {
         Logger.Error($"Cannot execute EN plugin: {ex.Message}", ex);
         Notifyer.NotifyError($"Cannot execute EN plugin: {ex.Message}");
     }
 }
Ejemplo n.º 4
0
 public CommandResult(int matchedLength, int argLength, CmdExecutor <TEnv> executor, TEnv env, Args args, Args dict)
 {
     MatchedLength = matchedLength;
     ArgLength     = argLength;
     Executor      = executor;
     Env           = env;
     Args          = args;
     Dict          = dict;
 }
Ejemplo n.º 5
0
        public void ExecuteCmdFileTest()
        {
            string file = "CommandLine/test.bat";

            if (!File.Exists(file))
            {
                return;
            }
            string output = CmdExecutor.ExecuteCmdFile(file);

            output.ShouldContain("dotnet\\sdk");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Обработка добавления исполнителя
        /// к задаче.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddExecutorButton_Click(object sender, EventArgs e)
        {
            var dialog = new InputDialog("Введите имя пользователя");

            dialog.ShowDialog();
            var userName = dialog.Value;
            var user     = TaskManager.GetInstance().GetUserByName(userName);

            if (user == null)
            {
                MessageBox.Show("Такого пользователя не существует.", "Ошибка");
                return;
            }

            var result = CmdExecutor.Execute(
                $"add_executor {ConnectedProject.Id} {ConnectedTask.Id} {user.Id}");

            MessageBox.Show(result.TextOutput, "Сообщение");
            TaskManager.GetInstance().CommitChanges();
            UpdateExecutorsComboBox();
        }
Ejemplo n.º 7
0
        public override async Task PerformCalculations(string inputFile)
        {
            List <string> listInput = await FileHelper.GetStringListFromFile(inputFile);

            Command[] input = PrepareInput(listInput);

            CalculateAndLogTime(() =>
            {
                int result1 = CmdExecutor.ExecuteToFirstLoop(input);
                Console.WriteLine();
                Console.WriteLine($"Result 1: {result1}");
            });

            CalculateAndLogTime(() =>
            {
                int result2 = CmdExecutor.FindCommandToReplace(input);
                Console.WriteLine();
                Console.WriteLine($"Result 2: {result2}");
            });

            Console.WriteLine();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Обработка выбора нового статуса задачи
        /// в списке статусов задачи.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StatusComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (statusComboBox.SelectedItem == null)
            {
                return;
            }

            var text = (string)statusComboBox.SelectedItem;

            // Определяем статус задачи из енума исходя из того, что было выбрано в списке.
            string taskStatus;

            switch (text)
            {
            case "Новая":
                taskStatus = "opened";
                break;

            case "В процессе выполнения":
                taskStatus = "inProgress";
                break;

            case "Завершенная":
                taskStatus = "closed";
                break;

            default:
                return;
            }

            var result = CmdExecutor.Execute(
                $"set_task_status {ConnectedProject.Id} {ConnectedTask.Id} {taskStatus}");

            MessageBox.Show(result.TextOutput, "Сообщение");

            TaskManager.GetInstance().CommitChanges();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Обработка нажатия кнопки удаления
        /// исполнителя задачи.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RemoveExecutorButton_Click(object sender, EventArgs e)
        {
            if (executorsComboBox.SelectedItem == null)
            {
                return;
            }
            string userName = (string)executorsComboBox.SelectedItem;
            //MessageBox.Show($"you want to remove {userName}", "");

            var user = TaskManager.GetInstance().GetUserByName(userName);

            if (user == null)
            {
                return;
            }

            var result = CmdExecutor.Execute(
                $"remove_executor {ConnectedProject.Id} {ConnectedTask.Id} {user.Id}");

            MessageBox.Show(result.TextOutput, "Сообщение");

            UpdateExecutorsComboBox();
            TaskManager.GetInstance().CommitChanges();
        }
Ejemplo n.º 10
0
        private IList <FileInfo> ProcessTtcFonts(Config config, IList <FileInfo> fonts, ProgressBar pb)
        {
            var failureList = new List <FileInfo>();

            if (!fonts.Any())
            {
                return(failureList);
            }

            var tempInputDirectory = Path.Combine(config.InputDirectory, "temp");

            if (!Directory.Exists(tempInputDirectory))
            {
                // Create a temp folder in the input folder
                Directory.CreateDirectory(tempInputDirectory);
            }
            else
            {
                // Clean the temp files
                DirectoryCleaner.CleanDirectoryAsync(tempInputDirectory).Wait();
            }

            // Create a temp folder in the output folder
            var tempOutputDirectory = Path.Combine(config.OutputDirectory, "temp");

            if (!Directory.Exists(tempOutputDirectory))
            {
                // Create a temp folder in the input folder
                Directory.CreateDirectory(tempOutputDirectory);
            }
            else
            {
                // Clean the temp files
                DirectoryCleaner.CleanDirectoryAsync(tempOutputDirectory).Wait();
            }

            pb.StartProcessingTtc();

            foreach (var font in fonts)
            {
                pb.StartProcessingTtc(font.Name);

                // X: & cd {InputDirectory}\temp & call "{AfdkoDirectory}\otc2otf.cmd" "{fontFullname}"
                pb.StartExtractingTtc(font.Name);
                var exitCode =
                    CmdExecutor.ExecuteCommand(
                        $"{tempInputDirectory.Substring(0, 2)} & cd \"{tempInputDirectory}\" & call \"{Path.Combine(config.AfdkoDirectory, "otc2otf.cmd")}\" \"{font.FullName}\"");

                Debug.Assert(exitCode == 0); // TODO
                if (exitCode != 0)
                {
                    failureList.Add(font);
                }
                else
                {
                    pb.StartProcessingExtractedFilesOf(font.Name);
                    var extractedTtfFiles = Directory.GetFiles(tempInputDirectory);
                    Debug.Assert(extractedTtfFiles.Any());
                    var exitCode2 = 0;
                    // Gasphack the extracted TTF files. Note that they should be processed in order of creation time to maintain the same order as the components in the original TTC file.
                    foreach (var extractedTtf in extractedTtfFiles.Select(it => new FileInfo(it)).OrderBy(it => it.CreationTimeUtc))
                    {
                        // X: & cd "{TtxExeDirectory}" & ttx.exe -o "{OutputDirectory}\temp\{fontName}" -m "{InputDirectory}\temp\{fontName}" GaspHack.ttx
                        exitCode2 = CmdExecutor.ExecuteCommand(
                            $"{config.TtxExeDirectory.Substring(0, 2)} & cd \"{config.TtxExeDirectory}\" & ttx.exe -o \"{Path.Combine(tempOutputDirectory, extractedTtf.Name)}\" -m \"{extractedTtf.FullName}\" GaspHack.ttx");
                        Debug.Assert(exitCode2 == 0); // TODO
                        if (exitCode2 != 0)
                        {
                            break;
                        }
                    }

                    if (exitCode2 != 0)
                    {
                        failureList.Add(font);
                    }
                    else
                    {
                        Debug.Assert(Directory.EnumerateFiles(tempOutputDirectory).Any());
                        pb.StartBuildingProcessedTtc(font.Name);
                        // X: & cd "{OutputDirectory}" & call "{AfdkoDirectory}\otf2otc.cmd" -o "{OutputDirectory}\{fontName}" "{OutputDirectory}\temp\1.ttf" "{OutputDirectory}\temp\2.ttf" ...
                        // Note that the input files should be ordered be creation time to maintain the same order as the components in the original TTC file.
                        var command = $"{config.OutputDirectory.Substring(0, 2)} & cd \"{config.OutputDirectory}\" & call \"{Path.Combine(config.AfdkoDirectory, "otf2otc.cmd")}\" -o \"{Path.Combine(config.OutputDirectory, font.Name)}\" ";
                        command = Directory.EnumerateFiles(tempOutputDirectory).Select(it => new FileInfo(it)).OrderBy(it => it.CreationTimeUtc)
                                  .Aggregate(command,
                                             (current, processedExtractedTtf) => current + $"\"{processedExtractedTtf.FullName}\" ");

                        var exitCode3 = CmdExecutor.ExecuteCommand(command);
                        Debug.Assert(exitCode3 == 0); // TODO
                        if (exitCode3 != 0)
                        {
                            failureList.Add(font);
                        }
                    }
                }

                // Clean the temp files
                Task.WaitAll(
                    DirectoryCleaner.CleanDirectoryAsync(tempInputDirectory),
                    DirectoryCleaner.CleanDirectoryAsync(tempOutputDirectory)
                    );
                pb.DoneProcessingTtc(font.Name);
            }

            // Delete the temp folders
            Debug.Assert(!Directory.EnumerateFiles(tempInputDirectory).Any());
            Debug.Assert(!Directory.EnumerateFiles(tempOutputDirectory).Any());
            try
            {
                Directory.Delete(tempInputDirectory);
                Directory.Delete(tempOutputDirectory);
            }
            catch (IOException)
            {
                // Doesn't matter if the temp folder is occupied.
            }

            // # {InputDirectory}\*.ttc should == # {OutputDirectory}\*.ttc + # failure fonts
            Debug.Assert(fonts.Count ==
                         Directory.EnumerateFiles(config.OutputDirectory, "*.*").Count(it => it.ToLowerInvariant().EndsWith(".ttc")) +
                         failureList.Count);

            pb.DoneProcessingTtc();

            return(failureList);
        }
Ejemplo n.º 11
0
        public void ExecuteCommandTest()
        {
            string output = CmdExecutor.ExecuteCmd("dotnet --info");

            output.ShouldContain("5.0");
        }
Ejemplo n.º 12
0
 public static void Run()
 {
     CmdExecutor.ExecuteCommand("D: & mkdir aaa", true);
 }
Ejemplo n.º 13
0
 public CommandNode <TEnv> Executes(CmdExecutor <TEnv> executor)
 {
     Executor = executor;
     return(this);
 }
Ejemplo n.º 14
0
 public PluginAppService(IApplicationLifetime applicationLifetime, CmdExecutor cmdExecutor, PluginOptions pluginOptions)
 {
     _app       = applicationLifetime;
     _cmd       = cmdExecutor;
     _pluginOpt = pluginOptions;
 }
Ejemplo n.º 15
0
 public CommandNode <TEnv> Executes(VoidCmdExecutor <TEnv> vce)
 {
     Executor = ArgUtil.Void2Null(vce);
     return(this);
 }