Esempio n. 1
0
        public Bcm_to_Lync_Rule findBcm2LyncRule(BcmState BS)
        {
            Bcm_to_Lync_Rule rule = null;
            BcmProfile       bp, confBS;

            // first match the state to ones configured for this group
            if (BS.Profile != null && BS.Profile.BcmID.Length > 0)
            {
                bp = BS.Profile;

                confBS = m_cfg.GetBCMProfile(bp.BcmID);
                if (confBS == null)
                {
                    confBS = m_cfg.GetBCMProfile(bp.Name);
                }

                if (confBS != null)
                {
                    if (m_Bcm2Lync.TryGetValue(confBS.Name, out rule))
                    {
                        m_log.Log("Found matching rule for " + confBS.Name);
                    }
                    else
                    {
                        m_log.Log("No matching rule for " + confBS.Name);
                    }
                }
                else
                {
                    m_log.Log("No matching BCM profile state for " + bp.Name + " , " + bp.BcmID);
                }
                //TBC: Default rule for BCM profile name -> lync custom state by lcid's
            }
            return(rule);
        }
 public bool IsDifferent(BcmState bnew)
 {
     if (Profile != null)
     {
         if (bnew.Profile != null)
         {
             if (Profile.BcmID != bnew.Profile.BcmID)
             {
                 return(true);
             }
         }
     }
     else
     if (bnew.Profile != null)
     {
         return(true);
     }
     if (ServiceState != bnew.ServiceState)
     {
         return(true);
     }
     if (CallState != bnew.CallState)
     {
         return(true);
     }
     if (LoginState != bnew.LoginState)
     {
         return(true);
     }
     return(false);
 }
 public void Set(BcmState bNew)
 {
     Profile.BcmID = bNew.Profile.BcmID;
     Profile.Name  = bNew.Profile.Name;
     Profile.Type  = bNew.Profile.Type;
     ServiceState  = bNew.ServiceState;
     CallState     = bNew.CallState;
     LoginState    = bNew.LoginState;
     Sticky        = bNew.Sticky;
 }
 public ObiUser()
 {
     Uri          = UserId = PSToken = FirstName = SurName = FName = "";
     bcm_initial  = lync_initial = true;
     LS           = new LyncState();
     BS           = new BcmState();
     prevLS       = null;
     prevBS       = null;
     ProfileGroup = null;
     CheckToken   = 0;
 }
Esempio n. 5
0
        protected void PSI_presencePoll()
        {
            PresenceChangeNotification[] aChanges;
            m_log.Log("Calling GetPresenceChanges\n");
            aChanges = m_PSI.GetPresenceChanges(m_PSI_Session, 5000);
            if (aChanges != null && aChanges.Length > 0)
            {
                foreach (PresenceChangeNotification p in aChanges)
                {
                    try
                    {
                        ObiUser u;
                        u = m_PL.getUserBCM(p.UserId);
                        if (u != null)
                        {
                            string           rname = null;
                            Bcm_to_Lync_Rule Rule  = null;
                            BcmState         bnew  = new BcmState();

                            m_log.Log("BCM change:" + u.logId + " profile:" + p.PresenceProfile + " login:"******" service:" + p.ServiceState + " call:" + p.CallState);

                            if (m_PL.getSyncDirection() == SyncDirection.Lync_2_BCM)
                            {
                                continue;
                            }

                            if (p.PresenceProfile != null && p.PresenceProfile.Length > 0)
                            {
                                bnew.Profile = m_CFG.GetBCMProfile(p.PresenceProfile);
                            }
                            else
                            {
                                bnew.Profile = u.BS.Profile;
                            }
                            if (bnew.Profile == null)
                            {
                                bnew.Profile = m_CFG.GetBcmUnkown();
                            }
                            if (p.LoginState != UserLoginState.No_Change)
                            {
                                if (p.LoginState == UserLoginState.Logged_In)
                                {
                                    rname           = "_Online";
                                    bnew.LoginState = true;
                                }
                                else
                                {
                                    rname           = "_Offline";
                                    bnew.LoginState = false;
                                }
                            }
                            else
                            {
                                bnew.LoginState = u.BS.LoginState;
                            }
                            if (p.ServiceState != UserServiceState.No_Change)
                            {
                                switch (p.ServiceState)
                                {
                                case UserServiceState.Working:
                                    rname             = "_Working";
                                    bnew.ServiceState = BcmServiceState.Working; break;

                                case UserServiceState.Paperwork:
                                    rname             = "_PaperWork";
                                    bnew.ServiceState = BcmServiceState.Paperwork; break;

                                case UserServiceState.Wrapup:
                                    rname             = "_WrapUp";
                                    bnew.ServiceState = BcmServiceState.WrapUp; break;

                                default:
                                    rname             = "_Working";
                                    bnew.ServiceState = BcmServiceState.Working; break;
                                }
                            }
                            else
                            {
                                bnew.ServiceState = u.BS.ServiceState;
                            }
                            if (p.CallState != UserCallState.No_Change)
                            {
                                if (p.CallState == UserCallState.Talking)
                                {
                                    rname          = "_Talking";
                                    bnew.CallState = true;
                                }
                                else
                                {
                                    rname          = "_EndCall";
                                    bnew.CallState = false;
                                }
                            }
                            else
                            {
                                bnew.CallState = u.BS.CallState;
                            }

                            if (p.EndTime != DateTime.MaxValue && p.EndTime != DateTime.MinValue)
                            {
                                m_log.Log("Endtime in notification now " + p.EndTime);
                            }

                            if (u.bcm_initial == false)
                            {
                                m_log.Log("User " + u.logId + "(" + u.FName + ") presence changed");
                                if (u.BS.IsDifferent(bnew))
                                {
                                    // find rule first by change indication
                                    if (rname != null)
                                    {
                                        m_log.Log("Change indication rule check " + rname);
                                        Rule = u.ProfileGroup.findBcm2LyncRule(bnew.Profile.Name + rname);
                                        if (Rule == null)
                                        {
                                            Rule = u.ProfileGroup.findBcm2LyncRule(rname);
                                        }
                                    }
                                    if (Rule == null)
                                    {
                                        if (bnew.Profile != u.BS.Profile)
                                        {
                                            m_log.Log("Profile changed - rule by profile");
                                            Rule = u.ProfileGroup.findBcm2LyncRule(bnew.Profile.Name);
                                        }
                                        else
                                        {
                                            m_log.Log("No profile change - no rule");
                                        }
                                    }
                                    if (bnew.Profile == u.BS.Profile)
                                    {
                                        if (u.BS.Sticky)
                                        {
                                            m_log.Log("No profile change - sticky bcm on - keeping it");
                                            bnew.Sticky = true;
                                        }
                                    }
                                    u.BS = bnew;
                                    if (Rule != null)
                                    {
                                        if (Rule.Sticky)
                                        {
                                            m_log.Log("Setting sticky BCM state ");
                                            u.BS.Sticky = true;
                                        }
                                        m_PL.Bcm_PresenceChanged(u, Rule);
                                    }
                                }
                            }
                            else
                            {
                                m_log.Log("User " + u.logId + "(" + u.FName + ") initial presence received");
                                u.bcm_initial = false;
                                u.BS          = bnew;
                                u.prevBS      = new BcmState();
                                u.prevBS.Set(bnew);

                                // check rule for stickiness
                                if (bnew.Profile.Name != null)
                                {
                                    Rule = u.ProfileGroup.findBcm2LyncRule(bnew.Profile.Name);
                                    if (Rule != null)
                                    {
                                        if (Rule.Sticky)
                                        {
                                            m_log.Log("User " + u.logId + " initial bcm availability is sticky");
                                            u.BS.Sticky = true;
                                        }
                                    }
                                }
                                if (m_Subscribed.ContainsKey(u.UserId) == false)
                                {
                                    m_Subscribed.Add(u.UserId, u);
                                }
                            }
                        }
                        else
                        {
                            m_log.Log("Error - unknown user " + p.UserId + " in presencechanges");
                        }
                    }
                    catch (Exception exp)
                    {
                        m_log.Log("Exceptoin in GetPresenceChanges: " + exp);
                    }
                }
            }
            else
            {
                m_log.Log("No presence changes");
            }
        }