PureConnect

 View Only
Discussion Thread View
  • 1.  How can I get the list of available user statuses?

    Posted 12-18-2017 22:48
    Hi, I am trying to create a drop down menu with all available user statuses. So I created an instance of the `UserStatusList()` class to listened to the `WatchedObjectsChanged` event to keep the client updated with the current status. like so var status = new UserStatusList(GetPeopleManager()); status.WatchedObjectsChanged += SessionUserStatusChanged; status.StartWatching(new string[] { "my username" }); But, how can I get a list of all available statuses the user can select from to construct the status menu? Also, how do I get the current user's status from the `SessionUserStatusChanged` event handler? private void SessionUserStatusChanged(Object sender, WatchedObjectsEventArgs<UserStatusProperty> e) { var username = GetUser.Identity.Name; ReadOnlyCollection<UserStatusProperty> props = e.Changed[username]; // How can I get the the current status of username }


  • 2.  RE: How can I get the list of available user statuses?

    Posted 12-26-2017 20:13
    Any idea on how to get a list of all available statuses for the logged in user?


  • 3.  RE: How can I get the list of available user statuses?

    Posted 12-27-2017 16:25
    This will give you a list of strings with status messages the user has access to. PeopleManager _pm = PeopleManager.GetInstance(_session); UserAccessListsSettings uacl = new UserAccessListsSettings(_pm); uacl.StartWatching(new[] { UserAccessListsAttributes.StatusMessages }); foreach(string status in uacl.StatusMessageList) { Console.WriteLine(status); } uacl.StopWatching();


  • 4.  RE: How can I get the list of available user statuses?

    Posted 12-27-2017 16:51
    Thanks a lot for that. How can I use the provided string to change my user's status? // Assume I was to set my status to "Break" string status = "Break"; var updater = new UserStatusUpdate(GetPeopleManager(), User.Identity.Name); updater.UpdateRequest();


  • 5.  RE: How can I get the list of available user statuses?

    Posted 12-28-2017 04:39
    So I think what you actually want to use is the FilteredStatusMessageList Class to generate the list of available statuses for a given user. The below code worked for me changing statuses, forgive brevity of the code. A few things I am not sure about yet or does not account for - If there is a better way to do this that implicitly uses the current session user. - If there is a method that only brings back status messages that a user can actually change to on their own without managing another collection. - Real validation of the status message changing too. //get and start watching the filtered status list. FilteredStatusMessageList fsml = new FilteredStatusMessageList(_pm); fsml.StartWatching(new string[] { _session.UserId }); //start a userstatuslist watch _usl = new UserStatusList(_pm); _usl.WatchedObjectsChanged += Usl_WatchedObjectsChanged; //_usl.StartWatchingAsync(new string[] { _session.UserId },); _usl.StartWatchingAsync(new string[] { _session.UserId }, StartWatchingCompleted,null); //Console.WriteLine("User Status List"); ReadOnlyCollection<StatusMessageDetails> smdList = fsml.GetList()[_session.UserId]; //get random status from list; Random rand = new Random(); StatusMessageDetails newStatus = smdList[rand.Next(0,smdList.Count())]; //Set the new status; Console.WriteLine("Changing Status to {0}", newStatus.MessageText); UserStatusUpdate updater = new UserStatusUpdate(_pm, _session.UserId); updater.StatusMessageDetails = newStatus; if (newStatus.IsValid && newStatus.IsSelectableStatus) { updater.UpdateRequest(); } private static void StartWatchingCompleted(object sender, AsyncCompletedEventArgs e) { Console.WriteLine("SWC Status is : {0}", _usl.GetUserStatus(_session.UserId).StatusMessageDetails.MessageText); } private static void Usl_WatchedObjectsChanged(object sender, WatchedObjectsEventArgs<UserStatusProperty> e) { foreach(var c in e.Changed) { Console.WriteLine("WOC Status for {0} is: {1}",c.Key, _usl.GetUserStatus(c.Key).StatusMessageDetails.MessageText); } } This is a sample output from above code: Changing Status to Out of the Office SWC Status is : WOC Status for sw is: Training WOC Status for sw is: Training WOC Status for sw is: Out of the Office Current Status After Change: Out of the Office


  • 6.  RE: How can I get the list of available user statuses?

    Posted 12-28-2017 18:51
    Thank you for your help with this again. That did work. However, I am puzzled on how to watch the user status. So after I change the user status, I am hoping for an event to trigger telling me your new status is "....". Here is how I am trying to watch for user's status change var status = new UserStatusList(GetPeopleManager()); status.WatchedObjectsChanged += SessionUserStatusChanged; status.StartWatching(new string[] { GetIdentity.Name }); private void SessionUserStatusChanged(Object sender, WatchedObjectsEventArgs<UserStatusProperty> e) { var username = GetUser.Identity.Name; ReadOnlyCollection<UserStatusProperty> props = e.Changed[username]; // I am hoping I can get the current user's status. }


  • 7.  RE: How can I get the list of available user statuses?

    Posted 12-29-2017 15:34
    That is what this is doing Console.WriteLine("WOC Status for {0} is: {1}",c.Key, _usl.GetUserStatus(c.Key).StatusMessageDetails.MessageText);


  • 8.  RE: How can I get the list of available user statuses?

    Posted 12-29-2017 16:55
    Sorry I missed that. I got it now. Lots of steps to get the user status :) I am surprise we can't just use e.Changed object to get the status directly.


  • 9.  RE: How can I get the list of available user statuses?

    Posted 12-29-2017 18:59
    Agreed, I didn't think it would take so much either.


  • 10.  RE: How can I get the list of available user statuses?

    Posted 02-14-2018 16:28
    May I suggest that you sign up for the ICELib training? How to perform tasks like this (which are quite common!) is part of the course and you may well find out a few more tit-bits that come in handy ;) The class is available online and doesn't run very often due to the somewhat specialized nature. If more people sign up, then more deliveries will get scheduled, I'm sure. Supply should rise if demand does!


  • 11.  RE: How can I get the list of available user statuses?

    Posted 02-14-2018 17:11
    Is the schedule for this posted anywhere? We were sent to the Genesys University site, but I didn't not see anything for PureConnect IceLib


Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources