Ready to get started?

Learn more about the CData ADO.NET Provider for FedEx or download a free trial:

Download Now

Powershell からの FedEx 統合タスクを自動化

PowerShell から FedEx data に簡単に接続する方法をお探しですか? CData ADO.NET Provider for FedEx は、PowerShell スクリプトの優位性を使い、シンプルで簡単に使えるADO.NET インターフェース を提供します。PowerShell スクリプトで、ADO.NET オブジェクトを使って簡単にFedEx data に接続して、同期、自動化、ダウンロードなどが可能!



CData ADO.NET Provider for FedEx は、ADO.NET 標準インターフェースへ統合し、PowerShell のような. NET アプリケーションからFedEx API へのアクセスを可能にします。このプロバイダーは、FedEx data の認証および相互作用を簡単にします。このチュートリアルでは、PowerShell から直接SQL クエリを実行するための、いくつかの一般的なADO.NET オブジェクトの使い方を説明します。

クエリの実行

次の3つのステップに従って create、read、update、およびdelete (CRUD) コマンドを PowerShell のFedEx data に実行:

  1. プロバイダーのアセンブリをロード:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for FedEx\lib\System.Data.CData.FedEx.dll")
  2. FedEx data に接続:

    There are five pieces of information needed in order to authenticate its actions with the FedEx service. This information is below.

    • Server: This controls the URL where the requests should be sent. Common testing options for this are: "https://gatewaybeta.fedex.com:443/xml", "https://wsbeta.fedex.com:443/xml", "https://gatewaybeta.fedex.com:443/web-service", and "https://wsbeta.fedex.com:443/web-service"
    • DeveloperKey: This is the identifier part of the authentication key for the sender's identity. This value will be provided to you by FedEx after registration.
    • Password: This is the secret part of the authentication key for the sender's identity. This value will be provided to you by FedEx after registration.
    • AccountNumber: This valid 9-digit FedEx account number is used for logging into the FedEx server.
    • MeterNumber: This value is used for submitting requests to FedEx. This value will be provided to you by FedEx after registration.
    • PrintLabelLocation: This property is required if one intends to use the GenerateLabels or GenerateReturnLabels stored procedures. This should be set to the folder location where generated labels should be stored.

    The Cache Database

    Many of the useful tasks available from FedEx require a lot of data. To ensure this data is easy to input and recall later, utilizes a cache database to make these requests. You must set the cache connection properties:

    • CacheProvider: The specific database you are using to cache with. For example, org.sqlite.JDBC.
    • CacheConnection: The connection string to be passed to the cache provider. For example, jdbc:sqlite:C:\users\username\documents\fedexcache.db

    $constr = "Server='https://gatewaybeta.fedex.com:443/xml';DeveloperKey='alsdkfjpqoewiru';Password='zxczxqqtyiuowkdlkn';AccountNumber='110371337';MeterNumber='240134349'; PrintLabelLocation='C:\users\username\documents\mylabels';CacheProvider='org.sqlite.JDBC';CacheConnection='jdbc:sqlite:C:\users\username\documents\fedexcache.db';" $conn= New-Object System.Data.CData.FedEx.FedExConnection($constr) $conn.Open()
  3. FedExDataAdapter のインスタンスを生成してSQL クエリを実行し、結果を出力:

    $sql="SELECT FirstName, Phone from Senders" $da= New-Object System.Data.CData.FedEx.FedExDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.firstname $_.phone }

FedEx Data の更新

$cmd = New-Object System.Data.CData.FedExCommand("UPDATE Senders SET SenderID='ab26f704-5edf-4a9f-9e4c-25' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.FedExParameter("myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

FedEx Data の挿入

$cmd = New-Object System.Data.CData.FedExCommand("UPDATE Senders SET SenderID='ab26f704-5edf-4a9f-9e4c-25' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.FedExParameter("myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

FedEx Data の削除

$cmd = New-Object System.Data.CData.FedExCommand("UPDATE Senders SET SenderID='ab26f704-5edf-4a9f-9e4c-25' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.FedExParameter("myId","10456255-0015501366")) $cmd.ExecuteNonQuery()
 
 
ダウンロード