Skip to content

Commit b1e4dec

Browse files
committed
Naive implementation for PutSchema
1 parent 92c5dbd commit b1e4dec

2 files changed

Lines changed: 60 additions & 2 deletions

File tree

Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static int Main(string[] args)
1515
)
1616
.MapResult(
1717
(GetSchema opts) => opts.InvokeAsync().Result,
18-
(PutSchema opts) => 0,
18+
(PutSchema opts) => opts.InvokeAsync().Result,
1919
errors => 2
2020
);
2121
}

Verbs/PutSchema.cs

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,67 @@
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

39
namespace 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

Comments
 (0)