using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using WIDESEA_Core.Utilities;
namespace WIDESEA_Services.Services.VueMonitorServices
{
public class VueMonitorService
{
///
/// 获取所有站台的信息
///
///
public static WebResponseContent AllStationData()
{
WebResponseContent content = new WebResponseContent();
try
{
List tmpList = new List();
GetallDirectory(tmpList, "D:/WCS_log");
content.OK(data: tmpList);
}
catch(Exception ex)
{
content.Error(ex.Message);
}
return content;
}
//获得指定路径下所有文件名
public static List getFileName(List 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;
}
//获得指定路径下的所有子目录名
// 文件列表
// 文件夹路径
public static List GetallDirectory(List 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(), d.FullName)
});
}
}
else
{
list.Add(new FileNames
{
label = d.Name,
children = GetallDirectory(new List(), d.FullName)
});
}
}
}
list = getFileName(list, path);
return list;
}
}
public class FileNames
{
public string label { get; set; }
public List children { get; set; }
}
}