What is the PowerServer C# solution

The PowerServer C# solution is generated during the build process. After the solution is generated, you can click the Open C# Solution in SnapDevelop button () in the toolbar to launch the PowerServer C# solution in SnapDevelop. Or go to the location where the solution is generated; and double click PowerServer_[appname].sln to launch the solution in SnapDevelop or other C# editor such as Visual Studio.

The PowerServer C# solution is an ASP.NET Core solution which contains three projects:

  • The AppModels project contains the C# models (converted from the PowerBuilder DataWindows) and the embedded SQLs (ESQL) from the PowerBuilder application.

  • The ServerAPIs project contains the PowerServer Web APIs which is RESTFul APIs for handling the database connections, data processing, PowerServer license activation, and advanced features such as file server etc.

  • The ServerAPIs.Tests project contains a number of test cases which can check if the PowerServer Web APIs is running correctly after the ServerAPIs project is modified. See Running the ServerAPIs.Tests project for more details.

The ServerAPIs project contains a number of configurable files and controllers. The following highlights the important files and settings only. For complete descriptions, refer to the readme.txt file under Solution Items.

  • Properties\launchSettings.json: This file contains the environment settings for running the PowerServer Web APIs in the local development environment, for example, the commandName key specifies the web server to launch (the value "Project" indicates that the Kestrel web server will be launched), and the applicationURL key specifies the host name and port number for the web server. For description of the settings in this file, See https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1#development-and-launchsettingsjson.

  • AppConfig

    • AppConfig.xml: This file contains the DB connection profile that is currently selected and deployed from the Database Configuration window.

    • Applications.json or Applications.[DBConnectionProfile].json: This file contains the basic information of the deployed applications and the database connection cache settings.

      For each DB connection profile configured in the Database Configuration window, an Applications.[DBConnectionProfile].json file is created. Applications.json is for the "Default" DB connection profile.

      • "Applications": This block includes the mappings of transactions and connection caches, timeout values for transaction, session, and request, and run mode (0-normal mode, 1-test mode) of each deployed application.

      • "Connections": This block includes the database connection cache name, database type, data source settings, and some advanced settings. The password for the database can be an encrypted value (encrypted by the CustomizeDeploy.dll tool) or a plain-text string.

  • Authentication: This folder contains the template and built-in server for the selected authentication type. For more information, refer to Tutorial 6: Authenticating your apps.

  • Controllers

    • ApplicationController.cs: This file provides APIs for dynamically adding, modifying or removing the application settings.

    • ConnectionController.cs: This file provides APIs for dynamically adding, modifying or removing the database connections such as cache or cache group.

    • LicenseController.cs: This file provides APIs for dynamically accessing the license information.

    • SessionController.cs: This file provides APIs for getting all user sessions or killing a particular user session. For more information, see Get/Kill user sessions.

    • StatisticsController.cs: This file provides APIs for getting statistics of the request and transaction.

    • TransactionController.cs: This file provides APIs for getting all transactions or rolling back a particular transaction.

    For documentation of these APIs, refer to View documentations for PowerServer Management APIs.

  • HealthChecks: Refer to the readme.txt file under Solution Items for more information. For more information, refer to Check the status of Web APIs.

  • Logging

    • log4net.xml: This file contains the logging settings for PowerServer. The "RollingFile" appender specifies the location, size, and backup of the log file, the "TraceAppender" appender specifies to generate the trace log, the "ConsoleAppender" appender specifies to print the logging information in the console and sets the font color of the logging information. For detailed syntax, refer to Apache Log4Net Manual.

    • Logging.json or Logging.Development.json: This file specifies the log level (Trace, Debug, Information, Warning, Error, Critical, and None), what level of logging information will be printed in the API console, and what type of PowerServer information (SQL, transaction, and session) will be logged.

      Logging.json will take effect in the production environment (for example, when Web APIs are published and running in IIS, docker etc.); and the default log level is warning. Logging.Development.json will take effect in the development environment (for example, when Web APIs is running from the SnapDevelop IDE or the PowerBuilder IDE); and the default log level is information.

  • OpenAPI: The OpenAPI Specification for implementing the API documentation.

  • Server.json or Server.Development.json: This file contains settings related with the server. As you can use multiple environments in ASP.NET Core (read more), there can be multiple configuration files, for example, Server.json will take effect in the production environment (for example, when Web APIs are published and running in IIS, docker etc.), while Server.Development.json will take effect in the development environment (for example, when Web APIs is running from the SnapDevelop IDE or the PowerBuilder IDE).

    • AllowedHosts: This setting specifies the host names to bind with PowerServer. See Host filtering for more.

    • PowerServer: This block specifies the settings for PowerServer.

      • LicenseKey & LicenseCode: PowerServer license information.

      • EncryptedSensitiveData: Sensitive data refers to the database login password which is used to create the database connection cache in AppConfig\Applications.json. If the password is an encrypted value (encrypted by the CustomizeDeploy.dll tool), this setting should be set to True; if the password is not encrypted (still a plain-text string), this setting should be set to False so that PowerServer will encrypt the password for you and store the encrypted value to the database. If this setting is set to True and you input a plain-text password, the plain-text password will be stored to the database.

      • AppModelsAssemblyNames: AppModels assembly name.

      • ProxyOptions: The IP address and login credentials of the proxy server. If the Web API host server connects to Internet through a proxy server, you will need to configure the proxy server settings here. The password for the proxy server must be an encrypted value (encrypted by the CustomizeDeploy.dll tool).

      • EmailOptions: This block must be configured first if you want to get notifications for license expiration. The settings include the SMTP server settings, sender email settings, and recipients.

      • StatisticsOptions: This block determines which type of transaction statistics will be generated and cached in the memory. Some settings are disabled by default to lower memory usages. You can also take advantage of the StatisticsController APIs in PowerServer NuGet package to get the statistics.

For files that are not mentioned here, refer to the readme.txt file under Solution Items for more information.