方法:にXPOベースのアプリケーションはどのようにカスタム永続フィールドを作成するには、管理者許可:XPOは、管理者がアプリケーションベースのカスタム永続フィールドを作成することができます

あなたは、アプリケーション管理者が作成できるようにすることができますカスタム永続フィールドを、アプリケーションを再コンパイルせずにUIに追加されたフィールドのデータを表示すると。この例では、SkypeIDのフィールドが追加され接触でビジネス・オブジェクトMainDemoのアプリケーション。

あなたは、管理者は、カスタムアプリケーションに持続的項目を作成することができ、およびデータフィールドを追加することができ、アプリケーションを再コンパイルすることなく、UIに表示。この例では、SkypeIDフィールドはMainDemoアプリケーション「連絡先」ビジネス・オブジェクトに追加されます。

CustomPersistentFields_Result

次のセクションでは、アプリケーション設定からランタイムのカスタマイズに実装カスタム永続フィールドのプロセスを説明します。

  • 前提条件
  • アプリケーションのセットアップ
  • モデルエディタの種類を選択してください
  • 永続フィールドを実装し、それを表示します
  • データベースへの変更の適用

 

次のセクションでは、カスタム実行時のカスタム永続フィールドを達成するためのアプリケーション・プロセスからの設定について説明します。

  • 前提
  • アプリケーション設定
  • エディタのモデルタイプを選択します
  • フィールドを持続し、それを表示します
  • データベースへの変更

前提条件

前提

アプリケーションは、以下の条件と矛盾しないことを確認してください。そうでない場合は、新しい永続フィールドを作成することは、実行時には不可能です。

  • WinFormsとASP.NETアプリケーションは、XPOデータモデルに基づくべきです。
  • このトピックで説明するアプローチは、モバイルプラットフォームでサポートされていないので、モバイルアプリケーションは、再コンパイルすることなく、UIのカスタマイズをサポートしていません。
  • 以下の機能が一緒に使用すべきではありません。

  • SecuredObjectSpaceProviderまたはXPObjectSpaceProviderはとのコンストラクタを使用して作成されたスレッドセーフにパラメータセット(このパラメータが有効ThreadSafeDataLayerを)。
  • 管理者のモデルの違いはデータベースに保存されている使用してXafApplication.CreateCustomModelDifferenceStoreのイベント(あなたはまだ使用して、データベース内のユーザーの違い格納することができますXafApplication.CreateCustomUserModelDifferenceStoreのイベントを)。
  • カスタムの永続フィールドは、管理者のモデルの違いで宣言されました。

アプリケーションは、以下の条件と矛盾しないことを確認してください。そうしないと、実行時に新しい持続的項目を作成することはできません。

  • WinFormsとASP.NETアプリケーションXPOデータモデルをベースとしなければなりません。
  • このトピックで説明するモバイルプラットフォームのアプローチがサポートされていないので、モバイル・アプリケーションは、再コンパイルせずにカスタムUIをサポートしていません。
  • 以下の機能が一緒に使用すべきではありません。
  • コンストラクタ真プロバイダまたはXPObjectSpaceProvider用に作成されたセキュリティオブジェクトのスペースを設定し、使用するスレッドセーフなパラメータ(このパラメータは、スレッドセーフなデータ層を可能にします)。
  • 管理者は、使用モデルの違いXAFアプリケーションはデータベースに格納されている。カスタムモデル差ストアイベントを作成する(あなたはまだデータベースに格納されているアプリケーションのユーザXAFの違いを使用することができます。イベント)。
  • カスタム永続フィールドは、管理者の中にモデルの違いで宣言されました。

 

この構成では、カスタムの永続的なデータベースからフィールドとでアプリケーションの負荷情報は、データベーススキーマを更新します。しかし、スレッドセーフなデータ層は、データベース接続が確立された後、データモデルを変更することはサポートされていません。

  • 中間層のセキュリティ- WCFサービスワークフローサーバサービス、または任意の他のappllication作成し、設定しサーバアプリケーション / XafApplicationことができ、または実行時にアプリケーションモデルをカスタマイズすることにより、(XAFMLコードまたはで)クライアントXAFアプリケーション・プロジェクトに追加されていないアクセスのカスタムフィールド。あなたは、共通モジュールでカスタムフィールドを追加し、あなたがそれを使用しようとしているすべてのアプリケーションでそれを参照する必要があります。

この構成では、データベースからのアプリケーションでは、カスタムの永続情報フィールドをロードして、データベーススキーマを更新します。しかし、スレッドセーフなデータ層は、データベース接続の確立にデータモデルの変更をサポートしていません。

  • セキュリティ層間 - WCFサービス、ワークフローサーバサービス、またはその他作成するとのconfigureサーバーアプリケーション/アプリケーションアプリケーションXAFアプリケーションは、(コードまたはにカスタムフィールドを追加するには、クライアントXAFアプリケーション・プロジェクトにアクセスすることはできませんXAFMLでは)、また、実行時にアプリケーション・モデルをカスタマイズすることはできません。あなたは、共通モジュールでカスタムフィールドを追加し、使用するすべてのアプリケーション内のフィールドを参照する必要があります。

アプリケーションのセットアップ

アプリケーション設定

アプリケーション管理者が作成し、UIで表示するカスタム永続フィールドのデータを許可するアプリケーションコードに次の変更を適用します。

  • 静的に設定ModelMemberReadOnlyCalculator.AllowPersistentCustomPropertiesのにプロパティを真の実行時に静的フィールドを作成できるようにします。開きModule.csModule.vb)ファイルを、モジュールのコンストラクタに次のコードを追加します。

アプリケーション管理者は、UI内のデータのカスタム永続フィールドを作成して表示できるようにするために、アプリケーションコードに次の変更を適用します。

  • 静的モデルメンバー読み取り専用計算機は、持続的なカスタムプロパティは、実行時に永続的なフィールドを作成するためには、trueに設定されている属性のことができます。オープンModule.cs(module.vb)ファイルには、コンストラクタのモジュールに次のコードを追加します。
DevExpress.ExpressApp.Model.Core.ModelMemberReadOnlyCalculator.AllowPersistentCustomProperties =  ;
  • 設定しIObjectSpaceProvider.CheckCompatibilityTypeのにプロパティをCheckCompatibilityType.DatabaseSchemaデータベースの変更をキャッチし、スキーマが変更された場合、データベースを更新します。

  • CheckCompatibilityTypeにIObjectSpaceProvider.Check・タイプの互換性プロパティ。データベースの変更を取得するデータベースのスキーマ、およびスキーマを変更したときにデータベースを更新します。

    CheckCompatibilityType

  • データベーススキーマの更新を許可するには、設定されXafApplication.DatabaseUpdateModeのにプロパティをDatabaseUpdateMode.UpdateDatabaseAlwaysDatabaseUpdateMode.UpdateOldDatabase
  • Copy the DBUpdater.v19.2.exe and DBUpdater.v19.2.config files from the %PROGRAMFILES(x86)%\DevExpress 19.2\Components\Tools\eXpressAppFramework\DBUpdater\ folder to the application's installation folder.
  • 要允许数据库架构更新,请将 XafApplication.DatabaseUpdateMode 属性设置为数据库更新模式.始终更新数据库或数据库更新模式。更新旧数据库。
  • 将 DBUpdater.v19.2.exe 和 DBUpdater.v19.2.config 文件从 %PROGRAMFILES(x86)%_DevExpress 19.2_组件_工具_eXpressAppFramework_DBUpdater_文件夹复制到应用程序的安装文件夹。

Choose the Model Editor Type

选择模型编辑器类型

It is necessary to determine which type of the Model Editor is appropriate for your application: standalone or built-in.

  • A built-in Model Editor

    When an administrator uses a WinForms application, it is possible to invoke the built-in Model Editor tool to add a custom field to the application model. Using this Model Editor type, the administrator can edit both Model Differences stored in the application database and Model Differences from the XAFML file.

  • A standalone Model Editor

    The use of the standalone Model Editor is preferred if an administrator uses only an ASP.NET application and Model Differences are stored in the XAFML file. For information on how to use this tool, refer to the Deploy and Run the Standalone Model Editor section of the Ways to Invoke the Model Editor topic.

Implement the Persistent Field and Display It

Follow the steps below to add a custom persistent field at an end-user workstation.

  1. Invoke the built-in Model Editor using the Tools | Edit Model command at runtime or close the application and start the standalone Model Editor by running the DevExpress.ExpressApp.ModelEditor.v19.2.exe executable file.

    If you use the standalone Model Editor, specify the path to the application configuration file (e.g., MainDemo.Win.exe.config or Web.config) and click Open in the Open Model dialog.

    CustomPersistentFields_RunME

  2. Navigate to the BO_Model | Contact node in the tree on the left. Right-click the OwnMembers child node and choose Add... | Member.

    CustomPersistentFields_AddMember

  3. Set the Name property of the newly added node to "SkypeID". Then, set the IsCalculated property to "False", Type to "System.String", Size to "32", and Caption to "Skype ID".

    CustomPersistentFields_MemberProperties

  4. If the built-in Model Editor is in use, copy the differences that you have introduced in the administrator's layer using the Merge Differences command. Otherwise, skip this step and move to the next one.

    CustomPersistentFields_Merge

  5. Save changes using the Save button or the CTRL+S shortcut and restart the Model Editor.
  6. Navigate to the Views | Contact_DetailView node in the tree on the left. Right-click the Items child node and choose Add... | PropertyEditor.

    CustomPersistentFields_AddEditor1

  7. Set PropertyName and Id to "SkypeID".

    CustomPersistentFields_AddEditor2

  8. Focus the Layout node. Right-click the empty space within the form preview displayed on the right and select Customize Layout.

    CustomPersistentFields_AddEditor3

  9. Drag the Skype ID item from the invoked Customization window to an appropriate position within the form.

    CustomPersistentFields_AddEditor4

    You can also add the Skype ID column to the Contact List View using a similar approach (see List View Columns Customization).

  10. If the built-in Model Editor is in use, merge the differences as described at the forth step.
  11. Save the changes and close the Model Editor.
  12. Update your database schema as described in the Apply Changes to the Database section.
  13. Restart the application and open the Contact Detail View to see the result demonstrated in the introduction of this topic.
Important

アプリケーションが複数のPCにインストールされており、管理者のモデルの違いは、に格納されている場合Model.xafmlのファイル、アプリケーションの作業フォルダから各PCにコピーします。そうでない場合は、作成したフィールドは、あなたがそれを追加しましたワークステーションで利用できるようになります。

データベースへの変更の適用

使用DBUpdaterのデータベースに新しく作成されたカスタム持続フィールドにマッピングされた列を追加するためのツールを。

、コマンドプロンプトを開き、作業ディレクトリアプリケーションにカレントディレクトリを変更し、次のコマンドを実行します。

DBUpdater.v19.2.exe MainDemo.Win.exe.config -forceUpdate

おすすめ

転載: www.cnblogs.com/foreachlife/p/12073128.html