Exemple #1
0
        /// <summary>
        /// This is called when we want to check the tables validity.  Then it calls buildFeedbackMessage so that,
        /// a a new EveryoneDict can be made with the new data.
        /// </summary>
        /// <param name="tables">This is a list of PropertiesWindow to be checked typically all of them</param>
        private void CheckChemicalStreamPropertiesWindowFeedback(IEnumerable <IPfdElement> tables)
        {
            IRule rule = new TableRule();

            List <string>            nonUniqueNames = new List <string>();
            List <IPropertiesWindow> listOfTables   = new List <IPropertiesWindow>();

            foreach (IPropertiesWindow table in tables)
            {
                rule.Target = table;
                rule.CheckRule();

                // TODO: fix (eventually)
                throw new NotImplementedException("Rule manager is broken");
                ITableAdapter tableAdapter = null;
                //ITableAdapter tableAdapter = TableAdapterFactory.CreateTableAdapter(table);
                int       i     = 0;
                int       items = tableAdapter.GetRowCount();
                TableType tableType;
                string    label, units, quantity, compound, temp;

                while (i < items)
                {
                    tableType = tableAdapter.GetTableType();
                    label     = tableAdapter.GetLabelAtRow(i);
                    units     = tableAdapter.GetUnitAtRow(i);
                    quantity  = tableAdapter.GetQuantityAtRow(i);
                    compound  = tableAdapter.GetCompoundAtRow(i);

                    if (currentDifficultySetting == OptionDifficultySetting.MaterialAndEnergyBalance)
                    {
                        temp = tableAdapter.GetTemperature();
                    }
                    else
                    {
                        //we dont need temp to just zero it out
                        temp = "0";
                    }

                    if (!tableDict.Keys.Contains(label))
                    {
                        tableDict.Add(label, new GenericTableData(table, tableType, label, units, quantity, compound, temp));
                    }
                    else
                    {
                        if (!nonUniqueNames.Contains(label))
                        {
                            nonUniqueNames.Add(label);
                        }
                        listOfTables.Add(table);
                    }
                    i++;
                }

                foreach (ValidationResult vr in rule.ValidationResults)
                {
                    if (!EveryoneDict.ContainsKey(vr.Target))
                    {
                        EveryoneDict.Add(vr.Target, new List <string>());
                    }
                    EveryoneDict[vr.Target].Add("[" + ruleNumber + "]\n-" + vr.Message + "\n");
                    ruleNumber++;
                }
            }
            if (nonUniqueNames.Count > 0)
            {
                ValidationResult vr = (new ValidationResult(listOfTables, ErrorMessageGenerator.GenerateMesssage(Validation.ErrorMessages.NonUniqueNames, nonUniqueNames.ToArray())));
                if (!EveryoneDict.ContainsKey(vr.Target))
                {
                    EveryoneDict.Add(vr.Target, new List <string>());
                }
                EveryoneDict[vr.Target].Add("[" + ruleNumber + "]\n-" + vr.Message + "\n");
                ruleNumber++;
            }
        }