¶Ô±ÈÐÂÎļþ |
| | |
| | | using iWare.Authorize; |
| | | using iWareCC_WC2CC.Authorize.Dto; |
| | | using iWareCCCommon; |
| | | using iWareModel; |
| | | using Newtonsoft.Json; |
| | | using ProjectCode; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Reflection.Emit; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace iWareCC_WC2CC.Common.Helper |
| | | { |
| | | /// <summary> |
| | | /// ææå¸®å©ç±» |
| | | /// </summary> |
| | | public class AuthorizeHelper |
| | | { |
| | | |
| | | private static AuthorizeClass authorizeClass = new AuthorizeClass(); |
| | | |
| | | /// <summary> |
| | | /// 对å¤å¼æ¾çææéªè¯æ¹æ³ |
| | | /// </summary> |
| | | /// <returns>false:éªè¯å¤±è´¥ï¼éè¦ç»æ¢æ¹æ³æ§è¡</returns> |
| | | public static bool Pul_ValidateLicense() |
| | | { |
| | | try |
| | | { |
| | | //å¢å ææ |
| | | var ret = AuthorizeHelper.ValidateLicense(); |
| | | if (ret.result) |
| | | { |
| | | if (!string.IsNullOrEmpty(ret.warnMsg)) |
| | | { |
| | | if (AuthorizeHelper.IsHasAuthorizeForToDay() == false) |
| | | { |
| | | MessageBox.Show("è¦å:" + ret.warnMsg); |
| | | //1天åºç°ä¸æ¬¡ |
| | | AuthorizeHelper.SetAuthorizeClass(true); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | AuthorizeHelper.SetAuthorizeClass(false);//éç½®å½å¤©ææ |
| | | MessageBox.Show("ææå¤±è´¥:" + ret.resMsg); |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | AuthorizeHelper.SetAuthorizeClass(false);//éç½®å½å¤©ææ |
| | | MessageBox.Show("ææå¼å¸¸:" + ex.Message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// éªè¯ææ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static AuthorizeFunRetEntity ValidateLicense() |
| | | { |
| | | var ret = RequestHelper.GetHttpRequest<AuthorizeFunRetEntity>("http://localhost:7777/", "WareAuthorize?waringDays=10"); |
| | | |
| | | return ret; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä»å¤©æ¯å¦å·²ç»éªè¯è¿äº |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private static bool IsHasAuthorizeForToDay() |
| | | { |
| | | var curDay = DateTime.Now.ToString("yyyyMMdd"); |
| | | if (curDay == authorizeClass.CurDay && authorizeClass.IsHasAuthorize == true) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// èµå¼éªè¯å¯¹è±¡ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private static void SetAuthorizeClass(bool isHasAuthorize) |
| | | { |
| | | var curDay = DateTime.Now.ToString("yyyyMMdd"); |
| | | authorizeClass.CurDay = curDay; |
| | | authorizeClass.IsHasAuthorize = isHasAuthorize; |
| | | } |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace iWareCC_WC2CC.Authorize.Dto |
| | | { |
| | | /// <summary> |
| | | /// ææä¿¡æ¯ç±» |
| | | /// </summary> |
| | | public class AuthorizeClass |
| | | { |
| | | /// <summary> |
| | | /// å½å天 |
| | | /// </summary> |
| | | public string CurDay { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦å·²ç»éªè¯è¿äº |
| | | /// </summary> |
| | | public bool IsHasAuthorize { get; set; } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace iWare.Authorize |
| | | { |
| | | /// <summary> |
| | | /// æ¹æ³è¿åå®ä½ |
| | | /// </summary> |
| | | public class AuthorizeFunRetEntity |
| | | { |
| | | /// <summary> |
| | | /// æ¹æ³è¿åç»æ |
| | | /// </summary> |
| | | public bool result { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¹æ³è¿åæ¶æ¯ |
| | | /// </summary> |
| | | public string resMsg { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¹æ³è¦åæ¶æ¯ |
| | | /// </summary> |
| | | public string warnMsg { get; set; } |
| | | |
| | | public object resData { get; set; } |
| | | |
| | | |
| | | /// <summary> |
| | | /// å©ä½å¤©æ° |
| | | /// </summary> |
| | | public double? remainingDays { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å°ææ¥æ |
| | | /// </summary> |
| | | public string expiryDate { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æææ¥æ |
| | | /// </summary> |
| | | public string issueDate { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 项ç®åç§° |
| | | /// </summary> |
| | | public string projectId { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ææç±»å |
| | | /// </summary> |
| | | public string type { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç»å®MAC |
| | | /// </summary> |
| | | public string macAddress { get; set; } |
| | | |
| | | /// <summary> |
| | | /// è¿åæå |
| | | /// </summary> |
| | | /// <param name="_resMsg"></param> |
| | | /// <returns></returns> |
| | | public static AuthorizeFunRetEntity Success(string _resMsg, AuthorizeFunRetEntity newFun) |
| | | { |
| | | return new AuthorizeFunRetEntity() |
| | | { |
| | | result = true, |
| | | resMsg = _resMsg, |
| | | |
| | | expiryDate = newFun.expiryDate, |
| | | issueDate = newFun.issueDate, |
| | | macAddress = newFun.macAddress, |
| | | projectId = newFun.projectId, |
| | | type = newFun.type |
| | | }; |
| | | } |
| | | /// <summary> |
| | | /// è¿åæå |
| | | /// </summary> |
| | | /// <param name="_resMsg"></param> |
| | | /// <returns></returns> |
| | | public static AuthorizeFunRetEntity Success(string _resMsg, double _remainingDays, AuthorizeFunRetEntity newFun) |
| | | { |
| | | return new AuthorizeFunRetEntity() |
| | | { |
| | | result = true, |
| | | resMsg = _resMsg, |
| | | remainingDays = _remainingDays, |
| | | |
| | | expiryDate = newFun.expiryDate, |
| | | issueDate = newFun.issueDate, |
| | | macAddress = newFun.macAddress, |
| | | projectId = newFun.projectId, |
| | | type = newFun.type |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¿åæå |
| | | /// </summary> |
| | | /// <param name="_resMsg"></param> |
| | | /// <returns></returns> |
| | | public static AuthorizeFunRetEntity Success(string _resMsg, double _remainingDays, string _warnMsg) |
| | | { |
| | | return new AuthorizeFunRetEntity() |
| | | { |
| | | result = true, |
| | | resMsg = _resMsg, |
| | | remainingDays = _remainingDays, |
| | | warnMsg = _warnMsg |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¿å失败 |
| | | /// </summary> |
| | | /// <param name="_resMsg"></param> |
| | | /// <returns></returns> |
| | | public static AuthorizeFunRetEntity Fail(string _resMsg, object _resData = null) |
| | | { |
| | | return new AuthorizeFunRetEntity() |
| | | { |
| | | result = false, |
| | | resMsg = _resMsg, |
| | | resData = _resData |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¿å失败 |
| | | /// </summary> |
| | | /// <param name="_resMsg"></param> |
| | | /// <returns></returns> |
| | | public static AuthorizeFunRetEntity Fail(string _resMsg, double _remainingDays, AuthorizeFunRetEntity newFun) |
| | | { |
| | | return new AuthorizeFunRetEntity() |
| | | { |
| | | result = false, |
| | | resMsg = _resMsg, |
| | | remainingDays = _remainingDays, |
| | | |
| | | expiryDate = newFun.expiryDate, |
| | | issueDate = newFun.issueDate, |
| | | macAddress = newFun.macAddress, |
| | | projectId = newFun.projectId, |
| | | type = newFun.type |
| | | }; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // 麻ççå·¥å¦é¢è®¸å¯è¯ |
| | | // |
| | | // çæææ (c) 2021-2023 zuohuaijunï¼å¤§åç§æï¼å¤©æ´¥ï¼æéå
¬å¸ èç³»çµè¯/微信ï¼18020030720 QQï¼515096995 |
| | | // |
| | | // ç¹æ¤å
è´¹æäºè·å¾æ¬è½¯ä»¶çä»»ä½äººä»¥å¤çæ¬è½¯ä»¶çæå©ï¼ä½é¡»éµå®ä»¥ä¸æ¡ä»¶ï¼å¨ææå¯æ¬æéè¦é¨åç软件ä¸å¿
é¡»å
æ¬ä¸è¿°çæå£°æåæ¬è®¸å¯å£°æã |
| | | // |
| | | // 软件æâåæ ·âæä¾ï¼ä¸æä¾ä»»ä½å½¢å¼çæç¤ºææç¤ºçä¿è¯ï¼å
æ¬ä½ä¸éäºå¯¹ééæ§ãéç¨æ§åéä¾µæçä¿è¯ã |
| | | // å¨ä»»ä½æ
åµä¸ï¼ä½è
æçæææäººåä¸å¯¹ä»»ä½ç´¢èµãæå®³æå
¶ä»è´£ä»»è´è´£ï¼æ 论æ¯å ååãä¾µææå
¶ä»æ¹å¼å¼èµ·çï¼ä¸è½¯ä»¶æå
¶ä½¿ç¨æå
¶ä»äº¤ææå
³ã |
| | | |
| | | using Furion.Schedule; |
| | | using Microsoft.AspNetCore.SignalR; |
| | | using System.Threading; |
| | | using WMS.WC2.Core.Helper; |
| | | |
| | | namespace WMS.WC2.Application; |
| | | |
| | | [JobDetail("job_verify", Description = "éªè¯æææä»¶", GroupName = "default", Concurrent = false)] |
| | | //[PeriodSeconds(3, TriggerId = "trigger_verify", Description = "éªè¯æææä»¶", RunOnStart = true)] |
| | | //æ£å¼ç¯å¢ä¸ï¼è¦1å°æ¶éªè¯ä¸æ¬¡ |
| | | [PeriodHours(1, TriggerId = "trigger_verify", Description = "éªè¯æææä»¶", RunOnStart = true)] |
| | | public class VerifyAuthrizeJob : IJob |
| | | { |
| | | private readonly IHubContext<OnlineUserHub, IOnlineUserHub> _onlineUserHubContext; |
| | | |
| | | public VerifyAuthrizeJob(IHubContext<OnlineUserHub, IOnlineUserHub> onlineUserHubContext) |
| | | { |
| | | _onlineUserHubContext = onlineUserHubContext; |
| | | } |
| | | |
| | | public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken) |
| | | { |
| | | var checkReault = await VerifyAuthorizationUtil.CheckAuthoriztion(); |
| | | if (!checkReault.result) |
| | | { |
| | | await _onlineUserHubContext.Clients.All.VerifyAuth(checkReault.resMsg); |
| | | } |
| | | else |
| | | { |
| | | if (string.IsNullOrEmpty(checkReault.warnMsg)) return; |
| | | await _onlineUserHubContext.Clients.All.VerifyAuth(checkReault.warnMsg); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace iWare.Authorize |
| | | { |
| | | /// <summary> |
| | | /// æ¹æ³è¿åå®ä½ |
| | | /// </summary> |
| | | public class AuthorizeFunRetEntity |
| | | { |
| | | /// <summary> |
| | | /// æ¹æ³è¿åç»æ |
| | | /// </summary> |
| | | public bool result { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¹æ³è¿åæ¶æ¯ |
| | | /// </summary> |
| | | public string resMsg { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¹æ³è¦åæ¶æ¯ |
| | | /// </summary> |
| | | public string warnMsg { get; set; } |
| | | |
| | | public object resData { get; set; } |
| | | |
| | | |
| | | /// <summary> |
| | | /// å©ä½å¤©æ° |
| | | /// </summary> |
| | | public double? remainingDays { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å°ææ¥æ |
| | | /// </summary> |
| | | public string expiryDate { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æææ¥æ |
| | | /// </summary> |
| | | public string issueDate { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 项ç®åç§° |
| | | /// </summary> |
| | | public string projectId { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ææç±»å |
| | | /// </summary> |
| | | public string type { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç»å®MAC |
| | | /// </summary> |
| | | public string macAddress { get; set; } |
| | | |
| | | /// <summary> |
| | | /// è¿åæå |
| | | /// </summary> |
| | | /// <param name="_resMsg"></param> |
| | | /// <returns></returns> |
| | | public static AuthorizeFunRetEntity Success(string _resMsg, AuthorizeFunRetEntity newFun) |
| | | { |
| | | return new AuthorizeFunRetEntity() |
| | | { |
| | | result = true, |
| | | resMsg = _resMsg, |
| | | |
| | | expiryDate = newFun?.expiryDate, |
| | | issueDate = newFun?.issueDate, |
| | | macAddress = newFun?.macAddress, |
| | | projectId = newFun?.projectId, |
| | | type = newFun?.type |
| | | }; |
| | | } |
| | | /// <summary> |
| | | /// è¿åæå |
| | | /// </summary> |
| | | /// <param name="_resMsg"></param> |
| | | /// <returns></returns> |
| | | public static AuthorizeFunRetEntity Success(string _resMsg, double _remainingDays, AuthorizeFunRetEntity newFun) |
| | | { |
| | | return new AuthorizeFunRetEntity() |
| | | { |
| | | result = true, |
| | | resMsg = _resMsg, |
| | | remainingDays = Convert.ToDouble(_remainingDays.ToString("0.0")), |
| | | |
| | | expiryDate = newFun.expiryDate, |
| | | issueDate = newFun.issueDate, |
| | | macAddress = newFun.macAddress, |
| | | projectId = newFun.projectId, |
| | | type = newFun.type |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¿åæå |
| | | /// </summary> |
| | | /// <param name="_resMsg"></param> |
| | | /// <returns></returns> |
| | | public static AuthorizeFunRetEntity Success(string _resMsg, double _remainingDays, string _warnMsg) |
| | | { |
| | | return new AuthorizeFunRetEntity() |
| | | { |
| | | result = true, |
| | | resMsg = _resMsg, |
| | | remainingDays = Convert.ToDouble(_remainingDays.ToString("0.0")), |
| | | warnMsg = _warnMsg |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¿å失败 |
| | | /// </summary> |
| | | /// <param name="_resMsg"></param> |
| | | /// <returns></returns> |
| | | public static AuthorizeFunRetEntity Fail(string _resMsg, object _resData = null) |
| | | { |
| | | return new AuthorizeFunRetEntity() |
| | | { |
| | | result = false, |
| | | resMsg = _resMsg, |
| | | resData = _resData |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¿å失败 |
| | | /// </summary> |
| | | /// <param name="_resMsg"></param> |
| | | /// <returns></returns> |
| | | public static AuthorizeFunRetEntity Fail(string _resMsg, double _remainingDays, AuthorizeFunRetEntity newFun) |
| | | { |
| | | return new AuthorizeFunRetEntity() |
| | | { |
| | | result = false, |
| | | resMsg = _resMsg, |
| | | remainingDays = Convert.ToDouble(_remainingDays.ToString("0.0")), |
| | | |
| | | expiryDate = newFun.expiryDate, |
| | | issueDate = newFun.issueDate, |
| | | macAddress = newFun.macAddress, |
| | | projectId = newFun.projectId, |
| | | type = newFun.type |
| | | }; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // 麻ççå·¥å¦é¢è®¸å¯è¯ |
| | | // |
| | | // çæææ (c) 2021-2023 zuohuaijunï¼å¤§åç§æï¼å¤©æ´¥ï¼æéå
¬å¸ èç³»çµè¯/微信ï¼18020030720 QQï¼515096995 |
| | | // |
| | | // ç¹æ¤å
è´¹æäºè·å¾æ¬è½¯ä»¶çä»»ä½äººä»¥å¤çæ¬è½¯ä»¶çæå©ï¼ä½é¡»éµå®ä»¥ä¸æ¡ä»¶ï¼å¨ææå¯æ¬æéè¦é¨åç软件ä¸å¿
é¡»å
æ¬ä¸è¿°çæå£°æåæ¬è®¸å¯å£°æã |
| | | // |
| | | // 软件æâåæ ·âæä¾ï¼ä¸æä¾ä»»ä½å½¢å¼çæç¤ºææç¤ºçä¿è¯ï¼å
æ¬ä½ä¸éäºå¯¹ééæ§ãéç¨æ§åéä¾µæçä¿è¯ã |
| | | // å¨ä»»ä½æ
åµä¸ï¼ä½è
æçæææäººåä¸å¯¹ä»»ä½ç´¢èµãæå®³æå
¶ä»è´£ä»»è´è´£ï¼æ 论æ¯å ååãä¾µææå
¶ä»æ¹å¼å¼èµ·çï¼ä¸è½¯ä»¶æå
¶ä½¿ç¨æå
¶ä»äº¤ææå
³ã |
| | | |
| | | |
| | | //using static ProjectCode.EnDecode; |
| | | |
| | | using iWare.Authorize; |
| | | using WMS.WC2.Core.Service; |
| | | |
| | | namespace WMS.WC2.Core.Helper; |
| | | public class VerifyAuthorizationUtil |
| | | { |
| | | |
| | | private static readonly Lazy<Task<string>> _lazyUrl = new Lazy<Task<string>>(async () => |
| | | {//ä½¿ç¨ Lazy<Task<T>> å®ç°çº¿ç¨å®å
¨çå»¶è¿å¼æ¥å è½½ |
| | | var _sysConfigService = App.GetRequiredService<SysConfigService>(); |
| | | return await _sysConfigService.GetConfigValue<string>("AuthoriztionUrl"); |
| | | }); |
| | | public static async Task<AuthorizeFunRetEntity> CheckAuthoriztion() |
| | | { |
| | | try |
| | | { |
| | | var _authorizationUrl = await _lazyUrl.Value; // 馿¬¡è®¿é®æ¶èªå¨æ§è¡å¼æ¥åå§å |
| | | var response = HttpHelper.Get($"{_authorizationUrl}WareAuthorize?WaringDays=10&&LicenseFolerName=licwms"); |
| | | var verify = JsonConvert.DeserializeObject<AuthorizeFunRetEntity>(response); |
| | | return verify; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return new AuthorizeFunRetEntity { resMsg = "æªææä¸å
许æä½" }; |
| | | } |
| | | } |
| | | } |