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?
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.
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.
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.
@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)
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?
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.
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).
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
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.
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.
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.
@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)
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?
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.
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
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
Thanks for all the replys! I will take the webservices approach and will let you all now how it goes.
Cheers
Aaron
is working on a reply...