Can you tell me why it does not work? I get an error. I tried using your method but it does not seem like it is working.
public void OnSignOut(int pin)
{
if (this.pin == pin && this.SignIn == true)
{
stopwatch.Stop();
double elasped = stopwatch.Elapsed.TotalSeconds;
stopwatch.Reset();
this.total += elasped;
MessageBox.Show("You have worked for " + elasped + " seconds." + " You have worked for " + this.total + " seconds in total.");
this.SignIn = false;
this.end = Convert.ToString(DateTime.Now);
this.log.Add(this.name + " worked for " + elasped + " seconds." + "\r\n" + "Total Time: " + this.total + " seconds" + "\r\n" + "Log in: " + this.start + " Log out: " + this.end + "\r\n\r\n\r\n");
this.logbook.Add(DateTime.Now, elasped);
json = JsonConvert.SerializeObject(this.logbook);
System.IO.File.WriteAllText(@"D:\path.json", json);
}
}
public double AddUp_Hours(DateTime start_date, DateTime end_date)
{
System.IO.File.ReadAllText(@"D:\path.json");
this.logbook = JsonConvert.DeserializeObject<Dictionary< DateTime, double> > (json);
DateTime first = start_date;
DateTime second = end_date;
double sums = this.logbook.Where(x => x.Key > first && x.Key < second)
.Sum(x => x.Value);
return sums;