1- using CommandLine ;
1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . IO ;
4+ using System . ServiceModel ;
5+ using System . Threading . Tasks ;
6+ using CommandLine ;
7+ using CommandLine . Text ;
28
39namespace PX . Api . ContractBased . Maintenance . Cli . Verbs
410{
511 [ Verb ( "putSchema" ) ]
612 internal class PutSchema
713 {
14+ [ Value ( 0 , Required = true , MetaName = "acumaticaBaseUrl" ) ]
15+ public string AcumaticaUrl { get ; set ; }
16+
17+ [ Option ( 'u' , "user" , Default = "admin" , Required = false ) ]
18+ public string Login { get ; set ; }
19+
20+ [ Option ( 'p' , "pwd" , Required = true ) ]
21+ public string Password { get ; set ; }
22+
23+ [ Option ( 's' , "service" ) ]
24+ public string ServiceVersion { get ; set ; }
25+
26+ [ Value ( 1 , Required = true , MetaName = "endpointDefinitionFile" ) ]
27+ public string EndpointDefinitionFile { get ; set ; }
28+
29+ [ Usage ]
30+ public static IEnumerable < Example > Usage
31+ {
32+ get
33+ {
34+ yield return new Example (
35+ "Typical usage" ,
36+ new UnParserSettings { PreferShortName = true } ,
37+ new PutSchema
38+ {
39+ AcumaticaUrl = "http://acumatica-host/acumatica-dir" ,
40+ EndpointDefinitionFile = "Custom-001.xml" ,
41+ Password = "<your admin password>"
42+ } ) ;
43+ }
44+ }
45+
46+ public async Task < int > InvokeAsync ( )
47+ {
48+ using ( var client = new Maintenance531 . EntityMaintenanceSoapClient ( new BasicHttpBinding
49+ {
50+ AllowCookies = true ,
51+ MaxReceivedMessageSize = 1024 * 1024 ,
52+ } , new EndpointAddress ( AcumaticaUrl + "/entity/maintenance/5.31" ) ) )
53+ {
54+ await client . LoginAsync ( Login , Password , null , null , null ) . ConfigureAwait ( false ) ;
55+ try
56+ {
57+ await client . PutSchemaAsync ( File . ReadAllText ( EndpointDefinitionFile ) ) . ConfigureAwait ( false ) ;
58+ }
59+ finally
60+ {
61+ client . Logout ( ) ;
62+ }
63+ }
64+ return 0 ;
65+ }
866 }
967}
0 commit comments