Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves 101 build warnings on CoreMessaging project #4216

Merged
merged 3 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Dnn.Modules.Console.Components
using DotNetNuke.Entities.Modules;

/// <summary>Implements the module's business controller interface(s).</summary>

public class BusinessController : IUpgradeable
{
/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Dnn.Modules.Console.XML</DocumentationFile>
<NoWarn>1591</NoWarn>
<NoWarn>
</NoWarn>
<LangVersion>7</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
Expand All @@ -43,8 +44,10 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Dnn.Modules.Console.XML</DocumentationFile>
<NoWarn>1591,1573</NoWarn>
<NoWarn>
</NoWarn>
<LangVersion>7</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Reference Include="DotNetNuke.WebUtility, Version=4.2.1.783, Culture=neutral, PublicKeyToken=null">
Expand Down
15 changes: 7 additions & 8 deletions DNN Platform/Library/Services/Exceptions/Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ namespace DotNetNuke.Services.Exceptions
/// Exceptions class provides operation to log most of the exceptions occured in system.
/// </summary>
/// <remarks>
/// <para>
/// For most developers, there is a hard problem need to face to is that our product will run on many and many servers with
/// much different environment, such as hardware, network, system version, framework version and so on, so there is many of reasons
/// will make our application throw lof of exceptions,even will stop our app to working. so when some error occured, we need a way
/// to find out the reason, we know we need to log all the exception, but the point is how to log useful information, you should log
/// the information what you need to location the code caught the error, but DONOT just log 'ERROR'. so we provide a full support of
/// exception log system. when error occured, we can found the detail information in event log and can locationt the error quickly.
/// <para>
/// Logging is an import part of a good architecture. A good practice is to provide enough logging to accurately be able to identify which
/// code caused an exception. Some exceptions are expected and you can display information to the user to help him figure out what happened.
/// It is however bad practice to catch any and all exceptions (general exception) and display this to users. In such situations it is best
/// to provide the user with a general message and only log the details in a way that the details are either just visible to administrators
/// (Event Log) or only to SuperUsers (hosts) in the server logs.
/// </para>
/// <para>
/// Current we immplement lot of custom exception to use in different levels:
/// Current we immplement a lot of custom exception to use in different levels:
valadas marked this conversation as resolved.
Show resolved Hide resolved
/// <list type="bullet">
/// <item><see cref="ModuleLoadException"/></item>
/// <item><see cref="ObjectHydrationException"/></item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,80 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace DotNetNuke.Modules.CoreMessaging.Components
{
using System;
using System.Collections.Generic;
namespace DotNetNuke.Modules.CoreMessaging.Components
{
using System;
using System.Collections.Generic;

using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Definitions;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Instrumentation;
using DotNetNuke.Services.Upgrade;
using DotNetNuke.Abstractions.Portals;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Definitions;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Instrumentation;
using DotNetNuke.Services.Upgrade;

public class CoreMessagingBusinessController : IUpgradeable
{
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(CoreMessagingBusinessController));

public string UpgradeModule(string Version)
{
try
{
switch (Version)
{
case "06.02.00":
var moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Message Center");
if (moduleDefinition != null)
{
var portals = PortalController.Instance.GetPortals();
foreach (PortalInfo portal in portals)
{
if (portal.UserTabId > Null.NullInteger)
{
// Find TabInfo
var tab = TabController.Instance.GetTab(portal.UserTabId, portal.PortalID, true);
if (tab != null)
{
foreach (var module in ModuleController.Instance.GetTabModules(portal.UserTabId).Values)
{
if (module.DesktopModule.FriendlyName == "Messaging")
{
// Delete the Module from the Modules list
ModuleController.Instance.DeleteTabModule(module.TabID, module.ModuleID, false);

// Add new module to the page
Upgrade.AddModuleToPage(tab, moduleDefinition.ModuleDefID, "Message Center", string.Empty, true);

break;
}
}
}
}
}
}

break;
}

return "Success";
}
catch (Exception exc)
{
Logger.Error(exc);

return "Failed";
}
}
}
}
/// <summary>
/// Module business controller to implement Dnn module interfaces.
/// </summary>
public class CoreMessagingBusinessController : IUpgradeable
{
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(CoreMessagingBusinessController));

/// <summary>
/// Runs upgrade logic upon module upgrade.
/// </summary>
/// <param name="Version">The version we are upgrading to.</param>
/// <returns>"Success" or "Failed".</returns>
public string UpgradeModule(string Version)
{
try
{
switch (Version)
{
case "06.02.00":
var moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Message Center");
if (moduleDefinition != null)
{
var portals = PortalController.Instance.GetPortals();
foreach (IPortalInfo portal in portals)
{
if (portal.UserTabId > Null.NullInteger)
{
// Find TabInfo
var tab = TabController.Instance.GetTab(portal.UserTabId, portal.PortalId, true);
if (tab != null)
{
foreach (var module in ModuleController.Instance.GetTabModules(portal.UserTabId).Values)
{
if (module.DesktopModule.FriendlyName == "Messaging")
{
// Delete the Module from the Modules list
ModuleController.Instance.DeleteTabModule(module.TabID, module.ModuleID, false);

// Add new module to the page
Upgrade.AddModuleToPage(tab, moduleDefinition.ModuleDefID, "Message Center", string.Empty, true);

break;
}
}
}
}
}
}

break;
}

return "Success";
}
catch (Exception exc)
{
Logger.Error(exc);

return "Failed";
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>1</WarningLevel>
<DocumentationFile>bin\DotNetNuke.Modules.CoreMessaging.XML</DocumentationFile>
<NoWarn>1591</NoWarn>
<NoWarn>
</NoWarn>
<LangVersion>7</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -49,8 +51,10 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\DotNetNuke.Modules.CoreMessaging.XML</DocumentationFile>
<NoWarn>1591</NoWarn>
<NoWarn>
</NoWarn>
<LangVersion>7</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Reference Include="DotNetNuke.Instrumentation">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace DotNetNuke.Modules.CoreMessaging.Services
{
using DotNetNuke.Web.Api;
namespace DotNetNuke.Modules.CoreMessaging.Services
{
using DotNetNuke.Web.Api;

public sealed class CoreMessagingRouteMapper : IServiceRouteMapper
{
public void RegisterRoutes(IMapRoute mapRouteManager)
{
mapRouteManager.MapHttpRoute("CoreMessaging", "default", "{controller}/{action}", new[] { "DotNetNuke.Modules.CoreMessaging.Services" });
}
}
}
/// <summary>
/// Maps the api routes for this module.
/// </summary>
public sealed class CoreMessagingRouteMapper : IServiceRouteMapper
{
/// <inheritdoc/>
public void RegisterRoutes(IMapRoute mapRouteManager)
{
mapRouteManager.MapHttpRoute("CoreMessaging", "default", "{controller}/{action}", new[] { "DotNetNuke.Modules.CoreMessaging.Services" });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ namespace DotNetNuke.Modules.CoreMessaging.Services
using DotNetNuke.Web.Api.Internal;
using Newtonsoft.Json;

/// <summary>
/// Provides a file upload web service.
/// </summary>
public class FileUploadController : DnnApiController
{
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(FileUploadController));
private readonly IFileManager _fileManager = FileManager.Instance;
private readonly IFolderManager _folderManager = FolderManager.Instance;

private readonly IFileManager fileManager = FileManager.Instance;
private readonly IFolderManager folderManager = FolderManager.Instance;

/// <summary>
/// Attempts to upload a file.
/// </summary>
/// <returns>A collection of <see cref="FilesStatus"/>.</returns>
[DnnAuthorize]
[HttpPost]
[IFrameSupportedValidateAntiForgeryToken]
Expand Down Expand Up @@ -67,10 +74,10 @@ private void UploadWholeFile(HttpContextBase context, ICollection<FilesStatus> s

try
{
var userFolder = this._folderManager.GetUserFolder(this.UserInfo);
var userFolder = this.folderManager.GetUserFolder(this.UserInfo);

// todo: deal with the case where the exact file name already exists.
var fileInfo = this._fileManager.AddFile(userFolder, fileName, file.InputStream, true);
var fileInfo = this.fileManager.AddFile(userFolder, fileName, file.InputStream, true);
var fileIcon = Entities.Icons.IconController.IconURL("Ext" + fileInfo.Extension, "32x32");
if (!File.Exists(context.Server.MapPath(fileIcon)))
{
Expand Down
99 changes: 69 additions & 30 deletions DNN Platform/Modules/CoreMessaging/Services/FilesStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,72 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace DotNetNuke.Modules.CoreMessaging.Services
{
public class FilesStatus
{
// ReSharper restore InconsistentNaming

public FilesStatus()
{
} // ReSharper disable InconsistentNaming
public bool success { get; set; }

public string name { get; set; }

public string extension { get; set; }

public string type { get; set; }

public int size { get; set; }

public string progress { get; set; }

public string url { get; set; }

public string thumbnail_url { get; set; }

public string message { get; set; }

public int id { get; set; }
}
}
namespace DotNetNuke.Modules.CoreMessaging.Services
{
/// <summary>
/// Represents the status of a file.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"StyleCop.CSharp.NamingRules",
"SA1300:Element should begin with upper-case letter",
Justification = "Acceptable in the context of a DTO to not cause an unneccessary breaking change.")]
public class FilesStatus
{
/// <summary>
/// Initializes a new instance of the <see cref="FilesStatus"/> class.
/// </summary>
public FilesStatus()
{
}

/// <summary>
/// Gets or sets a value indicating whether the upload succeeded.
/// </summary>
public bool success { get; set; }

/// <summary>
/// Gets or sets the file name.
/// </summary>
public string name { get; set; }

/// <summary>
/// Gets or sets the file extension.
/// </summary>
public string extension { get; set; }

/// <summary>
/// Gets or sets the file type.
/// </summary>
public string type { get; set; }

/// <summary>
/// Gets or sets the file size.
/// </summary>
public int size { get; set; }

/// <summary>
/// Gets or sets the upload progress.
/// </summary>
public string progress { get; set; }

/// <summary>
/// Gets or sets the file url.
/// </summary>
public string url { get; set; }

/// <summary>
/// Gets or sets the thumbnail url.
/// </summary>
public string thumbnail_url { get; set; }

/// <summary>
/// Gets or sets the message.
/// </summary>
public string message { get; set; }

/// <summary>
/// Gets or sets the unique id.
/// </summary>
public int id { get; set; }
}
}
Loading