Genesys CTI User Forum

Genesys CTI User Forum => Genesys-related Development => Topic started by: rnelson on September 12, 2018, 02:25:50 PM

Title: [.NET] Get UCID from extension attributes
Post by: rnelson on September 12, 2018, 02:25:50 PM
I am working with the .NET SDK (8.1.0.10) and trying to grab the UCID when an EventRinging event fires. The following code gets me to a byte array:

[code]var im = (IMessage) obj;
var extensions = im["Extensions"] as KeyValueCollection;
var ucid = extensions["UCID"] as byte[];[/code]

The problem we're running into is that we aren't able to determine how we go from that byte array to the 20 character string of digits we expect to see.

In my last test, the value was [tt]0xC2 0x1D 0x99 0x5B 0x65 0x30 0x01 0x00[/tt] ([tt]194 29 153 91 101 48 1 0[/tt]). Trying to interpret that as a null-terminated string, which is what I believe BSTRs are, results in gibberish.

What am I missing?
Title: Re: [.NET] Get UCID from extension attributes
Post by: hsujdik on September 12, 2018, 03:51:59 PM
What about something like this:
[code]
var num_ucid = 0 as decimal;
for (var i = 0; i < ucid.Length; ++i)
    num_ucid += (decimal)(ucid[i] << (i*8));
var str_ucid = String.Format("{0,0:00000000000000000000}",num_ucid);
[/code]
Title: Re: [.NET] Get UCID from extension attributes
Post by: rnelson on September 13, 2018, 07:12:48 PM
We figured it out! A post on some Avaya forum ([url=https://www.devconnectprogram.com/forums/posts/list/9473.page]https://www.devconnectprogram.com/forums/posts/list/9473.page[/url]) explained how the 20 character value we're seeing is being generated.

hsujdik's logic looks to convert the byte array into a UNIX timestamp, which is what the last 10 digits are. It's not the same timestamp our UCID elsewhere has, but that looks like the correct answer.

In our case, the UCID that other systems have can be generated by concatenating the following three values out of the Genesys SDK:
[list type=decimal]
[li]"0001"[/li]
[li]AttributeCallID (left padded with 0 to 5 digits)[/li]
[li]AttributeNetworkCallID (timestamp)[/li][/list]

Thank you!
[/list]