RefResult.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text;
  5. namespace Ips.Library.Entity
  6. {
  7. public class RefResult
  8. {
  9. public RefResult() { }
  10. public RefResult(DateTime outtime, double dto, double dfo)
  11. {
  12. OutTime = outtime;
  13. Dto = dto;
  14. Dfo = dfo;
  15. }
  16. public DateTime OutTime { get; set; }
  17. public double Dto { get; set; }
  18. public double Dfo { get; set; }
  19. public static RefResult FromString(string line)
  20. {
  21. var arr = line.Split(',');
  22. if (arr.Length != 3) return null;
  23. var time = DateTime.Parse(arr[0]);
  24. var dt = double.Parse(arr[1]);
  25. var df = double.Parse(arr[2]);
  26. return new RefResult(time, dt, df);
  27. }
  28. public static List<RefResult> FromStrings(string lines)
  29. {
  30. List<RefResult> results = new List<RefResult>();
  31. using (var sr = new StringReader(lines))
  32. {
  33. string line;
  34. while (true)
  35. {
  36. line = sr.ReadLine();
  37. if (!string.IsNullOrWhiteSpace(line)) break;
  38. var result = FromString(line);
  39. if (result != null)
  40. results.Add(result);
  41. }
  42. }
  43. return results;
  44. }
  45. }
  46. }