public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { HttpRequest request = context.Request; HttpResponse response = context.Response; NuxleusAsyncResult nuxleusAsyncResult = new NuxleusAsyncResult(cb, extraData); nuxleusAsyncResult.CompleteCall(); return(nuxleusAsyncResult); }
public IAsyncResult BeginProcessRequests(AsyncCallback callback, object extraData) { if (DEBUG) { m_logWriter.WriteLine("Beginning async HTTP request process..."); } NuxleusAsyncResult nuxleusAsyncResult = new NuxleusAsyncResult(callback, extraData); ProcessRequests(nuxleusAsyncResult); return(nuxleusAsyncResult); }
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { m_request = context.Request; m_response = context.Response; m_cookieCollection = context.Request.Cookies; String sessionid = m_cookieCollection["sessionid"].Value; String userid = m_cookieCollection["userid"].Value; String username = m_cookieCollection["username"].Value; String name = m_cookieCollection["name"].Value; String collection_id = m_request.QueryString["media-collection"]; //String uservalidated = m_cookieCollection["uservalidated"].Value; string ip = m_request.UserHostAddress.ToString(); m_task = new SelectTask { DomainName = new Domain { Name = "media" }, SelectExpression = String.Format("select * from media where mediacreator = '{0}' and CollectionId = '{1}'", userid, collection_id) }; m_iTaskResult = new NuxleusAsyncResult(cb, extraData); m_task.Transaction.OnSuccessfulTransaction += new OnSuccessfulTransaction(Transaction_OnSuccessfulTransaction); m_task.Transaction.OnFailedTransaction += new OnFailedTransaction(Transaction_OnFailedTransaction); return m_task.BeginInvoke(m_iTaskResult); }
private void ProcessRequests(NuxleusAsyncResult asyncResult) { int queryArrayLength = m_httpRequestArrayLength; TextWriter logWriter = m_logWriter; bool DEBUG = m_DEBUG; List <long> elaspedTimeList = m_elapsedTimeList; Encoding encoding = Encoding.UTF8; foreach (string r in m_httpRequestArray) { Stopwatch stopwatch = new Stopwatch(); if (DEBUG) { stopwatch.Start(); } string requestString = r; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(requestString)); new AsyncHttpRequest(request, logWriter, DEBUG, stopwatch, delegate(Stream stream, Stopwatch myStopwatch) { //logWriter.WriteLine("The stopwatch objects are the same: {0}", stopwatch.Equals(myStopwatch)); long elapsedTime = 0; if (DEBUG) { myStopwatch.Stop(); elapsedTime = stopwatch.ElapsedMilliseconds; elaspedTimeList.Add(elapsedTime); myStopwatch.Reset(); logWriter.WriteLine("Current thread id: {0} for current request: {1}", Thread.CurrentThread.ManagedThreadId, requestString); } try { using (stream) { StreamReader reader = new StreamReader(stream); m_responseStreamDictionary.Add(requestString.GetHashCode(), new MemoryStream(encoding.GetBytes(reader.ReadToEnd()))); } } catch (Exception e) { logWriter.WriteLine("Exception: {0}", e.Message); } if (m_responseStreamDictionary.Count == queryArrayLength) { if (DEBUG) { logWriter.WriteLine("Elapsed time of this request:\t {0}ms", elapsedTime); logWriter.WriteLine("Completing call."); } asyncResult.CompleteCall(); } else { if (DEBUG) { logWriter.WriteLine("Elapsed time of this request:\t {0}ms", elapsedTime); logWriter.WriteLine("Continuing process..."); } } }); } }
public IAsyncResult BeginInvoke(NuxleusAsyncResult asyncResult) { return new HttpWebService<SelectTask, SelectResponse>().BeginCallWebService(this, asyncResult); }