public Order[] FindOrders(OrderCriteria criteria) { ITicketingServiceOneWay prox = null; Guid callId = Guid.NewGuid(); try { // Find a proxy to the ticketing service (one way) prox = TicketingServiceOneWayProxyFactory.GetProxy(false); AutoResetEvent arrived = new AutoResetEvent(false); // Create a ResultPackage with a wait handle to wait on until a response arrives (on another channel) ResultPackage pack = new ResultPackage() { ResultArrived = arrived }; ResultsCache.Current.SetPackage(callId, pack); // Call the ticketing service via MSMQ channel on another thread. Action<ITicketingServiceOneWay> del = (p => p.FindOrders(criteria, callId)); del.BeginInvoke(prox, null, null); //Wait until result arrives arrived.WaitOne(timeout); Order[] result = ResultsCache.Current.GetResult(callId) as Order[]; ResultsCache.Current.ClearResult(callId); return result; } catch (Exception ex) { LoggingManager.Logger.Log(LoggingCategory.Error, StringsResource.FailedToContactTicketing + " " + ex.Message); throw new TicketingException(StringsResource.TicketingFailed + " " + ex.Message, ex); } finally { if ((prox != null) && ((prox as ICommunicationObject).State == CommunicationState.Opened)) (prox as ICommunicationObject).Close(); } }
public Order[] FindOrders(OrderCriteria criteria) { Order[] orders = manager.FindOrdersByCriteria(criteria); foreach (var item in orders) { FillPaymentInfo(item); FillEventInfo(item); FillCustomerInfo(item); } return orders; }
public void FindOrders(OrderCriteria criteria, Guid callID) { try { callback_prox = CallBackChannelFactory.GetProxy(false); // Do the job and call back the ticketing bridge callback_prox.OrdersArrived(generalTicketing.FindOrders(criteria), callID); } catch (TicketingException tex) { LoggingManager.Logger.Log(LoggingCategory.Error, StringsResource.TicketingFailed + " " + tex.Message); throw new TicketingException(StringsResource.TicketingFailed + " " + tex.Message, tex); } catch (Exception ex) { LoggingManager.Logger.Log(LoggingCategory.Error, StringsResource.FailedToContactTicketingBridge + " " + ex.Message); throw new TicketingException(StringsResource.TicketingFailed + " " + ex.Message, ex); } finally { if ((callback_prox != null) && ((callback_prox as ICommunicationObject).State == CommunicationState.Opened)) (callback_prox as ICommunicationObject).Close(); } }