Jump to content

CDS User Status


Maidzen

Recommended Posts

Hello

 

im trying to get a list of all users with their current status ( reachable, currently phoning , away, dnd) but i cant find a propertie in the UserEntry class displaying these

 

my Code looks like this at the moment


 

public static string getUserList()
{
  var cdsLib = init();

  List<User> Users = new List<User>();

  try
  {
    var userList = cdsLib.GetUsers("%");
    foreach (SWConfigDataClientLib.Proxies.Users.UserEntry userEntry in userList)
    {
      User tmpUsr = new User();
      tmpUsr.id = userEntry.UserID;
      tmpUsr.name = userEntry.Name;
      tmpUsr.status = userEntry.CurrentUserSituation; //wrong
      foreach(SWConfigDataClientLib.Proxies.Users.MembershipEntry groupUser in userEntry.MembershipEntryCollection)
      {
        tmpUsr.group = tmpUsr.group + groupUser.GroupID.ToString() + ","; //placeholder will be replaced with group stuct list
      }

      Users.Add(tmpUsr);
    }
    return JsonConvert.SerializeObject(Users);   
  }
  catch (Exception ex)
  {
    Console.WriteLine("Exception: "+ ex.Message);
    return "";
  }
}

 

CurrenUserSituation is sadly not what im looking for (always 0)

 

Is there a Method or Propertie displaying what im looking for ? if not what is the common way to get the status of a User.

 

Thanks in advance

 

 

(also if my Code has some bad practice feel free to correct me, im normaly not a C# Dev)

 

Link to comment
Share on other sites


Ok i found it by reversing a Powershellscript i found in the archive here.

 

UserStatus is not in UserEntry its in UserPhoneBook

 

i extended CDSLIB by getUserPhoneBooks where i search for the user by name (couldn't find a way to search for userID)

public PBXPhoneBookPrimaryCollection GetUserPhonebooks(string name)
{
  var stat = this.libManager.GetUserPhoneBookEnum();
  try
  {

    PBXPhoneBookPrimaryCollection books = stat.GetPBXPhoneBook(name, false, true);
    return books;
  } catch(Exception ex)
  {
    log.TraceException(ex, true);
    throw;
  }
}

and then loop through all results to filter the UserId Match and get the Status as string from the enum.

 

var pb = cdsLib.GetUserPhonebooks(userEntry.Name);
  foreach(SWConfigDataClientLib.Proxies.UserPhoneBook.PBXPhoneBookEntry phoneBook in pb)
  {

    if(phoneBook.UserID == tmpUsr.id)
    {
    SWConfigDataClientLib.WSUserPhoneBook.PhonebookStatus status = (SWConfigDataClientLib.WSUserPhoneBook.PhonebookStatus)phoneBook.UserStatus;
    tmpUsr.status = status.ToString(); 

  }

}

 

Is there maybe a better way ?

 

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.