/// <summary>
        /// Get the list of Respondent attributes from the Respondent Catalog webservice response
        /// </summary>
        /// <param name="respondentCatalogAttributesResponse"></param>
        /// <returns>Dictionary with the respondent Attributes</returns>
        public Dictionary<string, string> ProcessRespondentCatalogAttributesResponse(string respondentCatalogAttributesResponse)
        {
            var respondentCatalogueAttributes = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            try
            {
                //Load xml
                var xdoc = new XmlUtil().ParseXmlDocument(respondentCatalogAttributesResponse);

                respondentCatalogueAttributes = xdoc.Descendants("Item")
                    .Select(x =>
                    {
                        var xElement = x.Element("Ident");

                        return xElement != null ? new
                        {
                            name = xElement.Value,
                            id = ((x.Element("Value") != null && string.Equals(xElement.Value, Corebirthdate, StringComparison.OrdinalIgnoreCase) && x.Element("Value").Value.Length >= 10) ? x.Element("Value").Value.Substring(0, 10) : x.Element("Value").Value),
                        } :

                                     new
                                     {
                                         name = NoAttributes,
                                         id = x.Element("Message").Value
                                     }
                                     ;
                    })
                    .Where(x => x.name != null)
                    .ToDictionary(x => x.name, x => x.id);

                if (respondentCatalogueAttributes.ContainsKey(NoAttributes))
                    return new Dictionary<string, string>();

            }
            catch
            {
            }
            return respondentCatalogueAttributes;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the list of studies filtered by the activities: Screened, Completed,QuotaFull
        /// </summary>
        /// <param name="liveMatchStudiesActivityResponse"></param>
        /// <returns>Return list of studies filtered by the activities: Screened, Completed,QuotaFull </returns>
        /// 
        public List<string> ProcessLiveMatchStudiesActivityResponse(string liveMatchStudiesActivityResponse)
        {
            var studiesActivitiesDictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            var studiesList = new List<string>();

            try
            {
                //Load xml
                var xdoc = new XmlUtil().ParseXmlDocument(liveMatchStudiesActivityResponse);
                studiesList = (from c in xdoc.Descendants("NonGTMStudyData")
                               let xElement = c.Element("ActivityType")
                               let element = c.Element("StudyId")
                               where xElement != null && element != null && (xElement.Value == Completed || xElement.Value == QuotaFull || xElement.Value == Screened)
                               select element.Value).Distinct().ToList();
            }
            catch
            {
                throw;
            }
            return studiesList;
        }