From 51c7ba2285c44af268858099871946e0b91dda55 Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周一, 09 6月 2025 16:10:33 +0800 Subject: [PATCH] 222 --- WMS使用方法/WMS使用方法.docx | 0 WCS使用方法/WCS使用方法.docx | 0 WCS使用方法/代码/Authorize/AuthorizeHelper.cs | 103 +++++++++++ WMS使用方法/代码/VerifyAuthorization/VerifyAuthorizationUtil.cs | 39 ++++ WMS使用方法/VerifyAuthrizeJob.cs | 43 ++++ WMS使用方法/代码/VerifyAuthorization/AuthorizeFunRetEntity.cs | 154 +++++++++++++++++ WCS使用方法/代码/Authorize/Dto/AuthorizeFunRetEntity.cs | 154 +++++++++++++++++ WCS使用方法/代码/Authorize/Dto/AuthorizeClass.cs | 24 ++ 8 files changed, 517 insertions(+), 0 deletions(-) diff --git "a/WCS\344\275\277\347\224\250\346\226\271\346\263\225/WCS\344\275\277\347\224\250\346\226\271\346\263\225.docx" "b/WCS\344\275\277\347\224\250\346\226\271\346\263\225/WCS\344\275\277\347\224\250\346\226\271\346\263\225.docx" new file mode 100644 index 0000000..5532d1b --- /dev/null +++ "b/WCS\344\275\277\347\224\250\346\226\271\346\263\225/WCS\344\275\277\347\224\250\346\226\271\346\263\225.docx" Binary files differ diff --git "a/WCS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/Authorize/AuthorizeHelper.cs" "b/WCS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/Authorize/AuthorizeHelper.cs" new file mode 100644 index 0000000..f27a7bc --- /dev/null +++ "b/WCS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/Authorize/AuthorizeHelper.cs" @@ -0,0 +1,103 @@ +锘縰sing 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; + } + + } +} diff --git "a/WCS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/Authorize/Dto/AuthorizeClass.cs" "b/WCS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/Authorize/Dto/AuthorizeClass.cs" new file mode 100644 index 0000000..c031c79 --- /dev/null +++ "b/WCS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/Authorize/Dto/AuthorizeClass.cs" @@ -0,0 +1,24 @@ +锘縰sing 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; } + } +} diff --git "a/WCS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/Authorize/Dto/AuthorizeFunRetEntity.cs" "b/WCS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/Authorize/Dto/AuthorizeFunRetEntity.cs" new file mode 100644 index 0000000..928135f --- /dev/null +++ "b/WCS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/Authorize/Dto/AuthorizeFunRetEntity.cs" @@ -0,0 +1,154 @@ +锘縰sing 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 + }; + } + } +} diff --git "a/WMS\344\275\277\347\224\250\346\226\271\346\263\225/VerifyAuthrizeJob.cs" "b/WMS\344\275\277\347\224\250\346\226\271\346\263\225/VerifyAuthrizeJob.cs" new file mode 100644 index 0000000..d3d4fc7 --- /dev/null +++ "b/WMS\344\275\277\347\224\250\346\226\271\346\263\225/VerifyAuthrizeJob.cs" @@ -0,0 +1,43 @@ +锘�// 楹荤渷鐞嗗伐瀛﹂櫌璁稿彲璇� +// +// 鐗堟潈鎵�鏈� (c) 2021-2023 zuohuaijun锛屽ぇ鍚嶇鎶�锛堝ぉ娲ワ級鏈夐檺鍏徃 鑱旂郴鐢佃瘽/寰俊锛�18020030720 QQ锛�515096995 +// +// 鐗规鍏嶈垂鎺堜簣鑾峰緱鏈蒋浠剁殑浠讳綍浜轰互澶勭悊鏈蒋浠剁殑鏉冨埄锛屼絾椤婚伒瀹堜互涓嬫潯浠讹細鍦ㄦ墍鏈夊壇鏈垨閲嶈閮ㄥ垎鐨勮蒋浠朵腑蹇呴』鍖呮嫭涓婅堪鐗堟潈澹版槑鍜屾湰璁稿彲澹版槑銆� +// +// 杞欢鎸夆�滃師鏍封�濇彁渚涳紝涓嶆彁渚涗换浣曞舰寮忕殑鏄庣ず鎴栨殫绀虹殑淇濊瘉锛屽寘鎷絾涓嶉檺浜庡閫傞攢鎬с�侀�傜敤鎬у拰闈炰镜鏉冪殑淇濊瘉銆� +// 鍦ㄤ换浣曟儏鍐典笅锛屼綔鑰呮垨鐗堟潈鎸佹湁浜哄潎涓嶅浠讳綍绱㈣禂銆佹崯瀹虫垨鍏朵粬璐d换璐熻矗锛屾棤璁烘槸鍥犲悎鍚屻�佷镜鏉冩垨鍏朵粬鏂瑰紡寮曡捣鐨勶紝涓庤蒋浠舵垨鍏朵娇鐢ㄦ垨鍏朵粬浜ゆ槗鏈夊叧銆� + +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)] +//姝e紡鐜涓嬶紝瑕�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); + } + } +} diff --git "a/WMS\344\275\277\347\224\250\346\226\271\346\263\225/WMS\344\275\277\347\224\250\346\226\271\346\263\225.docx" "b/WMS\344\275\277\347\224\250\346\226\271\346\263\225/WMS\344\275\277\347\224\250\346\226\271\346\263\225.docx" new file mode 100644 index 0000000..6e4d40a --- /dev/null +++ "b/WMS\344\275\277\347\224\250\346\226\271\346\263\225/WMS\344\275\277\347\224\250\346\226\271\346\263\225.docx" Binary files differ diff --git "a/WMS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/VerifyAuthorization/AuthorizeFunRetEntity.cs" "b/WMS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/VerifyAuthorization/AuthorizeFunRetEntity.cs" new file mode 100644 index 0000000..f264f58 --- /dev/null +++ "b/WMS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/VerifyAuthorization/AuthorizeFunRetEntity.cs" @@ -0,0 +1,154 @@ +锘縰sing 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 + }; + } + } +} diff --git "a/WMS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/VerifyAuthorization/VerifyAuthorizationUtil.cs" "b/WMS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/VerifyAuthorization/VerifyAuthorizationUtil.cs" new file mode 100644 index 0000000..db4c16a --- /dev/null +++ "b/WMS\344\275\277\347\224\250\346\226\271\346\263\225/\344\273\243\347\240\201/VerifyAuthorization/VerifyAuthorizationUtil.cs" @@ -0,0 +1,39 @@ +锘�// 楹荤渷鐞嗗伐瀛﹂櫌璁稿彲璇� +// +// 鐗堟潈鎵�鏈� (c) 2021-2023 zuohuaijun锛屽ぇ鍚嶇鎶�锛堝ぉ娲ワ級鏈夐檺鍏徃 鑱旂郴鐢佃瘽/寰俊锛�18020030720 QQ锛�515096995 +// +// 鐗规鍏嶈垂鎺堜簣鑾峰緱鏈蒋浠剁殑浠讳綍浜轰互澶勭悊鏈蒋浠剁殑鏉冨埄锛屼絾椤婚伒瀹堜互涓嬫潯浠讹細鍦ㄦ墍鏈夊壇鏈垨閲嶈閮ㄥ垎鐨勮蒋浠朵腑蹇呴』鍖呮嫭涓婅堪鐗堟潈澹版槑鍜屾湰璁稿彲澹版槑銆� +// +// 杞欢鎸夆�滃師鏍封�濇彁渚涳紝涓嶆彁渚涗换浣曞舰寮忕殑鏄庣ず鎴栨殫绀虹殑淇濊瘉锛屽寘鎷絾涓嶉檺浜庡閫傞攢鎬с�侀�傜敤鎬у拰闈炰镜鏉冪殑淇濊瘉銆� +// 鍦ㄤ换浣曟儏鍐典笅锛屼綔鑰呮垨鐗堟潈鎸佹湁浜哄潎涓嶅浠讳綍绱㈣禂銆佹崯瀹虫垨鍏朵粬璐d换璐熻矗锛屾棤璁烘槸鍥犲悎鍚屻�佷镜鏉冩垨鍏朵粬鏂瑰紡寮曡捣鐨勶紝涓庤蒋浠舵垨鍏朵娇鐢ㄦ垨鍏朵粬浜ゆ槗鏈夊叧銆� + + +//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 = "鏈巿鏉冧笉鍏佽鎿嶄綔" }; + } + } +} -- Gitblit v1.9.3