@@ -25,6 +25,9 @@ public partial class LicenseManager : ObservableObject, ILicenseManager
2525 [ ObservableProperty ]
2626 public partial int ? Port { get ; set ; } = null ;
2727
28+ [ ObservableProperty ]
29+ public partial int Timeout { get ; set ; } = 10000 ;
30+
2831#nullable enable
2932 [ ObservableProperty ]
3033 public partial string ? AccessToken { get ; set ; }
@@ -55,21 +58,21 @@ public void Initialize(Uri licenseServer = null, int? port = null)
5558 Port = port ;
5659 options = new ( )
5760 {
61+ Timeout = TimeSpan . FromMilliseconds ( Timeout ) ,
5862 BaseUrl = new Uri ( $ "{ LicenseServer } :{ Port } ") ,
5963 Expect100Continue = true ,
6064 } ;
6165 RestClient = new RestClient ( httpClient : HttpClient , options : options ) ;
62- //client = new RestClient(httpClient: HttpClient, $"{LicenseServer}:{Port}",);
6366 }
6467 else
6568 {
6669 options = new ( )
6770 {
71+ Timeout = TimeSpan . FromMilliseconds ( Timeout ) ,
6872 BaseUrl = LicenseServer ,
6973 Expect100Continue = true ,
7074 } ;
7175 RestClient = new RestClient ( httpClient : HttpClient , options : options ) ;
72- //client = new(LicenseServer);
7376 }
7477 }
7578
@@ -80,7 +83,7 @@ public async Task<ILicenseQueryResult> ActivateLicenseAsync(ILicenseInfo license
8083 if ( license == null ) return result ;
8184 if ( license ? . Options ? . VerifyLicenseFormat == true && ! string . IsNullOrEmpty ( license ? . Options ? . LicenseCheckPattern ) )
8285 {
83- bool licenseFormatValid = LicenseManager . VerifyLicenseFormat ( license , license ? . Options . LicenseCheckPattern ) ;
86+ bool licenseFormatValid = VerifyLicenseFormat ( license , license ? . Options . LicenseCheckPattern ) ;
8487 result . Message = "License format is invalid" ;
8588 return result ;
8689 }
@@ -140,7 +143,7 @@ public async Task<ILicenseQueryResult> CheckLicenseAsync(ILicenseInfo license, L
140143 if ( license == null ) return result ;
141144 if ( license ? . Options ? . VerifyLicenseFormat == true && ! string . IsNullOrEmpty ( license ? . Options ? . LicenseCheckPattern ) )
142145 {
143- bool licenseFormatValid = LicenseManager . VerifyLicenseFormat ( license , license ? . Options . LicenseCheckPattern ) ;
146+ bool licenseFormatValid = VerifyLicenseFormat ( license , license ? . Options . LicenseCheckPattern ) ;
144147 result . Message = "License format is invalid" ;
145148 return result ;
146149 }
@@ -221,7 +224,7 @@ public async Task<ILicenseQueryResult> DeactivateLicenseAsync(ILicenseInfo licen
221224 if ( license == null ) return result ;
222225 if ( license ? . Options ? . VerifyLicenseFormat == true && ! string . IsNullOrEmpty ( license ? . Options ? . LicenseCheckPattern ) )
223226 {
224- bool licenseFormatValid = LicenseManager . VerifyLicenseFormat ( license , license ? . Options . LicenseCheckPattern ) ;
227+ bool licenseFormatValid = VerifyLicenseFormat ( license , license ? . Options . LicenseCheckPattern ) ;
225228 result . Message = "License format is invalid" ;
226229 return result ;
227230 }
@@ -285,7 +288,7 @@ public async Task<ILicenseQueryResult> DeleteLicenseAsync(ILicenseInfo license,
285288 if ( license == null ) return result ;
286289 if ( license ? . Options ? . VerifyLicenseFormat == true && ! string . IsNullOrEmpty ( license ? . Options ? . LicenseCheckPattern ) )
287290 {
288- bool licenseFormatValid = LicenseManager . VerifyLicenseFormat ( license , license ? . Options . LicenseCheckPattern ) ;
291+ bool licenseFormatValid = VerifyLicenseFormat ( license , license ? . Options . LicenseCheckPattern ) ;
289292 result . Message = "License format is invalid" ;
290293 return result ;
291294 }
@@ -494,7 +497,7 @@ async Task<WooActivationResponse[]> QueryWooCommerceAsync(string action, ILicens
494497 {
495498 parameters . Add ( "domain" , license . Domain ) ;
496499 }
497- string jsonResult = await RestApiCallAsync ( command , Method . Get , parameters , new ( 10000 ) ) ;
500+ string jsonResult = await RestApiCallAsync ( command , Method . Get , parameters , cts : new ( Timeout ) ) ;
498501 WooActivationResponse [ ] result = JsonSerializer . Deserialize ( jsonResult , LicenseSourceGenerationContext . Default . WooActivationResponseArray ) ;
499502 return result ;
500503 }
@@ -522,7 +525,7 @@ async Task<WooCodeVersionResponse[]> QueryLatestApplicationVersionFromWooCommerc
522525 parameters . Add ( "domain" , license . Domain ) ;
523526 }
524527 }
525- string jsonResult = await RestApiCallAsync ( command , Method . Get , parameters , new ( 10000 ) ) ;
528+ string jsonResult = await RestApiCallAsync ( command , Method . Get , parameters , cts : new ( Timeout ) ) ;
526529
527530 WooCodeVersionResponse [ ] result = JsonSerializer . Deserialize ( jsonResult , LicenseSourceGenerationContext . Default . WooCodeVersionResponseArray ) ;
528531 return result ;
@@ -543,7 +546,7 @@ async Task<WooCodeVersionResponse[]> QueryLatestApplicationVersionFromWooCommerc
543546 { "woo_sl_action" , action } ,
544547 { "product_unique_id" , productCode }
545548 } ;
546- string jsonResult = await RestApiCallAsync ( command , Method . Get , parameters , new ( 10000 ) ) ;
549+ string jsonResult = await RestApiCallAsync ( command , Method . Get , parameters , cts : new ( Timeout ) ) ;
547550 WooCodeVersionResponse [ ] result = JsonSerializer . Deserialize ( jsonResult , LicenseSourceGenerationContext . Default . WooCodeVersionResponseArray ) ;
548551 return result ;
549552 }
@@ -569,7 +572,7 @@ async Task<EnvatoVerifyPurchaseCodeRespone> QueryEnvatoAsync(ILicenseInfo licens
569572 Dictionary < string , string > parameters = new ( ) {
570573 { "code" , license . License } ,
571574 } ;
572- string jsonResult = await RestApiCallAsync ( command , Method . Get , parameters : parameters , headers : headers , new ( 10000 ) ) ;
575+ string jsonResult = await RestApiCallAsync ( command , Method . Get , parameters : parameters , headers : headers , cts : new ( Timeout ) ) ;
573576
574577 EnvatoVerifyPurchaseCodeRespone result = JsonSerializer . Deserialize ( jsonResult , LicenseSourceGenerationContext . Default . EnvatoVerifyPurchaseCodeRespone ) ;
575578 return result ;
0 commit comments