222
schangxiang@126.com
2025-06-09 9307b61fe8e046d32497e275ed714df72338ec1d
Api/Controllers/WareAuthorizeController.cs
@@ -7,6 +7,10 @@
    [Route("[controller]")]
    public class WareAuthorizeController : ControllerBase
    {
        private static bool isRuning_Fun_MianAgvFun = false;
        private static readonly SemaphoreSlim semaphore_MianAgvFun = new SemaphoreSlim(1, 1);
        private readonly ILogger<WareAuthorizeController> _logger;
        public WareAuthorizeController(ILogger<WareAuthorizeController> logger)
@@ -20,10 +24,18 @@
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet(Name = "ValidateLicense")]
        public AuthorizeFunRetEntity ValidateLicense([FromQuery] ValidateLicenseInput input)
        public async Task<AuthorizeFunRetEntity> ValidateLicense([FromQuery] ValidateLicenseInput input)
        {
            if (isRuning_Fun_MianAgvFun)
            {
                //认为是验证成功,不要并发导致读取授权文件失败
                //return AuthorizeFunRetEntity.Success("成功", null);
            }
            try
            {
                await semaphore_MianAgvFun.WaitAsync();
                isRuning_Fun_MianAgvFun = true;
                //if (input == null)
                //{
                //    return AuthorizeFunRetEntity.Fail("参数不能为空");
@@ -39,6 +51,11 @@
            {
                return AuthorizeFunRetEntity.Fail("异常:" + ex.Message);
            }
            finally
            {
                semaphore_MianAgvFun.Release();
                isRuning_Fun_MianAgvFun = false;
            }
        }
    }
}