ノーコードでクラウド上のデータとの連携を実現。
詳細はこちら →無償トライアル:
無償トライアルへ製品の情報と無償トライアルへ:
FinancialForce データに連携する.NET アプリケーションを素早く、簡単に開発できる便利なドライバー。
加藤龍彦
ウェブデベロッパー
CData ADO.NET Provider for FinancialForce は、Crystal Reports for Visual Studio 開発環境に統合されています。標準のADO.NET コンポーネントを使用して、SQL Server と同じようにレポートを作成でき、さらにFinancialForce とリアルタイムで連携できます。この記事では、開いたときに更新されるレポートにFinancialForce データを追加するために必要な3つのステップを完了する方法を説明します。
Note:このチュートリアルを実行するには、Crystal Reports とVisual Studio のデベロッパーバージョンをインストールしてください。
この記事を実行するにはVisual Studio Crystal Reports プロジェクトが必要になります。この記事では、WPF アプリケーションにレポートを追加します。「File」->「New Project」とクリックし、Crystal Reports WPF Application テンプレートを選択することで、作成できます。表示されるウィザードで空のレポートを作成するオプションを選択します。
Server Explorer からFinancialForce のADO.NET データソースを作成すると、Crystal Reports ウィザードおよびCrystal Reports Designer で使用できるDataSet を簡単に作成できます。Server Explorer でFinancialForce データを操作するためのガイドは、ヘルプドキュメントの「はじめに」の章を参照してください。
There are several authentication methods available for connecting to FinancialForce: login credentials, SSO, and OAuth.
Set the User and Password to your login credentials. Additionally, set the SecurityToken. By default, the SecurityToken is required, but you can make it optional by allowing a range of trusted IP addresses.
To disable the security token:
To obtain the security token:
If you do not have access to the user name and password or do not want to require them, use the OAuth user consent flow. See the OAuth section in the Help for an authentication guide.
Set UseSandbox to true (false by default) to use a FinancialForce sandbox account. Ensure that you specify a sandbox user name in User.
接続を構成する際に、Max Rows 接続プロパティも設定できます。これにより返される行数が制限されるため、レポートやビジュアライゼーションをデザインするときのパフォーマンスを向上させることができます。
以下のステップに従ってVisual Studio ADO.NET DataSet Designer を使用し、ADO.NET DataSet オブジェクトを作成します。Crystal Reports はFinancialForce テーブルのメタデータを含むDataSet オブジェクトにバインドします。またこのアプローチでは、App.config に接続文字列が追加されることに注意してください。後にこの接続文字列を使用してデータをレポートにロードします。
以下のステップに従って、DataSet からレポートにカラムを追加します。
メタデータのみを含むDataSet を作成したら、実際のデータを含むDataTable を作成する必要があります。FinancialForceDataAdapter を使用して、SQL クエリの結果をDataTable に入力できます。
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup>
Window.xaml.cs ファイルに以下の参照を追加します。
using System.Configuration; using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; using System.Data.CData.FinancialForce; using System.Data;
以下のWindow_Loaded メソッドをWindow.xaml.cs に追加し、DataTable を返すSQL クエリを実行します。最低でも、レポートで使用されているカラムと同じカラムは選択する必要があることに注意してください。
private void Window_Loaded(object sender, RoutedEventArgs e) { ReportDocument report = new ReportDocument(); report.Load("../../CrystalReport1.rpt"); var connectionString = ConfigurationManager.ConnectionStrings["MyAppConfigConnectionStringName"].ConnectionString; using (FinancialForceConnection connection = new FinancialForceConnection(connectionString)) { FinancialForceDataAdapter dataAdapter = new FinancialForceDataAdapter( "SELECT BillingState, Name FROM Account WHERE Industry = 'Floppy Disks'", connection); DataSet set = new DataSet("_set"); DataTable table = set.Tables.Add("_table"); dataAdapter.Fill(table); report.SetDataSource(table); } reportViewer.ViewerCore.ReportSource = report; }
Window.xaml ファイルでLoaded イベントを追加し、Window タグを以下のようにします。
<Window x:Class="CrystalReportWpfApplication4.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cr="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer" alt="WPF Crystal Report Viewer" Height="600" Width="800" Loaded="Window_Loaded"> ... </Window>
Chart Expert などのエキスパートとともにDataSet を使用することもできます。
Crystal Reports は、FinancialForce API などに対してGROUP BY を実行する代わりに、DataTable にロード済みのデータに対して集計を実行することに注意してください。これは、レポート作成ウィザードにも当てはまります。
別のDataSet を作成し、他のクエリを入力することで、FinancialForce に対して実行されるクエリをより細かく制御できます。ドライバのSQL エンジンの詳細については、ヘルプドキュメントを参照してください。