当前位置: 首页>>代码示例>>C#>>正文


C# Command.WithParam方法代码示例

本文整理汇总了C#中Command.WithParam方法的典型用法代码示例。如果您正苦于以下问题:C# Command.WithParam方法的具体用法?C# Command.WithParam怎么用?C# Command.WithParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Command的用法示例。


在下文中一共展示了Command.WithParam方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

    /// <summary>
    /// Code for executing the command
    /// </summary>
    public async Task Run(TestContext context)
    {
      var cmd = new Command().WithAml(this.Text);
      cmd.Action = CommandAction.DownloadFile;
      foreach (var kvp in context.Parameters)
      {
        cmd.WithParam(kvp.Key, kvp.Value);
      }

      try
      {
        var stream = await context.Connection.Process(cmd, true).ToTask();
        var memStream = await stream.ToMemoryStream();
        var start = await memStream.ReadStart(500);
        memStream.Position = 0;
        if (start.IndexOf("http://www.aras.com/InnovatorFault") > 0)
        {
          context.LastResult = XElement.Load(stream);
        }
        else
        {
          context.LastResult = new XElement("Result", new XElement("Item", Convert.ToBase64String(memStream.ToArray())));
        }
      }
      catch (ServerException se)
      {
        context.LastResult = XElement.Parse(se.AsAmlString());
      }
    }
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:32,代码来源:DownloadFile.cs

示例2: Apply

 /// <summary>
 /// Get the result of executing the specified query
 /// </summary>
 /// <param name="conn">Database action</param>
 /// <param name="action">SOAP action</param>
 /// <param name="query">Query to be performed.  If parameters are specified, then the query is fomatted using the <see cref="ElementFactory.FormatQuery"/> method</param>
 /// <param name="parameters">Parameters to be injected into the query</param>
 /// <returns>A read-only result</returns>
 public static IReadOnlyResult Apply(this IConnection conn, Command query, params object[] parameters)
 {
   if (parameters != null)
   {
     for (var i = 0; i < parameters.Length; i++)
     {
       query.WithParam(i.ToString(), parameters[i]);
     }
   }
   return conn.AmlContext.FromXml(conn.Process(query), query.Aml, conn);
 }
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:19,代码来源:ConnectionExtensions.cs

示例3: Run

    public async Task Run(TestContext context)
    {
      var cmd = new Command().WithAml(this.Text);
      cmd.Action = CommandAction.ApplyItem;
      if (this.Text.StartsWith("<sql") || this.Text.StartsWith("<SQL"))
        cmd.Action = CommandAction.ApplySQL;
      foreach (var kvp in context.Parameters)
      {
        cmd.WithParam(kvp.Key, kvp.Value);
      }

      var stream = await context.Connection.Process(cmd, true).ToTask();
      context.LastResult = XElement.Load(stream);
    }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:14,代码来源:Query.cs

示例4: ApplySql

 public static IReadOnlyResult ApplySql(this IConnection conn, Command sql, params object[] parameters)
 {
   if (parameters != null)
   {
     for (var i = 0; i < parameters.Length; i++)
     {
       sql.WithParam(i.ToString(), parameters[i]);
     }
   }
   if (!sql.Aml.TrimStart().StartsWith("<"))
   {
     sql.Aml = "<sql>" + sql.Aml + "</sql>";
   }
   return conn.Apply(sql.WithAction(CommandAction.ApplySQL));
 }
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:15,代码来源:ConnectionExtensions.cs

示例5: ApplyAsync

    public static IPromise<IReadOnlyResult> ApplyAsync(this IAsyncConnection conn, Command query, bool async, bool noItemsIsError, params object[] parameters)
    {
      var result = new Promise<IReadOnlyResult>();
      if (parameters != null)
      {
        for (var i = 0; i < parameters.Length; i++)
        {
          query.WithParam(i.ToString(), parameters[i]);
        }
      }

      result.CancelTarget(
        conn.Process(query, async)
        .Progress((p, m) => result.Notify(p, m))
        .Done(r =>
          {
            try
            {
              var res = conn.AmlContext.FromXml(r, query.Aml, conn);
              var ex = res.Exception;
              if (ex != null && (noItemsIsError || !(ex is NoItemsFoundException)))
              {
                result.Reject(ex);
              }
              else
              {
                result.Resolve(res);
              }
            }
            catch (Exception ex)
            {
              result.Reject(ex);
            }
          }).Fail(ex =>
          {
            result.Reject(ex);
          }));
      return result;
    }
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:39,代码来源:ConnectionExtensions.cs


注:本文中的Command.WithParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。