コード例 #1
0
        /// <summary>
        /// Override process method.
        /// </summary>
        public override void Process()
        {
            bool      unhandledExceptionDetected = true;
            Exception exceptionCaught            = null;

            try
            {
                RealTimeEndpoint   innerEndpoint = this.LocalEndpoint.InnerEndpoint;
                SendMessageOptions options       = new SendMessageOptions();
                options.ContentDescription = ContactCenterDiscoveryAsyncResult.GetDiscoveryRequestContentDescription();
                RealTimeAddress targetAddress = new RealTimeAddress(this.TargetUri);
                innerEndpoint.BeginSendMessage(MessageType.Service, targetAddress, options, this.ServiceRequestCompleted, innerEndpoint /*state*/);
                unhandledExceptionDetected = false;
            }
            catch (ArgumentException ae)
            {
                Helper.Logger.Error("Exception = {0}", EventLogger.ToString(ae));
                exceptionCaught            = ae;
                unhandledExceptionDetected = false;
            }
            catch (InvalidOperationException ioe)
            {
                Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe));
                exceptionCaught            = ioe;
                unhandledExceptionDetected = false;
            }
            catch (RealTimeException rte)
            {
                Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte));
                exceptionCaught            = rte;
                unhandledExceptionDetected = false;
            }
            finally
            {
                if (unhandledExceptionDetected)
                {
                    exceptionCaught = new Exception("Unhandled exception");
                    Helper.Logger.Info("Exception = {0}", EventLogger.ToString(exceptionCaught));
                }

                if (exceptionCaught != null)
                {
                    this.Complete(exceptionCaught);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Callback method for service completed.
        /// </summary>
        /// <param name="asyncResult">Async result.</param>
        private void ServiceRequestCompleted(IAsyncResult asyncResult)
        {
            RealTimeEndpoint innerEndpoint = asyncResult.AsyncState as RealTimeEndpoint;

            Debug.Assert(null != innerEndpoint, "Inner endpoint is null");
            bool      unhandledExceptionDetected = true;
            Exception exceptionCaught            = null;
            ContactCenterInformation result      = null;

            try
            {
                SipResponseData serviceResponse = innerEndpoint.EndSendMessage(asyncResult);
                byte[]          responseBody    = serviceResponse.GetMessageBody();

                if (responseBody != null)
                {
                    result = ContactCenterDiscoveryAsyncResult.DeserializeResponseData(responseBody);
                }

                if (result == null)
                {
                    //Deserialziation failed.
                    exceptionCaught = new XmlException("Deserialization of queue uri mapping failed");
                }
                unhandledExceptionDetected = false;
            }
            catch (XmlException xe)
            {
                exceptionCaught            = xe;
                unhandledExceptionDetected = false;
            }
            catch (ArgumentException ae)
            {
                exceptionCaught            = ae;
                unhandledExceptionDetected = false;
            }
            catch (RealTimeException rte)
            {
                exceptionCaught            = rte;
                unhandledExceptionDetected = false;
            }
            finally
            {
                if (unhandledExceptionDetected)
                {
                    exceptionCaught = new Exception("Unhandled exception");
                    Helper.Logger.Info("Exception = {0}", EventLogger.ToString(exceptionCaught));
                }

                if (exceptionCaught != null)
                {
                    Helper.Logger.Error("Exception = {0}", EventLogger.ToString(exceptionCaught));
                    this.Complete(exceptionCaught);
                }
                else
                {
                    Debug.Assert(null != result, "If no exception occured, we expect a valid result");
                    this.Complete(result);
                }
            }
        }