コード例 #1
0
        /// <summary>
        /// Publishes all files under the filter branch into the target folder path.
        /// </summary>
        /// <param name="TargetRootFolderPath">Path declared as the root, under which branch folders are maintained.</param>
        /// <param name="AppContext">Application context.</param>
        static void Publish(string TargetRootFolderPath, string FilterFolderBranch, ApplicationContext AppContext)
        {
            DocumentPublisher dp = new DocumentPublisher(AppContext, TargetRootFolderPath);

            dp.Publish(FilterFolderBranch);

            Console.WriteLine("Document publishing completed.");
        }
コード例 #2
0
        private static void Main(string[] args)
        {
            var logPath = ConfigurationManager.AppSettings["logPath"];

            if (string.IsNullOrWhiteSpace(logPath))
            {
                logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log.txt");
            }

            var sourcesPath = ConfigurationManager.AppSettings["sourcesPath"];

            IEnumerable <Paths> paths = null;

            if (File.Exists(sourcesPath))
            {
                try
                {
                    paths = JsonConvert.DeserializeObject <List <Paths> >(File.ReadAllText(sourcesPath));
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Exception has occured!");
                    Debug.WriteLine(ex.Message);
                    return;
                }
            }

            if (paths == null)
            {
                return;
            }

            var fileManagers = paths.Where(o => !IsUnc(o.InputPath)).Select(o => new FileManager(
                                                                                o.InputPath,
                                                                                o.TempPath,
                                                                                o.CorruptedPath
                                                                                ));

            var fileTarget = new FileTarget {
                Name     = "Default",
                FileName = logPath,
                Layout   = "${date} ${message} ${onexception:inner=${exception:format=toString}}"
            };

            var logConfig = new LoggingConfiguration();

            logConfig.AddTarget(fileTarget);
            logConfig.AddRuleForAllLevels(fileTarget);

            var logFactory = new LogFactory(logConfig);

            var documentPublisher = new DocumentPublisher();
            var statusPublisher   = new StatusPublisher();
            var documentManager   = new DocumentManager();
            var barcodeManager    = new BarcodeManager();
            var settingsListener  = new SettingsListener();

            HostFactory.Run(
                conf =>
            {
                conf.StartAutomaticallyDelayed();
                conf.SetServiceName("StreamingScannerService");
                conf.SetDisplayName("Streaming Scanner Service");
                conf.RunAsLocalSystem();
                conf.EnableServiceRecovery(recovery =>
                {
                    recovery
                    .RestartService(1)
                    .RestartService(3)
                    .RestartService(5)
                    .SetResetPeriod(1);
                });

                conf.Service <Classes.ScannerManager>(callback =>
                {
                    callback.ConstructUsing(() => new Classes.ScannerManager(
                                                fileManagers,
                                                documentManager,
                                                barcodeManager,
                                                documentPublisher,
                                                statusPublisher,
                                                settingsListener));
                    callback.WhenStarted(service => service.Start());
                    callback.WhenStopped(service => service.Stop());
                }).UseNLog(logFactory);
            }
                );
        }
コード例 #3
0
        /// <summary>
        /// Removes the documents.
        /// </summary>
        /// <param name="scope">The scope.</param>
        /// <param name="documents">The documents.</param>
        public void RemoveDocuments(string scope, string[] documents)
        {
            var publisher = new DocumentPublisher(SearchProvider);

            publisher.RemoveDocuments(scope, DocumentType, documents);
        }
コード例 #4
0
        private static async Task <bool> PublishDocumentationAsync(PublishOptions options)
        {
            var outputPath = options.OutputDirectory;

            FancyConsole.WriteLine("Publishing documentation to {0}", outputPath);

            DocSet docs = await GetDocSetAsync(options);

            if (null == docs)
            {
                return(false);
            }

            DocumentPublisher publisher = null;

            switch (options.Format)
            {
            case PublishOptions.PublishFormat.Markdown:
                publisher = new MarkdownPublisher(docs);
                break;

            case PublishOptions.PublishFormat.Html:
                publisher = new DocumentPublisherHtml(docs, options);
                break;

            case PublishOptions.PublishFormat.Mustache:
                publisher = new HtmlMustacheWriter(docs, options);
                break;

            case PublishOptions.PublishFormat.Swagger2:
                publisher = new SwaggerWriter(docs, "https://service.org")      // TODO: Plumb in the base URL.
                {
                    Title       = options.Title,
                    Description = options.Description,
                    Version     = options.Version
                };
                break;

            case PublishOptions.PublishFormat.Outline:
                publisher = new OutlinePublisher(docs);
                break;

            default:
                FancyConsole.WriteLine(
                    FancyConsole.ConsoleErrorColor,
                    "Unsupported publishing format: {0}",
                    options.Format);
                return(false);
            }

            FancyConsole.WriteLineIndented("  ", "Format: {0}", publisher.GetType().Name);
            publisher.VerboseLogging = options.EnableVerboseOutput;
            FancyConsole.WriteLine();

            FancyConsole.WriteLine("Publishing content...");
            publisher.NewMessage += publisher_NewMessage;

            try
            {
                await publisher.PublishToFolderAsync(outputPath);

                FancyConsole.WriteLine(FancyConsole.ConsoleSuccessColor, "Finished publishing documentation to: {0}", outputPath);
            }
            catch (Exception ex)
            {
                FancyConsole.WriteLine(
                    FancyConsole.ConsoleErrorColor,
                    "An error occured while publishing: {0}",
                    ex.Message);
                FancyConsole.VerboseWriteLine(ex.ToString());
                return(false);
            }

            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Publishes the documents.
        /// </summary>
        /// <param name="scope">The scope.</param>
        /// <param name="documents">The documents.</param>
        public void PublishDocuments(string scope, IDocument[] documents)
        {
            var publisher = new DocumentPublisher(SearchProvider);

            publisher.SubmitDocuments(scope, DocumentType, documents);
        }