/// <summary>
        /// Join new list with older values (concatenate with listseparator)
        /// </summary>
        /// <param name="intermediate"></param>
        /// <param name="tag"></param>
        public void Expand(Intermediate intermediate, string tag)
        {
            // Fix transaction entries and left length of value series
            Log.WriteLine(string.Format("expanding data for [{0}]", tag));

            // add key (transaction name) if not exist
            foreach (KeyValuePair <string, string> pair in intermediate)
            {
                if (!this.ContainsKey(pair.Key))
                {
                    Add(pair.Key, "");
                }
            }

            // normalize value length
            this.Normalize();

            // Add new values

            // add run tag
            AddValue(TAGKEY, tag);

            // add value
            foreach (KeyValuePair <string, string> pair in intermediate)
            {
                AddValue(pair.Key, pair.Value);
            }

            // normalize length of value series (to the right) for incomplete series
            this.Normalize();
        }
        /// <summary>
        /// Generate new Intermediate with baselining values
        /// ${Appbeheer_01_Inloggen_br // reference (baseline value)
        /// ${Appbeheer_01_Inloggen_be // evaluated value (difference from baseline in %)
        /// ${Appbeheer_01_Inloggen_be_c // colorcode, mark when current value exceeds threshold th1, green when diff > -15%, red when diff > +15%
        /// </summary>
        /// <param name="intermediate"></param>
        /// <param name="baselineIntermediate"></param>
        /// <param name="baselineReferenceIntermediate"></param>
        /// <param name="colorcodeBetter"></param>
        /// <param name="colorcodeWorse"></param>
        /// <returns></returns>
        public Intermediate GenerateBaselineEvaluationValues(Intermediate intermediate, Intermediate baselineIntermediate, Intermediate baselineReferenceIntermediate, string colorcodeBetter, string colorcodeWorse)
        {
            Intermediate result = new Intermediate();

            // voor alle items in de baseline reference: doe evaluatie
            foreach (KeyValuePair <string, string> baselinePair in baselineReferenceIntermediate)
            {
                // add _br value from baseline reference
                result.AddValue(GetBaselineReferenceKey(baselinePair.Key), baselinePair.Value);

                // evaluate and generate _be and _be_c values
                if (intermediate.ContainsKey(baselinePair.Key))
                {
                    string baselineValueSeries          = baselineIntermediate.GetValue(baselinePair.Key);
                    string baselineThresholdValueSeries = baselineIntermediate.GetValue(Thresholds.GetThresholdColorKey(baselinePair.Key));

                    string currentValueSeries          = intermediate.GetValue(baselinePair.Key);
                    string currentThresholdValueSeries = intermediate.GetValue(Thresholds.GetThresholdColorKey(baselinePair.Key));

                    // generate _be and _be_c values
                    Intermediate evalResult = GenerateEvaluation(baselinePair.Key, baselineValueSeries, currentValueSeries, baselineThresholdValueSeries, currentThresholdValueSeries, colorcodeBetter, colorcodeWorse);
                    result.Add(evalResult);
                }
            }

            return(result);
        }
        /// <summary>
        /// Format read measure data and replace SILK proprietary separators with parameter decimal- and listseparator
        /// </summary>
        /// <param name="keys"></param>
        /// <param name="srcDecSeparator"></param>
        /// <returns></returns>
        public string[] FormatMeasureData(string[] keys, char srcDecSeparator)
        {
            // convert values
            Log.Write("format measure values [");

            foreach (string key in keys)
            {
                items[key] = items[key].Replace(srcDecSeparator, MEASUREDECIMALSEPARATOR);
                items[key] = items[key].Replace(Intermediate.LISTSEPARATOR, MEASURETFIELDSEPARATOR);
                Log.Write(".");
            }
            Log.WriteLine("]");

            // convert names
            Log.Write("correct measure names if necessary [");

            Intermediate  newItems = new Intermediate();
            List <string> newKeys  = new List <string>();

            foreach (KeyValuePair <string, string> item in items)
            {
                newKeys.Add(ConformName(item.Key));
                newItems.Add(newKeys.Last(), item.Value);
                Log.Write(".");
            }
            Log.WriteLine("]");
            items = newItems;
            return(newKeys.ToArray());
        }
 /// <summary>
 /// Copy content from dictionary
 /// </summary>
 /// <param name="workList"></param>
 public void ReplaceFrom(Intermediate workList)
 {
     this.Clear();
     foreach (KeyValuePair <string, string> pair in workList)
     {
         this.Add(pair.Key, pair.Value);
     }
 }
        /// <summary>
        /// Return intermediate where key=value are replaced with -prefix-key=value
        /// </summary>
        /// <param name="intermediate"></param>
        /// <param name="prefix"></param>
        /// <returns></returns>
        public static Intermediate ApplyKeyPrefix(Intermediate intermediate, string prefix)
        {
            Intermediate newIntermediate = new Intermediate();

            foreach (string key in intermediate.Keys)
            {
                newIntermediate.AddValue(prefix + key, intermediate[key]);
            }
            return(newIntermediate);
        }
 /// <summary>
 /// Add intermediate content of param to current/this value set
 /// </summary>
 /// <param name="intermediate"></param>
 public void Add(Intermediate intermediate)
 {
     foreach (KeyValuePair <string, string> pair in intermediate)
     {
         //Log.WriteLine("adding key=value {0}={1}", pair.Key, pair.Value);
         if (!this.ContainsKey(pair.Key))
         {
             this.Add(pair.Key, pair.Value);
         }
     }
 }
 /// <summary>
 /// Add new key=value or (if key exist): add value to list of values
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 /// <param name="list"></param>
 private void AddToList(string key, string value, Intermediate list)
 {
     if (list.ContainsKey(key))
     {
         list[key] += Intermediate.LISTSEPARATOR + value;
     }
     else
     {
         list.Add(key, value);
     }
 }
Example #8
0
        /// <summary>
        /// Generate colorcode entries based on diff evaluation of all intermediate value entities
        /// input:
        /// key1=1;2;3;blaat;zee
        /// key2=1;3;3;blaat;zoo
        /// ...
        /// output (generated keys):
        /// key1_c="";"highlite";"";"highlite"
        /// key2_c="";"highlite";"";"highlite"
        /// ...
        /// </summary>
        /// <param name="intermediate"></param>
        /// <param name="colorCode"></param>
        /// <returns></returns>
        public Intermediate GenerateDiffValues(Intermediate intermediate, string colorCode)
        {
            Intermediate result = new Intermediate();

            // controleer occurence in overige intermediate
            foreach (KeyValuePair <string, string> pair in intermediate)
            {
                result.Add(pair.Key + "_c", GetDiffValue(pair, intermediate, colorCode));
            }

            return(result);
        }
        /// <summary>
        /// Generate
        /// </summary>
        /// <param name="intermediate"></param>
        /// <param name="green"></param>
        /// <param name="yellow"></param>
        /// <param name="red"></param>
        /// <returns></returns>
        public Intermediate GenerateThresholdValuesForTransactions(Intermediate intermediate, string green, string yellow, string red)
        {
            Intermediate thIntermediate = new Intermediate();

            foreach (KeyValuePair <string, string> pair in intermediate)
            {
                // add threshold color code for all value fields of this transaction
                thIntermediate.Add(GetThresholdColorKey(pair.Key), GenerateThresholdColorValuesForTransaction(pair.Key, pair.Value, green, yellow, red));
                // add threshold reference values (th[0,1]) for this transaction
                thIntermediate.Add(GetThresholdReferenceKey(pair.Key), GenerateThresholdReferenceForTransaction(pair.Key, pair.Value));
            }
            return(thIntermediate);
        }
Example #10
0
        /// <summary>
        /// Generate _be and _be_c values (baseline evaluation and colorcodes)
        /// </summary>
        /// <param name="key"></param>
        /// <param name="baselineValueSeries"></param>
        /// <param name="currentValueSeries"></param>
        /// <param name="baselineThresholdValueSeries"></param>
        /// <param name="currentThresholdValueSeries"></param>
        /// <param name="colorcodeBetter"></param>
        /// <param name="colorcodeWorse"></param>
        /// <returns></returns>
        private Intermediate GenerateEvaluation(string key, string baselineValueSeries, string currentValueSeries, string baselineThresholdValueSeries, string currentThresholdValueSeries, string colorcodeBetter, string colorcodeWorse)
        {
            Intermediate result = new Intermediate();

            string[] baselineValueArr          = baselineValueSeries.Split(Intermediate.LISTSEPARATOR);
            string[] baselineThresholdValueArr = baselineThresholdValueSeries.Split(Intermediate.LISTSEPARATOR);

            string[] currentValueArr          = currentValueSeries.Split(Intermediate.LISTSEPARATOR);
            string[] currentThresholdValueArr = currentThresholdValueSeries.Split(Intermediate.LISTSEPARATOR);

            List <string> beValues  = new List <string>();
            List <string> becValues = new List <string>();

            Log.Write(string.Format("baseline evaluation triggers for {0}: [", key));
            for (int i = 0; i < baselineValueArr.Length; i++)
            {
                try
                {
                    // only perform evaluation if current or baseline value is other than green
                    if ((currentThresholdValueArr[i] != Baselining.belowLowThreshold) || (baselineThresholdValueArr[i] != Baselining.belowLowThreshold))
                    {
                        //Log.WriteLine(string.Format("baseline evaluation trigger: current or baseline exceeding non-green level on {0}", key));

                        // add evaluation to beValues and becValues
                        DoEvaluate(baselineValueArr[i], currentValueArr[i], beValues, becValues, colorcodeBetter, colorcodeWorse);
                    }
                    else
                    {
                        beValues.Add("");  // no value evaluation
                        becValues.Add(""); // no colorcode
                    }
                }
                catch
                {
                    beValues.Add("");  // no value evaluation
                    becValues.Add(""); // no colorcode
                }
            }
            Log.WriteLine("]");

            // values
            result.Add(GetBaselineEvaluationKey(key), string.Join(Intermediate.LISTSEPARATOR.ToString(), beValues.ToArray()));

            // colorcodes
            result.Add(GetBaselineEvaluationColorKey(key), string.Join(Intermediate.LISTSEPARATOR.ToString(), becValues.ToArray()));

            return(result);
        }
        /// <summary>
        /// Fill values with blanks to normalize length of all values
        /// </summary>
        public void Normalize()
        {
            //Log.WriteLine("normalize intermediate...");

            int cnt;
            int maxCnt = 0;

            // find max value series length
            foreach (KeyValuePair <string, string> pair in this)
            {
                cnt    = NumOfElements(pair.Value);
                maxCnt = cnt > maxCnt ? cnt : maxCnt;
            }

            Intermediate tmpList = new Intermediate();

            // apply max value series length to shorter series (normalize)
            foreach (KeyValuePair <string, string> pair in this)
            {
                string newValue = pair.Value;

                // if new value: fill left
                if ((NumOfElements(newValue) == 1) && (maxCnt > 1))
                {
                    while (NumOfElements(newValue) < maxCnt)
                    {
                        newValue = LISTSEPARATOR + newValue;
                    }
                }
                // if already present: fill right
                else
                {
                    while (NumOfElements(newValue) < maxCnt)
                    {
                        newValue = newValue + LISTSEPARATOR;
                    }
                }

                tmpList.Add(pair.Key, newValue);
            }
            this.ReplaceFrom(tmpList);
        }
Example #12
0
 /// <summary>
 /// Compware value to all other value strings, return true if corresponding value is found
 /// </summary>
 /// <param name="refKey"></param>
 /// <param name="refValueItem"></param>
 /// <param name="intermediate"></param>
 /// <returns></returns>
 private bool EvaluateDiffValueItem(string refKey, string refValueItem, Intermediate intermediate)
 {
     foreach (KeyValuePair <string, string> item in intermediate)
     {
         // zichzelf overslaan
         if (item.Key != refKey)
         {
             // algoritme 1: zoek broertje of zusje in alle value items van alle keys in de intermediate
             // true als gevonden
             foreach (string evalValueItem in item.Value.Split(Intermediate.LISTSEPARATOR))
             {
                 if (evalValueItem == refValueItem)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Example #13
0
        /// <summary>
        /// Generate colorcode string for this key
        /// </summary>
        /// <param name="reference"></param>
        /// <param name="intermediate"></param>
        /// <param name="markColorCode"></param>
        /// <returns></returns>
        private string GetDiffValue(KeyValuePair <string, string> reference, Intermediate intermediate, string markColorCode)
        {
            List <string> colValues = new List <string>();

            // itereer over alle value items in values string
            foreach (string refValueItem in reference.Value.Split(Intermediate.LISTSEPARATOR))
            {
                if (EvaluateDiffValueItem(reference.Key, refValueItem, intermediate))
                {
                    colValues.Add("");
                }
                else
                {
                    Log.WriteLine(string.Format("add diffmark for {0}/{1}", reference.Key, refValueItem));
                    colValues.Add(markColorCode);
                }
            }
            // plak alle waarden weer in 1 string, listeparator gescheiden
            return(string.Join(Intermediate.LISTSEPARATOR.ToString(), colValues.ToArray()));
        }
        /// <summary>
        /// Get intermediate with only one value from datasource series
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public Intermediate GetIndexedValues(int index)
        {
            Intermediate filteredList = new Intermediate();

            foreach (KeyValuePair <string, string> pair in this)
            {
                string value = "";
                try
                {
                    string[] values = pair.Value.Split(Intermediate.LISTSEPARATOR);
                    value = values[index];
                }
                catch
                {
                    value = "";
                }
                filteredList.Add(pair.Key, value);
            }
            return(filteredList);
        }
        /// <summary>
        /// Generate new intermedate with new counters holding aggregated values (per column)
        /// </summary>
        /// <param name="aggregateKey"></param>
        /// <param name="keyPattern"></param>
        /// <param name="valuePattern"></param>
        /// <returns></returns>
        public Intermediate AggregateCount(string aggregateKey, string keyPattern, string valuePattern)
        {
            Log.WriteLine(string.Format("calculate aggregate {0} on {1}={2} ...", aggregateKey, keyPattern, valuePattern));

            Regex regKey = new Regex(keyPattern);
            Regex regVal = new Regex(valuePattern);

            Intermediate result = new Intermediate();

            // add aggregate values
            for (int i = 0; i < this.GetMaxNumOfValues(); i++)
            {
                //Log.WriteLine("aggregate value position: " + i);
                int aggr = 0;
                foreach (string key in this.Keys)
                {
                    if (regKey.IsMatch(key))
                    {
                        try
                        {
                            // beveiligd try/catch ivm onzekerheid aantal entry's in de value reeks
                            if (regVal.IsMatch(GetValue(key, i)))
                            {
                                //Log.WriteLine(string.Format("key={0} value={1}", key, GetValue(key, i)));
                                aggr = aggr + 1;
                            }
                        }
                        catch {}
                    }
                }
                //Log.WriteLine(string.Format("violations for position {0} = {1}", i, aggr.ToString()));
                result.AddValue(aggregateKey, aggr.ToString());
            }

            return(result);
        }