/// <inheritdoc/>
        protected sealed override void DoRun()
        {
            var input = new ModAutomationBaseCommonJobCodeGenerateInput
            {
                FileHandleProgress   = new AppCommonJobCodeGenerateProgress(HandleFileProgress),
                FolderHandleProgress = new AppCommonJobCodeGenerateProgress(HandleFolderProgress)
            };

            var result = new CoreBaseExecutionResult();

            try
            {
                Job.Execute(input).CoreBaseExtTaskWithCurrentCulture(false).GetResult();

                Job.OnSuccess(Logger, result, input);
            }
            catch (Exception ex)
            {
                Job.OnError(ex, Logger, result);
            }

            var msg = result.CoreBaseExtJsonSerialize(CoreBaseExtJson.OptionsForLogger);

            Show(msg, false);
        }
Esempio n. 2
0
        /// <summary>
        /// Генерировать код.
        /// </summary>
        /// <param name="input">Ввод.</param>
        /// <returns>Задача.</returns>
        public Task GenerateCode(ModAutomationBaseCommonJobCodeGenerateInput input)
        {
            var excludedFolderNames = new HashSet <string>
            {
                ".idea",
                "node_modules"
            };

            const string fileSearchPattern = "*.ts";

            var sourceEntityFileName = GetFileNameFromEntityName(input.SourceEntityName);

            var(filesCount, foldersCount) = GetCounts(
                input.SourcePath,
                fileSearchPattern,
                excludedFolderNames,
                filePath => CheckIfFilePathIsHandleable(filePath, sourceEntityFileName)
                );

            if (filesCount > 0)
            {
                var targetEntityFileName = GetFileNameFromEntityName(input.TargetEntityName);

                EnumerateFiles(
                    input.SourcePath,
                    fileSearchPattern,
                    excludedFolderNames,
                    (path, number) => HandleFile(
                        input.FileHandleProgress,
                        path,
                        number,
                        filesCount,
                        new UTF8Encoding(false),
                        input.SourceEntityName,
                        sourceEntityFileName,
                        input.SourcePath,
                        input.TargetEntityName,
                        targetEntityFileName,
                        input.TargetPath
                        ),
                    (path, number) => HandleFolder(
                        input.FolderHandleProgress,
                        path,
                        number,
                        foldersCount,
                        sourceEntityFileName,
                        input.SourcePath,
                        targetEntityFileName,
                        input.TargetPath,
                        fileSearchPattern
                        )
                    );
            }

            return(Task.CompletedTask);
        }
        /// <summary>
        /// Генерировать код.
        /// </summary>
        /// <param name="input">Ввод.</param>
        /// <returns>Задача.</returns>
        public Task GenerateCode(ModAutomationBaseCommonJobCodeGenerateInput input)
        {
            var excludedFolderNames = new HashSet <string>
            {
                ".vs",
                "bin",
                "doc",
                "obj"
            };

            const string fileSearchPattern = "*.cs";

            var(filesCount, foldersCount) = GetCounts(
                input.SourcePath,
                fileSearchPattern,
                excludedFolderNames,
                filePath => CheckIfFilePathIsHandleable(filePath, input.SourceEntityName)
                );

            if (filesCount > 0)
            {
                EnumerateFiles(
                    input.SourcePath,
                    fileSearchPattern,
                    excludedFolderNames,
                    (path, number) => HandleFile(
                        input.FileHandleProgress,
                        path,
                        number,
                        filesCount,
                        new UTF8Encoding(true),
                        input.SourceEntityName,
                        input.SourceEntityName,
                        input.SourcePath,
                        input.TargetEntityName,
                        input.TargetEntityName,
                        input.TargetPath
                        ),
                    (path, number) => HandleFolder(
                        input.FolderHandleProgress,
                        path,
                        number,
                        foldersCount,
                        input.SourceEntityName,
                        input.SourcePath,
                        input.TargetEntityName,
                        input.TargetPath,
                        fileSearchPattern
                        )
                    );
            }

            return(Task.CompletedTask);
        }