using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using WIDESEA.Core.Utilities;
using WIDESEA.Entity.DomainModels;
using WIDESEA_Entity.DomainModels;
using WIDESEA_Services.Services.Log;
namespace WIDESEA_WCSServer.Controllers.LogController
{
[Route("api/LogController")]
[ApiController]
public class LogController : ControllerBase
{
///
/// 获取日志目录结构
///
///
///
[HttpPost, Route("GetDirTree")]
public WebResponseContent GetDirTree()
{
WebResponseContent content = new WebResponseContent();
List fileNamesList = new List();
LogService.GetallDirectory(fileNamesList, "D:\\WMS_log");
return content.OK(data: fileNamesList);
}
///
/// 获取日志具体日志详情
///
///
///
[HttpPost, Route("GetLogInfo")]
public WebResponseContent GetLogInfo([FromBody] SaveModel saveModel)
{
WebResponseContent content = new WebResponseContent();
string filePath = saveModel.MainData["logName"].ToString();
//string text = System.IO.File.ReadAllText(filePath);
string line = String.Empty;
using (StreamReader reader = new StreamReader(filePath))
{
string l = String.Empty;
while ((l = reader.ReadLine()) != null)
{
line += l + Environment.NewLine;
}
}
return content.OK(data: line);
}
}
}