public TaggedFaultArray(IndexedHashtable ihs) { if (ihs == null || ihs.Count == 0) { return; } IList <TaggedFault> temp = new List <TaggedFault>(); for (int i = 0; i < ihs.Count; i++) { if (MdwsUtils.isException(ihs.GetValue(i))) { temp.Add(new TaggedFault((string)ihs.GetKey(i), (Exception)ihs.GetValue(i))); } } if (temp.Count > 0) { // we want to remove the exceptions from the hashtable because, in container objects, the constructors // for each of the property objects handle exception info. we need to keep the tag though so results collections are consistent foreach (TaggedFault tf in temp) { ihs.Remove(tf.tag); ihs.Add(tf.tag, null); } faults = new TaggedFault[temp.Count]; temp.CopyTo(faults, 0); } }
public IndexedHashtable connect() { int lth = cxnTable.Count; QueryThread[] queries = new QueryThread[lth]; Thread[] threads = new Thread[lth]; for (int i = 0; i < lth; i++) { queries[i] = new QueryThread(cxnTable.GetValue(i), "connect", new Object[0]); //queries[i].execute(); threads[i] = new Thread(new ThreadStart(queries[i].execute)); threads[i].Start(); } IndexedHashtable result = new IndexedHashtable(lth); for (int i = 0; i < lth; i++) { string key = (string)cxnTable.GetKey(i); threads[i].Join(); //Need to report result whether it's a connection or an exception. if (queries[i].isExceptionResult()) { result.Add(key, queries[i].Result); } else { result.Add(key, ((Connection)cxnTable.GetValue(key)).DataSource); } } //Now for all the results that failed to connect, we remove them from the connection table. for (int i = 0; i < lth; i++) { if (queries[i].isExceptionResult()) { string key = (string)cxnTable.GetKey(i); cxnTable.Remove(key); cxnTable.Add(key, queries[i].Result); } } return(result); }
public void removeConnection(string siteId) { if (cxnTbl.ContainsKey(siteId)) { Connection cxn = (Connection)cxnTbl.GetValue(siteId); if (cxn.IsConnected) { cxn.disconnect(); } cxnTbl.Remove(siteId); } }