ningshuxia
2024-06-18 e83dca6e861b622b54d3392ca0d3f1f1eb69f7c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
namespace IStation.Hydraulic
{
    public class DayValueHelper
    {
        
        public static List<DayValue> GetDayValues(int station)
        {
            string folderPath;
            if (station==1)
            {
                  folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}Eapnet验证数据\\陈行一输";
            }
            else
            {
                folderPath = $"{AppDomain.CurrentDomain.BaseDirectory}Eapnet验证数据\\陈行二输";
            }
 
            if (!Directory.Exists(folderPath))
                return default; 
            var fileList=Directory.GetFiles(folderPath);
            if (fileList == null || !fileList.Any())
                return default;
 
            var list = new List<DayValue>();
            foreach (var file in fileList)
            {
                var fileName = Path.GetFileNameWithoutExtension(file);
                if (!DateTime.TryParse(fileName, out DateTime day))
                    continue;
                var json=File.ReadAllText(file);
                var timeValues = JsonHelper.Json2Object<List<TimeValue>>(json);
                if (timeValues == null || !timeValues.Any())
                    continue;
                var dayValue = new DayValue();
                dayValue.Year = day.Year;
                dayValue.Month = day.Month;
                dayValue.Day = day.Day;
                dayValue.TimeValueList = timeValues;
                list.Add(dayValue); 
            }
 
            return list;
        } 
    }
}