Copied to clipboard

Flag this post as spam?

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


  • bayshield 50 posts 65 karma points
    Jul 25, 2009 @ 17:45
    bayshield
    0

    Using API from Winform application

    Hi,

    I have an existing Winform application that parses a proprietry database format and creates static html files for a website.  I am moving the site to umbraco and would like to modify the winform application to create the pages directly in umbraco.  I have found the forum articles for creating a page using the API, however I am not sure what I would need to do to use this from a webform app.  Is referencing some dlls and setting the  correct DB connection string all that is required?

    Anyone have a simple example of this working they would be able to share?

    Thanks,

    Aaron

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 25, 2009 @ 18:09
    Morten Bock
    0

    How many pages are you looking to create? There woud probably be different options depending on how large a number of pages with regards to performance and stability.

  • bayshield 50 posts 65 karma points
    Jul 25, 2009 @ 18:46
    bayshield
    0

    There will be approximately 2000 pages that need to be created initially.  After the first run I will need to be able to re-run the tool to update the existing pages and create any new pages.

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 26, 2009 @ 00:44
    Aaron Powell
    0

    It's not possible to use the Umbraco API (yet) to create Document objects in Umbraco. The reason for this is that Umbraco was never designed to operate with a running HttpContext.

    When you create a Document object (Document.CreateNew) you need to provide an instance of the DocumentType to create it from. The problem is that you'll need to access the Properties of the Document it will fall over.

    Your best option will be to use Web Services and pass across the data you require.

    If you can hold out until Umbraco 4.1 it will be much easier to do it. LINQ to Umbraco will be designed in a manner in which you can write DB interaction. I wont be providing it OOB (I don't have time to write the CRUD provider!), but it will be achievable.

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    Jul 26, 2009 @ 10:28
    Sebastiaan Janssen
    0

    @slace If it's no big deal for bayshield to create a document type with some properties, then it's quite easy to do. I've been there ;)

    @bayshield I did something like this:

    - reference the umbraco.dll, cms.dll and businesslogic.dll
    - for each pages in your current app, create a new document of the document type that you want
    - set the properties (one of them being the body of the page, probably a rich text editor)
    - set a template for the document
    - document.Save()
    - document.Publish(yourAdminCredentials)
    - umbraco.content.Instance.UpdateDocumentCache(document.Id)

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 26, 2009 @ 10:56
    Aaron Powell
    0

    Really, I wasn't sure that you could create them without the HttpContext, due to the way that Umbraco handles properties, or maybe that's just when you're digging too deep (I did have the problem with that when I started the Umbraco Interaction Layer project, which is a CRUD ORM for doc types).

    Actually I think you'll need a copy of the editor controls assembly in the executing folder of your WinForms app?

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    Jul 26, 2009 @ 11:11
    Sebastiaan Janssen
    0

    Ah, my fault.. I now get what you meant. The solution I described was actually an import (from within the site), so the HttpContext is obviously there.

    Well, that's a route to take, whenever you publish pages from the WinForm app, call a webpage, have it "import" the html.

    I hope there is some kind of templating engine in place already, it doesn't seem feasable to just create html including the head, body and lay-out mark-up and put it in a rich text editor. If the content is in a specific div, it'll probably be easy enough to filer out the rest though.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 26, 2009 @ 11:31
    Aaron Powell
    0

    The best way to integrate WinForms and Umbraco is via Web Services, which Thomas talked about at CG09 thist year - http://our.umbraco.org/wiki/codegarden-2009/codegarden09-sessions/the-box/using-webservices-in-umbraco

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Jul 26, 2009 @ 13:05
    Thomas Höhler
    0

    yap, download the samples of my CG09 session. In the demo #1 I showed an easy way of creating documents via webservices. if you have any questions about this just contact me (th at thoehler dot com).

    Thomas

  • bayshield 50 posts 65 karma points
    Jul 26, 2009 @ 13:13
    bayshield
    0

    Thanks for all the replys!  I will take the webservices approach and will let you all now how it goes.

     

    Cheers

    Aaron

Please Sign in or register to post replies

Write your reply to:

Draft