WSI Events Notification Callbacks
Beginning in version 7.0.2.0 ML, the AspDotNetStorefront software contains an Event Handler system which will post information to an endpoint URL when certain events occur on the site. This feature is accessed through the admin site at Misc -> EventHandler Parameters.
This allows you to add WSI automation based on real-time events that occur inside your AspDotNetStorefront storefront site (e.g. new order created).
The default events supported are:
ViewProductPage
ViewEntityPage
AddToCart
BeginCheckout
RemoveFromCart
CreateCustomer
UpdateCustomer
DeleteCustomer
NukeCustomer
CreateAccount
CheckoutShipping
CheckoutPayment
CheckoutReview
NewOrder
OrderDeleted
OrderVoided
OrderShipped
OrderRefunded
To enable one or more of these event handlers, go to Misc->Eventhandler Parameters in the admin site, set the Active field to "true" and specify a callout URL.
NOTE: The callout uses the html POST method
Users can also create their own event handlers, or modify the existing ones in the default package (event.default.xml.config in the XmlPackages folder). This requires modifying the source code. You will need to first create the event in the admin site, then add the following call to the page or event you want to activate:
AppLogic.eventHandler("CustomEventName").CallEvent ("SomeRuntimeParams");
The "CustomEventName" is the exact EventName specified in the admin site when the event was created
The "RunTimeParams" is an ampersand-delimited string (e.g. "someparam1=sometext&someparam2=othertext"). They are put in the "Runtime" section of the package data document.
Sample Listener Code
All callbacks require a listener page on the receiving end to accept the message. Below is a basic sample of a .NET listerner application.
protected void Page_Load(object sender, System.EventArgs e)
StringBuilder sb = new StringBuilder();
int streamLength;
int streamRead;
Stream s = Request.InputStream;
streamLength = Convert.ToInt32(s.Length);
Byte[] streamArray = new Byte[streamLength];
streamRead = s.Read(streamArray, 0, streamLength);
for (int i = 0; i < streamLength; i++)
{
sb.Append(Convert.ToChar(streamArray[i]));
}
// This assumes that the data is XML however the site admin could have designed
the output xmlpackage to send delimited text or some other format
XmlDocument x = new XmlDocument();
x.LoadXml(sb.ToString());
// do something with the incoming data
Sample Client Downloads
For a sample web and windows client WSI Event listener application, see the WSI documentation at:
http://manual.aspdotnetstorefront.com/wsi/
This sample client shows:
1) Database to store WSI events
2) Web client to receive events from your storefront
3) Windows client to process events (usually calling WSI on your storefront for full event data), either polled or async.