コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="result"></param>
        internal static void Read(XmlReader reader, PreApprovalSearchResult result)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(PreApprovalSearchResultSerializer.PreApprovalSearchResult);

            reader.MoveToContent();

            while (!reader.EOF)
            {

                if (XMLParserUtils.IsEndElement(reader, PreApprovalSearchResultSerializer.PreApprovalSearchResult))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case PreApprovalSearchResultSerializer.Date:
                            result.Date = reader.ReadElementContentAsDateTime();
                            break;
                        case PreApprovalSearchResultSerializer.CurrentPage:
                            result.CurrentPage = reader.ReadElementContentAsInt();
                            break;
                        case PreApprovalSearchResultSerializer.TotalPages:
                            result.TotalPages = reader.ReadElementContentAsInt();
                            break;
                        case PreApprovalSummaryListSerializer.PreApprovals:
                            PreApprovalSummaryListSerializer.Read(reader, result.PreApprovals);
                            break;
                        default:
                            XMLParserUtils.SkipElement(reader);
                            break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Finds a pre-approval with a matching date interval
 /// </summary>
 /// <param name="credentials">PagSeguro credentials</param>
 /// <param name="initialDate"></param>
 /// <param name="finalDate">End of date range. Use DateTime.MaxValue to search without an upper boundary.</param>
 /// <param name="pageNumber">Page number, starting with 1. If passed as 0, it will call the web service to get the default page, also page number 1.</param>
 /// <param name="resultsPerPage">Results per page, optional.</param>
 /// <returns></returns>
 public static PreApprovalSearchResult SearchByDate(Credentials credentials, DateTime initialDate, DateTime finalDate, int? pageNumber = null, int? resultsPerPage = null)
 {
     PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "PreApprovalSearchService.SearchByDate(initialDate={0} - finalDate={1}) - begin", initialDate, finalDate));
     try
     {
         using (HttpWebResponse response = HttpURLConnectionUtil.GetHttpGetConnection(BuildSearchUrlByDate(credentials, initialDate, finalDate, pageNumber, resultsPerPage)))
         {
             using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
             {
                 PreApprovalSearchResult preApproval = new PreApprovalSearchResult();
                 PreApprovalSearchResultSerializer.Read(reader, preApproval);
                 PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "PreApprovalSearchService.SearchByDate(initialDate={0} - finalDate={1}) - end {2}", initialDate, finalDate, preApproval));
                 return preApproval;
             }
         }
     }
     catch (WebException exception)
     {
         PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
         PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "PreApprovalSearchService.SearchByDate(initialDate={0} - finalDate={1}) - error {2}", initialDate, finalDate, pse));
         throw pse;
     }
 }
コード例 #3
0
        /// <summary>
        /// Finds a pre-approval with a matching day interval
        /// </summary>
        /// <param name="credentials">PagSeguro credentials</param>
        /// <param name="interval">Day interval</param>
        /// <returns cref="T:Uol.PagSeguro.PreApprovalSearchResult"><c>PreApprovalSearchResult</c></returns>
        public static PreApprovalSearchResult SearchByInterval(Credentials credentials, int interval)
        {
            PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "PreApprovalSearchService.SearchByInterval(Days={0}) - begin", interval));

            try
            {
                using (HttpWebResponse response = HttpURLConnectionUtil.GetHttpGetConnection(BuildSearchUrlByInterval(credentials, interval)))
                {
                    using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
                    {
                        PreApprovalSearchResult preApproval = new PreApprovalSearchResult();
                        PreApprovalSearchResultSerializer.Read(reader, preApproval);
                        PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "PreApprovalSearchService.SearchByInterval(Days={0}) - end {1}", interval, preApproval));
                        return preApproval;
                    }
                }
            }
            catch (WebException exception)
            {
                PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
                PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "PreApprovalSearchService.SearchByInterval(Days={0}) - error {1}", interval, pse));
                throw pse;
            }
        }