0

私のジレンマは、基本的に、2 つのアプリケーション間で列挙を共有する方法です。

ユーザーは、Web 上のフロントエンド アプリケーションを介してドキュメントをアップロードします。このアプリケーションは、バックエンド アプリケーションの Web サービスを呼び出し、ドキュメントをそれに渡します。バックエンド アプリはドキュメントを保存し、ドキュメント テーブルに行を挿入します。

ドキュメント タイプ (請求書、契約書などの 7 つのドキュメント タイプ) は、パラメータとして Web サービスの UploadDocument メソッドに渡されます。問題は、このパラメーターの型 (および可能な値) をどうするかということです。

両方のアプリケーションでこれらの値をハードコーディングする必要があるため、説明的な文字列 (Invoice、Contract、WorkOrder、SignedWorkOrder) を使用しても問題ないと思います。

最初のアプリケーションで DocumentTypes 列挙を作成し、2 番目のアプリケーションでもそれを再現してから、対応する整数値をそれらの間の Web サービスに渡す方がよい方法でしょうか?

4

2 に答える 2

0

If you're using .NET you can create an enumeration on the back end. Then create a web reference on the front end to that back end web service. That will then pick up the enumeration and expose it there on the front end, while only having it defined in one place.

The advantage with using the enumerations is that you can expose those on the front end, avoiding the problem of users passing in bad values. If you were to use an integer, that isn't very friendly and you'd have to check it at some point. Similar problem with strings. So if you have a well known set of values, I'd highly recommend using an enumeration.

于 2013-11-19T22:52:18.560 に答える