/////////////////////////////////////////////////////////////// // SetPresence // - Methods for setting the presence state for users public bool SetPresence(ObiUser usr, string sBcmProfile) { try { PresenceType pt = new PresenceType(); pt.CallState = 0; pt.EndTime = DateTime.MaxValue; pt.ServiceState = UserServiceState.No_Change; pt.CallState = UserCallState.No_Change; /*test * pt.EndTime = DateTime.Now; * pt.EndTime.AddHours(1); * pt.ServiceState = UserServiceState.Wrapup; * test*/ pt.PresenceProfile = sBcmProfile; if (usr.prevBS != null) { usr.prevBS.Set(usr.BS); } usr.BS.Profile = m_CFG.GetBCMProfile(sBcmProfile); m_log.Log("BCM::SetPresence:" + usr.logId + " profile=" + sBcmProfile); m_PSI.SetUserPresence(m_PSI_Session, usr.UserId, pt); m_PL.Bcm_PresenceUpdated(usr); return(true); } catch (Exception e) { m_log.Log("Exception in BCM_Control::SetPresence: " + e); } return(false); }
/////////////////////////////////////////////////////////////// // SetPresence // - Methods for setting the presence state for users public bool SetPresenceDirectory(ObiUser usr, string bcmValue) { bool bret = true; try { if (m_BcmDB != null) { if (m_CFG.GetParameter("BCM_Dir_AddStartTime", "0") == "1") { string stmp = bcmValue + " - " + DateTime.Now.ToString("HH:mm"); m_BcmDB.AddUpdate(usr.UserId, stmp); } else { m_BcmDB.AddUpdate(usr.UserId, bcmValue); } } else { m_log.Log("BCM_Control::SetPresenceDirectory called - no DB configuration exists"); bret = false; } } catch (Exception e) { m_log.Log("Exception in SetPresenceDirectory:" + e); bret = false; } return(bret); }
public bool StopPresenceBcm(string sUserId) { ObiUser u = m_PL.getUserBCM(sUserId); if (u == null) { return(false); } return(StopPresence(u)); }
/////////////////////////////////////////////////////////////// // StopPresence // public bool StopPresence(string sUri) { ObiUser u = m_PL.getUserLync(sUri); if (u == null) { return(false); } return(StopPresence(u)); }
/////////////////////////////////////////////////// // GetUserConfig // protected bool GetUserConfig() { try { UserType[] aUsers; string[] aPresenceTokens; m_Groups = m_CFG.GetProfileGroups(); aPresenceTokens = new string[1]; foreach (System.Collections.Generic.KeyValuePair <string, ProfileGroup> pg in m_Groups) { //todo: possibly multiple tokens.... aPresenceTokens[0] = pg.Value.m_id; aUsers = m_PSI.GetUsers(m_PSI_Session, aPresenceTokens); foreach (UserType u in aUsers) { ObiUser oU = new ObiUser(); bool badd = true; oU.UserId = u.BcmID; oU.Uri = u.ExtID.ToLower(); oU.PSToken = u.PSToken; oU.FirstName = u.FirstName; oU.SurName = u.SurName; oU.FName = u.FirstName + " " + u.SurName; oU.logId = "(" + oU.Uri + "," + oU.UserId + ")"; oU.ProfileGroup = pg.Value; oU.BS.Profile = m_CFG.GetBcmUnkown(); m_log.Log("Created user " + oU.UserId + " with lync id " + oU.Uri); if (m_PL.isUserBCM(oU.UserId)) { m_log.Log("Error - user " + oU.logId + "(" + oU.FName + ") already in subscriptions (token=" + oU.PSToken + ")"); badd = false; } if (m_PL.isUserLync(oU.Uri)) { m_log.Log("Error - user ext " + oU.logId + "(" + oU.FName + ") already in subscriptions (token=" + oU.PSToken + ")"); badd = false; } if (badd) { m_PL.addUser(oU); } } } } catch (Exception x) { m_log.Log("Error in Bcm_Control::GetUserConfig: " + x); return(false); } return(true); }
public bool StopPresence(ObiUser usr) { try { m_PSI.UnsubscribeUserPresence(m_PSI_Session, usr.UserId); m_Subscribed.Remove(usr.UserId); } catch (Exception e) { m_log.Log("Exception in BCM_Control::StopPresence: " + e); } return(true); }
/////////////////////////////////////////////////////////////// // SetPresence // - Methods for setting the presence state for users public bool SetPresence(ObiUser usr, BcmServiceState nServiceState) { try { PresenceType pt = new PresenceType(); pt.CallState = 0; pt.EndTime = DateTime.MaxValue; pt.ServiceState = (UserServiceState)nServiceState; pt.PresenceProfile = ""; m_PSI.SetUserPresence(m_PSI_Session, usr.UserId, pt); m_PL.Bcm_PresenceUpdated(usr); return(true); } catch (Exception e) { m_log.Log("Exception in BCM_Control::SetPresence: " + e); } return(false); }
/////////////////////////////////////////////////////////////// // Set In-a-Call state public bool SetPresence(ObiUser usr, bool bTalking) { try { PresenceType pt = new PresenceType(); if (bTalking) { pt.CallState = UserCallState.Talking; } else { pt.CallState = UserCallState.Idle; } pt.ServiceState = UserServiceState.No_Change; pt.PresenceProfile = ""; m_PSI.SetUserPresence(m_PSI_Session, usr.UserId, pt); m_PL.Bcm_PresenceUpdated(usr); } catch (Exception e) { m_log.Log("Exception in BCM_Control::SetPresence: " + e); } return(false); }
/////////////////////////////////////////////////////// // StartPresence // Start presence interchange for the given user // parameter obiuser - externally created user object // public bool StartPresence(ObiUser usr) { bool bret = true; m_log.Log("Adding user " + usr.logId + " for bcm presence"); try { if (m_Subscribed.ContainsKey(usr.UserId) == false) { m_PSI.SubscribeUserPresence(m_PSI_Session, usr.UserId, m_EvtFlags); m_Subscribed.Add(usr.UserId, usr); } else { m_log.Log("User " + usr.logId + " already subscribed"); } } catch (Exception x) { m_log.Log("StartPresence error:" + x); bret = false; } return(bret); }
/////////////////////////////////////// // Refresh users // protected bool RefreshUsers(int checktoken) { try { UserType[] aUsers; string[] aPresenceTokens; ObiUser oU = null; m_Groups = m_CFG.GetProfileGroups(); aPresenceTokens = new string[1]; foreach (System.Collections.Generic.KeyValuePair <string, ProfileGroup> pg in m_Groups) { //todo: possibly multiple tokens.... aPresenceTokens[0] = pg.Value.m_id; aUsers = m_PSI.GetUsers(m_PSI_Session, aPresenceTokens); foreach (UserType u in aUsers) { bool bnew = true; bool bmod = false; u.ExtID = u.ExtID.ToLower(); if (m_PL.isUserBCM(u.BcmID)) { bnew = false; oU = m_PL.getUserBCM(u.BcmID); oU.CheckToken = checktoken; if (oU.Uri != u.ExtID) { bmod = true; m_log.Log("User " + oU.logId + " external id changed to " + u.ExtID); if (m_PL.isUserLync(u.ExtID)) { m_log.Log("User " + oU.logId + " new uri " + u.ExtID + " had already uri bound to another user"); } } } else { m_log.Log("User " + u.BcmID + "," + u.ExtID + " is new to OBI"); bnew = true; } if (bnew) //TBC.... { oU = new ObiUser(); oU.UserId = u.BcmID; oU.Uri = u.ExtID; oU.PSToken = u.PSToken; oU.FirstName = u.FirstName; oU.SurName = u.SurName; oU.FName = u.FirstName + " " + u.SurName; oU.logId = "(" + oU.Uri + "," + oU.UserId + ")"; oU.ProfileGroup = pg.Value; oU.CheckToken = checktoken; oU.BS.Profile = m_CFG.GetBcmUnkown(); m_PL.addUser(oU); m_log.Log("Created user " + oU.UserId + " with lync id " + oU.Uri); } if (bmod) { if (oU != null) { m_log.Log("Modified user " + oU.UserId + " with lync id " + oU.Uri); m_PL.addUser(oU); } } } } } catch (Exception x) { m_log.Log("Error in Bcm_Control::GetUserConfig: " + x); return(false); } return(true); }