gov.va.medora.mdo.dao.MultiSourceQuery.execute2 C# (CSharp) Method

execute2() public static method

public static execute2 ( IndexedHashtable cxnTable, string daoName, string methodName, Object args ) : IndexedHashtable
cxnTable IndexedHashtable
daoName string
methodName string
args Object
return IndexedHashtable
        public static IndexedHashtable execute2(IndexedHashtable cxnTable, string daoName, string methodName, Object[] args)
        {
            if (cxnTable == null || cxnTable.Count == 0)
            {
                throw new Exception("No connections!");
            }
            int lth = cxnTable.Count;
            QueryThread[] queries = new QueryThread[lth];
            Thread[] threads = new Thread[lth];
            for (int i = 0; i < lth; i++)
            {
                if (cxnTable.GetValue(i).GetType().IsAssignableFrom(typeof(Exception)))
                {
                    continue;
                }
                Connection cxn = (Connection)cxnTable.GetValue(i);
                if (!cxn.IsConnected)
                {
                    continue;
                }
                Object dao = ((Connection)cxnTable.GetValue(i)).getDao(daoName);
                if (dao == null)
                {
                    continue;
                }
                queries[i] = new QueryThread(dao, methodName, args);
                threads[i] = new Thread(new ThreadStart(queries[i].execute));
                threads[i].Start();
            }
            IndexedHashtable result = new IndexedHashtable(cxnTable.Count);
            for (int i = 0; i < threads.Length; i++)
            {
                if (cxnTable.GetValue(i).GetType().IsAssignableFrom(typeof(Exception)))
                {
                    result.Add((string)cxnTable.GetKey(i), (Exception)cxnTable.GetValue(i));
                    continue;
                }
                Connection cxn = (Connection)cxnTable.GetValue(i);
                if (!cxn.IsConnected)
                {
                    result.Add((string)cxnTable.GetKey(i), new Exception("Source is not connected"));
                    continue;
                }
                Object dao = ((Connection)cxnTable.GetValue(i)).getDao(daoName);
                if (dao == null)
                {
                    result.Add((string)cxnTable.GetKey(i), new Exception("Invalid dao: " + daoName));
                    continue;
                }
                threads[i].Join();
                result.Add((String)cxnTable.GetKey(i), queries[i].Result);
            }
            return result;
        }