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_Services.Services.Log;
|
|
namespace WIDESEA_WCSServer.Controllers.LogController
|
{
|
|
[Route("api/LogController")]
|
[ApiController]
|
public class LogController : ControllerBase
|
{
|
/// <summary>
|
/// 获取日志目录结构
|
/// </summary>
|
/// <param name="taskinfo"></param>
|
/// <returns></returns>
|
[HttpPost, Route("GetDirTree"), AllowAnonymous]
|
public WebResponseContent GetDirTree()
|
{
|
WebResponseContent content = new WebResponseContent();
|
List<FileNames> fileNamesList = new List<FileNames>();
|
LogService.GetallDirectory(fileNamesList, "D:\\WCS_log");
|
return content.OK(data: fileNamesList);
|
}
|
|
|
/// <summary>
|
/// 获取日志具体日志详情
|
/// </summary>
|
/// <param name="taskinfo"></param>
|
/// <returns></returns>
|
[HttpPost, Route("GetLogInfo"), AllowAnonymous]
|
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);
|
}
|
|
}
|
}
|