Esempio n. 1
0
        public void Lync_PresenceChanged(ObiUser usr)
        {
            lock (this)
            {
                m_log.Log("Lync presence changed: " + usr.logId + " - " + usr.LS.BaseString);

                if (m_sync_direction == SyncDirection.BCM_2_Lync)                 // only BCM->Lync used
                {
                    return;
                }

                if (usr.LS != null)
                {
                    try
                    {
                        Lync_to_Bcm_Rule rule = null;
                        if (usr.BS.Sticky)
                        {
                            m_log.Log("User " + usr.logId + " lync state change, sticky bcm state on, ignoring");
                            return;
                        }

                        // TOCHECK: PROFILE GROUP BASED SETTING ???
                        if (m_use_bcm_directory > 0)
                        {
                            rule = usr.ProfileGroup.findLync2BcmRule(usr.LS);
                            if (rule != null)
                            {
                                m_BCM.SetPresenceDirectory(usr, rule.BcmOnline.Name);
                            }
                            return;
                        }


                        if (usr.ProfileGroup != null)
                        {
                            rule = usr.ProfileGroup.findLync2BcmRule(usr.LS);
                            if (rule != null)
                            {
                                string sBcmPro = null;
                                if (usr.BS.LoginState)
                                {
                                    if (rule.BcmOnline != null)
                                    {
                                        m_log.Log("user " + usr.logId + " changing online profile to " + rule.BcmOnline.BcmID + "," + rule.BcmOnline.Name);
                                        sBcmPro = rule.BcmOnline.BcmID;
                                    }
                                }
                                else
                                {
                                    if (rule.BcmOffline != null)
                                    {
                                        m_log.Log("user " + usr.logId + " changing offline profile to " + rule.BcmOffline.BcmID + "," + rule.BcmOffline.Name);
                                        sBcmPro = rule.BcmOffline.BcmID;
                                    }
                                }
                                if (Util.IsNullOrEmpty(sBcmPro))
                                {
                                    m_log.Log("User " + usr.logId + " bcm rule empty - ignoring");
                                }
                                else
                                {
                                    // check internal rules
                                    switch (sBcmPro)
                                    {
                                    case "_Talking":                                             // future: PSI call state
                                        m_log.Log("User " + usr.logId + " bcm rule _Talking");
                                        break;

                                    case "_EndCall":                                             // future: PSI call state
                                        m_log.Log("User " + usr.logId + " bcm rule _CallEnd");
                                        break;

                                    case "_PaperWork":
                                        m_log.Log("User " + usr.logId + " bcm rule _PaperWork");
                                        if (usr.BS.ServiceState != BcmServiceState.Paperwork)
                                        {
                                            m_BCM.SetPresence(usr, BcmServiceState.Paperwork);
                                        }
                                        else
                                        {
                                            m_log.Log("User " + usr.logId + " bcm already paperwork");
                                        }
                                        break;

                                    case "_Working":
                                        m_log.Log("User " + usr.logId + " bcm rule _Working");
                                        if (usr.BS.ServiceState != BcmServiceState.Working)
                                        {
                                            m_BCM.SetPresence(usr, BcmServiceState.Working);
                                        }
                                        else
                                        {
                                            m_log.Log("User " + usr.logId + " bcm already working");
                                        }
                                        break;

                                    case "_LateAdmin":
                                    case "_WrapUp":
                                        m_log.Log("User " + usr.logId + " bcm rule _WrapUp");
                                        if (usr.BS.ServiceState != BcmServiceState.WrapUp)
                                        {
                                            m_BCM.SetPresence(usr, BcmServiceState.WrapUp);
                                        }
                                        else
                                        {
                                            m_log.Log("User " + usr.logId + " bcm already wrapup");
                                        }
                                        break;

                                    case "_Previous":
                                        if (usr.prevBS != null)
                                        {
                                            if (usr.prevBS.Profile != null)
                                            {
                                                if (usr.prevBS.Profile.Type == BcmStateOption.Profile)
                                                {
                                                    m_BCM.SetPresence(usr, usr.prevBS.Profile.BcmID);
                                                }
                                            }
                                        }
                                        break;

                                    default:
                                        if (usr.BS.Profile != null && usr.BS.Profile.BcmID == sBcmPro)
                                        {
                                            m_log.Log("User " + usr.logId + " bcm profile already on, ignoring");
                                        }
                                        else
                                        {
                                            m_BCM.SetPresence(usr, sBcmPro);
                                        }
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                m_log.Log("User " + usr.logId + " no bcm rule - ignoring");
                            }
                        }
                        else
                        {
                            m_log.Log("User " + usr.logId + " has no profilegroup, ignoring");
                        }
                    }
                    catch (Exception ex)
                    {
                        m_log.Log("Exception in Lync_PresenceChanged", ex);
                    }
                }
            }
        }
Esempio n. 2
0
 public void Lync_PresenceChanged(ObiUser usr, Lync_to_Bcm_Rule rule)
 {
     m_log.Log("Unimplemented - Lync_PresenceChanged:" + usr.logId + " - rule " + rule.rId);
 }