getting user or phone status

Discussion in '3CX Phone System - General' started by simonatkins, Nov 2, 2011.

Thread Status:
Not open for further replies.
  1. simonatkins

    Joined:
    Nov 2, 2011
    Messages:
    9
    Likes Received:
    0
    Hi, does anyone know how to get the status of a user using the 3cx .NET API? There's a userstatus property on the extension but this seems to return only 'Available' all the time even if a phone is unregistered.

    thanks
    Simon
     
  2. cloidhamer

    Joined:
    Jan 30, 2009
    Messages:
    27
    Likes Received:
    0
    Public ps = New PhoneSystem
    ps.Root.Connect()
    Dim TDS As New DataSet()
    Dim ExtTable As DataTable = TDS.Tables.Add()
    Dim ConnTbl As DataTable = TDS.Tables.Add()


    ConnTbl.Columns.Add("Ext", GetType(String))
    ConnTbl.Columns.Add("Change", GetType(String))
    ConnTbl.Columns.Add("Status", GetType(String))
    ConnTbl.Columns.Add("CallID", GetType(String))
    ConnTbl.Columns.Add("Caller", GetType(String))
    ConnTbl.Columns.Add("Type", GetType(String))
    ConnTbl.Columns.Add("Outbound", GetType(String))

    ExtTable.Columns.Add("Ext", GetType(String))
    ExtTable.Columns.Add("Group", GetType(String))
    ExtTable.Columns.Add("Desc", GetType(String))
    ExtTable.Columns.Add("Reg", GetType(String))
    ExtTable.Columns.Add("Status", GetType(String))
    ExtTable.Columns.Add("Type", GetType(String))
    ExtTable.Columns.Add("", GetType(String))

    Dim d As DN() = ps.GetExtensions

    For x = 0 To d.GetUpperBound(0)
    Dim ext As TCX.Configuration.Extension = d(x), Grp As String = ""
    If ext.Groups.Length > 0 Then Grp = ext.Groups(0).Name
    Try
    ExtTable.Rows.Add(d(x).Number, Grp, d(x).ToString, CInt(ext.UserStatus), CInt(d(x).IsRegistered), "Ext", "")
    Catch ex As Exception

    End Try
    Dim conns As ActiveConnection() = d(x).GetActiveConnections()
    Dim AC As ActiveConnection
    For Each AC In conns
    Try
    ConnTbl.Rows.Add(AC.DN.Number, AC.CallID, AC.LastChangeStatus, CInt(AC.Status), AC.ExternalParty, "Call", CInt(AC.IsOutbound))
    Catch ex As Exception

    End Try
    Next
    Next

    Try
    ExtTbl.Dispose()
    CnnTbl.Dispose()
    Catch ex As Exception

    End Try
     
  3. SY

    SY Well-Known Member
    3CX Support

    Joined:
    Jan 26, 2007
    Messages:
    1,825
    Likes Received:
    2
    C# version. You should know how to convert is to VB .NET ;)
    try
    {
    Extension ext = PhoneSystem.Root.GetDNByNumber("100") as Extension;
    String nameofthestatus=ext.CurrentProfile.Name;
    bool isThisExtensionInDNDMode = (ext.UserStatus==UserStatusType.Away)
    bool doesThisExtensionHasRegisteredDevices = ext.IsRegistered;
    ... and then do everything you want
    }
    catch
    {
    it is not an "extension"...
    }

    Simpler, isn't it?
    P.S. blog provides complete information about API...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Thread Status:
Not open for further replies.