各製品の資料を入手。
詳細はこちら →Dynamics 365 のデータをDevExpress Data Grid にデータバインドする。
Dynamics 365 用の CData ADO.NET プロバイダーをDevExpress Windows Forms とWeb コントロールとともに使用し、Dynamics 365 をチャートに入力します。
最終更新日:2022-01-31
この記事で実現できるDynamics 365 連携のシナリオ
こんにちは!ウェブ担当の加藤です。マーケ関連のデータ分析や整備もやっています。
Dynamics 365 用の CData ADO.NET プロバイダーはサードパーティーコントロールで使うことのできる通常のADO.NET データベースアクセスコンポーネントを実装しています。データバインドするための通常のADO.NET プロセスに従うことで、UI コントロールから実データへの双方向アクセスを可能にします。 この記事では、CData を使ってDevExpress Windows Forms とウェブコントロールにデータバインドする方法を説明します。ここでは、最新のデータを表示するチャートにデータバインドします。
Dynamics 365 接続プロパティの取得・設定方法
Microsoft Dynamics 365 への接続
Microsoft Dynamics 365 ドライバーは、以下のMicrosoft Dynamics 365 エディションへの接続をサポートしています。
- CustomerService
- FieldService
- FinOpsOnline (デフォルト)
- FinOpsOnPremise
- HumanResources
- Marketing
- ProjectOperations
- Sales
Notes:
- Supply Chain Management はFinance and Operations と同一です。これらのいずれかに接続するには、Edition をFinOpsOnline またはFinOpsOnPremise のいずれかに設定します。
- Microsoft Dynamics 365 Business Central については、個別のMicrosoft Dynamics 365 Business Central ドライバーを使用してください。
- OrganizationUrl:お使いのMicrosoft Dynamics 365 組織のURL。例えば、https://orgcb42e1d0.crm.dynamics.com。
- Edition:上記のエディション一覧に示すとおり。
Microsoft Dynamics 365 への認証
Microsoft Dynamics 365 は、Azure AD、Azure サービスプリンシパル、Azure マネージドID(MSI)を経由する認証をサポートします。これらはすべてOAuth 規格に基づきます。 認証方法の詳細は、ヘルプドキュメントを参照してください。
Windows Forms コントロール
下のコードでは、Dynamics 365 でDevExpress のチャートに追加する方法を説明します。Dynamics365DataAdapter はチャートコントロールのSeries プロパティにバインドします。コントロールのDiagram プロパティはx 軸とy 軸をカラム名として定義します。
using (Dynamics365Connection connection = new Dynamics365Connection(
"OrganizationUrl=https://myaccount.operations.dynamics.com/;Edition=Sales;")) {
Dynamics365DataAdapter dataAdapter = new Dynamics365DataAdapter(
"SELECT GoalHeadingId, Name FROM GoalHeadings WHERE Name = 'MyAccount'", 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[] { "Name" });
series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Qualitative;
series.ArgumentDataMember = "GoalHeadingId";
series.ValueScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
((DevExpress.XtraCharts.SideBySideBarSeriesView)series.View).ColorEach = true;
}

Web コントロール
下のコードではDynamics 365 でDevExpress Web を操作するための設定方法を説明します。Dynamics365DataAdapter はチャートのSeries プロパティにバインドします。Diagram プロパティはx 軸とy 軸をカラム名として定義します。
using DevExpress.XtraCharts;
using (Dynamics365Connection connection = new Dynamics365Connection(
"OrganizationUrl=https://myaccount.operations.dynamics.com/;Edition=Sales;"))
{
Dynamics365DataAdapter Dynamics365DataAdapter1 = new Dynamics365DataAdapter("SELECT GoalHeadingId, Name FROM GoalHeadings WHERE Name = 'MyAccount'", connection);
DataTable table = new DataTable();
Dynamics365DataAdapter1.Fill(table);
DevExpress.XtraCharts.Series series = new Series("Series1", ViewType.Bar);
WebChartControl1.Series.Add(series);
DataTable table = new DataTable();
series.ValueDataMembers.AddRange(new string[] { "Name" });
series.ArgumentScaleType = ScaleType.Qualitative;
series.ArgumentDataMember = "GoalHeadingId";
series.ValueScaleType = ScaleType.Numerical;
((DevExpress.XtraCharts.SideBySideBarSeriesView)series.View).ColorEach = true;
}