Jump to content
Sign in to follow this  
Maidzen

CDS User Status

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)

 

Share this post


Link to post
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 ?

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×