using iWare.Authorize.Dto; using Microsoft.AspNetCore.Mvc; namespace iWare.Authorize { [ApiController] [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 _logger; public WareAuthorizeController(ILogger logger) { _logger = logger; } /// /// ÑéÖ¤ÊÚȨ /// /// /// [HttpGet(Name = "ValidateLicense")] public async Task 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("²ÎÊý²»ÄÜΪ¿Õ"); //} //if (string.IsNullOrEmpty(input.FolderPath)) //{ // return AuthorizeFunRetEntity.Fail("ÊÚȨ·¾¶²»ÄÜΪ¿Õ"); //} return AuthorizeHelper.ValidateLicense(input); } catch (Exception ex) { return AuthorizeFunRetEntity.Fail("Òì³£:" + ex.Message); } finally { semaphore_MianAgvFun.Release(); isRuning_Fun_MianAgvFun = false; } } } }