Esempio n. 1
0
        private void SetRules(GenericScore score)
        {
            grdRule.Rows.Clear();
            if (score.Rules == null)
            {
                return;
            }

            foreach (Rule rule in score.Rules)
            {
                Style st = m_center.FindStyle(rule.Format);
                grdRule.Rows.Add(rule.Column.ToString(),
                                 rule.Operator.ToString(),
                                 rule.Value,
                                 rule.Action.ToString(),
                                 st == null ? String.Empty : rule.Format);
            }
        }
        /// <summary>
        /// Defines a League.
        /// </summary>
        /// <param name="wfscore">The Worldfootball definition.</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        private static List <BaseScore> DefineLeague(WorldFootballScore wfscore, ScoreParameter[] parameters)
        {
            int index = 0;
            List <BaseScore> scores   = new List <BaseScore>();
            string           fullname = wfscore.FullLeagueName + "-" + wfscore.Season;

            ScoreDetails details = GetScoreDetails(wfscore, parameters);
            int          round   = details.Round;

            // add results
            details.AddResults(scores, round, IMG_RESULTS, fullname, index++);

            // Standings
            string element  = "0";
            string nbLeague = wfscore.Details.Split(',').FirstOrDefault(x => x.Contains(";"));

            if (!String.IsNullOrEmpty(nbLeague))
            {
                element = nbLeague;
            }

            GenericScore sc = CreateNewScore(wfscore.Id, "table", "Standings", IMG_STANDINGS, element, index++);

            sc.BetweenElts = BetweenElements.RepeatHeader;
            sc.Url         = String.Format("{0}spielplan/{1}-spieltag/{2}/tabelle/", WF_URL, fullname, round);
            sc.Skip        = 1;
            sc.Sizes       = ScoreCenter.GetParameter(parameters, "WF.LeagueStandings", SIZES_STANDINGS);
            sc.Dictionary  = "WF.table";
            sc.Headers     = ScoreCenter.GetParameter(parameters, "WF.HeaderStandings", HEADERS_STANDINGS);
            sc.AddLevelsRule(wfscore.Levels);
            sc.AddHighlightRule(wfscore.Highlights, 3, RuleAction.FormatLine);
            scores.Add(sc);

            details.AddTopScorerScore(scores, fullname, index++);
            details.AddAssistsScore(scores, fullname, index++);
            details.AddStadiumScore(scores, fullname, index++);
            details.AddRefereeScore(scores, fullname, index++);
            details.AddHistoryScore(scores, index++);
            details.AddTopScorerHistScore(scores, index++);

            return(scores);
        }
Esempio n. 3
0
        public override void LoadScore(BaseScore baseScore, ScoreCenter center)
        {
            m_center = center;
            UpdateStyleList();

            GenericScore score = baseScore as GenericScore;

            if (score == null)
            {
                throw new NullReferenceException("Not a generic score!");
            }

            errorProvider1.Clear();

            // always clear
            tbxScore.Clear();
            tbxUrl.Clear();
            tbxXpath.Clear();
            tbxXPathRow.Clear();
            tbxXPathCol.Clear();
            tbxEncoding.Clear();
            tbxHeaders.Clear();
            tbxSizes.Clear();
            tbxSkip.Clear();
            tbxMaxLines.Clear();
            tbxElement.Clear();
            ckxUseTheader.Checked    = false;
            ckxUseCaption.Checked    = false;
            ckxImgAlt.Checked        = false;
            ckxNewLine.Checked       = false;
            ckxAllowWrapping.Checked = false;
            ckxLive.Checked          = false;
            tbxLiveFormat.Clear();
            tbxLiveFilter.Clear();
            tbxDictionary.Clear();

            grdRule.Rows.Clear();
            grdRule.Enabled = false;

            // score
            EnableControls();
            tbxLiveFormat.Enabled = false;
            tbxLiveFilter.Enabled = false;

            ParsingOptions options = score.GetParseOption();

            tbxScore.Text = score.Name;

            tbxUrl.Text        = score.Url;
            tbxXpath.Text      = score.XPath;
            tbxXPathRow.Text   = score.XPathRow;
            tbxXPathCol.Text   = score.XPathCol;
            tbxEncoding.Text   = score.Encoding;
            tbxHeaders.Text    = score.Headers;
            tbxSizes.Text      = score.Sizes;
            tbxSkip.Text       = score.Skip.ToString();
            tbxMaxLines.Text   = score.MaxLines.ToString();
            tbxElement.Text    = score.Element;
            tbxDictionary.Text = score.Dictionary;

            if (score.LiveConfig != null)
            {
                ckxLive.Checked    = score.LiveConfig.enabled;
                tbxLiveFormat.Text = score.LiveConfig.Value;
                tbxLiveFilter.Text = score.LiveConfig.filter;
            }

            ckxUseTheader.Checked            = Tools.CheckParsingOption(options, ParsingOptions.UseTheader);
            ckxUseCaption.Checked            = Tools.CheckParsingOption(options, ParsingOptions.Caption);
            ckxNewLine.Checked               = Tools.CheckParsingOption(options, ParsingOptions.NewLine);
            ckxAllowWrapping.Checked         = Tools.CheckParsingOption(options, ParsingOptions.WordWrap);
            ckxReverseOrder.Checked          = Tools.CheckParsingOption(options, ParsingOptions.Reverse);
            ckxImgAlt.Checked                = Tools.CheckParsingOption(options, ParsingOptions.ImgAlt);
            cbxBetweenElements.SelectedValue = score.BetweenElts;
            tbxScoreId.Text = score.Id;

            grdRule.Enabled = true;
            SetRules(score, center);
        }
        /// <summary>
        /// Defines a Qualification Tournament.
        /// </summary>
        /// <param name="wfscore">The Worldfootball definition.</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        private static List <BaseScore> DefineQualification(WorldFootballScore wfscore, ScoreParameter[] parameters)
        {
            int index = 0;
            List <BaseScore> scores = new List <BaseScore>();
            GenericScore     sc     = null;

            string fullname = wfscore.FullLeagueName;

            if (String.IsNullOrEmpty(wfscore.Season) == false)
            {
                fullname += "-" + wfscore.Season;
            }

            // add results scores
            sc = CreateNewScore(wfscore.Id, "results", "Results", IMG_RESULTS, "2", index++);
            string competition = ScoreCenter.GetParameter(parameters, "WF.Competition", KEY_COMPETITION);

            sc.Url   = String.Format("{0}{2}/{1}/", WF_URL, wfscore.FullLeagueName, competition);
            sc.Sizes = ScoreCenter.GetParameter(parameters, "WF.Results", SIZES_RESULTS);
            sc.AddRule(3, Operation.IsNull, "", RuleAction.MergeCells, "Header");
            sc.LiveConfig = LiveConfig.Copy(wfscore.LiveConfig, ScoreCenter.GetParameter(parameters, "WF.LiveFormat", "{2} {5} {4}"));
            sc.SetCanLive(true);
            sc.Element = "0";
            scores.Add(sc);

            // retrieve details: first element is the list of groups
            List <string> items = wfscore.Details.Split(',').ToList();

            char[] groups = items[0].ToCharArray();
            foreach (char g in groups)
            {
                // add group results
                sc       = CreateNewScore(wfscore.Id, "gr" + g, String.Format("Group {0}", Char.ToUpper(g)), "", "0", index++);
                sc.Url   = String.Format("{0}spielplan/{1}-gruppe-{2}/0/", WF_URL, fullname, g);
                sc.Sizes = ScoreCenter.GetParameter(parameters, "WF.GroupResults", SIZES_GROUP_RESULTS);
                sc.Image = String.Format(@"Groups\Group{0}", Char.ToUpper(g));
                sc.AddRule(3, Operation.IsNull, "", RuleAction.MergeCells, "Header");
                sc.AddHighlightRule(wfscore.Highlights, 0, RuleAction.FormatCell);
                scores.Add(sc);

                // add group standings
                sc         = CreateNewScore(wfscore.Id, "resgr" + g, "Standings", "", "1", index++);
                sc.Url     = String.Format("{0}spielplan/{1}-gruppe-{2}/0/", WF_URL, fullname, g);
                sc.Skip    = 1;
                sc.Headers = ScoreCenter.GetParameter(parameters, "WF.HeaderStandings", HEADERS_STANDINGS);
                sc.Sizes   = ScoreCenter.GetParameter(parameters, "WF.GroupStandings", SIZES_GROUP_STANDINGS);
                sc.Image   = String.Format(@"Groups\Table{0}", Char.ToUpper(g));
                sc.AddHighlightRule(wfscore.Highlights, 3, RuleAction.FormatLine);
                scores.Add(sc);
            }

            // add rounds
            foreach (string round in items)
            {
                if (round == items[0])
                {
                    continue;
                }
                if (round == "stadium" || round == "referee")
                {
                    continue;
                }
                sc       = CreateNewScore(wfscore.Id, round, round, IMG_RESULTS, "0", index++);
                sc.Url   = String.Format("{0}spielplan/{1}-{2}/0/", WF_URL, fullname, round);
                sc.Sizes = wfscore.TwoLegs && round != "finale"
                    ? ScoreCenter.GetParameter(parameters, "WF.QualificationLevel2", SIZES_QUALIFICATION_LEVEL2)
                    : ScoreCenter.GetParameter(parameters, "WF.QualificationLevel1", SIZES_QUALIFICATION_LEVEL1);
                sc.AddRule(3, Operation.IsNull, "", RuleAction.MergeCells, "Header");
                sc.AddRule(0, Operation.Contains, "{Rückspiel},", RuleAction.ReplaceText, "");
                scores.Add(sc);
            }

            // add details
            ScoreDetails details = GetScoreDetails(wfscore, parameters);

            details.AddTopScorerScore(scores, fullname, index++);
            details.AddAssistsScore(scores, fullname, index++);
            details.AddStadiumScore(scores, fullname, index++);
            details.AddRefereeScore(scores, fullname, index++);
            details.AddHistoryScore(scores, index++);
            details.AddTopScorerHistScore(scores, index++);

            return(scores);
        }
 /// <summary>
 /// Create a new score for the WorldFootball score.
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="id"></param>
 /// <param name="name"></param>
 /// <param name="image"></param>
 /// <param name="element"></param>
 /// <param name="index"></param>
 /// <returns></returns>
 private static GenericScore CreateNewScore(string parent, string id, string name,
                                            string image, string element, int index)
 {
     return(GenericScore.CreateNewScore(parent, id, name, GLOBAL_XPATH, image, element, index));
 }
Esempio n. 6
0
        public static IList <BaseScore> GetRealScores(FussballdeScore score, ScoreParameter[] parameters)
        {
            List <BaseScore> scores = new List <BaseScore>();
            GenericScore     sc     = null;
            int index = 0;

            var details = score.Details.Split(',').ToList();

            sc     = GenericScore.CreateNewScore(score.Id, C_KEY_RESULTS, "Results", XPATH_RESULTS, IMG_RESULTS, "", index++);
            sc.Url = GetUrl(score.Url, C_KEY_RESULTS);
            SetRound(sc);
            sc.Skip       = 1;
            sc.Dictionary = "Fussballde";
            sc.Sizes      = ScoreCenter.GetParameter(parameters, "Fde.SizesResults", SIZES_RESULTS);
            sc.Headers    = ScoreCenter.GetParameter(parameters, "Fde.HeaderResults", HEADER_RESULTS);
            sc.AddRule(3, Operation.Contains, CUT_BEFORE, RuleAction.CutBefore, "");
            sc.AddRule(5, Operation.Contains, CUT_BEFORE, RuleAction.CutBefore, "");
            sc.AddRule(1, Operation.Contains, "vorheriger Spieltag", RuleAction.SkipLine, "");
            sc.AddRule(1, Operation.Contains, "Verlegte Spiele", RuleAction.MergeCells, "");
            sc.AddHighlightRule(score.Highlights, 0, RuleAction.FormatCell);
            scores.Add(sc);

            sc            = GenericScore.CreateNewScore(score.Id, C_KEY_TABELLE, "Standings", XPATH_TABELLE, IMG_TABELLE, "", index++);
            sc.Url        = GetUrl(score.Url, C_KEY_TABELLE);
            sc.Skip       = 1;
            sc.Dictionary = "Fussballde";
            sc.Sizes      = ScoreCenter.GetParameter(parameters, "Fde.SizesTabelle", SIZES_TABELLE);
            sc.Headers    = ScoreCenter.GetParameter(parameters, "Fde.HeaderTabelle", HEADER_TABELLE);
            sc.AddRule(2, Operation.Contains, CUT_BEFORE, RuleAction.CutBefore, "");
            sc.AddLevelsRule(score.Levels);
            sc.AddHighlightRule(score.Highlights, 2, RuleAction.FormatLine);
            scores.Add(sc);

            if (details.Contains("runde"))
            {
                sc            = GenericScore.CreateNewScore(score.Id, "hinrunde", "1st Round", XPATH_TABELLE, IMG_TABELLE_ROUND1, "0", index++);
                sc.Url        = GetUrl(score.Url, C_KEY_RUNDE);
                sc.Skip       = 1;
                sc.Dictionary = "Fussballde";
                sc.Sizes      = ScoreCenter.GetParameter(parameters, "Fde.SizesTabelle", SIZES_TABELLE);
                sc.Headers    = ScoreCenter.GetParameter(parameters, "Fde.HeaderTabelle", HEADER_TABELLE);
                sc.AddRule(2, Operation.Contains, CUT_BEFORE, RuleAction.CutBefore, "");
                sc.AddHighlightRule(score.Highlights, 2, RuleAction.FormatLine);
                scores.Add(sc);

                sc            = GenericScore.CreateNewScore(score.Id, "rueckrunde", "2nd Round", XPATH_TABELLE, IMG_TABELLE_ROUND2, "1", index++);
                sc.Url        = GetUrl(score.Url, C_KEY_RUNDE);
                sc.Skip       = 1;
                sc.Dictionary = "Fussballde";
                sc.Sizes      = ScoreCenter.GetParameter(parameters, "Fde.SizesTabelle", SIZES_TABELLE);
                sc.Headers    = ScoreCenter.GetParameter(parameters, "Fde.HeaderTabelle", HEADER_TABELLE);
                sc.AddRule(2, Operation.Contains, CUT_BEFORE, RuleAction.CutBefore, "");
                sc.AddHighlightRule(score.Highlights, 2, RuleAction.FormatLine);
                scores.Add(sc);
            }

            sc            = GenericScore.CreateNewScore(score.Id, "heim", "Home", XPATH_TABELLE, IMG_TABELLE_HOME, "0", index++);
            sc.Url        = GetUrl(score.Url, C_KEY_HEIMAUS);
            sc.Skip       = 1;
            sc.Dictionary = "Fussballde";
            sc.Sizes      = ScoreCenter.GetParameter(parameters, "Fde.SizesTabelle", SIZES_TABELLE);
            sc.Headers    = ScoreCenter.GetParameter(parameters, "Fde.HeaderTabelle", HEADER_TABELLE);
            sc.AddRule(2, Operation.Contains, CUT_BEFORE, RuleAction.CutBefore, "");
            sc.AddHighlightRule(score.Highlights, 2, RuleAction.FormatLine);
            scores.Add(sc);

            sc            = GenericScore.CreateNewScore(score.Id, "auswaerts", "Away", XPATH_TABELLE, IMG_TABELLE_AWAY, "1", index++);
            sc.Url        = GetUrl(score.Url, C_KEY_HEIMAUS);
            sc.Skip       = 1;
            sc.Dictionary = "Fussballde";
            sc.Sizes      = ScoreCenter.GetParameter(parameters, "Fde.SizesTabelle", SIZES_TABELLE);
            sc.Headers    = ScoreCenter.GetParameter(parameters, "Fde.HeaderTabelle", HEADER_TABELLE);
            sc.AddRule(2, Operation.Contains, CUT_BEFORE, RuleAction.CutBefore, "");
            sc.AddHighlightRule(score.Highlights, 2, RuleAction.FormatLine);
            scores.Add(sc);

            if (details.Contains("fairness"))
            {
                sc            = GenericScore.CreateNewScore(score.Id, C_KEY_FAIRNESS, "Fair Play", XPATH_FAIRPLAY, IMG_REFEREE, "", index++);
                sc.Url        = GetUrl(score.Url, C_KEY_FAIRNESS);
                sc.Skip       = 1;
                sc.Dictionary = "Fussballde";
                sc.Sizes      = ScoreCenter.GetParameter(parameters, "Fde.SizesFairplay", SIZES_FAIRPLAY);
                sc.Headers    = ScoreCenter.GetParameter(parameters, "Fde.HeaderFairplay", HEADER_FAIRPLAY);
                sc.AddRule(2, Operation.Contains, CUT_BEFORE, RuleAction.CutBefore, "");
                sc.AddHighlightRule(score.Highlights, 2, RuleAction.FormatLine);
                scores.Add(sc);
            }

            if (details.Contains("torjaeger"))
            {
                sc            = GenericScore.CreateNewScore(score.Id, C_KEY_SCORER, "Top Scorers", XPATH_SCORER, IMG_TOPSCORER, "", index++);
                sc.Url        = GetUrl(score.Url, C_KEY_SCORER);
                sc.Skip       = 1;
                sc.Dictionary = "Fussballde";
                sc.Sizes      = ScoreCenter.GetParameter(parameters, "Fde.SizesScorer", SIZES_SCORER);
                sc.Headers    = ScoreCenter.GetParameter(parameters, "Fde.HeaderScorer", HEADER_SCORER);
                sc.AddRule(3, Operation.Contains, CUT_BEFORE, RuleAction.CutBefore, "");
                sc.AddHighlightRule(score.Highlights, 3, RuleAction.FormatLine);
                scores.Add(sc);
            }

            return(scores);
        }