public bool readBaseConfig() { XmlReader rd = null; try { string sfile; sfile = m_path + "\\OBIConf.xml"; rd = XmlReader.Create(sfile); string sE, sA; ProfileGroup PG; bool bOK = false; while (rd.Read()) { if (rd.IsStartElement()) { sE = rd.Name; switch (sE) { case "environment": bOK = true; sA = rd.GetAttribute("urn"); if (sA != null) { m_ConfValues.Add("urn", sA); } sA = rd.GetAttribute("serverfqdn"); if (sA != null) { m_ConfValues.Add("serverfqdn", sA); } sA = rd.GetAttribute("autoprovision"); if (sA != null) { m_ConfValues.Add("autoprovision", sA); } sA = rd.GetAttribute("applicationname"); if (sA != null) { m_ConfValues.Add("applicationname", sA); } sA = rd.GetAttribute("fqdn"); if (sA != null) { m_ConfValues.Add("fqdn", sA); } sA = rd.GetAttribute("gruu"); if (sA != null) { m_ConfValues.Add("gruu", sA); } sA = rd.GetAttribute("listeningport"); if (sA != null) { m_ConfValues.Add("listeningport", sA); } sA = rd.GetAttribute("contacturi"); if (sA != null) { m_ConfValues.Add("contacturi", sA); } sA = rd.GetAttribute("dai"); if (sA != null) { m_ConfValues.Add("dai", sA); } sA = rd.GetAttribute("dai_poll"); if (sA != null) { m_ConfValues.Add("dai_poll", sA); } sA = rd.GetAttribute("PSI_Url"); if (sA != null) { m_ConfValues.Add("PSI_Url", sA); } sA = rd.GetAttribute("PSI_User"); if (sA != null) { m_ConfValues.Add("PSI_User", sA); } sA = rd.GetAttribute("PSI_UserPassword"); if (sA != null) { m_ConfValues.Add("PSI_UserPassword", sA); } sA = rd.GetAttribute("LocalCertificate"); if (string.IsNullOrEmpty(sA) == false) { m_ConfValues.Add("LocalCertificate", sA); } sA = rd.GetAttribute("localcertificate"); if (string.IsNullOrEmpty(sA) == false) { m_ConfValues.Add("LocalCertificate", sA); } sA = rd.GetAttribute("BCM_LyncStateAsEntry"); if (string.IsNullOrEmpty(sA) == false) { m_ConfValues.Add("BCM_LyncStateAsEntry", sA); } sA = rd.GetAttribute("BCM_DB_Directory"); if (string.IsNullOrEmpty(sA) == false) { m_ConfValues.Add("BCM_DB_Directory", sA); } sA = rd.GetAttribute("BCM_Dir_Attribute"); if (string.IsNullOrEmpty(sA) == false) { m_ConfValues.Add("BCM_Dir_Attribute", sA); } sA = rd.GetAttribute("BCM_Dir_Language"); if (string.IsNullOrEmpty(sA) == false) { m_ConfValues.Add("BCM_Dir_Language", sA); } else { m_ConfValues.Add("BCM_Dir_Language", "EN"); } sA = rd.GetAttribute("BCM_Dir_AddStartTime"); if (string.IsNullOrEmpty(sA) == false) { m_ConfValues.Add("BCM_Dir_AddStartTime", sA); } sA = rd.GetAttribute("localhostname"); if (string.IsNullOrEmpty(sA) == false) { m_ConfValues.Add("localhostname", sA); } sA = rd.GetAttribute("sync_direction"); if (string.IsNullOrEmpty(sA) == false) { m_ConfValues.Add("sync_direction", sA); } sA = rd.GetAttribute("RefreshLimitUsers"); if (sA != null) { m_ConfValues.Add("RefreshLimitUsers", sA); } sA = rd.GetAttribute("RefreshLimitTokens"); if (sA != null) { m_ConfValues.Add("RefreshLimitTokens", sA); } sA = rd.GetAttribute("RefreshLimitProfiles"); if (sA != null) { m_ConfValues.Add("RefreshLimitProfiles", sA); } sA = rd.GetAttribute("DailyRefresh"); if (sA != null) { m_ConfValues.Add("DailyRefresh", sA); } sA = rd.GetAttribute("EventFlags"); if (sA != null) { m_ConfValues.Add("EventFlags", sA); } break; case "group": sA = rd.GetAttribute("id"); m_log.Log("ProfileGroup:" + sA); PG = new ProfileGroup(sA, m_log, this); m_Groups.Add(sA, PG); break; default: break; } } } rd.Close(); if (bOK == false) { m_log.Log("No proper environment found in config - startup failed"); return(false); } if (m_Groups.Count == 0) { m_log.Log("No groups in config - startup failed"); return(false); } return(true); } catch (Exception e) { m_log.Log("Exception in readConfig: ", e); try { if (rd != null) { rd.Close(); } } catch (Exception er) { m_log.Log("Exception 2 in readConfig: ", er); } } return(false); }
/////////////////////////////////////// // Main thread // protected void PSI_MainThread() { int nRestartCount = 0; int nConfigCycle = 0; /* * try * { * string[] atoks; * atoks = new string[2]; * atoks[0] = "tiitaa"; * atoks[1] = "tuutuu"; * m_PSI.SubscribeConfigChanges(m_PSI_Session, atoks); * * atoks = new string[1]; * atoks[0] = "tuutuu"; * m_PSI.GetUsers(m_PSI_Session, atoks); * * } * catch (Exception e) * { * m_log.Log("Exception while subscribing conf changes:" + e); * } * /*ENDTEST*/ while (true) { Thread.Sleep(500); try { PSI_presencePoll(); } catch (Exception e) { m_log.Log("Exception in PSI_MainThread: " + e); nRestartCount++; } if (nRestartCount > 3) { m_PL.RequestRestart("Error count exceeded in BCM presence thread"); break; } nConfigCycle++; if (nConfigCycle > 2) // config? { try { PSI_changePoll(); nConfigCycle = 0; } catch (Exception e) { m_log.Log("Exception in PSI_MainThread: " + e); nRestartCount++; } foreach (System.Collections.Generic.KeyValuePair <string, ProfileGroup> pg in m_Groups) { if (pg.Value.IsConfigChanged()) { bool bgo = false; m_log.Log("Configuration for group " + pg.Key + " changed, rereading"); // test with temporary object first try { ProfileGroup tmp = new ProfileGroup(pg.Key, m_log, m_CFG); tmp.CreateBaseRules(); if (tmp.ReadConfig() == true) { bgo = true; } } catch (Exception e) { m_log.Log("Cannot prefetch changed configuration for group " + pg.Key + ", ignoring / exc:" + e); } if (bgo) { if (pg.Value.ReReadConfig() == false) { m_log.Log("Cannot re-read configuration for group " + pg.Key + " changed, rereading"); // fatal ???? } lock (m_PL) { RefreshProfiles(); } } } } } } }