Admin
2025-12-02 9e42f0dafa019f5ecf6b0ff425ecb966b002171e
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using WIDESEA_Core.Utilities;
 
namespace WIDESEA_Services.Services.VueMonitorServices
{
    public class VueMonitorService
    {
        /// <summary>
        /// 获取所有站台的信息
        /// </summary>
        /// <returns></returns>
        public static WebResponseContent AllStationData()
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<FileNames> tmpList = new List<FileNames>();
                GetallDirectory(tmpList, "D:/WCS_log");
 
                
 
                content.OK(data: tmpList);
            }
            catch(Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
 
 
        //获得指定路径下所有文件名
        public static List<FileNames> getFileName(List<FileNames> list, string filepath)
        {
            DirectoryInfo root = new DirectoryInfo(filepath);
            foreach (FileInfo f in root.GetFiles())
            {
                DateTime currtlyTime = DateTime.Now;
                TimeSpan ts = currtlyTime.Subtract(f.CreationTime);
 
                if (f.Name.Contains("20") && Math.Abs(ts.Days) < 100) 
                {
                    list.Add(new FileNames
                    {
                        label = f.Name,
                    });
                }
            }
            return list;
        }
        //获得指定路径下的所有子目录名
        // <param name="list">文件列表</param>
        // <param name="path">文件夹路径</param>
        public static List<FileNames> GetallDirectory(List<FileNames> list, string path)
        {
            DirectoryInfo root = new DirectoryInfo(path);
            var dirs = root.GetDirectories();
            if (dirs.Length > 0)
            {
                foreach (DirectoryInfo d in dirs)
                {
                    DateTime currtlyTime = DateTime.Now;
                    TimeSpan ts = currtlyTime.Subtract(d.CreationTime);
                    if (d.Name.Contains("20"))
                    {
                        if (Math.Abs(ts.Days) < 100)
                        {
                            list.Add(new FileNames
                            {
                                label = d.Name,
                                children = GetallDirectory(new List<FileNames>(), d.FullName)
                            });
                        }
                    }
                    else
                    {
                        list.Add(new FileNames
                        {
                            label = d.Name,
                            children = GetallDirectory(new List<FileNames>(), d.FullName)
                        });
                    }
                }
            }
            list = getFileName(list, path);
            return list;
        }
    
 
    }
 
 
    public class FileNames
    {
        public string label { get; set; }
        public List<FileNames> children { get; set; }
    }
 
 
}