Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

UCCX 4.1 -> 8.5 - Replace custom .class with XML

Hello,

I have a customer who is upgrading their old 4.x UCCX to 8.5, and they have something custom that I’m not sure will work if I bring it over.  They use a custom Java .class file today, which reads an Excel spreadsheet that today sits on the C drive of the old Windows server.  Below is an example of the contents of the spreadsheet.  It’s just three columns of data: a date, a key sequence, and a random 3 digit code.

accesscodexl.jpg

The script first prompts the user for 3 digits and stores that into a variable.  It then, ostensibly, pulls the data from the spreadsheet using the custom Java class file, and finally evaluates the data pulled from the spreadsheet to determine whether or not the 3 digits entered matches a code in the spreadsheet dated within 14 days of the current date.  Here's a screenshot of this functionality within the script itself.

accesscodess.jpg

While I am technically able to pull that AccessCodes JAR over to the new system (I had to install it to get the script to open in the editor), I know that at a minimum, the path to the spreadsheet wouldn’t be accurate.  I haven’t been successful in decompiling or editing the .class file within the JAR to make any modifications.

I’m wondering if there is an easier way for me to do this using XML files?  And if I am successful in pulling this information in from XML, how can I evaluate within 14 days of the access code date?  Does anyone have any ideas?

Thanks,

Eric

1 ACCEPTED SOLUTION

Accepted Solutions

Re: UCCX 4.1 -> 8.5 - Replace custom .class with XML

Hi Eric,

RE 1 (explain Get XML Document Data step): it uses a simple XPath expression. You can test it using any modern XML/XSLT capable IDE. I prefer Eclipse, but I guess Visual Studio or -your-favorite-programming-environment- would do too.

Again, the XML from my previous post:

And the XPath expression:

//holiday[@date='" + datestring + "']/@id

If I break it down to pieces:

// - select anywhere (more flexible than specifying the exact path)

holiday - elements,

[] - search criteria: @date means value of date attribute, must equal the string specified in the datestring string.

/@id - return the id attribute value of the elements that conform the above condition.

RE 2 (how much data): well, it depends. XML engines are highly optimized these days, but I would never use an XML file larger than 1 MB; but of course, it's a matter of taste and preference.

RE 3 (release data): no need. With the databases, it's only a good practice.

About your script: actually, I believe it would work the way you explained above. However, if I were you, I would probably want to save some CPU cycles not repeating the same task. Here's what I did:

I. modified the XML file (I am not sure whether this is an option for you too): instead of specifying the date in a human readable form, I use epoch time (which is the number of seconds since 1st January 1970 GMT). Here's my XML:

II. I wrote a CRS script, with the following variables:

dateNow - the today's date, epoch time (so the actual number of seconds since 1st January 1970 GMT),

offset - the offset from dateNow, in this case 14 days ~ 3600*24*14 = 1209600,

userCode - the string entered by the customer/calling party, this script uses a constant value, for the sake of simplicity,

xmldoc - we store our XML document in it,

matchingId - the value of the id attribute of the accesscode element that matches the following condition:

"The value of the date attribute is between ( today's date minus the offset and today's date plus the offset) and the code attribute equals the value of the userCode variable"

III. This is the actual script (sort of):

0. get today's date, put it into the dateNow variable,

0. set the offset variable to any desired

1. (Create XML Document step) load the contents of the file named "epoch_codes.xml" into the variable xmldoc,

2. (Get XML Document data) fire up the XSLT engine and let it filter out the information and place it into the matchingId variable)

3. (If step) evaluate and continue.

Now, back to that Get XML Document data step. Here's the XPath expression:

"//accesscode[@date<(" + dateNow + "+" +offset + ") and @date>(" + dateNow + "-" + offset+ ") and (@code='" + userCode + "')]/@id"

Explanation:

// - select anywhere

accescode - elements

[] - condition, which is: (the value of the date attribute is less than (dateNow + offset) and the value of the date attribute is greater than  (dateNow - offset)) and also the value of the code attribute equals the value of the userCode variable.

/@id - return the value of the id attribute of matched elements.

I tried this on our 8.0x IP IVR and works alright.

Have fun scripting

G.

4 REPLIES

UCCX 4.1 -> 8.5 - Replace custom .class with XML

Hi Eric,

you might want to check this post:

https://supportforums.cisco.com/thread/2112019?tstart=60

It's based on a similar concept; pulling information from an XML file.

G.

New Member

Re: UCCX 4.1 -> 8.5 - Replace custom .class with XML

Hi Gergely,

Thanks very much for the information and the link.  I looked at the examples that you posted in the other thread, and have a few of questions with regard to this as I attempt to apply it to my problem.

1.  Could you break down how the parse in the Get XML Document Data step in your example works?  I understand that it's trying to match the datestring variable, which is the date, and if it does, it should return the associated ID.  I guess I just don't understand exactly what causes it to return the results it does based on the structure of that line.  Particuarlly, I'm curious how you get it to return the ID.

2.  How much data is safe to read into UCCX from an XML file?  It would seem that holiday files wouldn't be an issue because there wouldn't be that many entries; however, what if I were to need to read in a file with 500-700 lines and parse it every call (figure several thousand calls a day)?  Would that cause any memory or resource issues with the server?  I could probably limit it to 52 lines; is there a way I can validate whether or not I have the memory to be reading this for every session of the application?

3.  Do I need to do anything to release the data once I'm done parsing?  Or does UCCX just release the memory once the application script is done running for each instance?  I know with database connections it's always good practice to close them; wasn't sure if something similar needed to be done with XML docs that had been read into memory.

So with my questions out of the way, here's what I'm thinking I might do to accomplish a validation within 7 days in either direction of a particular date.  Could you have a look and let me know whether or not you think something like this might work?

A) Put my information into an XML file that looks something like this:

I am going to have to parse off of the date rather than the code most likely, because the access codes could overlap, and I assume it wouldn't handle multiple results (please correct me if I'm wrong).

B) In the script, I would read in the date to the datestring var, but I would also read in the day, month, and year into their individual variables.  If I don't get a match, I'll need to adjust the date and reparse until I've gone 14 days in either direction of the date.  So I would have something like this in the script:

Set iDateMonth = D[now].month

Set iDateDay = D[now].date

Set iDateYear = D[now].year

Set sDatestring = iDateMonth + "/" + iDateDay + "/" + iDateYear

Here I'm thinking that I will want to load the individual date values as integer variables, as I'm going to want to perform basic addition on them.  I'm hoping that I'm able to concatenate those integer values into a string variable once computations have been completed.

I would also do a 3 digit Get Digit String and load it into a variable called sUserCode.

sUserCode = Get Digit String (--Triggering Contact--)

C) Because I know I'm going to go 7 days on either side of the code date, I would probably just go 7 days back from the current date, and start incrementing in a loop, like this:

Set iDateDay = (iDateDay - 7)

If iDateDay <= 0

     True

          Decrement iDateMonth

          Set iDateDay = 30 + iDateDay

     False

Set iLoopCounter = 1

LOOP:

Set sDatestring = iDateMonth + "/" + iDateDay + "/" + iDateYear

result = Get XML Document Data (xmldoc, "//accesscode[@date='" + sDatestring +"']/@id")

Increment iDateDay

If (result = sUserCode)

     True

          Goto CONTINUE

     False

          If iLoopCounter <= 14

               True

                    Increment iLoopCounter

                    If iDateDay >= 30

                         True

                              Increment iDateMonth

                              Set iDateDay = 1

                              Goto LOOP

                          False

                               Goto LOOP

                  False

                       Goto INVALID

What are your thoughts on that?  Do you think something like that would work?

Thanks again, and sorry about the verbosity of the post.  I really appreciate the help!

Eric

P.S. - I should add that the spreadsheet with the codes I listed above was a sample I made to illustrate the data being used, but I made a mistake with the dates.  Each entry was a date 1 week apart.  Here's a screenshot of some of the codes from years past.

Re: UCCX 4.1 -> 8.5 - Replace custom .class with XML

Hi Eric,

RE 1 (explain Get XML Document Data step): it uses a simple XPath expression. You can test it using any modern XML/XSLT capable IDE. I prefer Eclipse, but I guess Visual Studio or -your-favorite-programming-environment- would do too.

Again, the XML from my previous post:

And the XPath expression:

//holiday[@date='" + datestring + "']/@id

If I break it down to pieces:

// - select anywhere (more flexible than specifying the exact path)

holiday - elements,

[] - search criteria: @date means value of date attribute, must equal the string specified in the datestring string.

/@id - return the id attribute value of the elements that conform the above condition.

RE 2 (how much data): well, it depends. XML engines are highly optimized these days, but I would never use an XML file larger than 1 MB; but of course, it's a matter of taste and preference.

RE 3 (release data): no need. With the databases, it's only a good practice.

About your script: actually, I believe it would work the way you explained above. However, if I were you, I would probably want to save some CPU cycles not repeating the same task. Here's what I did:

I. modified the XML file (I am not sure whether this is an option for you too): instead of specifying the date in a human readable form, I use epoch time (which is the number of seconds since 1st January 1970 GMT). Here's my XML:

II. I wrote a CRS script, with the following variables:

dateNow - the today's date, epoch time (so the actual number of seconds since 1st January 1970 GMT),

offset - the offset from dateNow, in this case 14 days ~ 3600*24*14 = 1209600,

userCode - the string entered by the customer/calling party, this script uses a constant value, for the sake of simplicity,

xmldoc - we store our XML document in it,

matchingId - the value of the id attribute of the accesscode element that matches the following condition:

"The value of the date attribute is between ( today's date minus the offset and today's date plus the offset) and the code attribute equals the value of the userCode variable"

III. This is the actual script (sort of):

0. get today's date, put it into the dateNow variable,

0. set the offset variable to any desired

1. (Create XML Document step) load the contents of the file named "epoch_codes.xml" into the variable xmldoc,

2. (Get XML Document data) fire up the XSLT engine and let it filter out the information and place it into the matchingId variable)

3. (If step) evaluate and continue.

Now, back to that Get XML Document data step. Here's the XPath expression:

"//accesscode[@date<(" + dateNow + "+" +offset + ") and @date>(" + dateNow + "-" + offset+ ") and (@code='" + userCode + "')]/@id"

Explanation:

// - select anywhere

accescode - elements

[] - condition, which is: (the value of the date attribute is less than (dateNow + offset) and the value of the date attribute is greater than  (dateNow - offset)) and also the value of the code attribute equals the value of the userCode variable.

/@id - return the value of the id attribute of matched elements.

I tried this on our 8.0x IP IVR and works alright.

Have fun scripting

G.

New Member

UCCX 4.1 -> 8.5 - Replace custom .class with XML

Hi Gergely,

Thanks for the excellent explaination and the alternative (and more efficient) method of accomplishing this within the script - it helps immensly!

I will give this a shot in my script later on tonight and see how it comes out on the 8.5 system.  Again, I really appreciate your efforts and can't thank you enough.

Regards,

Eric

724
Views
0
Helpful
4
Replies
CreatePlease login to create content