/// <summary>
        /// Method to parse service response and create contact center information.
        /// </summary>
        /// <returns>Contact center information.</returns>
        /// <exception cref="XmlException">Thrown when deserialization fails.</exception>
        private static ContactCenterInformation DeserializeResponseData(byte[] responseBytes)
        {
            ContactCenterInformation contactCenterInformation = null;

            if (responseBytes != null && responseBytes.Length > 0)
            {
                XmlSerializer           serializer         = new XmlSerializer(typeof(queueUriMappingListType));
                queueUriMappingListType deserializedResult = CommonHelper.DeserializeObjectFragment(responseBytes, serializer) as queueUriMappingListType;
                if (deserializedResult != null && deserializedResult.queueUriMapping != null && deserializedResult.queueUriMapping.Length > 0)
                {
                    Dictionary <string, string> mappingData = new Dictionary <string, string>(deserializedResult.queueUriMapping.Length);
                    foreach (queueUriMappingType queueUriMapping in deserializedResult.queueUriMapping)
                    {
                        if (queueUriMapping != null && !String.IsNullOrEmpty(queueUriMapping.queueName) && !String.IsNullOrEmpty(queueUriMapping.uriValue))
                        {
                            mappingData.Add(queueUriMapping.queueName, queueUriMapping.uriValue);
                        }
                    }
                    contactCenterInformation = new ContactCenterInformation(mappingData);
                }
            }
            return(contactCenterInformation);
        }
예제 #2
0
            private void OnDefaultRoutingEndpointMessageReceived(object sender, MessageReceivedEventArgs args)
            {
                //First verify the origin to see whether it is a legitimate source (i.e. Contact Center WCF Service)
                List <SignalingHeader> listOfHeaders = new List <SignalingHeader>(args.RequestData.SignalingHeaders);

                listOfHeaders.ForEach(header =>
                {
                    if (header.Name.Equals("Contact", StringComparison.OrdinalIgnoreCase))
                    {
                        // check whether the contact address is a trusted GRUU and thus a legitimate source
                        if (_acdPlatform._platform.TopologyConfiguration.IsTrusted(args.Participant.ContactUri))
                        {
                            //check that the verb and content-type of the incoming request
                            if (args.MessageType == MessageType.Service &&
                                args.ContentType != null &&
                                args.ContentType.Equals(this.DiscoveryContentType))
                            {
                                // this is a legitimate request, let's return the list of portals to the requestor.
                                // the information needed consists of a collection of token representing the portal and its SIP URI
                                _acdPlatform._wcfAnonymousSubscriberUri = args.Participant.Uri;

                                _acdPlatform.UpdateAcdPlatformAnonymousSubscriberUri(_acdPlatform._wcfAnonymousSubscriberUri);

                                try
                                {
                                    // construct the list of Portals that need to be sent back.
                                    queueUriMappingListType contactCenterDiscoveryInfo = new queueUriMappingListType();

                                    contactCenterDiscoveryInfo.queueUriMapping = new queueUriMappingType[_acdPlatform._configuration.PortalConfigurations.Count];

                                    int i = 0;

                                    _acdPlatform._configuration.PortalConfigurations.ForEach(portalConfig =>
                                    {
                                        queueUriMappingType portalDiscoveryInfo = new queueUriMappingType();
                                        portalDiscoveryInfo.queueName           = portalConfig.Token;
                                        portalDiscoveryInfo.uriValue            = portalConfig.Uri;

                                        contactCenterDiscoveryInfo.queueUriMapping[i++] = portalDiscoveryInfo;
                                    });


                                    //Serialize using XmlSerializer.

                                    XmlSerializer serializer = new XmlSerializer(typeof(queueUriMappingListType));
                                    string discoveryResponse = SerializerHelper.SerializeObjectFragment(contactCenterDiscoveryInfo, serializer);


                                    args.SendResponse(ResponseCode.Success,
                                                      new ContentType("application/ContactCenterDiscovery+xml"),
                                                      discoveryResponse,
                                                      null);
                                }


                                catch (XmlException xe)
                                {
                                    _acdPlatform._logger.Log("AcdPlatform experienced an issue serializing the Contact Center discovery info", xe);
                                }
                                catch (InvalidOperationException ivoex)
                                {
                                    _acdPlatform._logger.Log("AcdPlatform failed to respond to a portal discovery request", ivoex);
                                }
                                catch (RealTimeException rtex)
                                {
                                    _acdPlatform._logger.Log("AcdPlatform failed to respond to a portal discovery request", rtex);
                                }
                            }
                        }
                    }
                });
            }