Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeff 17 posts 38 karma points
    Dec 13, 2012 @ 02:22
    Jeff
    0

    U4.9.1 ApplicationStartupHandler problems

    I've been struggling with an issue all day, and cannot find a way to work it out. I'm trying to tie into the Document.BeforePublish event, and after watching Umbraco.tv and reading several cases where this seemed like an easy task, I feel a little lost. Here is my code for a class I've called SaveToSolr.cs :

     

    namespace Project.Web
    {
        public class SaveToSolr : ApplicationStartupHandler
        {
            public SaveToSolr()
            {
                Document.BeforePublish += new Document.PublishEventHandler(Document_BeforePublish);
            }
           
            public void Document_BeforePublish(Document sender, PublishEventArgs args)
            {
                Log.Add(LogTypes.Publish, 0, "before publish log");
               
            }
        }
    }

    I've placed this file under the "App_Code" folder in Visual Studio to make sure it gets saved to this folder every time I make a change. I also recycle app pool in IIS every time I make a change and rebuild the solution.

    Am I missing a step?

    I've placed breakpoints to try and hit one during debugging after a publish, and nothing. It's just not ever going into my event, and I can't figure out why. I've tried removing the 'public' before the method, I've tried inheriting from ApplicationBase, and following the tutorial on Umbraco.tv to the letter. I've seen other similar questions, but others seem to be able to get it to work whereas I cannot. I'm thinking I'm missing an entry in a config file or something? I must be missing something. Any ideas? Thanks!

     

  • Jeff 17 posts 38 karma points
    Dec 14, 2012 @ 18:22
    Jeff
    0

    I've tried removing / re-adding Umbraco application itself, and am still running into the problem. Others seem to be able to do this; I'm not sure what I could be missing that others seem to know and I don't.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 26, 2013 @ 16:32
    Ismail Mayat
    0

    Jeff,

    Bit of topic but how are you saving to solr? Using solr.net api? Also I take it you had to setup solr config to accept the umbraco content?

    regards

    Ismail

  • Jeff 17 posts 38 karma points
    Feb 26, 2013 @ 17:04
    Jeff
    0

    Hey Ismail,

    Yes, I am using the solr.net API. Solr doesn't have an Umbraco context at all. I wrote a method that will take whatever properties are in the Umbraco node, and using those as dynamic fields in Solr. That way, if I want to search for anything with a Solr field "class" of Umbraco item "event", I can just run a solr query for "class:event" and it will return the Solr data transfer object much faster than a typical sql query.

    Side-note: I never got the handler to attach. Due to this and a few other problems with TinyMCE, my team has decided to use an alternate CMS for this project.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 26, 2013 @ 17:50
    Ismail Mayat
    0

    Jeff,

    In relation to the handler I have the following working

            public ExamineEvents()
            {
                //... do stuff since we are installed and configured, otherwise don't do stuff
                ExamineManager.Instance.IndexProviderCollection[Constants.Examine.GeoTechIndexer].GatheringNodeData += GeoTechIndexerGatheringNodeData;
            }

    My colleague Anthony told me to put in 

           public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                if (applicationContext.IsConfigured && applicationContext.DatabaseContext.IsDatabaseConfigured)
                {
    
                }
            }

     

    That didnt work. Ps I am using v6 I think in 491 the class is obsolete you are recommended to use the interface instead.  With regards to solr i was looking to push data into solr from umbraco but having to use solr config put me of. I did read about the dynamic field. Are you able to share the .net code on how you did it? I am assuming the solr.net api has something to allow you push the data and tell it that the field is dynamic?

    Many thanks.

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft