-
Notifications
You must be signed in to change notification settings - Fork 1
Developer reference Server
The server side of DEF consists of two main parts: Web UI and Scheduler. Both parts share the same database as the UI is responsible for all planning deploys and all the configuration whereas Scheduler processes planned deploys.
As scheduler is meant to run all the time and process planned jobs ion certain time, it uses Hangfire to carry out these tasks. In can run as a Windows service as well as inside IIS (either standalone or inside of the UI web application.)
Web UI appliaction is implemented as an ASP.NET MVC application. Glimpse and ELMAH are included to make development easier.
Client libraries are downloaded through Bower as it much widely used than NuGet and is also the recommended way for new ASP.NET projects. Build process uses Gulp to prepare client side files such as CSS or JavaScript.
All forms in the application are made with ChameleonForms.
Web UI also acts as a NuGet repository for all deploy packages. This is done using NuGet.Server package.
All strings displayed to users are found in the Resources project. In the project you'll find StringResources.resx, which is a simple key-value file. If you want to add a new language, simply add a new file named StringResources.CultureCode.resx, where CultureCode is one of [recognised culture codes] (https://arvindlounge.wordpress.com/2009/03/15/list-of-culture-codes/) (eg.: StringResources.cs-CZ.resx for Czech).
In order to use the strings in the application, you need to import the Baud.Deployment.Resources namespace, then you simply use StringResources.YourStringKey (eg.: StringResources.AddNewServer). For now, the application determines the language to use according to your OS settings. If it doesn't find a proper language file, it then defaults to English.
Both, Web UI and Scheduler use the same business logic as long as the logic is not specific for their respective purpose (web UI, scheduled task execution.)
Logic resides mainly in three types of objects:
Providers are simple services that provide simple, usually infrastructure, functions.
Example: CurrentUserProvider, AgentAdapterProvider
Repositories provide simple business actions inside a specific area, usually related to data storage. Repositories are covered by Unit of work
objects that are responsible for persisting changes caused by repositories.
Example: UsersRepository, InstallationsRepository
When a complicated business logic needs to be carried out or the process requires conduction of several other services, repositories, or providers, it shall be done inside a service.
Example: AgentDeployService, SecurityService
All objects are composed together using dependecy injection container Unity
Relational database is used as data storage. It is accessed using Entity Framework 6 Code First. EF DbContext is encapsulated inside a Unit of work object that provides the Context to its repositories.
The application automatically creates its database as specified in web.config
file. However, a database created in this way will be completely empty.
If you want to seed some initial data, you have to run database migrations manually. To do so, follow these steps:
- Open Package Manager Console window in Visual Studio
- Set the Default project to
Database
- Run following commands:
Update-Database -ConfigurationTypeName SecurityConfiguration
Update-Database -ConfigurationTypeName DeploymentConfiguration
Note: Since the migrations use connection string from Database\app.config
, make sure the connection string matches the one in Web\web.config
.
The same actions work if you already have database created but want to update its structure (-f
switch might be needed with the Update-Database
commands.)