C# Directory Numbers

Version 1
    This document was generated from CDN thread

    Created by: Chip Taylor on 02-04-2010 05:48:59 PM
    Does anyone know how to tie a line to a device?  The uuid of the line isnt the same as the device apparently.  I keep getting line not found exception.  I need a way to pull directory numbers, and device descriptions from CUCM.  This is all the information we are looking for.  Any help is appreciated.

    Subject: RE: C# Directory Numbers
    Replied by: David Staudt on 02-04-2010 10:10:21 PM
    A phone has a number of 'line appearances', each line appearance is linked to a line.  In the UCM database, these relationships are recorded in the device (phones), numplan (DNs), and devicenumplanmap (line appearances) tables:
     
    device ---[1:Many]---devicenumplanmap---[Many:1]---numplan
     
    If you know the device, it is easy to determine the line appearance IDs and line IDs via getPhone:
     
          <axl:getPhoneResponse sequence="1" xmlns:axl="http://www.cisco.com/AXL/API/7.0" xmlns:xsi="http://www.cisco.com/AXL/API/7.0">
             <return>
                <device ctiid="65" uuid="{C5E0EC7C-6F4B-D704-B1C9-6612F0DF79C4}">
                   <name>IPCMRAEU5UCM5X7</name>
    ...
                   <lines>
                      <line index="1" uuid="{0BB2730C-B3B6-EEAD-D124-134B2DC78A4E}">
                         <label/>
                         <asciiLabel/>
                         <display/>
                         <dirn uuid="{E3ADDEC9-8E96-FEFA-1AA0-59CE630D49CE}"/>
    ...
     
    If you only know the line ID, it's a bit tricker to find out the associated devices.  As AXL getLine doesn't provide a list of associated phones, you will need to use a SQL query.  Something like:
     
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/7.0">
       <soapenv:Header/>
       <soapenv:Body>
          <ns:executeSQLQuery sequence="1">
             <sql>select name from device,devicenumplanmap,numplan where devicenumplanmap.fkdevice=device.pkid and devicenumplanmap.fknumplan=numplan.pkid and numplan.pkid="e3addec9-8e96-fefa-1aa0-59ce630d49ce"</sql>
          </ns:executeSQLQuery>
       </soapenv:Body>
    </soapenv:Envelope>
     
    You may get multiple device's returned, if the line appears on more than one device.  Note that the <dirn> uuid attribute returned by getPhone has a bug in some versions where the uuid is capitalized and enclosed in brackets, whereas the actual pkid is lowercase and unadorned.

    Subject: RE: C# Directory Numbers
    Replied by: Chip Taylor on 05-04-2010 03:14:35 PM
    For some reason I still cannot see the lines associated with the device.  Once I can get the line uuid, from that point I can get the directory number.  What I have is below:
     
    GetPhoneReq phoneReq = new GetPhoneReq();
    phoneReq.ItemElementName = ItemChoiceType8.phoneName;
    phoneReq.Item = "SEP001360C3ED6F";
    GetPhoneResReturn phoneResRet = ax.getPhone(phoneReq).@return;
     
    phoneResRet.device.lines --  Is this not pointing to the lines associated with the device?
     
    I guess I might not be understanding how to extract the lineID of the line via this route.  Is the only way to get the information through a sqlQuery?
     
     

    Subject: RE: C# Directory Numbers
    Replied by: David Staudt on 08-04-2010 04:13:25 PM
    Not entirely certain how it looks in C#, but note that return/devices/lines lists the 'line appearances' not strictly the lines.  Each line appearance has a uuid value, and each line appearance has an associated line (with its own uuid).
     
    If you look at the XML snippet in my post above, the value I think you may be looking for is in the <dirn> element.  The uuid of <dirn> can be used with getLine to retrieve all the specific line info.

    Subject: RE: C# Directory Numbers
    Replied by: Chris Bertrand on 09-06-2010 08:05:58 AM
    Hi Chip,
     
    Have you found a solution for this yet? What version are you using?