Esempio n. 1
0
        public override bool Execute(ExportInput input)
        {
            var runnerDirectory = Assembly.GetExecutingAssembly().Location.ParentDirectory();

            var bottling = Task.Factory.StartNew(() =>
            {
                if (!input.NoBottlingFlag)
                {
                    new BottleCommand().Execute(new BottleInput {
                        NoZipFlag = true
                    });
                }
            });

            var cleaning = Task.Factory.StartNew(() => cleanExplodedBottleContents(runnerDirectory));

            var hostCleaning = Task.Factory.StartNew(() => {
                if (input.HostFlag.IsNotEmpty())
                {
                    input.TryToCleanOutFubuContentFolder();
                }
            });

            Task.WaitAll(bottling, cleaning, hostCleaning);


            var directories = input.ToDirectories();

            try
            {
                _fileSystem.CreateDirectory(input.Output);
                if (input.CleanFlag)
                {
                    _fileSystem.CleanDirectory(input.Output);
                }

                var projects = input
                               .IncludeProjectsFlag
                               .Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                               .Select(x => x.Trim());

                projects.Each(BottlesFilter.Include);

                FubuMode.Mode(string.Empty);
                var application = new FubuDocsExportingApplication(directories).BuildApplication();
                using (var server = application.RunEmbedded(directories.Solution))
                {
                    exportContent(input, server);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public override bool Execute(RunInput input)
        {
            string runnerDirectory = Assembly.GetExecutingAssembly().Location.ParentDirectory();

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);


            if (!input.NoBottlingFlag)
            {
                new BottleCommand().Execute(new BottleInput {
                    NoZipFlag = true
                });
            }
            cleanExplodedBottleContents(runnerDirectory);



            var failures = new List <string>();

            try
            {
                var directories = input.ToDirectories();

                // TODO -- It sure would be nice to turn off the pre-compile work so we don't get a ton of console errors
                using (var server = new FubuDocsExportingApplication(directories).BuildApplication().RunEmbedded(directories.Solution))
                {
                    var model = server.Endpoints.Get <UrlQueryEndpoint>(x => x.get_urls()).ReadAsJson <UrlList>();
                    var count = model.Urls.Length;
                    var i     = 0;
                    model.Urls.Select(x => server.BaseAddress + x).Each(url => {
                        i++;



                        var status     = server.Endpoints.Get(url).StatusCode;
                        string message = "{0}/{1} {2} ({3})".ToFormat(i.ToString().PadLeft(3), count, url, status);

                        if (status != HttpStatusCode.OK)
                        {
                            failures.Add(url);

                            ConsoleWriter.Write(ConsoleColor.Red, message);
                        }
                        else
                        {
                            ConsoleWriter.Write(ConsoleColor.Gray, message);
                        }
                    });
                }

                if (failures.Any())
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }

            return(true);
        }