Session.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Security.Cryptography.X509Certificates;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Newtonsoft.Json;
  9. namespace Server.JSONObjecten
  10. {
  11. [Serializable]
  12. public class Session
  13. {
  14. public int id { get; private set; }
  15. public List<Measurement> session { get; private set; }
  16. public bool isActive { get; private set; }
  17. public int bikeMode { get; private set; }
  18. public DateTime date { get; private set; }
  19. public string note { get; private set; }
  20. public string modevalue { get; private set; }
  21. public Session( int bikeMode, string modevalue )
  22. {
  23. string[] fileEntries = Directory.GetFiles(@"../../JSONObjecten/JSON Files/");
  24. if (fileEntries.Length > 0)
  25. {
  26. this.id = int.Parse(fileEntries[fileEntries.Length]);
  27. }
  28. else
  29. {
  30. this.id = 1;
  31. }
  32. this.session = new List<Measurement>();
  33. this.isActive = true;
  34. this.bikeMode = bikeMode;
  35. this.modevalue = modevalue;
  36. this.date = DateTime.Now;
  37. this.note = "";
  38. }
  39. public string GetJSONString()
  40. {
  41. return JsonConvert.SerializeObject(this);
  42. }
  43. }
  44. }