示例#1
0
        public override bool Execute(string[] arguments)
        {
            PageGenParameters args = new PageGenParameters();

            if (!ArgumentParser.ParseArguments(arguments, args))
            {
                return(false);
            }

            Api.LogLevel logLevel = args.Verbose ? Api.LogLevel.Detail : Api.LogLevel.Info;

            ILog log = new ConsoleLog(logLevel);

            ProjectLoader loader = new ProjectLoader(log, args.Directory);

            if (loader.TryLoadAndValidateConfig(out var config) &&
                loader.TryLoadAndValidateToc(config, out var toc) &&
                config != null &&
                toc != null)
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                var settings = loader.CreateRuntimeSettings(config, toc, new BuildConfig());

                switch (args.PageType)
                {
                case PageType.ExternalLinks:
                    RunGetLinks(settings, log);
                    break;

                case PageType.Chaptersummary:
                    RunChapterSummary(settings, log);
                    break;
                }

                stopwatch.Stop();
                log.Info("Total runtime: {0}ms", stopwatch.ElapsedMilliseconds);

                return(true);
            }

            return(false);
        }
示例#2
0
        public override bool Execute(string[] arguments)
        {
            PageGenParameters args = new PageGenParameters();

            if (!ArgumentParser.ParseArguments(arguments, args))
            {
                return(false);
            }

            CurrentState.Log.LogLevel = args.Verbose ? Api.LogLevel.Detail : Api.LogLevel.Info;

            FolderLock.ExitIfFolderIsLocked(args.Directory, CurrentState.Log);

            using (var l = new FolderLock(args.Directory))
            {
                ProjectLoader loader = new ProjectLoader(CurrentState.Log, args.Directory);

                loader.TryLoadProjectAndExecuteOperation((config, toc) =>
                {
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();

                    var settings = loader.CreateRuntimeSettings(config, toc, new BuildConfig());

                    switch (args.PageType)
                    {
                    case PageType.ExternalLinks:
                        RunGetLinks(settings, CurrentState.Log);
                        break;

                    case PageType.Chaptersummary:
                        RunChapterSummary(settings, CurrentState.Log);
                        break;
                    }

                    stopwatch.Stop();
                    CurrentState.Log.Info("Total runtime: {0}ms", stopwatch.ElapsedMilliseconds);

                    return(true);
                });
            }

            return(false);
        }