Import via webservice Options
tidmand
Posted: Sunday, February 10, 2008 11:31:41 PM

Rank: Enthusiast

Joined: 8/11/2006
Posts: 22
Location: Hedehusene, Denmark
I'm desperately trying to import and update calendar events via a webservice. No problem getting entries registrered the first time in umbraco content section, but I have a huge problem when it comes to the updating and making new entries. All because of limited C# experience.

The webservice delivers a XmlNodeList. I then try to catch the existing Event Items and update them. Then my problem arises as I don't know how to loop through the existing events and add the new ones.

Code:

// Get ParentId for the Event page
int ParentId = 3899;

//Hent Event fra umbraco
Node eventFolder = new Node(ParentId);
Nodes eventItem = eventFolder.Children;

//Find Event
foreach (Node child in eventItem)
{
    if (child.Name == _guid)
    {
        string eventId = Convert.ToString(child.Id);
        int eId = Convert.ToInt32(eventId);

        _doc = new Document(eId);

        existingEvents++;

        _doc.getProperty("subject").Value = _subject;
        _doc.getProperty("location").Value = _location;
        _doc.getProperty("participants").Value = _participants;
        _doc.getProperty("bodyText").Value = _description;
        _doc.getProperty("eventDate").Value = _starttime;
        _doc.getProperty("eventDateEnd").Value = _endtime;

        _doc.XmlGenerate(new XmlDocument());

        // Use the "Umbraco" system administrator user as creator (with id:0)
        User user = new User(0);

        // Publish the document
        _doc.Publish(user);

        // Reflect the publish to the runtime
        umbraco.library.PublishSingleNode(_doc.Id);

    }


    newEvents++;

    // Get the Event documenttype
    DocumentType dct = DocumentType.GetByAlias("Event");

    // Use the "Umbraco" system administrator user as creator (with id:0)
    User Creator = new User(0);

    // Create the document
    string docName = _guid;
    _doc = Document.MakeNew(docName, dct, Creator, ParentId);

    _doc.getProperty("guid").Value = _guid;
    _doc.getProperty("subject").Value = _subject;
    _doc.getProperty("location").Value = _location;
    _doc.getProperty("participants").Value = _participants;
    _doc.getProperty("bodyText").Value = _description;
    _doc.getProperty("eventDate").Value = _starttime;
    _doc.getProperty("eventDateEnd").Value = _endtime;

    _doc.XmlGenerate(new XmlDocument());

    // Publish the document
    _doc.Publish(Creator);

    // Reflect the publish to the runtime
    umbraco.library.PublishSingleNode(_doc.Id);
}


I hope that somebody will be able to give me a hint.

Thanks in advance.

/Søren

Freelace webdesigner - umbraco, xhtml, xslt, css, c#
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.