public override LeaveAnalysisResults Analyze(LeaveChart Data) { var dayCount = new Dictionary<String, int>(); foreach (var leaveEntry in Data.EnumerateLeave(StartDate, EndDate)) if (dayCount.ContainsKey(leaveEntry.Substitute)) dayCount[leaveEntry.Substitute] += 1; else dayCount.Add(leaveEntry.Substitute, 1); var result = new LeaveAnalysisResults(); result.ColumnNames.Add("Carrier"); result.ColumnNames.Add("Days Worked"); foreach (var sub in dayCount) { result.Rows.Add(new LeaveAnalysisRow { Name = sub.Key }); result.Rows[result.Rows.Count - 1].Columns.Add("Days Worked", sub.Value.ToString()); } result.SortRowsAlphabetically(); return result; }
public override LeaveAnalysisResults Analyze(LeaveChart Chart) { var usageTable = new Dictionary<String, Dictionary<String, int>>(); foreach (var leaveEntry in Chart.EnumerateLeave(StartDate, EndDate).Where(l => !Constants.PropogatableLeaveTypes.Contains(l.LeaveType))) { Dictionary<String, int> carrierEntry = null; if (!usageTable.TryGetValue(leaveEntry.Carrier, out carrierEntry)) { carrierEntry = new Dictionary<string, int>(); usageTable.Add(leaveEntry.Carrier, carrierEntry); } if (carrierEntry.ContainsKey(leaveEntry.LeaveType)) carrierEntry[leaveEntry.LeaveType] += 1; else carrierEntry.Add(leaveEntry.LeaveType, 1); } var result = new LeaveAnalysisResults(); result.ColumnNames.Add("Carrier"); foreach (var carrierEntry in usageTable) { var row = new LeaveAnalysisRow { Name = carrierEntry.Key }; foreach (var leaveType in carrierEntry.Value) { if (!result.ColumnNames.Contains(leaveType.Key)) result.ColumnNames.Add(leaveType.Key); row.Columns.Add(leaveType.Key, leaveType.Value.ToString()); } result.Rows.Add(row); } return result; }