schangxiang@126.com
2025-04-02 fdac93d134fa471bf4afb304407f506ba9e3a324
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
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<WareAuthorizeController> _logger;
 
        public WareAuthorizeController(ILogger<WareAuthorizeController> logger)
        {
            _logger = logger;
        }
 
        /// <summary>
        /// ÑéÖ¤ÊÚȨ
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet(Name = "ValidateLicense")]
        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("²ÎÊý²»ÄÜΪ¿Õ");
                //}
                //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;
            }
        }
    }
}