This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RecordInput | |
{ | |
public string FullName { get; set; } | |
public string Action { get; set; } | |
public DateTime Time { get; set; } | |
public void Deconstruct(out string name, out string action, out DateTime time) | |
=> (name, action, time) = (FullName, Action, Time); | |
public override string ToString() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
ArgsValidation.Run(args); | |
var inputFile = args[0]; | |
var attendanceFile = args[1]; | |
var lectureNumber = int.Parse(args[2]); | |
var startTime = args[3]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reading meeting file | |
var CsvInputRecords = CsvHelperExtension.GetInputRecords(inputFile); | |
var usersWithDates = new Dictionary<string, List<DateTime>>(); | |
foreach (var (name, _, time) in CsvInputRecords) | |
{ | |
if (usersWithDates.ContainsKey(name)) | |
usersWithDates[name].Add(time); | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RecordOutput | |
{ | |
public string FullName { get; set; } | |
public int AttendanceCount { get; set; } | |
public string AttendanceLength { get; set; } | |
} | |
public class RecordOutputMap : ClassMap<RecordOutput> | |
{ | |
public RecordOutputMap() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<RecordOutput> GetOutputRecords(string file) | |
{ | |
using var reader = new StreamReader(file, Encoding.UTF8); | |
using var csv = new CsvReader(reader, CultureInfo.InvariantCulture); | |
csv.Configuration.RegisterClassMap<RecordOutputMap>(); | |
var records = csv.GetRecords<RecordOutput>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void PostOutputRecords(string file, List<RecordOutput> records) | |
{ | |
using var writer = new StreamWriter(file, false, Encoding.UTF8); | |
using var csv = new CsvWriter(writer, CultureInfo.InvariantCulture); | |
csv.WriteRecords(records); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reading last attendance file | |
var LastAttendanceRecords = CsvHelperExtension.GetOutputRecords(attendanceFile); | |
var CsvOutputRecords = usersWithMinutes.Select(x => | |
{ | |
var fullName = string.Join(" ", x.Key.Split(' ').Reverse()).Trim(); | |
var lastRecord = LastAttendanceRecords.FirstOrDefault(f => f.FullName == fullName); | |
var count = lastRecord?.AttendanceCount ?? 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Writing updated attendance to new file | |
CsvHelperExtension.PostOutputRecords(OUTPUT_FILE, CsvOutputRecords.OrderBy(r => r.FullName).ToList()); | |
WriteLine($"Created new file {OUTPUT_FILE}."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<title>Todo List</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA==" crossorigin="anonymous" /> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> | |
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="an |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<RecordInput> GetInputRecords(string file) | |
{ | |
using var reader = new StreamReader(file, Encoding.UTF8); | |
using var csv = new CsvReader(reader, CultureInfo.InvariantCulture); | |
csv.Configuration.RegisterClassMap<RecordInputMap>(); | |
var records = csv.GetRecords<RecordInput>(); |