Admin
85 分钟以前 1cd9280bbecf557f8978ad3839f14827ff9f4d34
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
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);
        }
 
    }
}