示例#1
0
        public Match ParseFromUrl()
        {
            html = HtmlDocumentCreator.Get(url);
            Match match = new Match
            {
                Id         = url,
                Attendence = GetAttendence(),
                AwayTeam   = GetAwayTeam(),
                HomeTeam   = GetHomeTeam(),
                Referee    = GetReferee(),
                Time       = GetTime()
            };

            SetLeague(match);
            GetResult(match);
            return(match);
        }
示例#2
0
        static List <Match> HandleSeason(string seasonUrl)
        {
            var seasonDocument = HtmlDocumentCreator.Get(seasonUrl);
            var matchUrls      = seasonDocument.DocumentNode
                                 .Descendants("a")
                                 .Where(a => a.GetAttributeValue("href", "").Contains("id_mecz"))
                                 .Select(a => a.GetAttributeValue("href", ""))
                                 .ToList()
                                 .Distinct();
            List <Match> matches = new List <Match>();

            foreach (string matchUrl in matchUrls)
            {
                matches.Add(HandleMatch(@"http://www.90minut.pl/" + matchUrl));
            }
            return(matches);
        }
        public static SimpleLoadResponse ExecuteLoad(LoadSettings loadSettings, Order2 waitingPaidOrder)
        {
            //1. Generate crypto values:
            CardSettings settings = CryptoHelper.GetRandomSettings();

            //2. Fill letter:
            string errorMessage = HtmlDocumentCreator.ModifyHtmlFile(settings, waitingPaidOrder);

            if (errorMessage != null)
            {
                lastLoaded = null;
                return(new SimpleLoadResponse {
                    ErrorMessage = errorMessage
                });
            }

            //3. Send to printer:
            //Happens automatically in main window on ExecuteLoad success.

            //4. Email requires pre-known address... type-able to begin with? Will consider... it IS a lot to insert bits and send an email.
            //TODO

            //5. Insert variables into card image file:
            errorMessage = CardFileCreator.ModifyCardFile(settings, loadSettings);
            if (errorMessage != null)
            {
                lastLoaded = null;
                return(new SimpleLoadResponse {
                    ErrorMessage = errorMessage
                });
            }


            //6. Load card:
            errorMessage = CardLoader.LoadCard(loadSettings);
            if (errorMessage != null)
            {
                lastLoaded = null;
                return(new SimpleLoadResponse {
                    ErrorMessage = errorMessage
                });
            }

            //7 Delete the generated card settings file containing the private key:
            errorMessage = CardLoader.DeleteCardFile(CardFileCreator.outputPath);
            if (errorMessage != null)
            {
                lastLoaded = null;
                return(new SimpleLoadResponse {
                    ErrorMessage = errorMessage
                });
            }

            //8. Save order to simple database.
            if (!loadSettings.TestSettings)
            {
                OrderDB db    = new OrderDB();
                Order2  order = new Order2
                {
                    OrderNumber = settings.OrderNumber,
                    Password    = settings.aesPassword,
                    Address     = settings.AddressString,
                    WebOrder    = false
                };
                db.SaveOrder(order);
                lastLoaded = order;
            }

            return(new SimpleLoadResponse
            {
                Success = true,
                ErrorMessage = null
            });
        }