The nveloctiy template engine is used in Suteki.shop to provide a customized message template. And the function of the mail is when the order status changes, the system will send the buyer mail notification. The content of the mail message is customized using the nveloctiy template (. vm extension).
Because the latest source package in Sutekie.shop only partially implements its functionality, and all features are still being perfected, to run the functionality described in this article, you need to download its latest Program files (including unit test files) in the link address below:
http://code.google.com/p/sutekishop/source/detail?r=282
The files to download include:
/branches/JtG_Enhancements/Suteki.Shop/Suteki.Shop/Views/EmailTemplates/OrderC onfirmation.vm
/branches/JtG_Enhancements/Suteki.Shop/Suteki.Shop/Views/EmailTemplates/OrderDispatch.vm
/branches/JtG_Enhancements/Suteki.Shop/Suteki.Shop/Views/EmailTemplates/_orderDetails.vm< br />/branches/JtG_Enhancements/Suteki.Shop/Suteki.Shop/Controllers/OrderStatusController.cs
/branches/JtG_Enhancements/Suteki.Shop/Suteki.Shop/Services/EmailService.cs
Wait a minute.
After downloading and overwriting (or adding) to the local project, we also need to register the corresponding Emailbuilder component in the Castle Windsor. We just open the Containerbuilder class and find its Build method (Suteki.shop\containerbuilder.cs) and add the following code:
Component.for<iemailservice> (). Implementedby<emailservice> (). Lifestyle.singleton
Note: I have introduced the content of the IOC on Castle Windsor in this article.
The final code looks like this:
Container. Register (
Component.for<iunitofworkmanager> (). Implementedby<linqtosqlunitofworkmanager> (). Lifestyle.transient,
Component.for<iformsauthentication> (). Implementedby<formsauthenticationwrapper> (),
Component.for<iservicelocator> (). Instance (new Windsorservicelocator (container)),
Component.for<authenticatefilter> (). Lifestyle.transient,
Component.for<unitofworkfilter> (). Lifestyle.transient,
Component.for<databinder> (). Lifestyle.transient,
Component.for<loadusingfilter> (). Lifestyle.transient,
Component.for<currentbasketbinder> (). Lifestyle.transient,
Component.for<productbinder> (). Lifestyle.transient,
Component.for<orderbinder> (). Lifestyle.transient,
Component.for<iordersearchservice> (). Implementedby<ordersearchservice> (). Lifestyle.transient,
Component.for<iemailbuilder> (). Implementedby<emailbuilder> (). Lifestyle.singleton,
Component.for<iemailservice> (). Implementedby<emailservice> (). Lifestyle.singleton//Newly added code
);
Once we have done this, we can compile and run the project.
Let's take a look at today's protagonist Emailbuilder, which implements the work of loading template information using Nvelocityengine and binding the data in ViewData to a specified variable in the template. Here's the class diagram: