10-16-2003 03:41 PM - edited 03-13-2019 02:06 AM
Hi there;
Just wondering if anyone has been able to make Call
Handler changes from an external app or SQL query.
My aim is to change the value of a Call Handlers transfer options. I use a caller input value on the subscriber to go to a call handler which has a transfer to an external number, i would like to be able to change this from a web page.
Has any one done this?
Regards
Andrew
10-16-2003 06:43 PM
In this case youll need to edit values on the ContactRule table which at this time doesnt have any stored procedures wrapping it youll have to edit the table directly. Most of the stored procedures weve been working on up front since 4.0(1)s release have been related to subscriber creation/deletion/editing since thats what most sites doing programmatic administration are interested in. Well get stored procs in front of all objects in the database eventually, but for now youll have to do this one in the buff as it were.
In the Data Object Model document on the Documents page of www.CiscoUnityTools.com I talk about the contact rules and how they apply to call handlers the short story is every call handler is associated with 3 contact rules: an alternate, off hours and standard.
In your case Im assuming that the call handlers are already configured and the transfer rule you want to edit is the alternate. You can substitute standard or off hours in the SQL strings below if not. Also, if you dont have the latest CUDLE installed off www.CiscoUnityTools.com, itd probably be a good idea to get that its helpful to see the brief explanations for what all the columns mean in each of the tables as you go with such projects.
First, you want to find the call handler in question and then go fetch the contact rules for that guy. Im assuming youre probably finding call handlers by alias here. To get the alternate contact rule for the call handler with an alias of OperatorCH (the operator call handler) youd use a query like this:
SELECT ContactRule.* FROM ContactRule INNER JOIN vw_CallHandler
ON ContactRule.ParentObjectID=vw_CallHandler.CallHandlerObjectID
WHERE ContactRule.Alias='Alternate' AND vw_CallHandler.Alias='OperatorCH'
If youre using extensions to find handlers instead of aliases thatd work as well, youd just substitute AND vw_CallHandler.DTMFAccessID=1234 into the query above.
Notice that were not using the view for the contact rule here since were going to be editing it directly.
The examples out on the code samples page cover how to attach to SQL either on box or on a remote server and how to use queries like the above, that should get you from A to B for that. Just be sure to open the recordset as a keyset and allow optimistic updates if youre using ADO (as I do in all my examples).
If the call handler is already setup to do a transfer using this contact rule the only value you need to change is the Extension column this is the actual dial string that the transfer rule will use (be sure to include the CO prefix if necessary). Save it and youre done.
If the contact rule is not configured to transfer or youre not sure one way or the other youll want to check a few fields (explanations for these can all be found in CUDLE, of course). Make sure the Action field is set to 1 this means to attempt the transfer with this rule. Make sure the TimeExpires field is set to NULL this means the rule is active a time in the past means its disabled. Make sure the TransferType value is either 0 for release or 1 for supervised if its supervised make sure the TransferRings is set to the number of rings you want.
Thats about it. Not overly complicated, you just need to be careful. The one thing thatll bite you here is making sure the transfer string entered is allowed by the transfer restriction table of the person making the change Im not sure how youre setting up this web page or how users will authenticate or whatever, but one way or another youll want to grab the Class of Service of the person requesting the transfer string change and make sure the string they enter is allowed by their restriction tables. Ill post a brief VB source clip in the next post that shows how to do that so I dont run over my max allowed characters in a post here
10-16-2003 06:43 PM
Heres some VB code I pulled out of dbWalker that shows how to grab a COS entry and check a transfer string against its transfer restriction table rules. Unfortunately when I paste it in here it loses all it's indentation and color so it's not as fabulously readable as it is in my dev environment. Also, just in case one of my former Computer Science professors is reading this, I've yanked out the error handling code here to make it shorter - honest.
Just for review here restriction tables are a collection of pattern matching strings made up of numbers and wildcard characters and an allow or dont allow flag they are processed in order from top to bottom until the dial string matches and the allow/dont is evaluated. The last rule is always * which will match anything so youre guaranteed a rule will match.
For this routine, you pass in the Class of Service ObjectID of the subscriber and the transfer string you want to check and it returns True or False depending on if the string is allowed by that COS transfer restriction table or not.
This code uses a nifty little VBScript object called RegExp which is a RegularExpression object. To use it in VB you need to include the Microsoft VBScript Regular Expressions 5.5 object in your project references.
Private Function IsTransferStringLegal(strStringToCheck as String, strCOSObjectID as string) as Boolean
Dim rsRT As ADODB.Recordset
Dim rsPatterns As ADODB.Recordset
Dim rsCOS as ADODB.Recordset
Dim strPattern As String
Dim myRegExp As New RegExp
If Len(strStringToCheck) = 0 Then
'We assume that an empty string is legal
IsTransferStringLegal=True
Exit
End If
Assume false here
IsTransferStringLegal=false
Setup the regular expression object here
myRegExp.IgnoreCase = True
myRegExp.Global = False
Set rsCOS=New ADODB.Recordset
rsCOS.Open "SELECT * FROM vw_COS WHERE COSObjectID='" + strCOSObjectID + "'",strConnectionString, adOpenKeySet, adLockReadOnly
If rsCOS.RecordCount=0 Then
Msgbox (error) could not find COS reference
Exit
End If
Set rsRT = New ADODB.Recordset
rsRT.Open "SELECT * FROM vw_RestrictionTable WHERE RestrictionObjectID="+ rsCOS("XferRestrictionObjectID") + "'", strConnectionString, adOpenKeyset, adLockReadOnly
If rsRT.Recordcount=0 Then
MsgBox(error) could not find restriction table for transfer
Exit
End If
Pull the patterns associated with the restriction table out. Be sure to preserve the index order since the order in which theyre evaluated is important.
Set rsPatterns = New ADODB.Recordset
rsPatterns.CursorLocation = adUseClient
rsPatterns.Open "Select * from VW_RestrictionPattern WHERE ParentObjectID='" + rsRT("RestrictionObjectID") + "' ORDER BY [Index]", strConnectionString, adOpenStatic, adLockReadOnly
If rsPatterns.RecordCount = 0 Then
MsgBox (error) no restriction table patterns found for restriction table
Exit
End If
'do that regular expression thing, baby!
'First, strip out all commas
strStringToCheck = Replace(strStringToCheck, ",", "", , , vbTextCompare)
Now run through each pattern and see if it matches the dial string were looking at.
rsPatterns.MoveFirst
Do While rsPatterns.EOF = False
strPattern = rsPatterns("NumberPattern")
'replace ?s with .s to match the regular expression format.
strPattern = Replace(strPattern, "?", ".", , , vbTextCompare)
'replace * with "[0-9]*" to match the regular expression format.
strPattern = Replace(strPattern, "*", "[0-9]*", , , vbTextCompare)
myRegExp.Pattern = strPattern
If myRegExp.Test(strStringToCheck) = True Then
OK, the transfer string matches this pattern
If rsPatterns("Blocked") = True Then
the transfer string is not allowed just exit since the function value is false
Else
the transfer string is allowed
IsTransferStringLegal=true
End If
Exit Do
End If
rsPatterns.MoveNext
Loop
'clean up and pull the rip cord.
On Error Resume Next
rsRT.Close
Set rsRT = Nothing
rsPatterns.Close
Set rsPatterns = Nothing
rsCOS.Close
Set rsCOS=Nothing
End Sub
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide