Copied to clipboard

Flag this post as spam?

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


  • dcwoodsjr 12 posts 30 karma points
    Aug 06, 2010 @ 21:10
    dcwoodsjr
    0

    Create a new node from a windows service.

    I'm trying to write a service that will create a new document in the node tree.

    The service is monitoring an email account and when a new email comes in it should grab the attachment which will be a pdf and then upload the attachment in to a document type called Service Bulletins.

    I found this code below that looks like it will get me started, but what I need to figure out is how I can configure my application to point to the correct instance of umbraco.

    DocumentType dt = DocumentType.GetByAlias("ServiceBulletinFile");
    User author = User.GetUser(0);
    Document doc = Document.MakeNew(item.Name, dt, author, 1128);
    doc.Publish(author);
    umbraco.library.UpdateDocumentCache(doc.Id);

    Am I going about this the right way?  Should I possibly try looking at inserting it directly into the database?

    Any help would be greatly appreciated, that can point me in the right direction.

    -dw

     

     

  • Bogdan 250 posts 427 karma points
    Aug 06, 2010 @ 21:30
    Bogdan
    0

    I think one way of doing this is to keep the node creation in umbraco, in a user control, and from the service make an http request to the page on localhost. The code for creating the node is definitely good.

  • Steen Tøttrup 191 posts 291 karma points c-trib
    Aug 06, 2010 @ 21:46
    Steen Tøttrup
    0

    You can easily make a web-service and move the code to a method on the web-service. Calling a web-service from a windows service is quite easy too.

    That way the web app will run as usually, caching will work etc etc.

     

  • Sascha Wolter 615 posts 1101 karma points
    Aug 06, 2010 @ 23:05
    Sascha Wolter
    1

    Hi dw,

    going with a web service that opens a way into the Umbraco app is definitely the way to go as Steen said, and it's quite easy and straightforward too once you get the hang of it.

    All I wanted to add is that there are already a couple of web services waiting to be consumed, e.g. the DocumentServices usually found under /umbraco/webservices/api/documentservice.asmx which might already have what you are looking for (you probably need to enable the umbraco web services it in the web.config file).

    Cheers,
    Sascha

  • dcwoodsjr 12 posts 30 karma points
    Aug 06, 2010 @ 23:26
    dcwoodsjr
    0
  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 09, 2010 @ 00:52
    Aaron Powell
    0

    The 4.x API pretty much wont work without the HttpContext (particularly around the Document API) so you'll need to use a web service/ etc to do it.

  • Tom 713 posts 954 karma points
    Oct 18, 2010 @ 01:54
    Tom
    0

    Pardon my ignorance but how would one reference the preexisting umbraco services in VS2010?

    Cheers,

    Tom

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 18, 2010 @ 02:13
    Aaron Powell
    0

    Right Click on references -> Add Web Reference

    If you don't have that you can go Add Service Reference -> Advances -> Add Web Reference (under Compatibility)

  • Tom 713 posts 954 karma points
    Oct 18, 2010 @ 02:17
    Tom
    0

    awesome.. thanks..

    Basically what i need to do is read a csv.. loop through and add products to categories and update existing products in the content tree as a scheduled task..

    unfortunately I'll need to determine what the parent node is based on an id from their system.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 18, 2010 @ 02:23
    Aaron Powell
    0

    Might have to do multiple web service requests then :/

Please Sign in or register to post replies

Write your reply to:

Draft