Beispiel #1
0
 public static Vault GetVault(IReadOnlyItem i)
 {
   if (i == null || !i.Exists) return null;
   Vault result;
   if (!_vaults.TryGetValue(i.Id(), out result))
   {
     result = new Vault(i);
     _vaults[i.Id()] = result;
   }
   return result;
 }
 public UploadCommand(Vault vault)
 {
   _vault = vault;
 }
Beispiel #3
0
 /// <summary>
 /// Create an upload command with the specified vault metadata
 /// </summary>
 /// <param name="vault">Vault metadata</param>
 protected UploadCommand(Connection.IArasConnection conn, Vault vault)
 {
     Vault = vault;
     _conn = conn;
 }
Beispiel #4
0
        /// <summary>
        /// Uploads the files and applies the AML in a single transaction
        /// </summary>
        /// <param name="async">Whether to perform this action asynchronously</param>
        /// <returns>A promise to return an XML SOAP response as a <see cref="System.IO.Stream"/></returns>
        internal IPromise <Stream> UploadAndApply(string soapAction, string aml, IEnumerable <CommandFile> files, bool async)
        {
            return(_conn.FetchVersion(async).Continue(v =>
            {
                return Vault.TransformUrl(_conn, async).Continue(u =>
                {
                    // Compile the headers and AML query into the appropriate content
                    HttpRequest req;
                    var content = new FormContent
                    {
                        {
                            "XMLdata",
                            "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:i18n=\"http://www.aras.com/I18N\"><SOAP-ENV:Body><ApplyItem>" +
                            aml +
                            "</ApplyItem></SOAP-ENV:Body></SOAP-ENV:Envelope>"
                        }
                    };
                    foreach (var file in files)
                    {
                        content.Add(file.AsContent(this, _conn.AmlContext.LocalizationContext, true).Single());
                    }
                    content.Compression = _conn.Compression;
                    if (_conn.Version >= new Version(12, 0, 9))
                    {
                        req = GetUploadRequest12sp09(content, soapAction);
                    }
                    else
                    {
                        req = GetUploadRequestLegacy(content, soapAction);
                    }
                    foreach (var ac in _conn.DefaultSettings)
                    {
                        ac.Invoke(req);
                    }
                    Settings?.Invoke(req);

                    req.Headers.TransferEncodingChunked = true;

                    var trace = new LogData(4
                                            , "Innovator: Execute query"
                                            , LogListener ?? Factory.LogListener
                                            , Parameters)
                    {
                        { "aras_url", _conn.MapClientUrl("../../Server") },
                        { "database", _conn.Database },
                        { "query", aml },
                        { "soap_action", soapAction },
                        { "url", Vault.Url },
                        { "user_id", _conn.UserId },
                        { "vault_id", Vault.Id },
                        { "version", _conn.Version }
                    };
                    _conn.SetDefaultHeaders((name, value) =>
                    {
                        if (string.Equals(name, "LOCALE", StringComparison.OrdinalIgnoreCase) ||
                            string.Equals(name, "TIMEZONE_NAME", StringComparison.OrdinalIgnoreCase))
                        {
                            trace.Add(name.ToLowerInvariant(), value);
                        }
                    });
                    return Vault.HttpClient
                    .PostPromise(new Uri(Vault.Url), async, req, trace)
                    .Always(trace.Dispose)
                    .Always(req.Dispose);
                }).Convert(r => r.AsStream);
            }));
        }