Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/en/How-To-Create-Edit-Power-Tools-Templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# How to Create & Edit Power Tools Templates

Power Tools uses text templates for code generation, and these templates are located inside `/AspNetZeroRadTool/FileTemplates` directory in your project's root directory.

**MainTemplate.txt:** Power Tools uses this template for main code generation.
**PartialTemplates.txt:** Power Tools renders some placeholders in `MainTemplate.txt` conditionally. These conditional templates are stored in `PartialTemplates.txt`.
**TemplateInfo.txt:** Stores information about the template like path and condition.

*Folder structure*

![Folder structure](images/power-tools-folder-structure.png)

## Edit Pre-defined Templates

If you want to edit any file, copy it in the same directory and change it's an extension to `.custom.txt` from `.txt`. For example, you can create `MainTemplate.custom.txt` to override `MainTemplate.txt` in the same directory. Please don't make any changes to the original templates.

![Edit Template](images/power-tools-edit-template.png)

## Create New Templates

To create new templates, simply add a new file to the `FileTemplates` directory. You can use the existing templates as a reference. For guidance on how templates function and how to use placeholders, please refer to the documentation provided at [Understanding Power Tools Templates](power-tools-understanding-power-tools-templates.md).

Power Tools discovers templates in the `FileTemplates` directory every time it is run. So, restarting Power Tools will find your newly created templates.

## Change Destination Path Of New Files

To change the destination path of a template, find the template folder of it in `AspNetZeroRadTool/FileTemplates` directory and edit the content of `TemplateInfo.txt` file.
57 changes: 57 additions & 0 deletions docs/en/Power-Tools-Configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# ASP.NET ZERO Power Tools Configuration

The `config.json` file provided in your ASP.NET Zero project contains essential file paths and configuration settings used by the Power Tools. While the Power Tools **typically do not require manual configuration**, there are instances where you **might need** to modify the configuration to adapt to changes in file locations or project structure. In such cases, updating the `config.json` becomes necessary to ensure the Power Tools function correctly.

Here are some key points to consider when modifying the `config.json` file:

1. **Company Name and Project Name:** You may need to update the **CompanyName** and **ProjectName** fields with appropriate values to match your project's details.

2. **Project Type and Version:** Set the **ProjectType** to **Angular** or **Mvc** and specify the appropriate **ProjectVersion**.

3. **Application Area Name:** Ensure the **ApplicationAreaName** matches the relevant area name in your project (used only for MVC projects).

4. **License Code:** Replace **[YOURLICENSECODE]** with the valid license code for your project.

5. **File Locations:** This section contains various file paths used by the Power Tools for different functionalities. If you change any of these file locations in your project, you need to update the corresponding paths in the `config.json` file accordingly. For example, if you move the DbContext file to a different location, update the **DbContext** path to reflect the new location.

6. **Base Paths:** The `config.json` file uses base paths (e.g., `AngularSrcPath`, `AngularMergedSrcPath`, `CoreSrcPath`) to build the final file paths. Make sure to set these base paths correctly according to your project's structure.

7. **Angular Project Type:** Depending on whether your Angular project is separate from server side Host project or merged with server side Host project, use the appropriate base path (`AngularSrcPath` for split projects or `AngularMergedSrcPath` for merged projects) for the Angular-related file paths.

Always **double-check** the **changes** you make in the config.json file to avoid any errors or inconsistencies. It's crucial to keep the configuration updated to ensure the Power Tools can accurately locate the required files and function as expected with your project's structure.

*Example config.json*
```json
{
"CompanyName": "",
"ProjectName": "[YOURPROJECTNAME]",
"ProjectType": "Angular",
"ProjectVersion": "v8.0.0",
"ApplicationAreaName": "App",
"LicenseCode": "[YOURLICENSECODE]",
"AngularSrcPath": "\\..\\..\\angular\\src\\",
"AngularMergedSrcPath": "\\..\\src\\{{Namespace_Here}}.Web.Host\\src\\",
"CoreSrcPath": "\\..\\src\\",
"FormatGeneratedFiles": true,
"FileLocations": {
"DbContext": "{{Namespace_Here}}.EntityFrameworkCore\\EntityFrameworkCore\\{{Project_Name_Here}}DbContext.cs",
"CustomDtoMapper": "{{Namespace_Here}}.Application\\CustomDtoMapper.cs",
"AppAuthorizationProvider": "{{Namespace_Here}}.Core\\Authorization\\AppAuthorizationProvider.cs",
"EntityHistoryHelper": "{{Namespace_Here}}.Core\\EntityHistory\\EntityHistoryHelper.cs",
"AppPermissions": "{{Namespace_Here}}.Core\\Authorization\\AppPermissions.cs",
"LocalizationFile": "{{Namespace_Here}}.Core\\Localization\\{{Project_Name_Here}}\\{{Project_Name_Here}}.xml",
"EntityFrameWorkProjectFolder": "{{Namespace_Here}}.EntityFrameworkCore",
"Mvc": {
"AppNavigationProvider": "{{Namespace_Here}}.Web.Mvc\\Areas\\{{App_Area_Name_Here}}\\Startup\\{{App_Area_Name_Here}}NavigationProvider.cs",
"AppPageNames": "{{Namespace_Here}}.Web.Mvc\\Areas\\{{App_Area_Name_Here}}\\Startup\\{{App_Area_Name_Here}}PageNames.cs",
"BundleConfig": "{{Namespace_Here}}.Web.Mvc\\bundles.json"
},
"Angular": {
"AppNavigationService": "app\\shared\\layout\\nav\\app-navigation.service.ts",
"ServiceProxies": "shared\\service-proxies\\service-proxy.module.ts",
"Module": "app\\{{menu_Position_Here}}\\{{menu_Position_Here}}.module.ts",
"RoutingModule": "app\\{{menu_Position_Here}}\\{{menu_Position_Here}}-routing.module.ts"
}
}
}
```
186 changes: 186 additions & 0 deletions docs/en/Power-Tools-Creating-Entity-Json-File-Manually.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# Creating Entity Json File Manually

In this document, we will explain how to use **ASP.NET Zero Power Tools** without the Visual Studio extension.

Purpose of the **ASP.NET Zero Power Tools VS Extension** is to create an input file. So, in order to use it without extension, input file needs to be created manually.

## Creating Input File

For creating JSON file manually, you need to learn fields of the JSON file (configuration for entity).

Properties are written as an array in JSON file. Add an object to that array for every property of your entity. There will be some unnecessary fields depending on property type. For example, you don't have to set regular expression for a numeric property or don't have to set range for a string.

You have to fill the fields of the JSON file for your entity. However, some of the fields must match our constants.

A property should be one of those types:

* bool
* byte
* short
* DateTime
* decimal
* double
* Guid
* int
* long
* string

or one of the ENUMs you declared in **EnumDefinitions**.

You can find specification of the JSON file fields in the table below;

## Fields Table

| Name | Description |
| --- | --- |
| IsRegenerate | Set `true` if you have generated this entity before. |
| MenuPosition | `main` or `admin` |
| RelativeNamespace | Namespace of your entity (not including project's namespace) |
| EntityName | Entity Name |
| EntityNamePlural | Entity Name Plural |
| TableName | Database Table Name (might be same with plural name) |
| PrimaryKeyType | Type of primay key. <br />Can be `int`, `long`, `string`, `Guid` |
| BaseClass | Base class of your entity. <br />Can be `Entity`, `AuditedEntity`, `CreationAuditedEntity`, `FullAuditedEntity` |
| EntityHistory | Set `true` to track history of this entity. |
| AutoMigration | `true` add-migration automatically, false do not add migration (you need to add migration manually) |
| UpdateDatabase | `true` update-database automatically, false do not update-database (you need to update-database manually) |
| CreateUserInterface | `true` creates/modifies ui layer files |
| CreateViewOnly | `true` creates a view-only modal in actions button in table of your entity in ui |
| CreateExcelExport | `true` adds excel report button in ui |
| IsNonModalCRUDPage | `true` creates non-modal pages. |
| PagePermission | Multitenancy<br />`"PagePermission":{"Host": [ISHOSTALLOWED],"Tenant":[ISTENANTALLOWED]}` |
| Properties | Properties of your entity. See **Properties Table** for more. |
| NavigationProperties | Navigation properties of your entity. See **NavigationProperties Table** for more. |
| EnumDefinitions | Enum definitions you use on your entity. See **EnumDefinitions Table** for more. |

## Properties Table(Array):

| Name | Description |
| --- | --- |
| Name | Property Name |
| Type | Type of property. <br />Can be string, bool, byte, short, DateTime, decimal, double, Guid, int, long, enum |
| MaxLength | If type is string max length of string |
| MinLength | If type is string min length of string |
| Range | If type can have range value range of property<br />"Range": {"IsRangeSet": [ISRANGESET],"MinimumValue": [MINVAL],"MaximumValue": [MAXVAL]} |
| Required | Is property required |
| Nullable | Is property nullable |
| Regex | specifies the regex that this property should match |
| UserInterface | Will this property be listed, have a filter and editable in ui?<br />"UserInterface": {"List": true,"AdvancedFilter": true,"CreateOrUpdate": true} |

## NavigationProperties Table(Array):

| Name | Description |
| --- | --- |
| Namespace | Namespace of entity |
| ForeignEntityName | Foreign Entity Name |
| ForeignEntityNamePlural | Foreign Entity Name Plural |
| IdType | Type of Foreign Key. See Entity -> PrimaryKeyType |
| IsNullable | Is nullable |
| PropertyName | Property name (Property name for that entity which will store Foreign Key) |
| DisplayPropertyName | Property name of foreign entity. It will be displayed by that property on pages. |
| DuplicationNumber | If you have two navigation property that navigates to same foreign entity, number them starting from 1. If not, just skip this. |
| RelationType | single is the only option. |

## EnumDefinitions Table:

| Name | Description |
| --- | --- |
| Name | Name |
| Namespace | Namespace |
| EnumProperties | Properties <br />"EnumProperties":[{"Name":"[PROPERYNAME]","Value":[PROPERYVALUE]}] |

## Example JSON Input

```json
{
"IsRegenerate": false,
"MenuPosition": "main",
"RelativeNamespace": "Products",
"EntityName": "Product",
"EntityNamePlural": "Products",
"TableName": "Products",
"PrimaryKeyType": "int",
"BaseClass": "Entity",
"EntityHistory": false,
"AutoMigration": true,
"UpdateDatabase": true,
"CreateUserInterface": true,
"CreateViewOnly": true,
"CreateExcelExport": true,
"IsNonModalCRUDPage": false,
"PagePermission": {
"Host": true,
"Tenant": true
},
"Properties": [
{
"Name": "Name",
"Type": "string",
"MaxLength": 25,
"MinLength": 2,
"Range": {
"IsRangeSet": false,
"MinimumValue": 0,
"MaximumValue": 0
},
"Required": true,
"Nullable": false,
"Regex": "",
"UserInterface": {
"List": true,
"AdvancedFilter": true,
"CreateOrUpdate": true
}
},
{
"Name": "Type",
"Type": "ProductType",
"MaxLength": 0,
"MinLength": 0,
"Range": {
"IsRangeSet": false,
"MinimumValue": 0,
"MaximumValue": 0
},
"Required": false,
"Nullable": false,
"Regex": "",
"UserInterface": {
"List": true,
"AdvancedFilter": true,
"CreateOrUpdate": true
}
}
],
"NavigationProperties": [
{
"Namespace": "Volosoft.RadToolExplainer.Authorization.Users",
"ForeignEntityName": "User",
"IdType": "long",
"IsNullable": true,
"PropertyName": "UserId",
"DisplayPropertyName": "Name",
"DuplicationNumber": 0,
"RelationType": "single"
}
],
"EnumDefinitions": [
{
"Name": "ProductType",
"Namespace": "Volosoft.RadToolExplainer",
"EnumProperties": [
{
"Name": "Liquid",
"Value": 1
},
{
"Name": "Solid",
"Value": 2
}
]
}
]
}
```

> Note: Please Keep in mind that JSON file is completely **case sensitive**.
40 changes: 40 additions & 0 deletions docs/en/Power-Tools-Getting-Started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# ASP.NET ZERO Power Tools Getting Started

Did you know you can achieve Rapid Application Development (RAD) without sacrificing your ASP.Net Core habits and comforts?

## Pre Requirements

* [Visual Studio 2017 (v15.9.0+)](https://www.visualstudio.com/) (Only for Windows)
* [.NET 7 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)
* [EF Core Cli](https://docs.microsoft.com/en-us/ef/core/cli/dotnet)
* [ASP.NET Zero v5.0.0+](https://aspnetzero.com/Download)

## Installation

To harness the capabilities of ASP.NET Zero Power Tools, there are two convenient methods available. You can either install the Visual Studio extension or utilize the binaries provided within your ASP.NET Zero solution. Choose the approach that best suits your preferences and requirements.

### Windows

All you have to do is just install the ASP.NET Zero Power Tools extension on Visual Studio from [marketplace](https://marketplace.visualstudio.com/items?itemName=Volosoft.AspNetZeroPowerTools) or from Visual Studio's **Manage Extensions** menu.

![Visual studio extensions](images/power-tools-visual-studio-extensions.png)

### Mac/Linux

If you are a non-Windows user, you have the option to use the binaries of ASP.NET Zero Power Tools that are already included in your ASP.NET Zero solution.

The main purpose of the ASP.NET Zero Power Tools Visual Studio Extension is to create an input file automatically. However, if you prefer not to use the extension, you can create the input file manually.

To create the input file manually for ASP.NET Zero Power Tools, you can refer to the documentation provided at [ASP.NET Zero Power Tools](power-tools-creating-entity-json-file-manually.md). This documentation offers detailed instructions on how to create the input file, which is required to generate entities using the Power Tools.

Once you have created the JSON input file, you can proceed to generate the entity using the following command in the **AspNetZeroRadTool** folder within your project:

```bash
dotnet AspNetZeroRadTool.dll YourEntity.Json
```

## Notes

* If you are using the Visual Studio extension, you can find the generated JSON input file in the **AspNetZeroRadTool** folder within your project.
* Please keep in mind that JSON file is completely case sensitive.
* If you are working on ASP.NET Core & Angular template, after generating the entity via Power Tools, run your `*.Web.Host` project and then run `./angular/nswag/refresh.bat` to update `service-proxies.ts`
Loading