private void ContentService_Published(Umbraco.Core.Services.IContentService sender, Umbraco.Core.Events.ContentPublishedEventArgs e)
        {
            var autoPublishSites = _sitesRepository.GetAutoPublishSites();

            var sitesToDeploy = new List <ExtendedGeneratedSite>();

            foreach (var publishedItem in e.PublishedEntities)
            {
                foreach (var site in autoPublishSites)
                {
                    if (sitesToDeploy.Contains(site))
                    {
                        continue;
                    }

                    if (publishedItem.Path.Contains($",{site.RootNode},") || publishedItem.Path.EndsWith($",{site.RootNode}"))
                    {
                        sitesToDeploy.Add(site);
                    }
                }
            }

            //var context = _umbracoContext.EnsureUmbracoContext();
            var process       = new RebuildProcess(_umbracoContextFactory, _exportTypeSettings);
            var deployProcess = new DeployProcess(_storer, _deployerFactory, _sitesRepository);

            foreach (var site in sitesToDeploy)
            {
                //process.RebuildSite(site.Id);
                Task.Run(async() => {
                    await process.RebuildSite(site.Id);
                    await deployProcess.DeployStaticSite(site.Id);
                });
            }
        }
예제 #2
0
        public async Task <IXStaticWebResult> DeployStaticSite(int staticSiteId)
        {
            var process = new DeployProcess(_storer, _deployerFactory, _sitesRepo);

            var result = await process.DeployStaticSite(staticSiteId);

            if (!result.WasSuccessful)
            {
                Logger.Error <DeployController>(result.Exception, result.Message);
            }

            return(result);
        }