This shows you the differences between two versions of the page.
| — |
asp.net_intergration [2016/06/14 16:35] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Software integration for ASP.NET ===== | ||
| + | In this guide we will apply the logic used for [[foxbox_api#encoding_incoming_sms_with_xml|encoding incoming SMS with XML]] to the integration of an ASP.NET software with our FoxBox. | ||
| + | :id1: Remember to activate the XML module by removing the sharp character (i.e. ”#”) from the internal Eventhandler, near the call to the //sms2xml// script. Once done this, each time you will receive an SMS it will be stored inside of the file //sms.xml//. | ||
| + | |||
| + | As an example, we are going to create a simple Web page that loads data from the XML file //sms.xml//, showing them in a DataList element. For this implementation we used [[http://www.microsoft.com/visualstudio/ita/products/visual-studio-express-products|Microsoft™ Visual Web Developer]], a really interesting tool that provides a simple way for ASP.NET development. | ||
| + | |||
| + | The VWD environment provides a really good support to XML but, as many other programs, it takes informations from node attributes instead of their content. To override this issue, we provide a simple script that exports informations in the correct XML format: | ||
| + | <code> | ||
| + | Run this script only when a message was received. | ||
| + | if [ "$1" != "RECEIVED" ]; then exit; fi; | ||
| + | #Extract data from the SMS file | ||
| + | FROM=`/etc/procmail/formail -zx From: < $2` | ||
| + | TEXT=`/etc/procmail/formail -I "" <$2 | sed -e"1d"` | ||
| + | #Save as XML | ||
| + | #for some reason the mktemp-command creates two instances of the file if I | ||
| + | #add the .xml-extension to the FILENAME-variable. | ||
| + | FILENAME=`mktemp /mnt/flash/root/xml/smsXXXXXX` | ||
| + | BACKENDSWF="/mnt/flash/root/xml/sms.xml" | ||
| + | echo "" >$FILENAME.xml | ||
| + | echo "" >>$FILENAME.xml | ||
| + | echo " " >>$FILENAME.xml | ||
| + | echo "" >>$FILENAME.xml | ||
| + | #Delete the original file without the .xml-extension | ||
| + | rm $FILENAME | ||
| + | </code> | ||
| + | |||
| + | As you can see, all the informations are now assigned to the relative attribute in the tag, so that you can simply link a datasource to the file inside of your ASP.NET project. | ||