using System.Reflection; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using WIDESEAWCS_Core; using WIDESEAWCS_Core.BaseController; using WIDESEAWCS_DTO.ERP; using WIDESEAWCS_ISystemServices; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models.ERP; using WIDESEAWCS_Model.Models.TaskInfo; using System.IO; using WIDESEAWCS_Core.Helper; namespace WIDESEAWCS_Server.Controllers.ERP { [Route("api/ERP")] [ApiController] public class Dt_ERPController : ApiBaseController { public Dt_ERPController(IDt_ERPService service) : base(service) { } //获取ERP的AppTicket [HttpPost, HttpGet, Route("GetappTicket"), AllowAnonymous] public string GetappTicket([FromBody] AppTicket AppTicket) { return Service.GetappTicket(AppTicket); } ////ERP验证可信域名 //[HttpPost, HttpGet, Route("Reputation"), AllowAnonymous] //public string Reputation() //{ // try // { // //// 1. 获取文件的物理路径(根据项目结构,文件在ERP文件夹下) // //// 方式1:基于程序运行目录(推荐) // //string projectRoot = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // //string filePath = Path.Combine(projectRoot, "ERP", "CHANJET_CHECK.txt"); // //// 2. 检查文件是否存在 // //if (!global::System.IO.File.Exists(filePath)) // //{ // // return NotFound("文件不存在"); // //} // //// 3. 读取文件内容 // //byte[] fileBytes = global::System.IO.File.ReadAllBytes(filePath); // //string fileName = "CHANJET_CHECK.txt"; // //// 4. 返回文件(MIME类型为text/plain) // //return File(fileBytes, "text/plain", fileName); // string ERP = AppSettings.Get("ERPAppTicket"); // return ERP; // } // catch (Exception ex) // { // //return StatusCode(500, $"读取文件失败:{ex.Message}"); // return null; // } //} } }