Initial Commit

This commit is contained in:
2025-01-28 16:27:48 +01:00
commit baacb6e2df
14 changed files with 385 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
.vs
bin
obj
tools
.yo-rc.json

10
License.md Normal file
View File

@@ -0,0 +1,10 @@
Copyright (c) 2025 Summit, All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Summit.ApiDemo.DemoLibrary</AssemblyName>
<TargetFramework>net48</TargetFramework>
<OutputPath>..\..\bin</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Authors>Peter Donker</Authors>
<Company>Summit</Company>
<Product>apidemo</Product>
<Copyright>Copyright 2025 by Summit</Copyright>
<PackageId>ApiDemo</PackageId>
<AssemblyVersion>0.0.1</AssemblyVersion>
<FileVersion>0.0.1</FileVersion>
<Description>ApiDemo module</Description>
<NeutralLanguage>en-US</NeutralLanguage>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
<DebugType>Portable</DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DotNetNuke.Abstractions" Version="10.0.0" />
<PackageReference Include="DotNetNuke.Core" Version="10.0.0" />
<PackageReference Include="DotNetNuke.WebApi" Version="10.0.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,39 @@
using DotNetNuke.Web.Api;
using System.Net.Http;
using System.Web.Http;
using System.Net;
using System.IO;
namespace Summit.ApiDemo.DemoLibrary
{
public class TestController : DnnApiController, IServiceRouteMapper
{
public void RegisterRoutes(IMapRoute mapRouteManager)
{
mapRouteManager.MapHttpRoute(
"Demo/DemoModule",
"DemoModuleTestControllerMap1",
"Test/{action}",
new { Controller = "Test" },
null, new[] { "Summit.ApiDemo.DemoLibrary" });
}
[HttpGet]
public HttpResponseMessage Test1()
{
return Request.CreateResponse(HttpStatusCode.OK, "Hello from Test1");
}
[HttpGet]
public HttpResponseMessage Test2()
{
return Request.CreateResponse(HttpStatusCode.OK, $"Hello from {PortalSettings.PortalName}");
}
[HttpGet]
public HttpResponseMessage Test3()
{
return Request.CreateResponse(HttpStatusCode.OK, $"Hello from {UserInfo.DisplayName}.");
}
}
}

View File

@@ -0,0 +1,16 @@
{
"projectType": "library",
"name": "Summit_DemoLibrary",
"friendlyName": "Summit DemoLibrary",
"description": "Summit DemoLibrary Library",
"packageName": "Summit_DemoLibrary",
"folder": "Summit/DemoLibrary",
"library": {},
"pathsAndFiles": {
"pathToAssemblies": "./bin",
"pathToScripts": "./Server/SqlScripts",
"assemblies": ["Summit.ApiDemo.DemoLibrary.dll"],
"releaseFiles": [],
"zipName": "Summit.DemoLibrary"
}
}

22
Summit.ApiDemo.sln Normal file
View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Summit.ApiDemo.DemoLibrary", "Server\DemoLibrary\Summit.ApiDemo.DemoLibrary.csproj", "{3ABEC2E1-35BA-4A46-9A7A-47B64B6E7683}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3ABEC2E1-35BA-4A46-9A7A-47B64B6E7683}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3ABEC2E1-35BA-4A46-9A7A-47B64B6E7683}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3ABEC2E1-35BA-4A46-9A7A-47B64B6E7683}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3ABEC2E1-35BA-4A46-9A7A-47B64B6E7683}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

2
build.ps1 Normal file
View File

@@ -0,0 +1,2 @@
dotnet run --project build/Build.csproj -- $args
exit $LASTEXITCODE;

20
build/Build.csproj Normal file
View File

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<AssemblyVersion>0.0.1</AssemblyVersion>
<FileVersion>0.0.1</FileVersion>
<Product>apidemo</Product>
<Description>ApiDemo module</Description>
<Company>Summit</Company>
<Copyright>Copyright 2025 by Summit</Copyright>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cake.FileHelpers" Version="5.0.0" />
<PackageReference Include="Cake.Frosting" Version="2.0.0" />
<PackageReference Include="Cake.Npm" Version="1.0.0" />
<PackageReference Include="Dnn.CakeUtils" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>

156
build/Program.cs Normal file
View File

@@ -0,0 +1,156 @@
using Cake.Common.Diagnostics;
using Cake.Common.IO;
using Cake.Common.Tools.MSBuild;
using Cake.Common.Tools.NuGet;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Frosting;
using Cake.Npm;
using Dnn.CakeUtils;
using Dnn.CakeUtils.Manifest;
using System;
using System.Collections.Generic;
using System.Linq;
public static class Program
{
public static int Main(string[] args)
{
return new CakeHost()
.InstallTool(new Uri("nuget:?package=NuGet.CommandLine&version=5.8.1"))
.UseContext<BuildContext>()
.Run(args);
}
}
public class BuildContext : FrostingContext
{
public Solution Solution { get; set; }
public MSBuildSettings BuildSettings { get; set; }
public BuildContext(ICakeContext context)
: base(context)
{
context.Environment.WorkingDirectory = context.Environment.WorkingDirectory.FullPath + "/../";
this.Solution = Solution.New(".\\package.json");
this.BuildSettings = new MSBuildSettings()
.SetConfiguration("Release")
.UseToolVersion(MSBuildToolVersion.VS2022)
.WithProperty("OutDir", new System.IO.DirectoryInfo(this.Solution.dnn.pathsAndFiles.pathToAssemblies).FullName);
}
}
[TaskName("AssemblyInfo")]
public sealed class AssemblyInfoTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
var ptrn = new string[] { "./**/AssemblyInfo.*" };
var files = context.GetFilesByPatterns(ptrn, context.Solution.dnn.pathsAndFiles.excludeFilter);
foreach (var file in files)
{
context.Information("Updating Assembly: {0}", file);
context.UpdateAssemblyInfo(context.Solution, file);
}
ptrn = new string[] { "./**/*.csproj" };
files = context.GetFilesByPatterns(ptrn, context.Solution.dnn.pathsAndFiles.excludeFilter);
foreach (var file in files)
{
context.Information("Updating Project File: {0}", file);
context.UpdateCsProjFile(context.Solution, file);
}
}
}
[TaskName("Build")]
[IsDependentOn(typeof(AssemblyInfoTask))]
public sealed class BuildTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
context.CleanDirectory(context.Solution.dnn.pathsAndFiles.pathToAssemblies);
context.NuGetRestore(context.Solution.dnn.pathsAndFiles.solutionFile);
context.MSBuild(context.Solution.dnn.pathsAndFiles.solutionFile, context.BuildSettings);
// context.NpmRunScript("build");
}
}
[TaskName("Package")]
[IsDependentOn(typeof(BuildTask))]
public sealed class PackageTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
var packageName = context.Solution.dnn.pathsAndFiles.zipName + "_" + context.Solution.version + "_Install.zip";
var packagePath = context.Solution.dnn.pathsAndFiles.packagesPath + "/" + packageName;
if (!System.IO.Directory.Exists(context.Solution.dnn.pathsAndFiles.packagesPath))
{
System.IO.Directory.CreateDirectory(context.Solution.dnn.pathsAndFiles.packagesPath);
}
if (System.IO.File.Exists(packagePath))
{
System.IO.File.Delete(packagePath);
}
var addedDlls = new List<string>();
foreach (var pfolder in context.Solution.dnn.projectFolders)
{
var p = context.Solution.dnn.projects[pfolder];
context.Information("Loading " + p.name);
var devPath = System.IO.Path.Combine(context.Solution.dnn.pathsAndFiles.devFolder, pfolder);
var releaseFiles = p.pathsAndFiles.releaseFiles == null ? context.Solution.dnn.pathsAndFiles.releaseFiles : p.pathsAndFiles.releaseFiles;
if (releaseFiles.Length > 0)
{
var excludeFiles = p.pathsAndFiles.excludeFilter;
if (excludeFiles == null)
{
excludeFiles = context.Solution.dnn.pathsAndFiles.excludeFilter;
}
else
{
excludeFiles = excludeFiles.Concat(context.Solution.dnn.pathsAndFiles.excludeFilter).ToArray();
}
context.CreateResourcesFile(new DirectoryPath(devPath), packagePath, p.packageName, releaseFiles, excludeFiles);
}
foreach (var a in p.pathsAndFiles.assemblies)
{
if (!addedDlls.Contains(a))
{
var files = context.GetFiles(context.Solution.dnn.pathsAndFiles.pathToAssemblies + "/" + a);
context.AddFilesToZip(packagePath, context.Solution.dnn.pathsAndFiles.pathToAssemblies, context.Solution.dnn.pathsAndFiles.packageAssembliesFolder, files, true);
addedDlls.Add(a);
}
}
if (!string.IsNullOrEmpty(p.pathsAndFiles.pathToScripts))
{
var files = context.GetFiles(p.pathsAndFiles.pathToScripts + "/*.SqlDataProvider");
context.AddFilesToZip(packagePath, p.pathsAndFiles.pathToScripts, context.Solution.dnn.pathsAndFiles.packageScriptsFolder + "/" + p.packageName, files, true);
}
}
if (context.Solution.dnn.pathsAndFiles.licenseFile != "")
{
var license = context.GetTextOrMdFile(System.IO.Path.GetFileNameWithoutExtension(context.Solution.dnn.pathsAndFiles.licenseFile));
if (license != "")
{
context.AddTextFileToZip(packagePath, license, "License.txt", true);
}
}
if (context.Solution.dnn.pathsAndFiles.releaseNotesFile != "")
{
var releaseNotes = context.GetTextOrMdFile(System.IO.Path.GetFileNameWithoutExtension(context.Solution.dnn.pathsAndFiles.releaseNotesFile));
if (releaseNotes != "")
{
context.AddTextFileToZip(packagePath, releaseNotes, "ReleaseNotes.txt", true);
}
}
var m = new Manifest(context.Solution);
context.AddXmlFileToZip(packagePath, m, context.Solution.name + ".dnn", true);
}
}
[TaskName("Default")]
[IsDependentOn(typeof(PackageTask))]
public class DefaultTask : FrostingTask
{
}

3
cake.config Normal file
View File

@@ -0,0 +1,3 @@
[settings]
skippackageversioncheck=true

6
nuget.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="local" value="D:\Tools\NuGet\TempPackages" />
</packageSources>
</configuration>

12
package-lock.json generated Normal file
View File

@@ -0,0 +1,12 @@
{
"name": "apidemo",
"version": "0.0.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "apidemo",
"version": "0.0.1"
}
}
}

56
package.json Normal file
View File

@@ -0,0 +1,56 @@
{
"name": "apidemo",
"version": "0.0.1",
"description": "ApiDemo module",
"dnn": {
"projectFolders": [
"Server/DemoLibrary"
],
"owner": {
"name": "Peter Donker",
"organization": "Summit",
"url": "www.dnn-connect.org",
"email": "peter@bring2mind.net"
},
"pathsAndFiles": {
"solutionFile": "./Summit.ApiDemo.sln",
"pathToAssemblies": "./bin",
"devSiteUrl": "",
"devSitePath": "",
"excludeFilter": [
"bin/",
"obj/",
"node_modules"
],
"licenseFile": "./License.md",
"releaseNotesFile": "",
"releaseFiles": [
"App_LocalResources/*.resx",
"**/*.ascx",
"**/*.cshtml",
"**/*.vbhtml",
"js/*.js",
"css/*.css",
"*.css",
"**/*.html",
"**/*.png",
"**/*.jpg",
"**/*.jpeg",
"**/*.gif",
"**/*.eot",
"**/*.svg",
"**/*.ttf",
"**/*.woff",
"**/*.woff2",
"*.txt"
],
"zipName": "Summit.ApiDemo"
}
},
"scripts": {
"build": "set NODE_ENV=production&&webpack --config Client/webpack.config.js",
"watch": "webpack --config Client/webpack.config.js --progress --watch",
"watch-server": "node watch.js"
},
"author": "Peter Donker"
}

7
tslint.json Normal file
View File

@@ -0,0 +1,7 @@
{
"extends": ["tslint:latest", "tslint:react"],
"rules": {
"object-literal-sort-keys": false,
"no-unused-variable": [true, "react"]
}
}