示例#1
0
        /// <summary>
        /// Compares 2 scores.
        /// </summary>
        /// <param name="score">The score definition.</param>
        /// <param name="oldScore">The previous score.</param>
        /// <param name="newScore">The new score.</param>
        /// <returns>A message with the differences between scores.</returns>
        private string CompareScores(BaseScore score, string[][] oldScore, string[][] newScore)
        {
            if (oldScore == null || newScore == null)
            {
                return(String.Format("ERROR {0} {1}", oldScore == null, newScore == null));
            }

            string message = "";

            try
            {
                string scoreFormat = "";
                if (!String.IsNullOrEmpty(score.LiveConfig.Value) && score.LiveConfig.Value.Contains("{"))
                {
                    scoreFormat = score.LiveConfig.Value;
                }

                string[] filters = score.LiveConfig.filter.Split(',');
                string   sep     = m_center.GetParameterValue("DiffSeparator", "*");

                // for all row of old score
                for (int iRow = 0; iRow < oldScore.Length; iRow++)
                {
                    // ignore missing row in new score
                    if (newScore.Length <= iRow || newScore[iRow] == null)
                    {
                        continue;
                    }

                    // format the row
                    string newRow = BuildScore(scoreFormat, newScore[iRow]);

                    // if old score is missing then new is new
                    if (oldScore[iRow] == null)
                    {
                        message = AddToMessage(message, newRow, filters);
                        continue;
                    }

                    // format the old row the same way
                    string oldRow = BuildScore(scoreFormat, oldScore[iRow]);

                    // compare old and new
                    if (!String.Equals(oldRow, newRow))
                    {
                        Tools.LogMessage("OLD = {0}", oldRow);
                        Tools.LogMessage("NEW = {0}", newRow);
                        var zz = score.GetDifferences(oldRow, newRow);
                        message = AddToMessage(message, ScoreDifference.StringFromList(zz, sep), filters);
                    }
                }
            }
            catch (Exception exc)
            {
                Tools.LogError("CompareScore", exc);
                message = "ERROR";
            }

            return(message);
        }