private void QueryThreadChanged(object sender, EventArgs e) { QueryThread messenger = (QueryThread)sender; QueryThreadPoolEventArgs arg = (QueryThreadPoolEventArgs)e; string siteId = messenger.Connection.DataSource.SiteId.Id; if (arg.ConnectionEventType == QueryThreadPoolEventArgs.ConnectionChangeEventType.ConnectionAvailable) { messenger.CompleteTimestamp = DateTime.Now; messenger.Connection.IsAvailable = true; QueryThread qt; if ((qt = _queue.dequeue(siteId)) != null) // if there are queued items for this cxn site { qt.setConnection(messenger.Connection); qt.DequeueTimestamp = DateTime.Now; qt.Changed += new EventHandler(QueryThreadChanged); qt.execute(); } } else if (arg.ConnectionEventType == QueryThreadPoolEventArgs.ConnectionChangeEventType.Disconnected) { _connections[siteId].Remove(messenger.Connection); _currentActiveConnections--; // re-allocate connection? some out of process algorithm to re-use? } }
public void execute() { if (dao == null) // This data source has no DAO for this data domain { return; } Type theClass = dao.GetType(); Type[] theParamTypes = new Type[this.args.Length]; for (int i = 0; i < args.Length; i++) { if (args[i] == null) { throw new MdoException(MdoExceptionCode.ARGUMENT_NULL, "Cannot have null args in QueryThread"); } else { theParamTypes[i] = args[i].GetType(); } } MethodInfo theMethod = theClass.GetMethod(methodName, theParamTypes); try { // set the symbol table set for the connection elsewhere //if (this.Connection.IsPooled && this.Connection is vista.VistaConnection && this.Connection.Session != null) //{ // ((vista.VistaConnection)this.Connection).setSymbolTable(); //} result = theMethod.Invoke(dao, BindingFlags.InvokeMethod, null, args, null); } catch (TargetInvocationException tie) { result = tie.InnerException; } catch (Exception e) { result = e; } finally { // on cleanup - need to get/reset the symbol table - TBD: will some type of manager retrieve it? //if (this.Connection.IsPooled && this.Connection is vista.VistaConnection) //{ // ((vista.VistaConnection)this.Connection).getSerializedSymbolTable(); //} // done with symbol table QueryThreadPoolEventArgs e = new QueryThreadPoolEventArgs(); e.ConnectionEventType = QueryThreadPoolEventArgs.ConnectionChangeEventType.ConnectionAvailable; OnChanged(e); } }
public void queue(QueryThread qt, string siteId) { lock (_connectionQueues) { if (!_connectionQueues.ContainsKey(siteId)) { _connectionQueues.Add(siteId, new Queue<QueryThread>()); } _connectionQueues[siteId].Enqueue(qt); } QueryThreadPoolEventArgs e = new QueryThreadPoolEventArgs() { QueueEventType = QueryThreadPoolEventArgs.QueueChangeEventType.QueryAdded, SiteId = siteId }; QueueChanged(e); }
public void queue(QueryThread qt, string siteId) { lock (_connectionQueues) { if (!_connectionQueues.ContainsKey(siteId)) { _connectionQueues.Add(siteId, new Queue <QueryThread>()); } _connectionQueues[siteId].Enqueue(qt); } QueryThreadPoolEventArgs e = new QueryThreadPoolEventArgs() { QueueEventType = QueryThreadPoolEventArgs.QueueChangeEventType.QueryAdded, SiteId = siteId }; QueueChanged(e); }
private void QueueChanged(object sender, EventArgs e) { QueryThreadPoolEventArgs arg = (QueryThreadPoolEventArgs)e; if (arg.QueueEventType == QueryThreadPoolEventArgs.QueueChangeEventType.QueryAdded) { // if connection available then execute AbstractConnection cxn = getAvailableConnection(arg.SiteId); if (cxn != null) { QueryThread qt = _queue.dequeue(arg.SiteId); qt.DequeueTimestamp = DateTime.Now; qt.setConnection(cxn); qt.Changed += new EventHandler(QueryThreadChanged); qt.execute(); } } }
public void execute() { if (dao == null) // This data source has no DAO for this data domain { return; } Type theClass = dao.GetType(); Type[] theParamTypes = new Type[this.args.Length]; for (int i = 0; i < args.Length; i++) { if (args[i] == null) { throw new MdoException(MdoExceptionCode.ARGUMENT_NULL, "Cannot have null args in QueryThread"); } else { theParamTypes[i] = args[i].GetType(); } } MethodInfo theMethod = theClass.GetMethod(methodName, theParamTypes); try { result = theMethod.Invoke(dao, BindingFlags.InvokeMethod, null, args, null); } catch (TargetInvocationException tie) { result = tie.InnerException; } catch (Exception e) { result = e; } finally { QueryThreadPoolEventArgs e = new QueryThreadPoolEventArgs(); e.ConnectionEventType = QueryThreadPoolEventArgs.ConnectionChangeEventType.ConnectionAvailable; OnChanged(e); } }