本文整理汇总了C#中Command.ToNormalizedAml方法的典型用法代码示例。如果您正苦于以下问题:C# Command.ToNormalizedAml方法的具体用法?C# Command.ToNormalizedAml怎么用?C# Command.ToNormalizedAml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command
的用法示例。
在下文中一共展示了Command.ToNormalizedAml方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Download
public IPromise<Stream> Download(Command request, bool async)
{
var parsedAml = _conn.AmlContext.FromXml(request.ToNormalizedAml(_conn.AmlContext.LocalizationContext));
var file = (IReadOnlyItem)parsedAml.AssertItem("File");
var hasVaults = file.Relationships("Located")
.Select(r => r.RelatedId().AsItem())
.Any(i => i.Exists);
var filePromise = hasVaults ?
Promises.Resolved(file) :
_conn.ItemByQuery(new Command(DownloadFileAmlFormat, file.Id()), async);
// Get the file data and user data as necessary
return Promises
.All(filePromise, _vaultStrategy.ReadPriority(async))
.Continue(o =>
{
// Get the correct vault for the file
var vault = GetReadVaultForFile(o.Result1, o.Result2);
if (vault == null) throw new ApplicationException("Vault location of the file is unknown");
// Download the file
return DownloadFileFromVault(o.Result1, vault, async, request);
})
.Convert(r => r.AsStream);
}
示例2: DownloadFile
private IPromise<Stream> DownloadFile(Command request, bool async)
{
var parsedAml = _factory.FromXml(request.ToNormalizedAml(_factory.LocalizationContext));
var file = parsedAml.AssertItem("File");
if (string.IsNullOrEmpty(file.Id()))
return Promises.Rejected<Stream>(new ArgumentException("Request does not represent a single file item", "request"));
var downloadBase = new Uri(_endpoints.Base, _endpoints.Download.First());
return _service.Execute("GET"
, new Uri(downloadBase, Uri.EscapeUriString(_database) + "/"
+ Uri.EscapeUriString(file.Id())).ToString()
, null, CredentialCache.DefaultCredentials, async, r =>
{
foreach (var a in _defaults)
{
a.Invoke(r);
}
})
.Convert(r => r.AsStream);
}
示例3: Process
public IPromise<Stream> Process(Command request, bool async)
{
var upload = request as UploadCommand;
if (upload == null)
{
if (request.Action == CommandAction.DownloadFile)
return DownloadFile(request, async);
return Query(_sessionToken, request.Action.ToString(), request.ToNormalizedAml(_factory.LocalizationContext)
, this.SessionPolicy, null, async)
.Convert(r => r.AsStream);
} else if (request.Action == CommandAction.DownloadFile)
{
throw new ArgumentException("Cannot download a file with an upload request.");
}
var multiWriter = new MultiPartFormWriter(async, _factory.LocalizationContext);
multiWriter.AddFiles(upload);
multiWriter.WriteFormField("SOAPACTION", request.Action.ToString());
multiWriter.WriteFormField("XMLdata", "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:i18n=\"http://www.aras.com/I18N\"><SOAP-ENV:Body><ApplyItem>"
+ upload.ToNormalizedAml(_factory.LocalizationContext)
+ "</ApplyItem></SOAP-ENV:Body></SOAP-ENV:Envelope>");
return _service.Execute("POST", new Uri(_endpoints.Base, _endpoints.Query.First()).ToString()
, null, CredentialCache.DefaultCredentials, async, req =>
{
req.ConfigureForFileUpload();
foreach (var a in _defaults)
{
a.Invoke(req);
}
req.Timeout = -1;
req.SetHeader("Content-Length", multiWriter.GetLength().ToString());
req.SetHeader("Accept", "text/xml");
if (!string.IsNullOrEmpty(_sessionToken))
req.SetHeader("Authorization", "Bearer " + _sessionToken);
req.SetHeader("SOAPACTION", request.Action.ToString());
req.SetContent(multiWriter.WriteToRequest, multiWriter.ContentType);
}).Convert(r => r.AsStream);
}
示例4: UploadAml
private IPromise<IHttpResponse> UploadAml(Uri uri, string action, Command request, bool async)
{
return _service.Execute("POST", uri.ToString(), null, CredentialCache.DefaultCredentials, async, req =>
{
((IArasConnection)this).SetDefaultHeaders((k, v) => { req.SetHeader(k, v); });
foreach (var a in _defaults)
{
a.Invoke(req);
}
if (request.Settings != null) request.Settings.Invoke(req);
if (!string.IsNullOrEmpty(action)) req.SetHeader("SOAPACTION", action);
req.SetContent(w => w.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + request.ToNormalizedAml(_factory.LocalizationContext)).Close(), "text/xml");
});
}