wangxinhui
2024-12-26 78b99e5348592a29ca1393a5e13db619cc4eba56
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
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.IO;
using System;
using WIDESEA_Core.Controllers.Basic;
using WIDESEA_Core.Utilities;
using WIDESEA_Entity.DomainModels;
using WIDESEA_Services.IServices;
 
namespace WIDESEA_Services.Controllers
{
    [Route("api/Sys_Log")]
    public partial class Sys_LogController : ApiBaseController<ISys_LogService>
    {
        public Sys_LogController(ISys_LogService service)
        : base("System", "System", "Sys_Log", service)
        {
        }
 
        [HttpPost, Route("GetLogName"), AllowAnonymous]
        public WebResponseContent GetLogName()
        {
            return Service.GetLogName();
        }
        [HttpPost, Route("GetLog"), AllowAnonymous]
        public WebResponseContent GetLog([FromBody] SaveModel saveModel)
        {
            return Service.GetLog(saveModel);
        }
 
        [HttpPost, HttpGet, Route("DownLoadLog"), AllowAnonymous]
        public virtual ActionResult DownLoadLog(string fileName)
        {
            string path = AppContext.BaseDirectory + "log\\";
            if (fileName.Contains("info"))
            {
                fileName = fileName.Replace("info", "");
                path = AppContext.BaseDirectory + "\\log\\Info\\";
            }
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
            path += fileName;
            byte[] fileBytes = System.IO.File.ReadAllBytes(path);
            return File(
                    fileBytes,
                    System.Net.Mime.MediaTypeNames.Application.Octet,
                    System.IO.Path.GetFileName(path)
                );
        }
    }
}