Raven.Documentation.Web.Controllers.DocsController.GetImagesUrl C# (CSharp) Method

GetImagesUrl() public static method

public static GetImagesUrl ( IDocumentStore store ) : string
store IDocumentStore
return string
		public static string GetImagesUrl(IDocumentStore store)
		{
			var remoteStore = store as DocumentStore;
			if (remoteStore != null)
				return remoteStore.Url.ForDatabase(remoteStore.DefaultDatabase) + "/static/";

			var embeddableDocumentStore = (EmbeddableDocumentStore)store;
			if (embeddableDocumentStore.Url != null)
				return embeddableDocumentStore.Url.ForDatabase(embeddableDocumentStore.DefaultDatabase) + "/static/";

			return null;
		}

Usage Example

コード例 #1
0
        public virtual ActionResult Generate(string key)
        {
            var parser =
                new ArticleParser(
                    new ParserOptions
            {
                PathToDocumentationDirectory = GetArticleDirectory(),
                RootUrl   = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~")),
                ImagesUrl = DocsController.GetImagesUrl(DocumentStore)
            }, new NoOpGitFileInformationProvider());

            DocumentStore
            .DatabaseCommands
            .DeleteByIndex("Raven/DocumentsByEntityName", new IndexQuery {
                Query = "Tag:ArticlePages"
            })
            .WaitForCompletion();

            foreach (var page in parser.Parse())
            {
                DocumentSession.Store(page);

                Parallel.ForEach(
                    page.Images,
                    image =>
                {
                    if (System.IO.File.Exists(image.ImagePath) == false)
                    {
                        return;
                    }

                    using (var file = System.IO.File.OpenRead(image.ImagePath))
                    {
                        DocumentStore.DatabaseCommands.PutAttachment(image.ImageKey, null, file, new RavenJObject());
                    }
                });
            }

            foreach (var toc in parser.GenerateTableOfContents())
            {
                DocumentSession.Store(toc);
            }

            DocumentSession.SaveChanges();

            while (true)
            {
                var stats = DocumentStore.DatabaseCommands.GetStatistics();
                if (stats.StaleIndexes.Any() == false)
                {
                    break;
                }

                Thread.Sleep(500);
            }

            if (string.IsNullOrEmpty(key))
            {
                return(RedirectToAction(MVC.Articles.ActionNames.Articles));
            }

            return(RedirectToAction(MVC.Articles.ActionNames.Articles, MVC.Articles.Name, new { key = key }));
        }
All Usage Examples Of Raven.Documentation.Web.Controllers.DocsController::GetImagesUrl