# Legitimate Licences Environment Readiness Checklist

## Overview
This checklist provides a comprehensive guide for setting up Dev, Test, and Production environments for the Legitimate Licences system. The system consists of multiple web applications, Windows services, desktop applications, and database components.

## Environment Components

### 1. Database Setup

#### 1.1 SQL Server Database
- [ ] **Database Creation**
  - [ ] Create `LegitimateNATIONAL` database
  - [ ] Create `LegitimateKZN_LTPS` database (for KZN specific data)
  - [ ] Set database owner to 'sa'
  - [ ] Enable TRUSTWORTHY property on databases

#### 1.2 Database Users and Permissions
- [ ] **User Setup**
  - [ ] Create `Legitimate` database user
  - [ ] Set password: `@L3g1t1mat3`
  - [ ] Grant appropriate permissions (SELECT, INSERT, UPDATE, DELETE, EXECUTE)
  - [ ] Grant EXTERNAL ACCESS ASSEMBLY permission for CLR functions

#### 1.3 CLR Integration
- [ ] **SQL Server CLR Configuration**
  - [ ] Enable CLR integration: `sp_configure 'clr enabled', 1`
  - [ ] Reconfigure SQL Server
  - [ ] Install Neo.Afx.SqlServer assembly
  - [ ] Install System.Core assembly
  - [ ] Install System.Xml.Linq assembly
  - [ ] Register CLR functions and stored procedures

#### 1.4 Database Scripts
- [ ] **Migration Scripts**
  - [ ] Run all scripts in `Neo.LegitimateLicences.Web/DBUp/Scripts/2024/`
  - [ ] Run all scripts in `Neo.LegitimateLicences.Web/DBUp/Scripts/2025/`
  - [ ] Run migration scripts in `Neo.LegitimateLicences.Web/DBUp/Scripts/Migration/`
  - [ ] Verify all stored procedures are created
  - [ ] Verify all functions are created
  - [ ] Verify all views are created

### 2. Web Applications

#### 2.1 Main Web Application (`Neo.LegitimateLicences.Web`)
- [ ] **IIS Configuration**
  - [ ] Create IIS application pool (.NET Framework 4.6.2)
  - [ ] Deploy web application
  - [ ] Configure application pool identity
  - [ ] Set appropriate permissions on application folder

- [ ] **Configuration Updates**
  - [ ] Update connection strings for environment
  - [ ] Update `BaseUrl` in appSettings
  - [ ] Update `AfxServicesPath` in appSettings
  - [ ] Update `AfxCdnPath` in appSettings
  - [ ] Configure Sentry DSN for environment
  - [ ] Update eNatis configuration (URLs, certificates, credentials)

#### 2.2 API Application (`Neo.LegitimateLicences.Api`)
- [ ] **IIS Configuration**
  - [ ] Create separate IIS application pool
  - [ ] Deploy API application
  - [ ] Configure CORS if needed
  - [ ] Set appropriate permissions

- [ ] **Configuration Updates**
  - [ ] Update connection strings for environment
  - [ ] Update API endpoints configuration
  - [ ] Configure authentication/authorization

#### 2.3 AFX Services (`Neo.Afx.Services.Web`)
- [ ] **IIS Configuration**
  - [ ] Create IIS application pool
  - [ ] Deploy AFX services
  - [ ] Configure service endpoints

- [ ] **Configuration Updates**
  - [ ] Update connection strings for environment
  - [ ] Configure service paths

### 3. Windows Services

#### 3.1 Main Windows Service (`Neo.LegitimateLicences.WinService`)
- [ ] **Service Installation**
  - [ ] Copy service files to `C:\Installs\LegitimateLicense\`
  - [ ] Run `install.bat` from `WIndowServiceInstall/` folder
  - [ ] Verify service is installed in Windows Services
  - [ ] Configure service to start automatically

- [ ] **Configuration Updates**
  - [ ] Update connection strings in `app.config`
  - [ ] Configure service account (Local System or dedicated service account)
  - [ ] Set appropriate file permissions

#### 3.2 Service Dependencies
- [ ] **Required Assemblies**
  - [ ] Verify all Neo.Afx assemblies are present
  - [ ] Verify EntityFramework assemblies
  - [ ] Verify Newtonsoft.Json assembly
  - [ ] Verify System.Web assemblies

### 4. Desktop Applications

#### 4.1 Desktop Application (`Neo.LegitimateLicences.Desktop`)
- [ ] **Application Deployment**
  - [ ] Deploy desktop application to client machines
  - [ ] Register custom protocol: `legitimatedesktop`
  - [ ] Configure application settings in `App.config`
  - [ ] Set up auto-updater functionality

- [ ] **Configuration Updates**
  - [ ] Update API endpoint URLs
  - [ ] Configure environment settings
  - [ ] Set up scanning and printing configurations

#### 4.2 ActiveX Components
- [ ] **ActiveX Registration**
  - [ ] Register `Neo.LegitimateLicences.ActiveX.Printing` components
  - [ ] Configure printing controls for different document types:
    - [ ] Accreditation Certificates
    - [ ] Accreditation Decals
    - [ ] Operating Licences
    - [ ] Payment Advice
    - [ ] App Receipts
    - [ ] Temporary Replacement Licences

### 5. External Integrations

#### 5.1 eNatis Integration
- [ ] **Certificate Setup**
  - [ ] Install eNatis certificate (`DOT.pfx`)
  - [ ] Configure certificate path: `C:\Applications\eNatis Certificates\DOT.pfx`
  - [ ] Set certificate password: `FGB20025WE$`

- [ ] **Configuration Updates**
  - [ ] Update eNatis URLs for environment:
    - [ ] Login URL: `https://ifprod.enatis.co.za:4443/eNaTIS_PROD/secure/X0000`
    - [ ] Query URL: `https://ifprod.enatis.co.za:4443/eNaTIS_PROD/secure/X1001`
  - [ ] Configure eNatis credentials:
    - [ ] Username: `3090A001`
    - [ ] Password: `BL0966`
  - [ ] Set operation mode: `LIVE`

#### 5.2 Clickatell Integration
- [ ] **SMS Service**
  - [ ] Configure Clickatell credentials
  - [ ] Test SMS functionality
  - [ ] Verify message delivery

### 6. Database Tables and Services

#### 6.1 Core Database Tables
- [ ] **Verify Required Tables**
  - [ ] Services table (for workflow services)
  - [ ] Connections table (for external integrations)
  - [ ] Audit tables
  - [ ] Workflow tables
  - [ ] Document tables
  - [ ] Form tables
  - [ ] Integration tables
  - [ ] Security tables
  - [ ] Notification tables
  - [ ] Performance monitoring tables

#### 6.2 SQL Jobs
- [ ] **Database Maintenance Jobs**
  - [ ] Create database backup jobs
  - [ ] Create index maintenance jobs
  - [ ] Create statistics update jobs
  - [ ] Create cleanup jobs for temporary data
  - [ ] Create monitoring jobs for service health

### 7. Environment-Specific Configurations

#### 7.1 Development Environment
- [ ] **Database**
  - [ ] Use development database server
  - [ ] Configure connection strings for dev server
  - [ ] Set up development data

- [ ] **Applications**
  - [ ] Configure for local development URLs
  - [ ] Enable debugging
  - [ ] Set up development certificates
  - [ ] Configure Sentry for development

#### 7.2 Test Environment
- [ ] **Database**
  - [ ] Use test database server
  - [ ] Configure connection strings for test server
  - [ ] Set up test data

- [ ] **Applications**
  - [ ] Configure for test URLs
  - [ ] Set up test certificates
  - [ ] Configure Sentry for testing
  - [ ] Test eNatis integration with test endpoints

#### 7.3 Production Environment
- [ ] **Database**
  - [ ] Use production database server
  - [ ] Configure connection strings for production server
  - [ ] Set up production data
  - [ ] Configure high availability if required

- [ ] **Applications**
  - [ ] Configure for production URLs
  - [ ] Set up production certificates
  - [ ] Configure Sentry for production
  - [ ] Enable production eNatis integration
  - [ ] Configure SSL certificates
  - [ ] Set up load balancing if required

### 8. Security and Permissions

#### 8.1 File System Permissions
- [ ] **Application Folders**
  - [ ] Set appropriate permissions on web application folders
  - [ ] Set appropriate permissions on service folders
  - [ ] Set appropriate permissions on desktop application folders
  - [ ] Configure access to certificate folders

#### 8.2 Database Security
- [ ] **User Permissions**
  - [ ] Verify database user has minimum required permissions
  - [ ] Set up appropriate database roles
  - [ ] Configure row-level security if required

#### 8.3 Network Security
- [ ] **Firewall Configuration**
  - [ ] Open required ports for web applications
  - [ ] Configure firewall rules for database access
  - [ ] Set up VPN access if required

### 9. Monitoring and Logging

#### 9.1 Application Monitoring
- [ ] **Sentry Configuration**
  - [ ] Configure Sentry DSN for environment
  - [ ] Test error reporting
  - [ ] Set up alerting rules

#### 9.2 Database Monitoring
- [ ] **Performance Monitoring**
  - [ ] Set up database performance monitoring
  - [ ] Configure alerts for slow queries
  - [ ] Monitor database size and growth

#### 9.3 Service Monitoring
- [ ] **Windows Service Monitoring**
  - [ ] Set up service health monitoring
  - [ ] Configure automatic restart on failure
  - [ ] Set up alerting for service failures

### 10. Testing Checklist

#### 10.1 Functional Testing
- [ ] **Web Application Testing**
  - [ ] Test user login/logout
  - [ ] Test application workflows
  - [ ] Test document upload/download
  - [ ] Test printing functionality
  - [ ] Test scanning functionality

- [ ] **API Testing**
  - [ ] Test API endpoints
  - [ ] Test authentication
  - [ ] Test data retrieval and updates

- [ ] **Desktop Application Testing**
  - [ ] Test printing from desktop app
  - [ ] Test scanning from desktop app
  - [ ] Test auto-updater functionality

#### 10.2 Integration Testing
- [ ] **eNatis Integration**
  - [ ] Test vehicle lookup functionality
  - [ ] Test certificate validation
  - [ ] Test error handling

- [ ] **SMS Integration**
  - [ ] Test SMS sending functionality
  - [ ] Test message delivery

#### 10.3 Performance Testing
- [ ] **Load Testing**
  - [ ] Test web application under load
  - [ ] Test database performance under load
  - [ ] Test API performance under load

### 11. Documentation

#### 11.1 Environment Documentation
- [ ] **Configuration Documentation**
  - [ ] Document all connection strings
  - [ ] Document all configuration settings
  - [ ] Document deployment procedures
  - [ ] Document troubleshooting procedures

#### 11.2 User Documentation
- [ ] **User Guides**
  - [ ] Create user guides for web application
  - [ ] Create user guides for desktop application
  - [ ] Create administrator guides

### 12. Backup and Recovery

#### 12.1 Backup Procedures
- [ ] **Database Backup**
  - [ ] Set up automated database backups
  - [ ] Test backup restoration procedures
  - [ ] Document backup schedules

#### 12.2 Application Backup
- [ ] **Configuration Backup**
  - [ ] Backup all configuration files
  - [ ] Backup certificates and keys
  - [ ] Document recovery procedures

### 13. Go-Live Checklist

#### 13.1 Pre-Go-Live
- [ ] **Final Testing**
  - [ ] Complete all functional testing
  - [ ] Complete all integration testing
  - [ ] Complete all performance testing
  - [ ] Verify all configurations are correct

#### 13.2 Go-Live
- [ ] **Deployment**
  - [ ] Deploy to production environment
  - [ ] Verify all services are running
  - [ ] Verify all applications are accessible
  - [ ] Monitor system health

#### 13.3 Post-Go-Live
- [ ] **Monitoring**
  - [ ] Monitor system performance
  - [ ] Monitor error rates
  - [ ] Monitor user feedback
  - [ ] Address any issues promptly

## Environment-Specific Notes

### Development Environment
- Use local database instances where possible
- Enable detailed logging and debugging
- Use development certificates and test data
- Configure for local development URLs

### Test Environment
- Use dedicated test database
- Use test certificates and test data
- Configure for test URLs
- Test all integrations with test endpoints

### Production Environment
- Use production database with high availability
- Use production certificates and real data
- Configure for production URLs
- Enable all security features
- Set up comprehensive monitoring and alerting

## Contact Information
- **Database Administrator**: [Contact Info]
- **System Administrator**: [Contact Info]
- **Application Support**: [Contact Info]
- **Network Administrator**: [Contact Info]

---
*This checklist should be completed for each environment before going live. All items must be verified and tested thoroughly.* 