locked
Developing a multi-tier application

    问题

  • Hi,

    I should implement a web application using a multi-tier architecture, WCF and C#. Basically my application receives requests from some clients, processes these requests and then sends the results to the client. The persistence storage is currently consists of an XML file, but in future it may be necessary to use a database. Moreover, some application parameters are configurable, so you need to load these parameters from the app.config file.

    I read some article and I think I understand that I must develop the application in at least 3 layers:

    1. The Data Access Layer which provides simplified access to data.
    2. The Business Logic Layer, that is the domain layer: in this layer my application processes the requests received from the clients.
    3. The Presentation Layer, that is the UI.

    As already mentioned above, the values ​​of configuration parameters are stored in the app.config file. How the application should access to these parameters in order to read/modify them? I read that at run time a DLL cannot have a config file (link), so these values should not be accessed through the Data Access Layer... However, if these parameters must be changed via the UI, this should be done via the Data Access Layer... Or not...? I'm a bit confused...

    And where is the communication? Does the business layer also include the WCF communication?

    Thanks in advance!




    • 已编辑 archimede83 2012年2月28日 23:38 improved formatting
    2012年2月28日 23:20

答案

  • Hi Archimede,

    Question: "As already mentioned above, the values ​​of configuration parameters are stored in the app.config file. How the application should access to these parameters in order to read/modify them?"

    Answer: You can only read the values of your configuration files as shown in the below example:

                    AppSettingsReader appSettingsReader = new AppSettingsReader();
                    string configXMLPath = (string)appSettingsReader.GetValue("XMLPath", typeof(string));

    Question: "And where is the communication? Does the business layer also include the WCF communication?"

    Answer:

    In your case, the WCF service will have layers some thing like shown below, and your UI should call the WCF service call to get the request process.

    1. Service Interface Layer and Service Class implementing the interface

    2. Business Layer

    3. Business Process Component (Orchestration layer is optional)

    3. Data Access Layer

    -Mohammed Ghouse Ibne Barq Kadapavi
    http://www.ProgrammersVision.blogspot.com
    https://sites.google.com/site/BarqKadapavi
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.


    2012年2月29日 5:09
  •  When you say your application receives requests from some clients do you mean it is from your Asp.net User interface or from some other application too?

    Anyway a typical 3-tier you can refer is as below where you can use WCF in your Service Interface tier. For time being you can ignore WCF service Adopter.

    Yes, .NET Framework does not support configuration for DLLs as it cannot be executed on its own. It needs to be deployed into a hosting environment or need to be called from a executable. So  All your Config which are required by your DAL need to be on the Host/Executable’s App.config/ Webconfig file.

    Say for above image your BL and DAL will be called by WCF service host (IIS/Windows Service/Self Host). So in this case all your config of DAL need to be present in WCF service’s app.config/web.config file.


    Lingaraj Mishra

    2012年2月29日 5:33

全部回复

  • Hi Archimede,

    Question: "As already mentioned above, the values ​​of configuration parameters are stored in the app.config file. How the application should access to these parameters in order to read/modify them?"

    Answer: You can only read the values of your configuration files as shown in the below example:

                    AppSettingsReader appSettingsReader = new AppSettingsReader();
                    string configXMLPath = (string)appSettingsReader.GetValue("XMLPath", typeof(string));

    Question: "And where is the communication? Does the business layer also include the WCF communication?"

    Answer:

    In your case, the WCF service will have layers some thing like shown below, and your UI should call the WCF service call to get the request process.

    1. Service Interface Layer and Service Class implementing the interface

    2. Business Layer

    3. Business Process Component (Orchestration layer is optional)

    3. Data Access Layer

    -Mohammed Ghouse Ibne Barq Kadapavi
    http://www.ProgrammersVision.blogspot.com
    https://sites.google.com/site/BarqKadapavi
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.


    2012年2月29日 5:09
  •  When you say your application receives requests from some clients do you mean it is from your Asp.net User interface or from some other application too?

    Anyway a typical 3-tier you can refer is as below where you can use WCF in your Service Interface tier. For time being you can ignore WCF service Adopter.

    Yes, .NET Framework does not support configuration for DLLs as it cannot be executed on its own. It needs to be deployed into a hosting environment or need to be called from a executable. So  All your Config which are required by your DAL need to be on the Host/Executable’s App.config/ Webconfig file.

    Say for above image your BL and DAL will be called by WCF service host (IIS/Windows Service/Self Host). So in this case all your config of DAL need to be present in WCF service’s app.config/web.config file.


    Lingaraj Mishra

    2012年2月29日 5:33
  •  When you say your application receives requests from some clients do you mean it is from your Asp.net User interface or from some other application too?

    The requests come from other applications via the Internet.
    2012年2月29日 10:08
  • You can only read the values of your configuration files as shown in the below example:

                    AppSettingsReader appSettingsReader = new AppSettingsReader();
                    string configXMLPath = (string)appSettingsReader.GetValue("XMLPath", typeof(string));

    Is the reading of the configuration usually part of the DAL?

    Could be wrong my choice to read the configuration application using DAL?

    2012年2月29日 10:14
  • If your DAL need some information from Configuration files, than nothing wrong on reading the configuration application using DAL.


    Lingaraj Mishra

    2012年2月29日 11:04
  • Hi Archimede,

    Welcome to the MSDN Forum.

    Based on your description, it seems that MVC structure should be what you are looking for: http://www.asp.net/mvc 

    Please take a look at it.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2012年3月1日 10:41
    版主