コード例 #1
0
 private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e)
 {
     foreach (var item in e.PublishedEntities)
     {
         if (item.ContentType.Alias == "materiale")
         {
             try
             {
                 using (bywhoEntities db = new bywhoEntities())
                 {
                     Materials mat = null;
                     var       id  = item.GetValue <string>("materialeId");
                     mat = db.Materials.FirstOrDefault(x => x.Id.ToString() == id);
                     if (mat == null)
                     {
                         mat = new Materials();
                         PopulateModel(item, mat, true);
                         db.Materials.Add(mat);
                         db.SaveChanges();
                         item.SetValue("materialeId", mat.Id.ToString());
                         sender.SaveAndPublish(item, raiseEvents: false);
                     }
                     else
                     {
                         PopulateModel(item, mat, true);
                         db.SaveChanges();
                     }
                 }
             }
             catch
             {
             }
         }
     }
 }
コード例 #2
0
 private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e)
 {
     foreach (var entity in e.PublishedEntities)
     {
         uFPCCache.Create(entity.Id);
     }
 }
        private void GenerateErrorPages(IContentService sender, ContentPublishedEventArgs e)
        {
            // only when website settings or an error page is published do we want to generate the static version
            var validAliases = new[] { "websiteSettings", "errorPage" };

            if (e.PublishedEntities.All(x => !validAliases.Contains(x.ContentType.Alias)))
            {
                // website settings or error page wasn't published, nothing to update
                return;
            }

            using (var contextReference = _contextFactory.EnsureUmbracoContext())
            {
                var originalRequestUrl = contextReference.UmbracoContext.HttpContext.Request.Url;

                // generate static error pages in the background
                Task.Run(() =>
                {
                    using (var errorService = new ErrorPageService(_contextFactory, _domainService, _logger, originalRequestUrl))
                    {
                        errorService.GenerateStaticErrorPages();
                    }
                });
                e.Messages.Add(new EventMessage("Generating error page", "The error page(s) are being regenerated, so it might take up to a minute before you see the changes on the website.", EventMessageType.Info));
            }
        }
コード例 #4
0
 private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e)
 {
     foreach (var item in e.PublishedEntities)
     {
         if (item.ContentType.Alias == "page")
         {
             try
             {
                 bywhoEntities db      = new bywhoEntities();
                 int           pguid   = item.GetValue <int>("pageId");
                 var           topic   = db.Topic.FirstOrDefault(x => x.Id == pguid);
                 var           baseURL = "/cms";
                 if (topic != null)
                 {
                     topic.Title          = item.GetValue <string>("title");
                     topic.SystemName     = item.GetValue <string>("systemName");
                     topic.BodyTekst      = TemplateUtilities.ResolveMediaFromTextString(item.GetValue <string>("bodyText"));
                     topic.IsPage         = item.GetValue <bool>("isPage");
                     topic.SeoTitle       = item.GetValue <string>("seoTitle");
                     topic.SeoDescription = item.GetValue <string>("seoDescription");
                     topic.SeoKeywords    = item.GetValue <string>("seoKeywords");
                     topic.NoFollow       = item.GetValue <bool>("noFollow");
                     db.SaveChanges();
                 }
             }
             catch (Exception ex)
             {
             }
         }
     }
 }
コード例 #5
0
        /// <summary>
        /// Content nodes were published.
        /// </summary>
        private void ContentService_Published(IContentService contentService,
                                              ContentPublishedEventArgs e)
        {
            var nodes = e.PublishedEntities;

            HandleChangedContent(nodes);
        }
コード例 #6
0
        private void ContentServicePublished(IContentService sender, ContentPublishedEventArgs e)
        {
            // when something is published, (if it's a ForumPost)
            // clear the relevant forum cache.
            // we do it in two steps because more than one post in a forum
            // may have been published, so we only need to clear the cache
            // once.

            List <string> invalidCacheList = new List <string>();

            foreach (var item in e.PublishedEntities)
            {
                // is a forum post...
                if (item.ContentTypeId == postContentTypeId)
                {
                    // get parent Forum.
                    invalidCacheList = AddParentForumCaches(item, invalidCacheList);
                }
            }

            // clear the cache for any forums that have had child pages published...
            foreach (var cache in invalidCacheList)
            {
                //Logger.Info<ForumCacheHandler>("Clearing Forum Info Cache: {0}", cache);
                Umbraco.Core.Composing.Current.AppCaches.RuntimeCache.ClearByKey(cache);
            }
        }
コード例 #7
0
 /// <summary>
 /// ensure rules and config are updated when keepout rules are published or trashed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e)
 {
     if (!e.PublishedEntities.Any(x => x.ContentType.Alias.StartsWith("keepOutSecurityRule")) && KeepOutRulesFolderId > 0)
     {
         return;
     }
     Reload(e.Messages);
 }
コード例 #8
0
 private void Content_Published(IContentService sender, ContentPublishedEventArgs e)
 {
     foreach (IContent content in e.PublishedEntities)
     {
         PurgeCloudflareCache(content);
         UpdateContentIdToUrlCache(content);
     }
 }
コード例 #9
0
 private void ContentServiceOnPublished(IContentService sender, ContentPublishedEventArgs e)
 {
     foreach (var node in e.PublishedEntities)
     {
         _logger.Debug <SubscribeToPublishEventComponent>($"Content {node.Id} published");
         var hub = GlobalHost.ConnectionManager.GetHubContext <GatsbyHub>();
         hub.Clients.All.nodePublished(node.Id);
     }
 }
コード例 #10
0
        private static void ProcessContentPublished(IContentService sender, ContentPublishedEventArgs e)
        {
            var services = DependencyResolver.Current.GetServices <IUmbracoContentPublishedEventService>();

            foreach (var service in services)
            {
                service.ProcessContentPublished(sender, e);
            }
        }
コード例 #11
0
        private void ObtenerEstudiantesMeritorios(string fileName, IContent Content, ContentPublishedEventArgs e)
        {
            long records    = 0;
            int  ChildCount = Current.Services.ContentService.CountChildren(Content.Id);

            if (ChildCount > 0)
            {
                var Childrens = Current.Services.ContentService.GetPagedChildren(Content.Id, 0, ChildCount, out records);
                foreach (var child in Childrens)
                {
                    Current.Services.ContentService.Delete(child);
                }
            }

            using (SpreadsheetDocument doc = SpreadsheetDocument.Open(fileName, false))
            {
                WorkbookPart          workbookPart = doc.WorkbookPart;
                SharedStringTablePart sstpart      = workbookPart.GetPartsOfType <SharedStringTablePart>().First();
                SharedStringTable     sst          = sstpart.SharedStringTable;

                var sheets         = workbookPart.Workbook.Sheets.Cast <Sheet>().ToList();
                var worksheetParts = workbookPart.WorksheetParts;
                worksheetParts = worksheetParts.OrderBy(w => sheets.IndexOf(sheets.Where(x => x.Id.Value == doc.WorkbookPart.GetIdOfPart(w)).First()));
                foreach (var worksheetPart in worksheetParts)
                {
                    Worksheet sheet = worksheetPart.Worksheet;
                    var       rows  = sheet.Descendants <Row>().Skip(1);

                    foreach (Row row in rows)
                    {
                        var celdas = row.Elements <Cell>().ToArray();
                        if (celdas[0].CellValue != null)
                        {
                            var Numero         = celdas[0].CellValue.Text;
                            var Matricula      = celdas[1].CellValue.Text;
                            var NombreCompleto = sst.ChildElements[int.Parse(celdas[2].CellValue.Text)].InnerText;
                            var Decanato       = sst.ChildElements[int.Parse(celdas[3].CellValue.Text)].InnerText;
                            var Carrera        = sst.ChildElements[int.Parse(celdas[4].CellValue.Text)].InnerText;
                            var CodigoCarrera  = sst.ChildElements[int.Parse(celdas[5].CellValue.Text)].InnerText;
                            var Estudiante     = Current.Services.ContentService.Create($"{Matricula} - {NombreCompleto}", Content.Id, "estudianteMeritorio");
                            Estudiante.Properties["no"].SetValue(Numero);
                            Estudiante.Properties["matricula"].SetValue(Matricula);
                            Estudiante.Properties["nombreCompleto"].SetValue(NombreCompleto);
                            Estudiante.Properties["decanato"].SetValue(Decanato);
                            Estudiante.Properties["carrera"].SetValue(Carrera);
                            Estudiante.Properties["codigoCarrera"].SetValue(CodigoCarrera);
                            Current.Services.ContentService.SaveAndPublish(Estudiante, "*", -1, false);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
コード例 #12
0
        private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e)
        {
            if (!PublishHookEnabled())
            {
                return;
            }

            var contentIds = e.PublishedEntities.Select(c => c.Id);

            PurgeCache(e.Messages, contentIds);
        }
 private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e)
 {
     foreach (var node in e.PublishedEntities)
     {
         if (node.ContentType.Alias == USNConstants.HomePageAlias || node.ContentType.Alias == USNConstants.PageAlias || node.ContentType.Alias == USNConstants.BlogPostAlias)
         {
             IContent pageComponentsNode = CreatePageComponentsFolder(node, true);
             if (pageComponentsNode != null)
             {
                 _contentService.SaveAndPublish(pageComponentsNode);
             }
         }
     }
 }
コード例 #14
0
ファイル: PageComponents.cs プロジェクト: bkclerke/MyUmbDocs
        private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e)
        {
            foreach (var node in e.PublishedEntities)
            {
                if (NodeHasPcFolder(node.Id))
                {
                    continue;
                }

                if (IsValidContentTypeAlias(node.ContentType.Alias))
                {
                    var pageComponentsFolder = _services.ContentService.CreateContent("Page Components", node.GetUdi(), "pcFolder");
                    _services.ContentService.SaveAndPublish(pageComponentsFolder);
                }
            }
        }
コード例 #15
0
 private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e)
 {
     foreach (var node in e.PublishedEntities)
     {
         if (!node.AvailableCultures.Any())
         {
             _autoNode.Run(node);
         }
         else
         {
             foreach (var c in node.AvailableCultures.Where(x => e.HasPublishedCulture(node, x)))
             {
                 _autoNode.Run(node, c);
             }
         }
     }
 }
コード例 #16
0
        private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e)
        {
            // the custom code to fire everytime content is published goes here!
            var ide = e.PublishedEntities.First();

            if (ide.ContentType.Alias == "contenedorSlang")
            {
                var xls = ide.GetValue("Documento");
                //var excel = Content.Properties["Documento"].GetValue();
                if (xls.ToString() != String.Empty || xls != null)
                {
                    var docExcel = Path.Combine("https://localhost:44347" + xls.ToString());
                    var cliente  = new WebClient();
                    var fullPath = Path.GetTempFileName();
                    cliente.DownloadFile(docExcel, fullPath);
                    ReadExcelFileSax(fullPath, ide);
                }

                //var content = _prueba.Create("My First Blog Post 2", ide, "slangs");
                //content.SetValue("descripcion", "<p>Test</p>");
                //_prueba.SaveAndPublish(content, "*", -1, false);
            }
        }
コード例 #17
0
ファイル: ContentScaffolding.cs プロジェクト: kows/ubase
        private void ContentService_Published(IContentService contentService, ContentPublishedEventArgs e)
        {
            foreach (var content in e.PublishedEntities)
            {
                if (content.ContentType.Alias.InvariantEquals(SiteContainer.ModelTypeAlias))
                {
                    var noOfChildren = contentService.CountChildren(content.Id);

                    if (noOfChildren == 0)
                    {
                        var domainService       = Current.Services.DomainService;
                        var localizationService = Current.Services.LocalizationService;
                        var domain = HttpContext.Current.Request.Url.Host;

                        var siteRoot = CreateSiteRoot(contentService, content, domainService, localizationService, domain);

                        CreateRepositories(contentService, content);
                        CreatePages(contentService, siteRoot);

                        contentService.SaveAndPublishBranch(content, true);
                    }
                }
            }
        }
コード例 #18
0
 private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e)
 {
     foreach (var item in e.PublishedEntities)
     {
         if (item.ContentType.Alias == "product")
         {
             try
             {
                 bywhoEntities db      = new bywhoEntities();
                 Guid          pguid   = Guid.Parse(item.GetValue <string>("productId"));
                 var           style   = db.Styles.FirstOrDefault(x => x.Id == pguid);
                 var           baseURL = "/cms";
                 if (style != null)
                 {
                     style.Name             = item.GetValue <string>("productName");
                     style.Description      = item.GetValue <string>("description");
                     style.Price            = item.GetValue <decimal>("price");
                     style.OldPrice         = item.GetValue <decimal>("oldPrice");
                     style.Picture          = baseURL + item.GetValue <string>("picture");
                     style.Poster           = baseURL + item.GetValue <string>("poster");
                     style.AmountOfPictures = (int)item.GetValue <decimal>("amountOfPictures");
                     style.Published        = item.GetValue <bool>("published");
                     style.HasText          = item.GetValue <bool>("hasTextInStyle");
                     style.SeoTitle         = item.GetValue <string>("seoTitle");
                     style.SeoDescription   = item.GetValue <string>("seoDescription");
                     style.SeoKeywords      = item.GetValue <string>("seoKeywords");
                     style.NoFollow         = item.GetValue <bool>("noFollow");
                     db.SaveChanges();
                 }
             }
             catch (Exception ex)
             {
             }
         }
     }
 }
コード例 #19
0
        private void ContentService_Published(IContentService sender, ContentPublishedEventArgs e)
        {
            foreach (var item in e.PublishedEntities)
            {
                if (item.ContentType.Alias == "resource")
                {
                    try
                    {
                        bywhoEntities db         = new bywhoEntities();
                        string        systemName = item.Name;
                        var           resource   = db.Resources.FirstOrDefault(x => x.Name == systemName);

                        if (resource != null)
                        {
                            resource.Value = item.GetValue <string>("text");
                            db.SaveChanges();
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
コード例 #20
0
 private void ContentPublished(IContentService sender, ContentPublishedEventArgs e)
 {
     InvalidateCache(e.PublishedEntities);
 }
コード例 #21
0
        private void ContentService_Published(Umbraco.Core.Services.IContentService sender, ContentPublishedEventArgs contentPublishedEventArgs)
        {
            foreach (var node in contentPublishedEventArgs.PublishedEntities)
            {
                if (node.ContentType.Alias != Theme.ModelTypeAlias)
                {
                    continue;
                }

                var result = _sassService.BuildSass(node.Id);

                contentPublishedEventArgs.Messages.Add(result == string.Empty
                    ? new EventMessage("Sass File Built", result,
                                       EventMessageType.Info)
                    : new EventMessage("Sass Build Error", result,
                                       EventMessageType.Error));
            }
        }
コード例 #22
0
        private void ContentService_Published(IContentService sender, ContentPublishedEventArgs args)
        {
            var oldRoutes = GetOldRoutes(args.EventState);

            CreateRedirects(oldRoutes);
        }