示例#1
0
    public void setHourlyRecord(Worksheet targetSheet, Models.Student student)
    {
        var collector = new System.Collections.Generic.Dictionary <ExcelExport.Key, int>();

        foreach (var b in student.Behaviors)
        {
            var key = new ExcelExport.Key {
                DayOfWeek = b.TimeRecorded.DayOfWeek.ToString(), Hour = b.TimeRecorded.Hour
            };
            if (collector.ContainsKey(key))
            {
                collector[key] += 1;
            }
            else
            {
                collector.Add(key, 1);
            }
        }
        foreach (var key in collector.Keys)
        {
            var value = key.Hour - 1;
            switch (key.DayOfWeek.ToString())
            {
            case "Monday": ((Range)(targetSheet.Cells[6, value])).Value = collector[key];
                break;

            case "Tuesday": ((Range)(targetSheet.Cells[7, value])).Value = collector[key];
                break;

            case "Wednesday": ((Range)(targetSheet.Cells[8, value])).Value = collector[key];
                break;

            case "Thursday": ((Range)(targetSheet.Cells[9, value])).Value = collector[key];
                break;

            case "Friday": ((Range)(targetSheet.Cells[10, value])).Value = collector[key];
                break;

            default:
                break;
            }
        }
    }
    public void setHourlyRecord(Worksheet targetSheet, Models.Student student)
    {
        var collector = new System.Collections.Generic.Dictionary<ExcelExport.Key, int>();
        foreach (var b in student.Behaviors)
        {
            var key = new ExcelExport.Key { DayOfWeek = b.TimeRecorded.DayOfWeek.ToString(), Hour = b.TimeRecorded.Hour };
            if (collector.ContainsKey(key))
                collector[key] += 1;
            else
                collector.Add(key, 1);

        }
        foreach (var key in collector.Keys)
        {
            var value = key.Hour - 1;
                switch (key.DayOfWeek.ToString())
                {
                    case "Monday": ((Range)(targetSheet.Cells[6, value])).Value = collector[key];
                        break;
                    case "Tuesday": ((Range)(targetSheet.Cells[7, value])).Value = collector[key];
                        break;
                    case "Wednesday": ((Range)(targetSheet.Cells[8, value])).Value = collector[key];
                        break;
                    case "Thursday": ((Range)(targetSheet.Cells[9, value])).Value = collector[key];
                        break;
                    case "Friday": ((Range)(targetSheet.Cells[10, value])).Value = collector[key];
                        break;
                    default:
                        break;
                }
            }
    }