Пример #1
0
        /// <summary>
        /// Summarize the specified input.
        /// </summary>
        /// <returns>The summarize.</returns>
        /// <param name="input">Input.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public IEnumerable <string[]> Summarize <T>(Dictionary <string, IEnumerable <T> > input) where T : ICsvWritable
        {
            var results = new List <string[]> {
            };

            foreach (var inputKey in input.Keys)
            {
                var reachResults = (IEnumerable <ForwardReachResult>)input[inputKey];
                if (!SelectSummaries.ContainsKey(inputKey) || SelectSummaries[inputKey] == null)
                {
                    SelectSummaries[inputKey] = new SelectSummary();
                }
                if (reachResults != null && reachResults.Any())
                {
                    SelectSummaries[inputKey].ForwardReachStartNums = reachResults
                                                                      .Select(x => UtilityService.GetMinInt(x.FirstShiftRecordNum[0], x.FirstShiftRecordNum[1]).Value).ToList();
                }
            }

            foreach (var summary in SelectSummaries)
            {
                var source      = summary.Key;
                var selectTasks = summary.Value.SelectTasks;
                var reachNums   = summary.Value.ForwardReachStartNums;

                var selectTaskCount = selectTasks.Keys.Count();
                var reachCount      = reachNums.Count();
                var count           = UtilityService.GetMaxInt(selectTaskCount, reachCount);

                var firstLinePrinted = false;
                for (int i = 0; i < count; i++)
                {
                    var selectTaskName = selectTaskCount > i?selectTasks.Keys.ElementAt(i) : "N/A";

                    var selectTaskStartNum = selectTaskCount > i ? selectTasks[selectTaskName].ToString() : "N/A";
                    var reachStartNum      = reachCount > i ? reachNums[i].ToString() : "N/A";

                    results.Add(new string[]
                    {
                        !firstLinePrinted ? source : "N/A",
                        selectTaskName,
                        selectTaskStartNum,
                        reachStartNum,
                        summary.Value.IsMatch(reachStartNum).ToString()
                    });

                    firstLinePrinted = true;
                }
            }

            return(results);
        }
Пример #2
0
        /// <summary>
        /// Initialize the specified InputData.
        /// </summary>
        /// <returns>The initialize.</returns>
        /// <param name="InputData">Input data.</param>
        public void Initialize(Dictionary <string, IEnumerable <SensorReading> > InputData)
        {
            if (SelectSummaries == null)
            {
                SelectSummaries = new Dictionary <string, SelectSummary>();
            }
            foreach (var key in InputData.Keys)
            {
                if (!SelectSummaries.ContainsKey(key) || SelectSummaries[key] == null)
                {
                    SelectSummaries[key] = new SelectSummary();
                }

                SelectSummaries[key].SelectTasks = InputData[key]
                                                   .Where(x => x.Label.Contains("select"))
                                                   .GroupBy(x => x.Label)
                                                   .ToDictionary(x => x.First().Label, x => x.First().RecordNum);
            }
        }