Infragistics XamDataGrid を使用してAzure Data Lake Storage のダイナミックグリッドを作成

CData ADO.NET Provider for ADLS とInfragistics XamDataGrid を使用してダイナミックグリッドを構築。

杉本和也
リードエンジニア


こんにちは!リードエンジニアの杉本です。

Infragistics WPF UI コントロールを使用すると、デスクトップおよびタッチデバイス用の、最新のMicrosoft Office に着想を得たアプリを構築できます。CData ADO.NET Provider for ADLS と組み合わせると、ライブのAzure Data Lake Storage にアクセスして動的なグリッド、グラフその他のビジュアライゼーションを構築できます。この記事では、Infragistics XamDataGrid コントロールを使用してVisual Studio でダイナミックグリッドを作成する方法について説明します。

続行するには、Infragistics WPF UI コンポーネントをインストールしてください。こちらから無償トライアルをダウンロードできます。:https://www.infragistics.com/products/wpf

WPF プロジェクトを作成する

VisualStudio を開き、新しいWPF プロジェクトを作成します。

SQL クエリをCData ADO.NET Provider に渡すためのTextBox と、クエリを実行するためのButton を追加します。

Adding a TextBox and Button to the App.

以下は、この時点でのXAML です。


  
    
    

XamDataGrid の追加と構築

初期コントロールを追加した後、アプリにXamDataGrid を追加します。コンポーネントがVisual Studio に表示されます。

Adding the XamDataGrid to the App.

コンポーネントをデザイナーで配置して、TextBoxButton の下に配置し、アプリの境界に接するようにします。

XamDataGrid Placement.

XamDataGrid を配置したら、XAML を編集してXamDataGrid のDataSource 属性を「{Binding}」に設定し、FieldSettings のAllowRecordFilteringAllowSummaries を「true」に設定します。次に、Button コンポーネントのClick イベントハンドラーとして空のメソッドを追加します。以下は、この時点でのXAML です。


  
    
    

Azure Data Lake Storage に接続してクエリする

ダイナミックDataGrid を使用してWPG App を構築するための最後のステップとして、リアルタイムAzure Data Lake Storage データに接続し、クエリを実行します。まず、CData ADO.NET Provider への参照をプロジェクトに追加します。(通常、C:\Program Files\CData\CData ADO.NET Provider for ADLS\lib にあります。)

Adding the CData ADO.NET Provider as a Reference (Salesforce is shown.)

次に、プロバイダーを標準のData ライブラリとともに名前空間に追加します。

using System.Data.CData.ADLS;
using System.Data;

最後に、Azure Data Lake Storage に接続するコードを追加し、TextBox からのテキストを使用してClick イベントハンドラーにクエリします。

Authenticating to a Gen 1 DataLakeStore Account

Gen 1 uses OAuth 2.0 in Azure AD for authentication.

For this, an Active Directory web application is required. You can create one as follows:

  1. Sign in to your Azure Account through the .
  2. Select "Azure Active Directory".
  3. Select "App registrations".
  4. Select "New application registration".
  5. Provide a name and URL for the application. Select Web app for the type of application you want to create.
  6. Select "Required permissions" and change the required permissions for this app. At a minimum, "Azure Data Lake" and "Windows Azure Service Management API" are required.
  7. Select "Key" and generate a new key. Add a description, a duration, and take note of the generated key. You won't be able to see it again.

To authenticate against a Gen 1 DataLakeStore account, the following properties are required:

  • Schema: Set this to ADLSGen1.
  • Account: Set this to the name of the account.
  • OAuthClientId: Set this to the application Id of the app you created.
  • OAuthClientSecret: Set this to the key generated for the app you created.
  • TenantId: Set this to the tenant Id. See the property for more information on how to acquire this.
  • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.

Authenticating to a Gen 2 DataLakeStore Account

To authenticate against a Gen 2 DataLakeStore account, the following properties are required:

  • Schema: Set this to ADLSGen2.
  • Account: Set this to the name of the account.
  • FileSystem: Set this to the file system which will be used for this account.
  • AccessKey: Set this to the access key which will be used to authenticate the calls to the API. See the property for more information on how to acquire this.
  • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.
private void Button_Click(object sender, RoutedEventArgs e)
{
  //connecting to Azure Data Lake Storage
  string connString = "Schema=ADLSGen2;Account=myAccount;FileSystem=myFileSystem;AccessKey=myAccessKey;";
  using (var conn = new ADLSConnection(connString))
  {
    //using the query from the TextBox
    var dataAdapter = new ADLSDataAdapter(textBox.Text, conn);
    var table = new DataTable();
    dataAdapter.Fill(table);
    
    //passing the DataRowCollection to the DataContext
    //  for use in the XamDataGrid
    this.DataContext = table.Rows;
  }
}

アプリケーションを実行する

アプリが構築が完了したら、XamDataGrid にAzure Data Lake Storage データを表示する準備が整いました。「Execute」をクリックすると、アプリはAzure Data Lake Storage に接続し、CData ADO.NET Provider を介してSQL クエリを送信します。

Querying Azure Data Lake Storage データ

リアルタイムAzure Data Lake Storage データがグリッドに表示されます。

Displying Azure Data Lake Storage データ (Salesforce is shown)

カラム名をヘッダーにドラッグ & ドロップし、データをグループ化します。

Grouping Azure Data Lake Storage データ (Salesforce is shown)

グループ化とフィルタを追加すると、もとになるSQL クエリがAzure Data Lake Storage に直接送信されるため、リアルタイムAzure Data Lake Storage データをドリルダウンして特定の必要な情報のみを見つけることができます。

Grouped and filtered Azure Data Lake Storage データ (Salesforce is shown)

無償トライアルと詳細

この時点で、リアルタイムAzure Data Lake Storage データへのアクセスを持つダイナミックWPF アプリが作成されています。詳細については、CData ADO.NET プロバイダページをご覧ください。30日の無償評価版をダウンロードすれば、Infragistics UI コントロールを使用して構築したアプリでリアルタイムAzure Data Lake Storage データを今すぐ試すことができます。

関連コンテンツ

トライアル・お問い合わせ

30日間無償トライアルで、CData のリアルタイムデータ連携をフルにお試しいただけます。記事や製品についてのご質問があればお気軽にお問い合わせください。