Ejemplo n.º 1
0
        protected List<IndicatorValue> GetDynamicIndicatorValues(DataSet ds, DataRow row, ref string errors)
        {
            Dictionary<string, IndicatorValue> multicolumnIndicators = new Dictionary<string, IndicatorValue>();
            List<IndicatorValue> inds = new List<IndicatorValue>();
            foreach (DataColumn col in ds.Tables[0].Columns)
            {
                string indicatorName = col.ColumnName.Replace("* ", "");
                bool hasMultipleCols = false;
                if (indicatorName.Contains(Translations.ImportSelectionOption))
                {
                    hasMultipleCols = true;
                    indicatorName = indicatorName.Replace(Translations.ImportSelectionOption, "^").Split('^')[0];
                }
                if (translatedIndicators.ContainsKey(indicatorName))
                {
                    string val = row[col].ToString().Trim();
                    Indicator curInd = translatedIndicators[indicatorName];
                    errors += GetValueAndValidate(curInd, ref val, indicatorName);

                    IndicatorValue ival = new IndicatorValue
                    {
                        IndicatorId = curInd.Id,
                        DynamicValue = val,
                        Indicator = curInd
                    };

                    if (!hasMultipleCols || !multicolumnIndicators.ContainsKey(indicatorName))
                        inds.Add(ival);

                    if (hasMultipleCols)
                    {
                        if (multicolumnIndicators.ContainsKey(indicatorName))
                            multicolumnIndicators[indicatorName].DynamicValue = multicolumnIndicators[indicatorName].DynamicValue + "|" + val;
                        else
                            multicolumnIndicators.Add(indicatorName, ival);
                    }
                }
            }
            return inds;
        }
        public List<IndicatorValue> GetValues() 
        {
            var valList = new List<IndicatorValue>();

            foreach (DynamicContainer cnt in controlList)
            {
                IndicatorValue val = new IndicatorValue();
                val.DynamicValue = cnt.GetValue();
                val.Indicator = cnt.Indicator;
                val.IndicatorId = cnt.Indicator.Id;
                valList.Add(val);
            }
            return valList;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts a collection of meta data to values that can be validated against
        /// </summary>
        /// <param name="indicators">Collection of indicators that contain values for the meta data</param>
        /// <param name="metaData">The meta data collection</param>
        /// <returns></returns>
        private List<IndicatorValue> ConvertMetaDataToIndicatorValues(Dictionary<string, Indicator> indicators, List<KeyValuePair<string, string>> metaData)
        {
            List<IndicatorValue> indicatorValues = new List<IndicatorValue>();

            if (metaData == null)
                return indicatorValues;

            foreach (KeyValuePair<string, Indicator> indicator in indicators)
            {
                string translatedIndicatorName = TranslationLookup.GetValue(indicator.Key, indicator.Key);

                KeyValuePair<string, string> correspondingMetaData = metaData.Where(k => k.Key == translatedIndicatorName).FirstOrDefault();
                if (correspondingMetaData.Equals(new KeyValuePair<string, string>()))
                    continue;

                IndicatorValue val = new IndicatorValue();
                val.DynamicValue = correspondingMetaData.Value;
                val.Indicator = indicator.Value;
                val.IndicatorId = indicator.Value.Id;
                indicatorValues.Add(val);
            }

            return indicatorValues;
        }