示例#1
0
        private void LoadTable(CATable caTable, string[] indexArray, Dictionary <string, double> dictionary, string tableName)
        {
            if (caTable == null)
            {
                string message = $"caTable name is null {tableName}";
                Logger.Error(message);
                throw new ArgumentNullException(nameof(caTable));
            }

            if (dictionary == null)
            {
                const string message = "dictionary is null";
                Logger.Error(message);
                throw new ArgumentNullException(nameof(dictionary));
            }

            if (!caTable.SetIndexOrder(indexArray))
            {
                string message = $"LoadTable() failed, SetIndexOrder() failed: indexArray = {ConvertIndexArrayToString(indexArray)}  {tableName}";
                Logger.Error(message);
                throw new Exception(message);
            }

            if (dictionary.Count == 0)
            {
                Logger.Error("LoadTable(): dictionary is empty");
                return;
            }

            foreach (KeyValuePair <string, double> keyValuePair in dictionary)
            {
                string key   = keyValuePair.Key;
                double value = keyValuePair.Value;

                const char comma       = ',';
                string[]   indexArray2 = key.Split(comma);

                if (!caTable.SetDataByLabels(value, indexArray2))
                {
                    string message = $"UpdateTable failed: SetDataByLabels() failed: indexArray = {ConvertIndexArrayToString(indexArray2)}, value = {value}, ErrorText = {_caEngine.ErrorText} {tableName}";
                    Logger.Error(message);
                    throw new Exception(message);
                }
            }

            if (!caTable.Update())
            {
                const string message = "Update() failed";
                Logger.Error(message);
                throw new Exception(message);
            }
        }
示例#2
0
        private void SetSecondFoulPossession(NbaGame nbaGame)
        {
            CATable caTable = GetDefTable("EGT");

            string[] indexArray = { "S" };
            int      seconds    = nbaGame.NbaScore.Seconds;

            if (!caTable.SetDataByLabels(seconds, indexArray))
            {
                string message = $"SetDataByLabels() failed: seconds = {seconds}, indexArray1 = {ConvertIndexArrayToString(indexArray)}";
                Logger.Error(message);
                throw new Exception(message);
            }

            indexArray = new[] { "F" };
            int foul = nbaGame.Foul;

            if (!caTable.SetDataByLabels(foul, indexArray))
            {
                string message = $"SetDataByLabels() failed: foul = {foul}, indexArray2 = {ConvertIndexArrayToString(indexArray)}";
                throw new Exception(message);
            }

            indexArray = new[] { "P" };
            string possession = $"{nbaGame.Possession}";

            Logger.Info($"possession = {possession}, indexArray3 = {ConvertIndexArrayToString(indexArray)}");

            // todo bug here
            if (!caTable.SetDataByLabels(possession, indexArray))
            {
                throw new Exception($"SetDataByLabels() failed: possession = {possession}, indexArray3 = {ConvertIndexArrayToString(indexArray)}");
            }

            if (!caTable.Update())
            {
                throw new Exception("Update() failed");
            }
        }