# iWebServices v5 (iWS5) - FEMA
iWebServices v5, commonly referred to as iWS5, is a backend solution that provides services and APIs for managing data in the Process Director software ecosystem. It uses [Entity Framework](https://learn.microsoft.com/en-us/ef/) to interface with the Process Director database, as well as other .NET Core technologies. It replaces and expands on the previous version of iWebServices, which took the form of a WSDL service (a SOAP API).

There are two versions of the iWS5 solution, one for the FEMA branch (this repository) and one for the [LPNU branch](https://github.com/Greenfield-Investments/iWS5_LPNU). There are a number of differences between the two branches, including database schema changes and entirely different projects. The information listed in this document is specific to the FEMA branch.

## Projects

### Applications

The FEMA branch of iWS5 includes the following application projects:

1. [IWS5.Database](IWS5.Database/) - An [SQL Database project](https://learn.microsoft.com/en-us/sql/tools/sql-database-projects/sql-database-projects?view=sql-server-ver17) containing all of the database tables (in [T-SQL](https://learn.microsoft.com/en-us/sql/t-sql/language-reference?view=sql-server-ver17)), pre-deploy scripts, and post-deploy scripts used to populate and initialize the Process Director database.
2. [IWS5.Api](IWS5.Api/) - A RESTful API which provides endpoints and methods for client applications to consume to facilitate workflow processing by users of the Process Director system. For the FEMA branch specifically, the API is consumed by the [React Rapid Workplace (react-rwp)](https://github.com/Greenfield-Investments/react-rwp) application.
3. [IWS5.AdminApi](IWS5.AdminApi/) - A work-in-progress RESTful API which provides endpoints and methods for client applications to consume to facilitate the management of configurations by administrator users of the Process Director system. This API is consumed by the work-in-progress [React iAdmin (react-iAdmin)](https://github.com/Greenfield-Investments/react-iAdmin) application.
4. [IWS5.Server](IWS5.Server/) - A worker service responsible for moving work items through workflows in the Process Director system.
5. [IWS5.Importer.Worker](IWS5.Importer.Worker/) - A worker service responsible for importing work items in bulk to the Process Director system.

For more information on each project, read the READMEs in the directories linked for each.

### Backend

In addition to the application projects, the following projects are included which abstract away most data management logic:

1. [IWS5.Core](IWS5.Core/) - Provides common interfaces, helpers, constants, enums, and etc. for other projects to use.
2. [IWS5.DatabaseAccess](IWS5.DatabaseAccess/) - Provides Entity Framework models for database schemas, as well as repositories for retrieving/updating database data.
3. [IWS5.Importer.Core](IWS5.Importer.Core/) - Provides common interfaces, helpers, constants, enums, and etc. for the IWS5.Importer.Worker project specifically.
4. [IWS5.Ldap](IWS5.Ldap/) - Provides Active Directory authentication functionality via the [Lightweight Directory Access Protocol (LDAP)](https://ldap.com/).
5. [IWS5.Services](IWS5.Services/) - Provides methods for retrieving, creating, updating, and deleting Process Director database objects, as well as additional processing for work item and document functionalities.
6. [IWS5.Signature](IWS5.Signature/) - Provides work item and document signature processing methods used by Lviv Polytechnic National University for digital signage applications. This code is functional in the FEMA branch, and an implementation via a feature flag does exist in React Rapid Workplace, but the feature is unused.
7. [IWS5.Autotest](IWS5.Autotest/) - Provides automated testing for the IWS5.Api project. Test cases are incomplete and sometimes non-functional.

Individual READMEs are not provided for these projects as they would not effectively convey the projects' purposes. Code analysis is a much more effective way to determine what each project is doing.

## Development & Configurations
The requirements for developing each project are expanded on in their individual READMEs (linked above by project name) when necessary. In particular, the IWS5.Signature project has an additional dependency that must be installed.

General requirements for developing the iWS5 solution are as follows:

1. [Visual Studio](https://visualstudio.microsoft.com/) - Version 2022 or later recommended, although most projects should build with versions as low as 2017. The Community version will suffice for development. The "ASP.NET and web development" and ".NET desktop development" workloads must be installed. These workloads should provide all of the components required to build and run projects in the iWS5 solution.

For specific information about configuration variables that must be set/changed to run individual projects, read their individual READMEs. In particular, database connections must be set for IWS5.Api, IWS5.AdminApi, IWS5.Server, and IWS5.Importer.Worker.

## Publishing & Deployments
The requirements for publishing and deploying each application project are expanded on in their individual READMEs (linked above by project name), but the following instructions apply to all publishable projects (IWS5.Api, IWS5.AdminApi, IWS5.Server, and IWS5.Importer.Worker) *except* for the IWS5.Database project:

1. In Visual Studio, right click the project's name (such as IWS5.Api) in the Solution Explorer pane and click "Publish".
2. If the "Where are you publishing today?" dialog appears, select "Folder" and click "Next" followed by "Finish". If the dialog does not appear, skip this step.
3. Note the "Target location" value, which tells you where the build artifacts will be placed. For iWS5 projects, the default is `bin\Release\net8.0\publish`.
4. Click the "Publish" button next to the folder profile name (such as `FolderProfile.pubxml`).

Once a project has been published, the build artifacts can be found in the project's root directory combined with the "Target location" value shown in the Publish window. For the IWS5.Api project, if the iWS5 solution was cloned to `F:\source\iWS5`, this may look like: `F:\source\iWS5\IWS5.Api\bin\Release\net8.0\publish`.

For a given iWS5 project, that path is often what you want to set as the value for the `PublishPath` pre-processor variable in the Inno Setup script for the project's setup package. See the [setup-packages](https://github.com/Greenfield-Investments/setup-packages) repository for more information.

**Important note:** when compiling setup packages for iWS5 projects, the values for database connections and etc. set during development will be copied to the final installation directory. Luckily, the setup packages are built to require users enter new values for those configuration variables, and as such they will be overwritten on deployment.