We have a Windows service running on CD Server, which is scheduled to run daily. This service basically does some database interaction and send details in email to registered users.
An earlier mail template was created in Tridion and published on the file system, this service they were using that template to send emails. (The template path was configured in a service configuration file.)
Now, as we have moved to DD4T, the mail template will be published as JSON in the Broker; as we didn't change the Windows service logic, our Windows service still needs that template file available in CD Server. To make it work temporarily we deployed the email template file on CD Server. (So now the Email template is not coming from Tridion anymore; it's a file which is already deployed in the server.)
But, now as we have time, we decided to fetch the email template from the broker in my Windows service. So that it should come from Tridion only. I can see two ways to do this:
Add the Tridion DLLs to the Windows Service, create a class for the mail template, make a broker query to retrieve the page data as JSON, then parse it to the newly created email class.
Add the DD4T DLLs, create a class for the mail template, use the DD4T Framework to fetch JSON from the Broker, and parse it to the newly created email class.
My first question is in both approaches, somehow I have to create the view which will use this model, but I am not sure if this is really possible to use HTML with a model in a Windows service.
The second question is: can I use DD4T on a Windows service (I believe I need a controller to initialize DD4T objects like page factory and all), so is it possible to use the DD4T Framework on Windows service, or I should go with my first approach that is making a broker query?
If I can't make it a view in Windows service then I am thinking to publish an HTML template (with HTML using DWT as it was earlier) to the Broker, then I can use this HTML in my Windows service using the first or second approach above.