Esempio n. 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);
            }
        }
Esempio n. 2
0
        protected Array GetTableArray(string tableName, string[] indexArray)
        {
            CATable caTable = GetResultTable(tableName);

            if (!caTable.SetIndexOrder(indexArray))
            {
                const string message = "SetIndexOrder() failed";
                Logger.Error(message + " " + tableName);
                throw new Exception(message);
            }

            dynamic safeArray = caTable.GetSafeArray();
            Array   array     = (Array)safeArray;

            return(array);
        }
Esempio n. 3
0
        public void InitializeTables(Dictionary <string, string[]> tableIndicesDictionary)
        {
            foreach (KeyValuePair <string, string[]> keyValuePair in tableIndicesDictionary)
            {
                string   tableName  = keyValuePair.Key;
                string[] indexArray = keyValuePair.Value;

                CATable caTable = GetDefTable(tableName);

                if (!caTable.SetIndexOrder(indexArray))
                {
                    const string message = "SetIndexOrder() failed";
                    Logger.Error(message);
                    throw new Exception(message);
                }

                const double initialValue = 0L;
                InitializeTable(caTable, initialValue);
            }
        }
Esempio n. 4
0
        public Array LogTableValues(CATable caTable, string[] indexArray)
        {
            if (caTable == null)
            {
                const string message = "caTable is null";
                Logger.Error(message);
                throw new ArgumentNullException(nameof(caTable));
            }

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

            dynamic safeArray = caTable.GetSafeArray();
            Array   array     = (Array)safeArray;

            return(array);
        }