Пример #1
0
        /// <summary>
        /// Calls a SOAP action asynchronously
        /// </summary>
        /// <param name="request">Request AML and possibly files <see cref="UploadCommand" /></param>
        /// <param name="async">Whether to perform this action asynchronously</param>
        /// <returns>
        /// A promise to return an XML SOAP response as a string
        /// </returns>
        public IPromise <Stream> Process(Command request, bool async)
        {
            var upload = request as UploadCommand;

            if (upload == null)
            {
                if (request.Action == CommandAction.DownloadFile)
                {
                    return(_vaultConn.Download(request, async));
                }

                var input = new XmlDocument();
                input.LoadXml(request.ToNormalizedAml(AmlContext.LocalizationContext));
                var output = new XmlDocument();

                using (new LogData(4
                                   , "Innovator: Execute query"
                                   , request.LogListener ?? Factory.LogListener
                                   , request.Parameters)
                {
                    { "database", _httpDatabase },
                    { "query", request.Aml },
                    { "soap_action", request.ActionString },
                    { "url", _requestUrl },
                    { "user_name", _httpUsername },
                    { "user_id", UserId },
                    { "version", Version }
                })
                {
                    _callAction(request.ActionString, input, output);
                }

                return(Promises.Resolved <Stream>(new XmlStream(() => new XmlNodeReader(output))));
            }

            // Files need to be uploaded, so build the vault request
            return(_vaultConn.Upload(upload, async));
        }
Пример #2
0
        public Stream Process(Command request)
        {
            if (request is UploadCommand)
            {
                return(_vaultConn.Upload((UploadCommand)request, false).Wait());
            }

            LastRequest = request;
            var elem = XElement.Parse(request.ToNormalizedAml(this.AmlContext.LocalizationContext));

            QueryCallback?.Invoke(request.ActionString, elem.ToString(SaveOptions.DisableFormatting));
            var result = DefaultResponse;

            if (request.Action == CommandAction.GetIdentityList)
            {
                result = @"<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
  <SOAP-ENV:Body>
    <Result>F13AF7BC3D7A4084AF67AB7BF938C409,A73B655731924CD0B027E4F4D5FCC0A9</Result>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>";
            }
            else if (AttrEquals(elem, "action", "get"))
            {
                switch (AttrValue(elem, "type"))
                {
                case "Company":
                    if (AttrEquals(elem, "id", "0E086FFA6C4646F6939B74C43D094182"))
                    {
                        result = @"<Item type='Company' typeId='3E71E373FC2940B288760C915120AABE' id='0E086FFA6C4646F6939B74C43D094182'>
  <created_by_id keyed_name='First Last' type='User'>
    <Item type='User' typeId='45E899CD2859442982EB22BB2DF683E5' id='8227040ABF0A46A8AF06C18ABD3967B3'>
      <id keyed_name='First Last' type='User'>8227040ABF0A46A8AF06C18ABD3967B3</id>
      <first_name>First</first_name>
      <itemtype>45E899CD2859442982EB22BB2DF683E5</itemtype>
    </Item>
  </created_by_id>
  <id keyed_name='Another Company' type='Company'>0E086FFA6C4646F6939B74C43D094182</id>
  <permission_id keyed_name='Company' type='Permission'>
    <Item type='Permission' typeId='C6A89FDE1294451497801DF78341B473' id='A8FC3EC44ED0462B9A32D4564FAC0AD8'>
      <id keyed_name='Company' type='Permission'>A8FC3EC44ED0462B9A32D4564FAC0AD8</id>
      <name>Company</name>
    </Item>
  </permission_id>
  <itemtype>3E71E373FC2940B288760C915120AABE</itemtype>
</Item>";
                    }
                    break;

                case "User":
                    if (AttrEquals(elem, "id", "2D246C5838644C1C8FD34F8D2796E327") || elem.Element("id")?.Value == "2D246C5838644C1C8FD34F8D2796E327")
                    {
                        result = @"<Result>
  <Item type='User' typeId='45E899CD2859442982EB22BB2DF683E5' id='8227040ABF0A46A8AF06C18ABD3967B3'>
    <default_vault keyed_name='Default' type='Vault'>
      <Item type='Vault' typeId='8FC29FEF933641A09CEE13A604A9DC74' id='51C2A8877C4D4038A5A0C3071A863706'>
        <id keyed_name='Default' type='Vault'>51C2A8877C4D4038A5A0C3071A863706</id>
        <keyed_name>Default</keyed_name>
        <vault_url_pattern>$[HTTP_PREFIX_SERVER]$[HTTP_HOST_SERVER]$[HTTP_PORT_SERVER]$[HTTP_PATH_SERVER]/vault/vaultserver.aspx</vault_url_pattern>
        <name>Default</name>
        <vault_url>http://server/innovator11sp12/vault/vaultserver.aspx</vault_url>
      </Item>
    </default_vault>
    <id keyed_name='First Last' type='User'>8227040ABF0A46A8AF06C18ABD3967B3</id>
    <itemtype>45E899CD2859442982EB22BB2DF683E5</itemtype>
    <Relationships>
      <Item type='ReadPriority' typeId='8CFAF78BCFFB41E6A3ED838D9EC2FD7C' id='749A3C52A15247F4AB7EDE406AA19AF8'>
        <id keyed_name='749A3C52A15247F4AB7EDE406AA19AF8' type='ReadPriority'>749A3C52A15247F4AB7EDE406AA19AF8</id>
        <priority>10</priority>
        <related_id keyed_name='Default' type='Vault'>
          <Item type='Vault' typeId='8FC29FEF933641A09CEE13A604A9DC74' id='51C2A8877C4D4038A5A0C3071A863706'>
            <id keyed_name='Default' type='Vault'>51C2A8877C4D4038A5A0C3071A863706</id>
            <keyed_name>Default</keyed_name>
            <vault_url_pattern>$[HTTP_PREFIX_SERVER]$[HTTP_HOST_SERVER]$[HTTP_PORT_SERVER]$[HTTP_PATH_SERVER]/vault/vaultserver.aspx</vault_url_pattern>
            <name>Default</name>
            <vault_url>http://server/innovator11sp12/vault/vaultserver.aspx</vault_url>
          </Item>
        </related_id>
        <source_id keyed_name='First Last' type='User'>
          <Item type='User' typeId='45E899CD2859442982EB22BB2DF683E5' id='8227040ABF0A46A8AF06C18ABD3967B3'>
            <id keyed_name='First Last' type='User'>8227040ABF0A46A8AF06C18ABD3967B3</id>
            <itemtype>45E899CD2859442982EB22BB2DF683E5</itemtype>
          </Item>
        </source_id>
      </Item>
    </Relationships>
  </Item>
</Result>";
                    }
                    else if (AttrEquals(elem, "id", "8227040ABF0A46A8AF06C18ABD3967B3"))
                    {
                        result = @"<Result><Item type='User' typeId='45E899CD2859442982EB22BB2DF683E5' id='8227040ABF0A46A8AF06C18ABD3967B3'>
  <id keyed_name='First Last' type='User'>8227040ABF0A46A8AF06C18ABD3967B3</id>
  <first_name>First</first_name>
  <itemtype>45E899CD2859442982EB22BB2DF683E5</itemtype>
</Item></Result>";
                    }
                    break;

                case "Permission":
                    if (AttrEquals(elem, "id", "A8FC3EC44ED0462B9A32D4564FAC0AD8"))
                    {
                        result = @"<Result><Item type='Permission' typeId='C6A89FDE1294451497801DF78341B473' id='A8FC3EC44ED0462B9A32D4564FAC0AD8'>
  <id keyed_name='Company' type='Permission'>A8FC3EC44ED0462B9A32D4564FAC0AD8</id>
  <name>Company</name>
</Item></Result>";
                    }
                    break;

                case "ItemType":
                    result = @"<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
  <SOAP-ENV:Body>
    <Result>
      <Item type='ItemType' typeId='450906E86E304F55A34B3C0D65C097EA' id='4F1AC04A2B484F3ABA4E20DB63808A88'>
        <allow_private_permission>1</allow_private_permission>
        <auto_search>0</auto_search>
        <config_id keyed_name='Part' type='ItemType' name='Part'>4F1AC04A2B484F3ABA4E20DB63808A88</config_id>
        <core>0</core>
        <created_by_id keyed_name='Super User' type='User'>AD30A6D8D3B642F5A2AFED1A4B02BEFA</created_by_id>
        <created_on>2010-04-06T12:41:29</created_on>
        <default_page_size>30</default_page_size>
        <enforce_discovery>1</enforce_discovery>
        <generation>1</generation>
        <help_url xml:lang='en'>mergedProjects/ProductEngineering/plm_Parts.htm</help_url>
        <hide_where_used>0</hide_where_used>
        <history_template keyed_name='Default' type='History Template'>3BC16EF9E52B4F9792AB76BCE0492F29</history_template>
        <id keyed_name='Part' type='ItemType'>4F1AC04A2B484F3ABA4E20DB63808A88</id>
        <implementation_type>table</implementation_type>
        <instance_data>PART</instance_data>
        <is_cached>0</is_cached>
        <is_current>1</is_current>
        <is_dependent>0</is_dependent>
        <is_relationship>0</is_relationship>
        <is_released>0</is_released>
        <is_versionable>1</is_versionable>
        <keyed_name>Part</keyed_name>
        <label xml:lang='en'>Part</label>
        <label_plural xml:lang='en'>Parts</label_plural>
        <major_rev>A</major_rev>
        <manual_versioning>1</manual_versioning>
        <maxrecords>1000</maxrecords>
        <new_version>0</new_version>
        <not_lockable>0</not_lockable>
        <permission_id keyed_name='ItemType' type='Permission'>102D29B8CD9948BFB5F558341DF4C0F9</permission_id>
        <show_parameters_tab>1</show_parameters_tab>
        <structure_view>tab view</structure_view>
        <unlock_on_logout>0</unlock_on_logout>
        <use_src_access>0</use_src_access>
        <name>Part</name>
      </Item>
    </Result>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>";
                    break;
                }
            }

            return(new MemoryStream(Encoding.UTF8.GetBytes(result)));
        }