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 Bcm_to_Lync_Rule findBcm2LyncRule(string ruleName) { Bcm_to_Lync_Rule rule = null; if (m_Bcm2Lync.TryGetValue(ruleName, out rule)) { return(rule); } m_log.Log("No matching rule for " + ruleName); return(null); }
private bool readBcm2LyncRules(XmlReader r) { Bcm_to_Lync_Rule R; BcmProfile bs; string sE, sA; bs = null; R = null; try { while (r.Read()) { if (r.IsStartElement()) { sE = r.Name; if (sE == "state") { R = new Bcm_to_Lync_Rule(); sA = r.GetAttribute("id"); bs = m_cfg.GetBCMProfile(sA); if (bs != null) { m_Bcm2Lync.Add(sA, R); R.rId = sA; R.BcmState = bs; R.LyncOffline = null; R.LyncOnline = null; sA = r.GetAttribute("sticky"); if (Util.IsNullOrEmpty(sA)) { R.Sticky = false; } else if (sA == "1") { R.Sticky = true; } sA = r.GetAttribute("lync_online"); if (Util.IsNullOrEmpty(sA) == false && m_LyncStates.ContainsKey(sA)) { R.LyncOnline = m_LyncStates[sA]; } sA = r.GetAttribute("lync_offline"); if (Util.IsNullOrEmpty(sA) == false && m_LyncStates.ContainsKey(sA)) { R.LyncOffline = m_LyncStates[sA]; } } else { m_log.Log("Error - invalid configuration element in Bcm2LyncRules - no BCM profile with name " + sA); } } if (sE == "BCM_to_Lync") { readBcm2LyncRules(r); return(true); } if (sE == "Lync_to_BCM") { readLync2BcmRules(r); return(true); } } } } catch (Exception e) { m_log.Log("Exception while reading bcm2lyncRules " + e); return(false); } return(true); }
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"); } }