Business b-ridge 用の CData ADO.NET プロバイダーをDevExpress Windows Forms とWeb コントロールとともに使用し、Business b-ridge をチャートに入力します。
Business b-ridge 用の CData ADO.NET プロバイダーはサードパーティーコントコントロールで使うことのできる通常のADO.NET データベースアクセスコンポーネントを実装しています。データバインドするための通常のADO.NET プロセスに従うことで、UI コントロールから実データへの双方向アクセスを可能にします。 この記事では、CData を使ってDevExpress Windows Forms とウェブコントロールにデータバインドする方法を説明します。ここでは、最新のデータを表示するチャートにデータバインドします。
When connecting to Business b-ridge, CompanyKey, ProjectKey, and SubscriptionKey are required.
To obtain the SubscriptionKey, follow the steps below:
- Log in to Business b-ridge API Protal and go to "Profile" in the "Your name" menu.
- In your subscription section click "Main Key" to retrieve their respective values.
Authenticate to Business b-ridge Account
Set the following connection properties to connect:
- CompanyKey: Set the Business b-ridge Company Key of the connection destination.
- ProjectKey: Set the Business b-ridge Project Key of the connection destination.
- SubscriptionKey: Set the value "Subscription Key".
Windows Forms コントロール
下のコードでは、Business b-ridge でDevExpress のチャートに追加する方法を説明します。BusinessBridgeDataAdapter はチャートコントロールのSeries プロパティにバインドします。コントロールのDiagram プロパティはx 軸とy 軸をカラム名として定義します。
using (BusinessBridgeConnection connection = new BusinessBridgeConnection(
"")) {
BusinessBridgeDataAdapter dataAdapter = new BusinessBridgeDataAdapter(
"SELECT ItemId, StructureId FROM CDATA WHERE ItemTypeId = '1'", connection);
DataTable table = new DataTable();
dataAdapter.Fill(table);
DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series();
chartControl1.Series.Add(series);
DataTable table = new DataTable();
series.ValueDataMembers.AddRange(new string[] { "StructureId" });
series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Qualitative;
series.ArgumentDataMember = "ItemId";
series.ValueScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
((DevExpress.XtraCharts.SideBySideBarSeriesView)series.View).ColorEach = true;
}

Web コントロール
下のコードではBusiness b-ridge でDevExpress Web を操作するための設定方法を説明します。BusinessBridgeDataAdapter はチャートのSeries プロパティにバインドします。Diagram プロパティはx 軸とy 軸をカラム名として定義します。
using DevExpress.XtraCharts;
using (BusinessBridgeConnection connection = new BusinessBridgeConnection(
""))
{
BusinessBridgeDataAdapter BusinessBridgeDataAdapter1 = new BusinessBridgeDataAdapter("SELECT ItemId, StructureId FROM CDATA WHERE ItemTypeId = '1'", connection);
DataTable table = new DataTable();
BusinessBridgeDataAdapter1.Fill(table);
DevExpress.XtraCharts.Series series = new Series("Series1", ViewType.Bar);
WebChartControl1.Series.Add(series);
DataTable table = new DataTable();
series.ValueDataMembers.AddRange(new string[] { "StructureId" });
series.ArgumentScaleType = ScaleType.Qualitative;
series.ArgumentDataMember = "ItemId";
series.ValueScaleType = ScaleType.Numerical;
((DevExpress.XtraCharts.SideBySideBarSeriesView)series.View).ColorEach = true;
}