Author Message
Hans-GerdSandhagen
Joined: Nov 16, 2013
Messages: 3
Offline
I found a problem reading UserData from event (e.g. DeliveredEvent):

Scenario:

Execute MakeCall from Dashboard, UserData is "Hello world":

The following XML is sent:
<MakeCall xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.ecma-international.org/standards/ecma-323/csta/ed3">
<callingDevice typeOfNumber="other" mediaClass="notKnown">971000:SWITCHLINK:10.87.37.11:0</callingDevice>
<calledDirectoryNumber typeOfNumber="other" mediaClass="notKnown">971001:SWITCHLINK:10.87.37.11:0</calledDirectoryNumber>
<userData>
<string>48656C6C6F20776F726C64</string>
</userData>
<callCharacteristics>
<priorityCall>false</priorityCall>
</callCharacteristics>
</MakeCall>

The string for userData (48656C6C6F20776F726C64) is the hexbinary encoded text.

The DeliveredEvent contains the same string.

XML Message: <?xml version="1.0" encoding="UTF-8"?>
<DeliveredEvent xmlns="http://www.ecma-international.org/standards/ecma-323/csta/ed3">
   <monitorCrossRefID>91</monitorCrossRefID>
   .....
   <userData>
      <string>48656C6C6F20776F726C64</string>
   </userData>
   .....
</DeliveredEvent>

I tried to get the sent text with the following code:
void ProceedEvent() {
   System.Diagnostics.Debug.WriteLine("Size: " + e.getUserData.getUserDataSize);
   System.Diagnostics.Debug.WriteLine("AsString: " + e.getUserData.getUserDataAsString);
   System.Diagnostics.Debug.WriteLine("AsDecodedString: " + e.getUserData.decodeDataToString());
   System.Diagnostics.Debug.Write("AsByteArray: ");
   foreach (var item in e.getUserData.getUserDataAsByteArray) {
      System.Diagnostics.Debug.Write(item);
   }
}

which produce this output:
Size: 22
AsString: 52565453546754675470504855555470555054675452
AsDecodedString: 48656C6C6F20776F726C64
AsByteArray: 52565453546754675470504855555470555054675452


So I did not found a property/method to get the originally sent text from the event.

MartinFlynn
Joined: Nov 30, 2009
Messages: 1922
Offline
Hi Hans-Gerd,

This issue was reported a few months ago. As developers may have coded a workaround it was decided not to change the operation of the existing methods. Instead, the method decodeDataToText() was added to the UserData class. This should be available in the next release of the .Net SDK. I believe AE Services 6.2 is tentatively planned for some time in May.

In the mean time, there are several possible workarounds. One the the developer suggested is:

string myResult = "";
string myUserData = e.getUserData.decodeDataToString();
int myUserDataSize = e.getUserData.decodeDataToString().Length;

for(int i=0; i<myUserDataSize; i=i+2)
{
// Obtain each hex value from the string
string hex = myUserData.Substring(i, 2);

// Convert the number expressed in base-16 to an integer.
int value = Convert.ToInt32(hex, 16);

// Get and append the character corresponding to the integral value.
myResult += (char)value;
}
// At this point myResult is your original set of characters

Martin
Hans-GerdSandhagen
Joined: Nov 16, 2013
Messages: 3
Offline
Thank you for fast respone.

In the meantime I found a, maybe easier, workaround.

String str = (e.getUserData.decodeDataToString();         System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary hexBinary = System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary.Parse(str);
String text = System.Text.Encoding.ASCII.GetString(hexBinary.Value);
Go to:   
Mobile view