Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 21, 2013 @ 12:11
    Ismail Mayat
    0

    GatheringNode data issue

    Guys,

    I am using umbraco 4.7.0 and I have a webservice in same umbraco site. This webservice takes a json array of content and then creates / updates or deletes umbraco documents in the backend. All the crud stuff works fine after the crud activity i publish the doc and update the xml cache.  The issue i am having is that data injected into the index via gatheringnode data event seems to be missing i.e gatheringnode data is not firing. However after doing import if i manually re publish items the data is present in the index.  Some code below:

        private static void CreateNewOrphan(StringBuilder interestsString, HashSet<int> activeOrphans,
                                            StringBuilder aspirationsString, OrphanProfile orphan)
        {
            DocumentType nodeType = DocumentType.GetByAlias("OrphanCase");
            User author = new User(6);
    
            Document orphanNode = Document.MakeNew(orphan.SponsoreeId.ToString(), nodeType, author, 1547);
    
            activeOrphans.Add(orphanNode.Id);
    
            orphanNode.getProperty("priority").Value = orphan.Priority;
            orphanNode.getProperty("dateCreated").Value = orphan.DateCreated;
            orphanNode.getProperty("orphanId").Value = orphan.SponsoreeId;
            orphanNode.getProperty("firstName").Value = orphan.FirstName;
            orphanNode.getProperty("lastName").Value = orphan.LastName;
            orphanNode.getProperty("sex").Value = orphan.Sex;
            orphanNode.getProperty("dateOfBirth").Value = orphan.DateOfBirth;
            orphanNode.getProperty("countryCode").Value = orphan.LocationCode;
            orphanNode.getProperty("mHSponsored").Value = orphan.IsSponsoredByUs;
            orphanNode.getProperty("fathersCauseOfDeath").Value = orphan.FatherCauseOfDeath;
            orphanNode.getProperty("fathersDateOfDeath").Value = orphan.FatherDateOfDeath.ToString("MMMM yyyy");
            orphanNode.getProperty("currentGuardian").Value = orphan.GuardianRelationship;
            orphanNode.getProperty("meansOfSupport").Value = orphan.MeansOfSupport;
            orphanNode.getProperty("hobbies").Value = interestsString.ToString();
            orphanNode.getProperty("careerAspirations").Value = aspirationsString.ToString();
    
            orphanNode.Publish(author);
            umbraco.library.UpdateDocumentCache(orphanNode.Id);
        }
    
        private static void UpdateExistingOrphan(StringBuilder aspirationsString, OrphanProfile orphan,
                                                 StringBuilder interestsString, int orphanCaseId, HashSet<int> activeOrphans)
        {
            Type genderType = typeof (Sex);
            bool updateDocument = false;
            Document orphanNode = new Document(orphanCaseId);
    
            activeOrphans.Add(orphanNode.Id);
    
            if (orphanNode.getProperty("priority").Value.ToString() != orphan.Priority.ToString())
            {
                orphanNode.getProperty("priority").Value = orphan.Priority;
                updateDocument = true;
            }
    
            if (orphanNode.getProperty("dateCreated").Value.ToString() != orphan.DateCreated.ToString())
            {
                orphanNode.getProperty("dateCreated").Value = orphan.DateCreated;
                updateDocument = true;
            }
    
            if (orphanNode.getProperty("firstName").Value.ToString() != orphan.FirstName)
            {
                orphanNode.getProperty("firstName").Value = orphan.FirstName;
                updateDocument = true;
            }
    
            if (orphanNode.getProperty("lastName").Value.ToString() != orphan.LastName)
            {
                orphanNode.getProperty("lastName").Value = orphan.LastName;
                updateDocument = true;
            }
    
            if (Enum.ToObject(genderType, Convert.ToInt32(orphanNode.getProperty("sex").Value)).ToString() !=
                orphan.Sex.ToString())
            {
                orphanNode.getProperty("sex").Value = orphan.Sex;
                updateDocument = true;
            }
    
            if (orphanNode.getProperty("dateOfBirth").Value.ToString() != orphan.DateOfBirth.ToString())
            {
                orphanNode.getProperty("dateOfBirth").Value = orphan.DateOfBirth;
                updateDocument = true;
            }
    
            if (orphanNode.getProperty("countryCode").Value.ToString() != orphan.LocationCode)
            {
                orphanNode.getProperty("countryCode").Value = orphan.LocationCode;
                updateDocument = true;
            }
    
            if (Convert.ToBoolean(orphanNode.getProperty("mHSponsored").Value) != orphan.IsSponsoredByUs)
            {
                orphanNode.getProperty("mHSponsored").Value = orphan.IsSponsoredByUs;
                updateDocument = true;
            }
    
            if (orphanNode.getProperty("fathersCauseOfDeath").Value.ToString() != orphan.FatherCauseOfDeath)
            {
                orphanNode.getProperty("fathersCauseOfDeath").Value = orphan.FatherCauseOfDeath;
                updateDocument = true;
            }
    
            if (orphanNode.getProperty("fathersDateOfDeath").Value.ToString() != orphan.FatherDateOfDeath.ToString("MMMM yyyy"))
            {
                orphanNode.getProperty("fathersDateOfDeath").Value = orphan.FatherDateOfDeath.ToString("MMMM yyyy");
                updateDocument = true;
            }
    
            if (orphanNode.getProperty("currentGuardian").Value.ToString() != orphan.GuardianRelationship)
            {
                orphanNode.getProperty("currentGuardian").Value = orphan.GuardianRelationship;
                updateDocument = true;
            }
    
            if (orphanNode.getProperty("meansOfSupport").Value.ToString() != orphan.MeansOfSupport)
            {
                orphanNode.getProperty("meansOfSupport").Value = orphan.MeansOfSupport;
                updateDocument = true;
            }
    
            if (orphanNode.getProperty("hobbies").Value.ToString() != interestsString.ToString())
            {
                orphanNode.getProperty("hobbies").Value = interestsString.ToString();
                updateDocument = true;
            }
    
            if (orphanNode.getProperty("careerAspirations").Value.ToString() != aspirationsString.ToString())
            {
                orphanNode.getProperty("careerAspirations").Value = aspirationsString.ToString();
                updateDocument = true;
            }
    
            if (orphanNode.Text != orphan.SponsoreeId.ToString())
            {
                orphanNode.Text = orphan.SponsoreeId.ToString();
                updateDocument = true;
            }
    
            if (updateDocument)
            {
                User author = new User(6);
                orphanNode.Publish(author);
                umbraco.library.UpdateDocumentCache(orphanNode.Id);
            }
        }

    As i am doing the import I can see the index being updated real time using index admin dashboard.  

    I recall something about gatheringnode data running on different thread?

    Regards

     

    Ismail

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 21, 2013 @ 14:51
    Ismail Mayat
    100

    Ok so figured out what the issue is.  I had examine event that was injecting data into the index this data was coming from tab on the doc type and each property on the doctype had Name field set to dictionary item e.g #fathersName. On my laptop and dev sites culture was default set to en-GB so becuase i had GB entries in dictionary it all worked. On my staging and live servers culture was not set so was defaulting to something else possibly US. The webservice and examine gathering node data event were running under US culture and were getting blank entries from the dictionary.

    GRRRR!!!

Please Sign in or register to post replies

Write your reply to:

Draft