Exemple #1
0
        private IEnumerable <AgentSkill> ProcessMimeParts(IEnumerable <MimePartContentDescription> contextualData, out productType productInformation)
        {
            List <AgentSkill> listOfRequestedSkills = new List <AgentSkill>();

            List <MimePartContentDescription> listOfMimeParts = new List <MimePartContentDescription>(contextualData);

            productType product = null;

            _logger.Log(String.Format("Processing MIME parts {0}", listOfMimeParts.Count));

            bool success = true;

            listOfMimeParts.ForEach(mp =>
            {
                if (mp.ContentType.Equals(new ContentType("application/octet-stream")))
                {
                    try
                    {
                        //Now deserialize and make sure we have right data.

                        XmlSerializer serializer = new XmlSerializer(typeof(productType));

                        product = SerializerHelper.DeserializeObjectFragment(mp.GetBody(), serializer) as productType;

                        if (product != null &&
                            product.agentSkillsList != null &&
                            product.agentSkillsList.Length > 0)
                        {
                            List <agentSkillType> list = new List <agentSkillType>(product.agentSkillsList);
                            list.ForEach(sk =>
                            {
                                _logger.Log(String.Format("Finding skill name {0}", sk.name));
                                Skill skillFound = Skill.FindSkill(sk.name, _matchMaker.Configuration.Skills);
                                if (null != skillFound)
                                {
                                    if (!String.IsNullOrEmpty(sk.Value))
                                    {
                                        try
                                        {
                                            AgentSkill agentSkill = new AgentSkill(skillFound, sk.Value);
                                            listOfRequestedSkills.Add(agentSkill);
                                            _logger.Log(String.Format("Adding agent skill {0} value = {1}", skillFound, sk.Value));
                                        }
                                        catch (ArgumentException aex)
                                        {
                                            _logger.Log(String.Format("AcdPortal detected a skill value that is not provisioned {0}", sk.Value), aex);
                                        }
                                    }
                                }
                                else
                                {
                                    _logger.Log(String.Format("Skill name {0}. Not found", sk.name));
                                }
                            });
                        }
                        else
                        {
                            _logger.Log("Product is null or agentSkillsList is empty");
                        }
                    }
                    catch (XmlException xex)
                    {
                        _logger.Log("AcdPortal detected a derialization isssue", xex);
                        success = false;
                    }
                }
                else
                {
                    _logger.Log("Invalid content type");
                }
            });


            productInformation = product;


            if (success)
            {
                return(listOfRequestedSkills);
            }
            else
            {
                return(new List <AgentSkill>());
            }
        }