Author Topic: [.NET] Get UCID from extension attributes  (Read 2300 times)

Offline rnelson

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
[.NET] Get UCID from extension attributes
« 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?
« Last Edit: September 12, 2018, 03:07:33 PM by rnelson »

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: [.NET] Get UCID from extension attributes
« Reply #1 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]
« Last Edit: September 12, 2018, 03:53:40 PM by hsujdik »

Offline rnelson

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: [.NET] Get UCID from extension attributes
« Reply #2 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]