Exemplo n.º 1
0
        public static DataTypes.GetSendStatisticsResult ParseGetSendStatisticsResult(string xmlResponse)
        {
            var result = new DataTypes.GetSendStatisticsResult();

            var root = XElement.Parse(xmlResponse);
            var response = root.Descendants(SesNs + "GetSendStatisticsResult").FirstOrDefault();
            if (response != null)
            {
                result.SendDataPoints = (from member in response.Descendants(SesNs + "member")
                    select new DataTypes.SendDataPoint
                    {
                        
                        Bounces = long.Parse(member.Descendants(SesNs + "Bounces").First().Value),
                        Complaints = long.Parse(member.Descendants(SesNs + "Complaints").First().Value),
                        DeliveryAttempts = long.Parse(member.Descendants(SesNs + "DeliveryAttempts").First().Value),
                        Rejects = long.Parse(member.Descendants(SesNs + "Rejects").First().Value),
                        Timestamp = DateTime.Parse(member.Descendants(SesNs + "Timestamp").First().Value)
                    });
            }
            return result;
        }
Exemplo n.º 2
0
        public static DataTypes.GetSendStatisticsResult ParseGetSendStatisticsResultJson(string jsonResponse)
        {
            var result = new DataTypes.GetSendStatisticsResult();

            var root = JObject.Parse(jsonResponse);
            var response = root.SelectToken("GetSendStatisticsResponse.GetSendStatisticsResult.SendDataPoints");
            if (response != null && response.Children().Count() > 0)
            {
                result.SendDataPoints = (from member in response.Children()
                                         select new DataTypes.SendDataPoint
                                         {

                                             Bounces = member["Complaints"].Value<long>(),
                                             Complaints = member["Bounces"].Value<long>(),
                                             DeliveryAttempts = member["DeliveryAttempts"].Value<long>(),
                                             Rejects = member["Rejects"].Value<long>(),
                                             Timestamp = UnixTimeStampToDateTime(member["Timestamp"].Value<double>())
                                         });
            }
            return result;
        }