예제 #1
0
        public static bool ChangeCurrentCard(PaymentCard card)
        {
            // initialize mbottom.asp get request
            var request = (HttpWebRequest)WebRequest.Create(
                String.Concat("https://www.sbsibank.by/mbottom.asp?crd_id=", card.Id));
            AddCommonHeadersToHttpRequest(request);
            request.Referer = "https://www.sbsibank.by/right.asp";

            // get response
            Log.InfoFormat("Change current card id to {0} at https://www.sbsibank.by/mbottom.asp?crd_id={0}", card.Id);
            // get response
            using (var response = (HttpWebResponse)request.GetResponse())
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    _currentCard = card;
                    return true;
                }
            }
            return false;
        }
예제 #2
0
        public static IEnumerable<PaymentCard> ParseCardList(StreamReader content)
        {
            var cards = new List<PaymentCard>();
            var htmlDocument = new HtmlDocument();
            htmlDocument.Load(content);
            var html = htmlDocument.DocumentNode;

            var cardsHtml = html.CssSelect("input[type=radio][name=R1]");
            foreach (var cardHtml in cardsHtml.Where(card => card.HasAttributes))
            {
                var card = new PaymentCard
                               {
                                   Id =
                                       cardHtml.Attributes["Value"] != null
                                           ? cardHtml.Attributes["Value"].Value
                                           : String.Empty,
                                   Name = cardHtml.NextSibling.CssSelect("i").First().InnerText
                               };

                Log.InfoFormat("Card name: {0}", card.Name);

                if (card.Id != null)
                {
                    Log.InfoFormat("Card id: {0}", card.Id);
                }
                cards.Add(card);
            }
            return cards;
        }