Skip to content

Commit

Permalink
Merge pull request #2 from DNNCommunity/dnn-standards
Browse files Browse the repository at this point in the history
Resolved all build warnings
  • Loading branch information
valadas authored Oct 16, 2020
2 parents 34eb175 + 03c4a3e commit 9eba784
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 102 deletions.
10 changes: 4 additions & 6 deletions Components/BusinessController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ namespace Dnn.Modules.ModuleCreator.Components
using System;

using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Definitions;
using DotNetNuke.Services.Upgrade;

/// <summary>
///
/// The module business controller is used to implement Dnn module interfaces.
/// </summary>
public class BusinessController : IUpgradeable
{
/// <summary>
///
/// Runs when the module is upgraded.
/// </summary>
/// <param name="version"></param>
/// <returns></returns>
/// <param name="version">The version of the new package.</param>
/// <returns>"Success" or "Failed".</returns>
public string UpgradeModule(string version)
{
try
Expand Down
71 changes: 50 additions & 21 deletions CreateModule.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
namespace Dnn.Module.ModuleCreator
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Web.UI.WebControls;

using DotNetNuke.Abstractions;
using DotNetNuke.Common;
using DotNetNuke.Abstractions.Application;
using DotNetNuke.Abstractions.Portals;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Content.Taxonomy;
using DotNetNuke.Entities.Controllers;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Definitions;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Installer.Packages;
Expand All @@ -23,35 +23,49 @@ namespace Dnn.Module.ModuleCreator
using DotNetNuke.UI.Skins.Controls;
using Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Codebehind for the CreateModule view.
/// </summary>
public partial class CreateModule : PortalModuleBase
{
private readonly INavigationManager _navigationManager;
private readonly INavigationManager navigationManager;
private readonly IHostSettingsService hostSettingsService;
private readonly IApplicationStatusInfo applicationStatusInfo;
private readonly IPortalSettings portalSettings;

/// <summary>
/// Initializes a new instance of the <see cref="CreateModule"/> class.
/// </summary>
public CreateModule()
{
this._navigationManager = this.DependencyProvider.GetRequiredService<INavigationManager>();
this.navigationManager = this.DependencyProvider.GetRequiredService<INavigationManager>();
this.hostSettingsService = this.DependencyProvider.GetRequiredService<IHostSettingsService>();
this.applicationStatusInfo = this.DependencyProvider.GetRequiredService<IApplicationStatusInfo>();
this.portalSettings = PortalController.Instance.GetCurrentSettings();
}

/// <inheritdoc/>
protected override void OnInit(EventArgs e)
{
base.OnInit(e);

this.optLanguage.SelectedIndexChanged += this.optLanguage_SelectedIndexChanged;
this.cboTemplate.SelectedIndexChanged += this.cboTemplate_SelectedIndexChanged;
this.cmdCreate.Click += this.cmdCreate_Click;
this.optLanguage.SelectedIndexChanged += this.OptLanguageSelectedIndexChanged;
this.cboTemplate.SelectedIndexChanged += this.CboTemplateSelectedIndexChanged;
this.cmdCreate.Click += this.CmdCreateClick;
}

/// <inheritdoc/>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (this.UserInfo.IsSuperUser)
{
if (!this.Page.IsPostBack)
{
Dictionary<string, string> HostSettings = HostController.Instance.GetSettingsDictionary();
if (HostSettings.ContainsKey("Owner"))
var hostSettings = this.hostSettingsService.GetSettingsDictionary();
if (hostSettings.ContainsKey("Owner"))
{
this.txtOwner.Text = HostSettings["Owner"];
this.txtOwner.Text = hostSettings["Owner"];
}

this.LoadLanguages();
Expand All @@ -66,26 +80,41 @@ protected override void OnLoad(EventArgs e)
}
}

protected void optLanguage_SelectedIndexChanged(object sender, EventArgs e)
/// <summary>
/// Fires up when the language is changed.
/// </summary>
/// <param name="sender">The sender of the event.</param>
/// <param name="e">The event arguments.</param>
protected void OptLanguageSelectedIndexChanged(object sender, EventArgs e)
{
this.LoadModuleTemplates();
}

protected void cboTemplate_SelectedIndexChanged(object sender, EventArgs e)
/// <summary>
/// Fires up when the template selection is changed.
/// </summary>
/// <param name="sender">The sender of the event.</param>
/// <param name="e">The event arguments.</param>
protected void CboTemplateSelectedIndexChanged(object sender, EventArgs e)
{
this.LoadReadMe();
}

protected void cmdCreate_Click(object sender, EventArgs e)
/// <summary>
/// Fires up when the create button is clicked.
/// </summary>
/// <param name="sender">The sender of the event.</param>
/// <param name="e">The event arguments.</param>
protected void CmdCreateClick(object sender, EventArgs e)
{
if (this.UserInfo.IsSuperUser)
{
if (!string.IsNullOrEmpty(this.txtOwner.Text) && !string.IsNullOrEmpty(this.txtModule.Text) && this.cboTemplate.SelectedIndex > 0 && !string.IsNullOrEmpty(this.txtControl.Text))
{
HostController.Instance.Update("Owner", this.txtOwner.Text, false);
this.hostSettingsService.Update("Owner", this.txtOwner.Text, false);
if (this.CreateModuleDefinition())
{
this.Response.Redirect(this._navigationManager.NavigateURL(), true);
this.Response.Redirect(this.navigationManager.NavigateURL(), true);
}
}
else
Expand Down Expand Up @@ -155,7 +184,7 @@ private void LoadModuleTemplates()

private void CreateModuleFolder()
{
var moduleFolderPath = Globals.ApplicationMapPath + "\\DesktopModules\\" + this.GetFolderName().Replace("/", "\\");
var moduleFolderPath = this.applicationStatusInfo.ApplicationMapPath + "\\DesktopModules\\" + this.GetFolderName().Replace("/", "\\");

if (!Directory.Exists(moduleFolderPath))
{
Expand All @@ -167,7 +196,7 @@ private string CreateModuleControl()
{
var moduleTemplatePath = this.Server.MapPath(this.ControlPath) + "Templates\\" + this.optLanguage.SelectedValue + "\\" + this.cboTemplate.SelectedValue + "\\";

EventLogController.Instance.AddLog("Processing Template Folder", moduleTemplatePath, this.PortalSettings, -1, EventLogController.EventLogType.HOST_ALERT);
EventLogController.Instance.AddLog("Processing Template Folder", moduleTemplatePath, this.portalSettings, -1, EventLogController.EventLogType.HOST_ALERT);

var controlName = Null.NullString;
var fileName = Null.NullString;
Expand Down Expand Up @@ -249,7 +278,7 @@ private string CreateModuleControl()
tw.Close();
}

EventLogController.Instance.AddLog("Created File", modulePath + fileName, this.PortalSettings, -1, EventLogController.EventLogType.HOST_ALERT);
EventLogController.Instance.AddLog("Created File", modulePath + fileName, this.portalSettings, -1, EventLogController.EventLogType.HOST_ALERT);
}
}

Expand Down Expand Up @@ -290,9 +319,9 @@ private string GetClassName()
}

/// <summary>
/// Creates the module definition.
/// </summary>
/// <remarks>
/// </remarks>
/// <returns>A value indicating whether the operation succeeded.</returns>
private bool CreateModuleDefinition()
{
try
Expand Down
9 changes: 6 additions & 3 deletions Dnn.Modules.ModuleCreator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Dnn.Modules.ModuleCreator.XML</DocumentationFile>
<LangVersion>7</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -184,9 +185,6 @@
<Content Include="module.css" />
<Content Include="CreateModule.ascx" />
</ItemGroup>
<ItemGroup>
<Content Include="Module.build" />
</ItemGroup>
<ItemGroup>
<Content Include="dnn_ModuleCreator.dnn">
<SubType>Designer</SubType>
Expand Down Expand Up @@ -216,6 +214,11 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<AdditionalFiles Include="stylecop.json" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="packages\StyleCop.Analyzers.1.1.118\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
<Analyzer Include="packages\StyleCop.Analyzers.1.1.118\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
Expand Down
47 changes: 0 additions & 47 deletions Module.build

This file was deleted.

7 changes: 5 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
// See the LICENSE file in the project root for more information

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyCompany(".NET Foundation")]
[assembly: AssemblyCopyright("Copyright 2002-2020 by .NET Foundation. All Rights Reserved.")]
[assembly: AssemblyDescription("Dnn Module Creator Module")]
[assembly: AssemblyProduct("https://dnncommunity.org")]
[assembly: AssemblyTitle("Dnn.Modules.ModuleCreator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTrademark("DNN")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
Expand Down
5 changes: 4 additions & 1 deletion dnn_ModuleCreator.dnn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dotnetnuke type="Package" version="5.0">
<packages>
<package name="DotNetNuke.Module Creator" type="Module" version="09.07.02">
<package name="DotNetNuke.Module Creator" type="Module" version="">
<friendlyName>Module Creator</friendlyName>
<description>Development of modules.</description>
<iconFile>~/Icons/Sigma/ModuleCreator_32x32.png</iconFile>
Expand All @@ -13,6 +13,9 @@
<license src="license.txt" />
<releaseNotes src="releaseNotes.txt" />
<azureCompatible>true</azureCompatible>
<dependencies>
<dependency type="coreVersion">09.07.01</dependency>
</dependencies>
<components>
<component type="Module">
<desktopModule>
Expand Down
2 changes: 2 additions & 0 deletions packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<package id="DotNetNuke.DependencyInjection" version="9.7.1" targetFramework="net472" />
<package id="DotNetNuke.Instrumentation" version="9.7.1" targetFramework="net472" />
<package id="DotNetNuke.Web" version="9.7.1" targetFramework="net472" />
<package id="EntityFramework" version="5.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection" version="2.1.1" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.1.1" targetFramework="net472" />
<package id="StyleCop.Analyzers" version="1.1.118" targetFramework="net472" developmentDependency="true" />
</packages>
49 changes: 49 additions & 0 deletions stylecop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"indentation": {
"indentationSize": 4,
"tabSize": 4,
"useTabs": false
},
"orderingRules": {
"elementOrder": [
"kind",
"accessibility",
"constant",
"static",
"readonly"
],
"systemUsingDirectivesFirst": true,
"usingDirectivesPlacement": "insideNamespace",
"blankLinesBetweenUsingGroups": "require"
},
"namingRules": {
"allowCommonHungarianPrefixes": true,
"allowedHungarianPrefixes": [],
"allowedNamespaceComponents": [],
"includeInferredTupleElementNames": false,
"tupleElementNameCasing": "PascalCase"
},
"maintainabilityRules": {
"topLevelTypes": [ "class" ]
},
"layoutRules": {
"newlineAtEndOfFile": "require",
"allowConsecutiveUsings": true
},
"documentationRules": {
"companyName": ".NET Foundation",
"copyrightText": "Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.\nSee the LICENSE file in the project root for more information",
"xmlHeader": false,
"documentInterfaces": true,
"documentExposedElements": true,
"documentInternalElements": true,
"documentPrivateElements": false,
"documentPrivateFields": false,
"documentationCulture": "en-US",
"fileNamingConvention": "stylecop",
"excludeFromPunctuationCheck": [ "seealso" ]
}
}
}
Loading

0 comments on commit 9eba784

Please sign in to comment.