Reuse or expose business library services

I'm having trouble choosing two possible design options. I have a website with a fairly extensive business layer, and DAL (website, bll and dal are in several separate DLLs). I need to create a Windows service that can take some of my business objects, write them to a file, and save them locally on our network. Then the files are imported into a third-party program that performs further processing.

I can create this service in one of two ways:

  • Wrap the service around a business layer and DAL. This would be quick and easy, but the disadvantage is that every time the business layer changes, the service needs to be updated.

  • Add the web service to the website and just request the web service for what I need. Windows will not have to use the business layer, and until the web service changes, I will be good. The only drawback is that I may have to create some basic business objects to parse the xml web service.

The Windows service will need to poll the business layer / dal or web service every 10-20 minutes or so. The Windows service is necessary because the website is hosted outside the website and therefore does not have access to any of our local resources. I tend to option 2, but I'm torn.

Given two options, which is the best option? Are there other possible options that I have not considered? In addition, how do you usually develop situations where you have one basic set of libraries that are initially used by a website, but which can ultimately be used either to extract data or to perform certain functions?

+3
source share
4 answers

I'm not sure what are the criteria for storing certain business objects as files on the network, but if you do this on a regular basis, then you are supposedly trying to track some changes, so there is another solution: build the logic directly at the level business / persistence.

-, - . , , , - , , .

- , - - , -, , , , . , -, ( , , WCF , MSMQ , ).

, , , , , .., - . , -, , , , "", , .

, , 2. , WCF , , XML. , -, .NET. API-, -.

- , , , ( ). , API , . , , , .

+1

:

WCF , , DTO DataContracts. AutoMapper WCF - DTO.

+1

, DAL , - ( -), , : interface s, , Inversion of Control, , DAL DAL . , , .

, , , .

Edit:

. # , .

// Get a System.Type from string representation
Type t = Type.GetType("type name");
// Create instance of type.
object o = Activator.CreateInstance(t);
// Cast it to the interface (or actual Type) you're working with.
IMyInterface strongObject = (IMyInterface)o;
// ... and continue from there with the instance.

, , MSDN Type.AssemblyQualifiedName, Type.GetType . , , , app.config web.config, .

0

From your point of view, I understand that you simply add web-api for this additional service. Thus, you will need to update two parts for any changes (extra-service, web-api, dll). With one option, you will only need to update two parts (optional service, dll), so I would go with one.

BUT, if you are aiming for a general web avia that you should always support, go with option 2.

0
source

Source: https://habr.com/ru/post/1735672/


All Articles