User Tools

Site Tools


sis_developer_manual

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sis_developer_manual [2023/02/20 21:10] – [Main Development Tools] ghacheysis_developer_manual [2024/03/11 01:52] (current) – [Packaging the Frontend] ghachey
Line 52: Line 52:
  
   - Download and install [[https://git-scm.com/|Git]]   - Download and install [[https://git-scm.com/|Git]]
-  - Download and install latest [[https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx|Visual Studio]] (developers mostly on 2019 or 2022).+  - Download and install latest [[https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx|Visual Studio]] (developers mostly on 2022).
   - Download and install [[https://dev.mysql.com/downloads/|MySQL Community Version]] (the server and workbench).    - Download and install [[https://dev.mysql.com/downloads/|MySQL Community Version]] (the server and workbench). 
   - Download and install latest LTS [[https://nodejs.org/en/|NodeJS]].   - Download and install latest LTS [[https://nodejs.org/en/|NodeJS]].
Line 100: Line 100:
  
 The backup will need access to the databases and this is done in the ''API/opensisAPI/appsettings.json'' file as shown below. The backup will need access to the databases and this is done in the ''API/opensisAPI/appsettings.json'' file as shown below.
- 
 <code javascript> <code javascript>
 { {
Line 124: Line 123:
  
 {{ :sis-developer-manual:catalogdb-1.jpg?nolink |}} {{ :sis-developer-manual:catalogdb-1.jpg?nolink |}}
 +
 +In production the name of the database should both:
 +
 +  * Be the hostname in the URL (e.g. a system hosted at https://pacificsis.pacific-emis.org would have a database called pacificsis)
 +  * Have the correct tenant_name in the catalogdb database configured as above to pacificsis (to use the same example as above)
 +
 +In development, it may be more convenient to use the database name opensisv2_ef6 at the moment. That way it does not matter what is in the development URL (typically http://localhost). In this case only:
 +
 +  * Have the correct tenant_name in the catalogdb database configured as above to pacificsis (to use the same example as above)
 +
 +A screenshot of a developer's machine could look like this where the pacificsis was a dump of the production system online and the opensisv2_ef6 is an exact same database that was created simply with a different name using a no schema options (i.e. no database name specified at dump but created during import)
 +
 +{{ :sis-developer-manual:database-setup-example-1.png?nolink |}}
 +
 +==== Database Upgrades ====
 +
 +Database upgrades are done using the .NET EntityFrameworkCore migrations. When a new migration is made available typically in the source code you'll need to apply the migration. This can be done in a number of ways depending on preference and environment (development vs production). One way is to open the Package Manager Console within Visual Studio and run something like the following.
 +
 +<code>
 +PM> Update-Database -Project opensis.data -Context CRMContextMySQL
 +Build started...
 +Build succeeded.
 +Applying migration '20230216092200_AlterStaffSchoolInfoMembershipId'.
 +Done.
 +</code>
 +
 +A developer also suggested another by "hitting the API from postman or swagger" the URL https://localhost:port/{databaseName}/Common/getAllLanguageForLogin (replace the {databaseName} with the local databaseName) to automatically trigger the migration. 
 +
 +<note important>At the time of this writing I had to enabled (uncomment) the commented lines below in the file **opensis.data/Models/CRMContextMySQL.cs** to run the upgrade.
 +
 +<code csharp>
 +using System;
 +using System.Collections.Generic;
 +using System.Text;
 +using Microsoft.EntityFrameworkCore;
 +
 +namespace opensis.data.Models
 +{
 +    public class CRMContextMySQL : CRMContext
 +    {
 +        private readonly DbContextOptions? contextOptions;
 +        public CRMContextMySQL() { }
 +        public CRMContextMySQL(DbContextOptions options) : base(options)
 +        {
 +            this.contextOptions = options;
 +        }
 +        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 +        {
 +            if (!optionsBuilder.IsConfigured)
 +            {
 +                //var tenant = "opensisv2_ef6";
 +
 +                //string connectionString = $"server=localhost;database={tenant};user=theuser;password=thepassword";
 +                //optionsBuilder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
 +            }
 +
 +        }
 +    }
 +}
 +</code>
 +
 +</note>
  
 ==== Building and Running Backend ==== ==== Building and Running Backend ====
Line 138: Line 199:
 > npm install -g @angular/cli > npm install -g @angular/cli
 </code> </code>
 +
 +<note important>While the command above may install a version of Angular that will work fine in your environment, you may have better luck by installing a specific version of Angular as below.
 +
 +<code>
 +> npm install -g @angular/cli@10.0.5
 +</code>
 +</note>
  
 Browse to the ''Pacific-SIS/UI'' folder and execute the following to install all the dependencies. Browse to the ''Pacific-SIS/UI'' folder and execute the following to install all the dependencies.
Line 175: Line 243:
  
  
 +===== Deploying =====
 +
 +The deployment can be done in a number of ways. You can use the deployment tools in both the backend and frontend to package the files for the production server. Below explains how.
 +
 +==== Packaging the Backend ====
 +
 +Simply use the Visual Studio's publish feature. There is a publish "profile" in there that can be use as example. Two  apps need to be deployed on the backend.
 +
 +  * opensisAPI
 +  * opensis.backgroundjob
 +
 +This should look something like this.
 +
 +{{ :sis-developer-manual:pacific-sis-deploy-1.png |}}
 +
 +This will put the packaged files in specific directories on your development computer based on your publish profile.
 +
 +==== Packaging the Frontend ====
 +
 +Navigate to the ''Pacific-SIS/UI'' directory and execute the following command.
 +
 +<code>
 +> ng build
 +</code>
  
 +This should package all the frontend files in ''Pacific-SIS/UI/dist/vex/''
  
 +==== Deploying to Production Server ====
  
 +Is a matter of preference. You could simply copy the files produced in the two previous steps and configure the Apache Server to server them. The database will need to also be deployed. One of the maintainers of the system uses Ansible to automate all of these final deployment tasks.
sis_developer_manual.1676927435.txt.gz · Last modified: 2023/02/20 21:10 by ghachey