Browse Source

Ported existing projects to Asp.Net Core (Except ServerMaint)

tags/3.0.0^2
Teknikode 1 year ago
parent
commit
5eb45263d9
100 changed files with 1574 additions and 1718 deletions
  1. 4
    6
      .editorconfig
  2. 106
    49
      .gitignore
  3. 1
    7
      Configuration/ApiConfig.cs
  4. 1
    6
      Configuration/BlogConfig.cs
  5. 22
    32
      Configuration/Config.cs
  6. 17
    0
      Configuration/Configuration.csproj
  7. 1
    8
      Configuration/ContactConfig.cs
  8. 0
    0
      Configuration/DatabaseConfig.cs
  9. 1
    7
      Configuration/EmailAccount.cs
  10. 1
    6
      Configuration/EmailConfig.cs
  11. 1
    7
      Configuration/GitConfig.cs
  12. 1
    7
      Configuration/IRCConfig.cs
  13. 1
    6
      Configuration/LoggingConfig.cs
  14. 1
    7
      Configuration/PasteConfig.cs
  15. 1
    7
      Configuration/PiwikConfig.cs
  16. 1
    5
      Configuration/PodcastConfig.cs
  17. 1
    6
      Configuration/ShortenerConfig.cs
  18. 1
    7
      Configuration/StatsConfig.cs
  19. 1
    5
      Configuration/StreamConfig.cs
  20. 0
    3
      Configuration/UploadConfig.cs
  21. 0
    7
      Configuration/UserConfig.cs
  22. 1
    6
      Configuration/VaultConfig.cs
  23. 0
    2
      GitVersionConfig.yaml
  24. 3
    6
      Logging/LogMessage.cs
  25. 161
    0
      Logging/Logger.cs
  26. 17
    0
      Logging/LoggerExtensions.cs
  27. 30
    0
      Logging/LoggerProvider.cs
  28. 14
    0
      Logging/Logging.csproj
  29. 126
    0
      MailService/HMailService.cs
  30. 27
    0
      MailService/IMailService.cs
  31. 29
    0
      MailService/MailService.cs
  32. 19
    0
      MailService/MailService.csproj
  33. 173
    0
      MailService/MysqlDatabase.cs
  34. BIN
      MailService/lib/Teknik.hMailServer.dll
  35. 13
    0
      Piwik/Piwik.csproj
  36. 96
    0
      Piwik/Reporting.cs
  37. 93
    0
      Piwik/Tracking.cs
  38. 0
    0
      Piwik/VisitorData.cs
  39. 39
    102
      Teknik.sln
  40. 0
    54
      Teknik/App_Start/BundleConfig.cs
  41. 0
    51
      Teknik/App_Start/CustomRazorViewEngine.cs
  42. 0
    17
      Teknik/App_Start/FilterConfig.cs
  43. 0
    23
      Teknik/App_Start/RouteConfig.cs
  44. 0
    101
      Teknik/App_Start/SubdomainRoute.cs
  45. 0
    154
      Teknik/App_Start/SubdomainRouteExtension.cs
  46. 0
    70
      Teknik/Areas/API/APIAreaRegistration.cs
  47. 10
    3
      Teknik/Areas/API/Controllers/APIController.cs
  48. 126
    120
      Teknik/Areas/API/Controllers/APIv1Controller.cs
  49. 1
    8
      Teknik/Areas/API/Models/APIv1PasteModel.cs
  50. 3
    2
      Teknik/Areas/API/Models/APIv1UploadModel.cs
  51. 0
    36
      Teknik/Areas/API/Views/web.config
  52. 0
    30
      Teknik/Areas/About/AboutAreaRegistration.cs
  53. 12
    4
      Teknik/Areas/About/Controllers/AboutController.cs
  54. 2
    2
      Teknik/Areas/About/ViewModels/AboutViewModel.cs
  55. 6
    8
      Teknik/Areas/About/Views/About/Index.cshtml
  56. 0
    36
      Teknik/Areas/About/Views/web.config
  57. 0
    30
      Teknik/Areas/Abuse/AbuseAreaRegistration.cs
  58. 11
    3
      Teknik/Areas/Abuse/Controllers/AbuseController.cs
  59. 0
    1
      Teknik/Areas/Abuse/Views/Abuse/Index.cshtml
  60. 0
    3
      Teknik/Areas/Abuse/Views/_ViewStart.cshtml
  61. 0
    36
      Teknik/Areas/Abuse/Views/web.config
  62. 36
    0
      Teknik/Areas/Accounts/ResourceOwnerPasswordValidator.cs
  63. 0
    77
      Teknik/Areas/Admin/AdminAreaRegistration.cs
  64. 37
    30
      Teknik/Areas/Admin/Controllers/AdminController.cs
  65. 0
    2
      Teknik/Areas/Admin/Views/Admin/Dashboard.cshtml
  66. 0
    2
      Teknik/Areas/Admin/Views/Admin/UploadResult.cshtml
  67. 5
    7
      Teknik/Areas/Admin/Views/Admin/UploadSearch.cshtml
  68. 5
    7
      Teknik/Areas/Admin/Views/Admin/UserInfo.cshtml
  69. 0
    2
      Teknik/Areas/Admin/Views/Admin/UserResult.cshtml
  70. 1
    1
      Teknik/Areas/Admin/Views/Admin/UserResults.cshtml
  71. 5
    7
      Teknik/Areas/Admin/Views/Admin/UserSearch.cshtml
  72. 0
    3
      Teknik/Areas/Admin/Views/_ViewStart.cshtml
  73. 0
    36
      Teknik/Areas/Admin/Views/web.config
  74. 0
    74
      Teknik/Areas/Blog/BlogAreaRegistration.cs
  75. 145
    79
      Teknik/Areas/Blog/Controllers/BlogController.cs
  76. 1
    1
      Teknik/Areas/Blog/Models/BlogPost.cs
  77. 20
    0
      Teknik/Areas/Blog/Models/BlogPostTag.cs
  78. 11
    7
      Teknik/Areas/Blog/ViewModels/BlogViewModel.cs
  79. 0
    3
      Teknik/Areas/Blog/ViewModels/CommentViewModel.cs
  80. 2
    8
      Teknik/Areas/Blog/ViewModels/CreatePostViewModel.cs
  81. 2
    8
      Teknik/Areas/Blog/ViewModels/EditPostViewModel.cs
  82. 2
    4
      Teknik/Areas/Blog/ViewModels/PostViewModel.cs
  83. 20
    12
      Teknik/Areas/Blog/Views/Blog/Blog.cshtml
  84. 0
    2
      Teknik/Areas/Blog/Views/Blog/Comment.cshtml
  85. 1
    1
      Teknik/Areas/Blog/Views/Blog/Comments.cshtml
  86. 23
    19
      Teknik/Areas/Blog/Views/Blog/EditPost.cshtml
  87. 23
    19
      Teknik/Areas/Blog/Views/Blog/NewPost.cshtml
  88. 0
    2
      Teknik/Areas/Blog/Views/Blog/Post.cshtml
  89. 1
    1
      Teknik/Areas/Blog/Views/Blog/Posts.cshtml
  90. 12
    14
      Teknik/Areas/Blog/Views/Blog/ViewPost.cshtml
  91. 0
    3
      Teknik/Areas/Blog/Views/_ViewStart.cshtml
  92. 0
    36
      Teknik/Areas/Blog/Views/web.config
  93. 0
    44
      Teknik/Areas/Contact/ContactAreaRegistration.cs
  94. 28
    24
      Teknik/Areas/Contact/Controllers/ContactController.cs
  95. 9
    10
      Teknik/Areas/Contact/Views/Contact/Index.cshtml
  96. 0
    3
      Teknik/Areas/Contact/Views/_ViewStart.cshtml
  97. 0
    36
      Teknik/Areas/Contact/Views/web.config
  98. 10
    7
      Teknik/Areas/Dev/Controllers/DevController.cs
  99. 0
    31
      Teknik/Areas/Dev/DevAreaRegistration.cs
  100. 0
    0
      Teknik/Areas/Dev/Views/_ViewStart.cshtml

+ 4
- 6
.editorconfig View File

@@ -1,9 +1,7 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
indent_style = space
end_of_line = crlf
trim_trailing_whitespace = false
insert_final_newline = true

[*.cshtml]
indent_size = 4

+ 106
- 49
.gitignore View File

@@ -4,26 +4,34 @@
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
build/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

# Roslyn cache directories
*.ide/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
wwwroot/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

#NUNIT
# NUNIT
*.VisualState.xml
TestResult.xml

@@ -32,6 +40,11 @@ TestResult.xml
[Rr]eleasePS/
dlldata.c

# DNX
project.lock.json
project.fragment.lock.json
artifacts/

*_i.c
*_p.c
*_i.h
@@ -64,14 +77,18 @@ _Chutzpah*
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap

# TFS 2012 Local Workspace
$tf/
@@ -84,7 +101,7 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding addin-in
# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
@@ -96,6 +113,7 @@ _TeamCity*
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*

# MightyMoose
*.mm.*
@@ -123,43 +141,63 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
## TODO: Comment the next line if you want to checkin your
## web deploy settings but do note that will include unencrypted
## passwords
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml

# NuGet Packages Directory
packages/*
## TODO: If the tool you use requires repositories.config
## uncomment the next line
#!packages/repositories.config

# Enable "build/" folder in the NuGet Packages folder since
# NuGet packages use it for MSBuild targets.
# This line needs to be after the ignore of the build folder
# (and the packages folder if the line above has been uncommented)
!packages/build/

# Windows Azure Build Output
*.publishproj

# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets

# Microsoft Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
# Microsoft Azure Emulator
ecf/
rcf/

# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
bower_components/
orleans.codegen.cs

# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/

# RIA/Silverlight projects
Generated_Code/
@@ -184,26 +222,45 @@ UpgradeLog*.htm
# Microsoft Fakes
FakesAssemblies/

# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
/Teknik/ConnectionStrings.config
/Teknik/App_Data/Config.json
/.vs/config/applicationhost.config
/Teknik/TransformWebConfig/assist/Web.config
/Teknik/Properties/PublishProfiles/IIS.pubxml
/Teknik/App_Data/ConnectionStrings.config
/Teknik/App_Data/Config.json.old
# GhostDoc plugin setting file
*.GhostDoc.xml

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions

# Paket dependency manager
.paket/paket.exe
paket-files/

# FAKE - F# Make
.fake/

# JetBrains Rider
.idea/
*.sln.iml

# CodeRush
.cr/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
/Teknik/App_Data/MachineKey.config
/.vs/Teknik/v15/sqlite3/storage.ide
/.vs/Teknik/v15/sqlite3/storage.ide-wal
/.vs/Teknik/v15/sqlite3/storage.ide-shm
/.vs/Teknik/v15/sqlite3/db.lock
/.vs/Teknik/v15/sqlite3
/.vs/Teknik/v15/Server/sqlite3/storage.ide-wal
/.vs/Teknik/v15/Server/sqlite3/storage.ide-shm
/.vs/Teknik/v15/Server/sqlite3/storage.ide
/.vs/Teknik/v15/Server/sqlite3/db.lock
/.vs/Teknik/v15/Server/sqlite3
/.vs/Teknik/v15
/Teknik/App_Data/ConnectionStrings.config
/Teknik/App_Data/Config.json
/Teknik/appsettings.Production.json
/Teknik/appsettings.Development.json

Utilities/Configuration/ApiConfig.cs → Configuration/ApiConfig.cs View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class ApiConfig
{

Utilities/Configuration/BlogConfig.cs → Configuration/BlogConfig.cs View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class BlogConfig
{

Utilities/Configuration/Config.cs → Configuration/Config.cs View File

@@ -1,10 +1,7 @@
using Newtonsoft.Json;
using System;
using System.IO;
using System.Threading;
using System.Web;
using System.Web.Caching;
using Newtonsoft.Json;
using Teknik.Utilities;
using Teknik.Utilities.Cryptography;

namespace Teknik.Configuration
@@ -12,9 +9,13 @@ namespace Teknik.Configuration
public class Config
{
private const string _ConfigCacheKey = "ConfigCache";
private const string _ConfigFileName = "Config.json";

private static Config _Config { get; set; }
private static string _FileHash { get; set; }

private ReaderWriterLockSlim _ConfigRWLock;
private ReaderWriterLockSlim _ConfigFileRWLock;
private JsonSerializerSettings _JsonSettings;

private bool _DevEnvironment;
@@ -117,6 +118,8 @@ namespace Teknik.Configuration

public Config()
{
_ConfigRWLock = new ReaderWriterLockSlim();
_ConfigFileRWLock = new ReaderWriterLockSlim();
_JsonSettings = new JsonSerializerSettings();
_JsonSettings.Formatting = Formatting.Indented;

@@ -168,39 +171,26 @@ namespace Teknik.Configuration
return JsonConvert.SerializeObject(config, Formatting.Indented);
}

public static Config Load()
{
HttpContext context = HttpContext.Current;
if (context != null)
_Config = (Config)context.Cache[_ConfigCacheKey];
if (_Config == null)
{
string path = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
_Config = Load(path);
context?.Cache.Insert(_ConfigCacheKey, _Config, new CacheDependency(path));
}
return _Config;
}

public static Config Load(string path)
{
Config config = new Config();
if (!File.Exists(Path.Combine(path, "Config.json")))
string newHash = string.Empty;
string fullPath = Path.Combine(path, _ConfigFileName);

if (!File.Exists(fullPath))
{
Save(Path.Combine(path, "Config.json"), config);
Config config = new Config();
Save(fullPath, config);
}
else

newHash = MD5.FileHash(fullPath);
if (_Config == null || _FileHash == null || newHash != _FileHash)
{
string configContents = File.ReadAllText(Path.Combine(path, "Config.json"));
config = Deserialize(configContents);
string configContents = File.ReadAllText(fullPath);
_Config = Deserialize(configContents);
_FileHash = newHash;
}
return config;
}

public static void Save(Config config)
{
string path = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
Save(Path.Combine(path, "Config.json"), config);
return _Config;
}

public static void Save(string path, Config config)

+ 17
- 0
Configuration/Configuration.csproj View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>Teknik.Configuration</RootNamespace>
<AssemblyName>Teknik.Configuration</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Utilities\Utilities.csproj" />
</ItemGroup>

</Project>

Utilities/Configuration/ContactConfig.cs → Configuration/ContactConfig.cs View File

@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Mail;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class ContactConfig
{

Utilities/Configuration/DatabaseConfig.cs → Configuration/DatabaseConfig.cs View File


Utilities/Configuration/EmailAccount.cs → Configuration/EmailAccount.cs View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class EmailAccount
{

Utilities/Configuration/EmailConfig.cs → Configuration/EmailConfig.cs View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class EmailConfig
{

Utilities/Configuration/GitConfig.cs → Configuration/GitConfig.cs View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class GitConfig
{

Utilities/Configuration/IRCConfig.cs → Configuration/IRCConfig.cs View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class IRCConfig
{

Utilities/Configuration/LoggingConfig.cs → Configuration/LoggingConfig.cs View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class LoggingConfig
{

Utilities/Configuration/PasteConfig.cs → Configuration/PasteConfig.cs View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class PasteConfig
{

Utilities/Configuration/PiwikConfig.cs → Configuration/PiwikConfig.cs View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class PiwikConfig
{

Utilities/Configuration/PodcastConfig.cs → Configuration/PodcastConfig.cs View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.IO;

namespace Teknik.Configuration
{

Utilities/Configuration/ShortenerConfig.cs → Configuration/ShortenerConfig.cs View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class ShortenerConfig
{

Utilities/Configuration/StatsConfig.cs → Configuration/StatsConfig.cs View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class StatsConfig
{

Utilities/Configuration/StreamConfig.cs → Configuration/StreamConfig.cs View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace Teknik.Configuration
{

Utilities/Configuration/UploadConfig.cs → Configuration/UploadConfig.cs View File

@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace Teknik.Configuration
{

Utilities/Configuration/UserConfig.cs → Configuration/UserConfig.cs View File

@@ -1,10 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Teknik.Utilities;

namespace Teknik.Configuration
{
public class UserConfig

Utilities/Configuration/VaultConfig.cs → Configuration/VaultConfig.cs View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Teknik.Configuration
namespace Teknik.Configuration
{
public class VaultConfig
{

+ 0
- 2
GitVersionConfig.yaml View File

@@ -1,2 +0,0 @@
assembly-versioning-scheme: MajorMinorPatch
next-version: 2.0.6

Utilities/Logging/LogMessage.cs → Logging/LogMessage.cs View File

@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using System;
using Teknik.Utilities;

namespace Teknik.Logging
@@ -21,7 +18,7 @@ namespace Teknik.Logging

public void SetDefaults()
{
Level = LogLevel.Info;
Level = LogLevel.Information;
EntryDate = DateTime.Now;
Message = string.Empty;
Exception = null;

+ 161
- 0
Logging/Logger.cs View File

@@ -0,0 +1,161 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Mail;
using System.Text;
using Teknik.Configuration;
using Teknik.Utilities;

namespace Teknik.Logging
{
public class Logger : ILogger
{
private static readonly object Locker = new object();

private readonly string _name;
private readonly Config _config;

public Logger(string name, Config config)
{
_name = name;
_config = config;
}

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
if (!IsEnabled(logLevel))
return;

// write an entry to the logs
LogMessage log = new LogMessage();
log.Level = logLevel;
log.Message = formatter(state, exception);
log.Exception = exception;

WriteLogMessage(log);
}

public bool IsEnabled(LogLevel logLevel)
{
if (_config.LoggingConfig.Enabled)
{
// Do we want to write a log for this level? (Default to Error)
LogLevel minLogLevel = LogLevel.Error;
Enum.TryParse(_config.LoggingConfig.LogLevel, out minLogLevel);
if (logLevel >= minLogLevel)
return true;
}
return false;
}

public IDisposable BeginScope<TState>(TState state)
{
return null;
}

private void WriteLogMessage(LogMessage log)
{

try
{
// Lock the file processing so only 1 thread is working on the log file at a time
lock (Locker)
{
if (!Directory.Exists(_config.LoggingConfig.OutputDirectory))
{
Directory.CreateDirectory(_config.LoggingConfig.OutputDirectory);
}
// Get current log file
string fileName = Constants.LOG_FILE_NAME_PREFIX + Constants.LOG_FILE_EXT;
string logFile = Path.Combine(_config.LoggingConfig.OutputDirectory, fileName);

if (File.Exists(logFile))
{
// File already exists, so lets see if we need to rotate it
if (_config.LoggingConfig.RotateLogs)
{
FileInfo info = new FileInfo(logFile);
if (_config.LoggingConfig.MaxSize < info.Length && _config.LoggingConfig.MaxSize > 0)
{
// File is too large, so let's create a new name for it based on todays date
string newFileName = Constants.LOG_FILE_NAME_PREFIX + "_" + DateTime.Now.ToString("yyyyMMdd") + Constants.LOG_FILE_EXT;
newFileName = FileHelper.MakeUniqueFilename(newFileName, _config.LoggingConfig.OutputDirectory);
string newLog = Path.Combine(_config.LoggingConfig.OutputDirectory, newFileName);

// Move the current file to the new file
File.Move(logFile, newLog);
}

// Make sure we have less than the max number of logs
List<string> totalFiles = Directory.GetFiles(_config.LoggingConfig.OutputDirectory, string.Format("{0}*{1}", Constants.LOG_FILE_NAME_PREFIX, Constants.LOG_FILE_EXT), SearchOption.TopDirectoryOnly).ToList();
if (totalFiles.Count + 1 > _config.LoggingConfig.MaxCount && _config.LoggingConfig.MaxCount > 0)
{
// We will have too many logs, so let's remove the last one
totalFiles.Sort();
string fileToRemove = totalFiles[totalFiles.Count - 1];
File.Delete(fileToRemove);
}
}
}

// We have rotated if needed, so let's write the entry
File.AppendAllText(logFile, log.ToString() + Environment.NewLine);
}
}
catch (Exception) { } // If we throw when writing the log, still try to send the email if needed

try
{
// Send Email Message if enabled
if (_config.LoggingConfig.SendEmail)
{
// Do we want to send an email for this level? (Default to error)
LogLevel minEmailLevel = LogLevel.Error;
Enum.TryParse(_config.LoggingConfig.EmailLevel, out minEmailLevel);
if (log.Level >= minEmailLevel)
{
string subject = string.Format("{0} Log Message", log.Level);
string message = "Message: " + log.Message;
if (log.Exception != null)
{
message += Environment.NewLine + Environment.NewLine + "Exception: " + log.Exception.GetFullMessage(true, true);
}
SendErrorEmail(subject, message);
}
}
}
catch (Exception)
{
// Can't do anything about it. :/
}
}

private void SendErrorEmail(string subject, string message)
{
try
{
// Let's also email the message to support
SmtpClient client = new SmtpClient();
client.Host = _config.LoggingConfig.SenderAccount.Host;
client.Port = _config.LoggingConfig.SenderAccount.Port;
client.EnableSsl = _config.LoggingConfig.SenderAccount.SSL;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential(_config.LoggingConfig.SenderAccount.Username, _config.LoggingConfig.SenderAccount.Password);
client.Timeout = 5000;

MailMessage mail = new MailMessage(_config.LoggingConfig.SenderAccount.EmailAddress, _config.LoggingConfig.RecipientEmailAddress);
mail.Subject = subject;
mail.Body = message;
mail.BodyEncoding = UTF8Encoding.UTF8;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Never;

client.Send(mail);
}
catch (Exception ex) { /* don't handle something in the handler */
}
}
}
}

+ 17
- 0
Logging/LoggerExtensions.cs View File

@@ -0,0 +1,17 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;
using Teknik.Configuration;

namespace Teknik.Logging
{
public static class LoggerExtensions
{
public static ILoggerFactory AddLogger(this ILoggerFactory loggerFactory, Config config)
{
loggerFactory.AddProvider(new LoggerProvider(config));
return loggerFactory;
}
}
}

+ 30
- 0
Logging/LoggerProvider.cs View File

@@ -0,0 +1,30 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text;
using Teknik.Configuration;

namespace Teknik.Logging
{
public class LoggerProvider : ILoggerProvider
{
private readonly Config _config;
private readonly ConcurrentDictionary<string, Logger> _loggers = new ConcurrentDictionary<string, Logger>();

public LoggerProvider(Config config)
{
_config = config;
}

public ILogger CreateLogger(string categoryName)
{
return _loggers.GetOrAdd(categoryName, name => new Logger(name, _config));
}

public void Dispose()
{
_loggers.Clear();
}
}
}

+ 14
- 0
Logging/Logging.csproj View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Teknik.Logging</AssemblyName>
<RootNamespace>Teknik.Logging</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Configuration\Configuration.csproj" />
<ProjectReference Include="..\Utilities\Utilities.csproj" />
</ItemGroup>

</Project>

+ 126
- 0
MailService/HMailService.cs View File

@@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Teknik.MailService
{
public class HMailService : MailService
{
private readonly hMailServer.Application _App;

private string _Username { get; set; }
private string _Password { get; set; }
private string _Domain { get; set; }

private string _CounterServer { get; set; }
private string _CounterDatabase { get; set; }
private string _CounterUsername { get; set; }
private string _CounterPassword { get; set; }
private int _CounterPort { get; set; }

public HMailService(string username, string password, string domain, string counterServer, string counterDatabase, string counterUsername, string counterPassword, int counterPort)
{
_Username = username;
_Password = password;
_Domain = domain;

_CounterServer = counterServer;
_CounterDatabase = counterDatabase;
_CounterUsername = counterUsername;
_CounterPassword = counterPassword;
_CounterPort = counterPort;

_App = InitApp();
}

public override void CreateAccount(string username, string password, int size)
{
var domain = _App.Domains.ItemByName[_Domain];
var newAccount = domain.Accounts.Add();
newAccount.Address = username;
newAccount.Password = password;
newAccount.Active = true;
newAccount.MaxSize = size;

newAccount.Save();
}

public override bool AccountExists(string username)
{
try
{
GetAccount(username);
// We didn't error out, so the email exists
return true;
}
catch { }
return false;
}

public override void Delete(string username)
{
throw new NotImplementedException();
}

public override void Enable(string username)
{
EditActivity(username, true);
}

public override void Disable(string username)
{
EditActivity(username, false);
}

public override void EditActivity(string username, bool active)
{
var account = GetAccount(username);
account.Active = active;
account.Save();
}

public override void EditMaxEmailsPerDay(string username, int maxPerDay)
{
//We need to check the actual git database
MysqlDatabase mySQL = new MysqlDatabase(_CounterServer, _CounterDatabase, _CounterUsername, _CounterPassword, _CounterPort);
string sql = @"INSERT INTO mailcounter.counts (qname, lastdate, qlimit, count) VALUES ({1}, NOW(), {0}, 0)
ON DUPLICATE KEY UPDATE qlimit = {0}";
mySQL.Execute(sql, new object[] { maxPerDay, username });
}

public override void EditMaxSize(string username, int size)
{
var account = GetAccount(username);
account.MaxSize = size;
account.Save();
}

public override void EditPassword(string username, string password)
{
var account = GetAccount(username);
account.Password = password;
account.Save();
}

public override DateTime LastActive(string username)
{
var account = GetAccount(username);
return (DateTime)account.LastLogonTime;
}

private hMailServer.Application InitApp()
{
var app = new hMailServer.Application();
app.Connect();
app.Authenticate(_Username, _Password);

return app;
}

private hMailServer.Account GetAccount(string username)
{
var domain = _App.Domains.ItemByName[_Domain];
return domain.Accounts.ItemByAddress[username];
}
}
}

+ 27
- 0
MailService/IMailService.cs View File

@@ -0,0 +1,27 @@
using System;

namespace Teknik.MailService
{
public interface IMailService
{
bool AccountExists(string username);

DateTime LastActive(string username);

void CreateAccount(string username, string password, int size);

void EditActivity(string username, bool active);

void EditPassword(string username, string password);

void EditMaxSize(string username, int size);

void EditMaxEmailsPerDay(string username, int maxPerDay);

void Enable(string username);

void Disable(string username);

void Delete(string username);
}
}

+ 29
- 0
MailService/MailService.cs View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Teknik.MailService
{
public abstract class MailService : IMailService
{
public abstract void CreateAccount(string username, string password, int size);

public abstract bool AccountExists(string username);

public abstract void Delete(string username);

public abstract void Disable(string username);

public abstract void EditActivity(string username, bool active);

public abstract void EditMaxEmailsPerDay(string username, int maxPerDay);

public abstract void EditMaxSize(string username, int size);

public abstract void EditPassword(string username, string password);

public abstract void Enable(string username);

public abstract DateTime LastActive(string username);
}
}

+ 19
- 0
MailService/MailService.csproj View File

@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Teknik.MailService</AssemblyName>
<RootNamespace>Teknik.MailService</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MySql.Data" Version="8.0.11" />
</ItemGroup>

<ItemGroup>
<Reference Include="Teknik.hMailServer">
<HintPath>lib\Teknik.hMailServer.dll</HintPath>
</Reference>
</ItemGroup>

</Project>

+ 173
- 0
MailService/MysqlDatabase.cs View File

@@ -0,0 +1,173 @@
using System;
using System.Collections.Generic;
using System.Threading;
using MySql.Data.MySqlClient;

namespace Teknik.MailService
{
public class MysqlDatabase
{
public event EventHandler<string> MysqlErrorEvent;

private bool Connected { get; set; }
private MySqlConnection Connection { get; set; }
private ReaderWriterLockSlim DatabaseLock { get; set; }

public MysqlDatabase(string server, string database, string username, string password, int port)
{
Connected = false;
Connection = null;
DatabaseLock = new ReaderWriterLockSlim();
Connect(server, database, username, password, port);
}

public List<Dictionary<string, object>> Query(string query, params object[] args)
{
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
if (Connected)
{
DatabaseLock.EnterWriteLock();
MySqlCommand cmd = PrepareQuery(query, args);
try
{
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Dictionary<string, object> row = new Dictionary<string, object>();
for (int i = 0; i < reader.FieldCount; i++)
{
row.Add(reader.GetName(i), reader.GetValue(i));
}
rows.Add(row);
}
reader.Close();
}
catch (MySqlException exception)
{
if (MysqlErrorEvent != null)
{
MysqlErrorEvent(this, exception.Message);
}
}
catch (Exception exception)
{
if (MysqlErrorEvent != null)
{
MysqlErrorEvent(this, exception.Message);
}
}
DatabaseLock.ExitWriteLock();
}
return rows;
}

public object ScalarQuery(string query, params object[] args)
{
if (Connected)
{
DatabaseLock.EnterWriteLock();
MySqlCommand cmd = PrepareQuery(query, args);
object result = null;
try
{

result = cmd.ExecuteScalar();
}
catch (MySqlException exception)
{
if (MysqlErrorEvent != null)
{
MysqlErrorEvent(this, exception.Message);
}
}
catch (Exception exception)
{
if (MysqlErrorEvent != null)
{
MysqlErrorEvent(this, exception.Message);
}
}
DatabaseLock.ExitWriteLock();
return result;
}
return null;
}

public void Execute(string query, params object[] args)
{
if (Connected)
{
DatabaseLock.EnterWriteLock();
MySqlCommand cmd = PrepareQuery(query, args);
try
{
int result = cmd.ExecuteNonQuery();
}
catch (MySqlException exception)
{
if (MysqlErrorEvent != null)
{
MysqlErrorEvent(this, exception.Message);
}
}
catch (Exception exception)
{
if (MysqlErrorEvent != null)
{
MysqlErrorEvent(this, exception.Message);
}
}
DatabaseLock.ExitWriteLock();
}
}

private void Connect(string server, string database, string username, string password, int port)
{
if (Connection == null)
{
if (!string.IsNullOrEmpty(server) && !string.IsNullOrEmpty(database) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
{
string strCon = string.Format("Server={0}; database={1}; user={2}; password={3}; port={4}; charset=utf8; Allow Zero Datetime=true;", server, database, username, password, port);
Connection = new MySqlConnection(strCon);
try
{
Connection.Open();
Connected = true;
}
catch (MySqlException ex)
{
Connected = false;
}
}
}
}

private void Disconnect()
{
if (Connection != null && Connected)
{
Connected = false;
Connection.Close();
}
}

private MySqlCommand PrepareQuery(string query, object[] args)
{
if (Connected)
{
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = Connection;
for (int i = 0; i < args.Length; i++)
{
string param = "{" + i + "}";
string paramName = "@DBVar_" + i;
query = query.Replace(param, paramName);
cmd.Parameters.AddWithValue(paramName, args[i]);
}
cmd.CommandText = query;
return cmd;
}
return null;
}
}
}

BIN
MailService/lib/Teknik.hMailServer.dll View File


+ 13
- 0
Piwik/Piwik.csproj View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Teknik.Piwik</AssemblyName>
<RootNamespace>Teknik.Piwik</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Configuration\Configuration.csproj" />
</ItemGroup>

</Project>

+ 96
- 0
Piwik/Reporting.cs View File

@@ -0,0 +1,96 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Teknik.Configuration;

namespace Teknik.Piwik
{
public static class Reporting
{
public static List<VisitorData> GetVisitSummaryByDays(Config config, int days)
{
List<VisitorData> visitorData = new List<VisitorData>();
try
{
if (config.PiwikConfig.Enabled)
{
//PiwikAnalytics.URL = config.PiwikConfig.API;
//VisitsSummary visitSummary = new VisitsSummary();
//visitSummary.setTokenAuth(config.PiwikConfig.TokenAuth);

//Hashtable results = visitSummary.Get(
// config.PiwikConfig.SiteId,
// PiwikPeriod.DAY,
// RelativeRangeDate.LAST(days)
// );

//foreach (string period in results.Keys)
//{
// // Create a new object to return
// VisitorData data = new VisitorData();

// // Set Period Date
// DateTime date = new DateTime(1900, 1, 1);
// DateTime.TryParse(period, out date);
// data.Date = date;

// // Pull Out Data
// if (results[period].GetType() == typeof(Hashtable))
// {
// Hashtable result = (Hashtable) results[period];

// int UniqueVisitors = 0;
// int.TryParse(result["nb_uniq_visitors"].ToString(), out UniqueVisitors);
// data.UniqueVisitors = UniqueVisitors;

// int visits = 0;
// int.TryParse(result[VisitsSummary.NB_VISITS].ToString(), out visits);
// data.Visits = visits;

// int VisitsConverted = 0;
// int.TryParse(result[VisitsSummary.NB_VISITS_CONVERTED].ToString(), out VisitsConverted);
// data.VisitsConverted = VisitsConverted;

// int Actions = 0;
// int.TryParse(result[VisitsSummary.NB_ACTIONS].ToString(), out Actions);
// data.Actions = Actions;

// decimal ActionsPerVisit = 0;
// decimal.TryParse(result[VisitsSummary.NB_ACTIONS_PER_VISIT].ToString(), out ActionsPerVisit);
// data.ActionsPerVisit = ActionsPerVisit;

// int MaxActions = 0;
// int.TryParse(result[VisitsSummary.MAX_ACTIONS].ToString(), out MaxActions);
// data.MaxActions = MaxActions;

// int BounceCount = 0;
// int.TryParse(result[VisitsSummary.BOUNCE_COUNT].ToString(), out BounceCount);
// data.BounceCount = BounceCount;

// data.BounceRate = result[VisitsSummary.BOUNCE_RATE].ToString();

// int AverageTimeOnSite = 0;
// int.TryParse(result[VisitsSummary.AVG_TIME_ON_SITE].ToString(), out AverageTimeOnSite);
// data.AverageTimeOnSite = AverageTimeOnSite;

// int VisitLengthTotal = 0;
// int.TryParse(result[VisitsSummary.SUM_VISIT_LENGTH].ToString(), out VisitLengthTotal);
// data.VisitLengthTotal = VisitLengthTotal;
// }

// visitorData.Add(data);
//}
}
}
catch (Exception ex)
{
}

return visitorData;
}
}
}

+ 93
- 0
Piwik/Tracking.cs View File

@@ -0,0 +1,93 @@
using System;
using System.Web;
using Teknik.Configuration;
using Teknik.Utilities;

namespace Teknik.Piwik
{
public static class Tracking
{
public static void TrackPageView(Config config, string title, string sub, string clientIp, string url, string urlReferrer, string userAgent, int pixelWidth, int pixelHeight, bool hasCookies, string acceptLang, bool hasJava)
{
try
{
if (config.PiwikConfig.Enabled)
{
if (config.DevEnvironment)
{
sub = "dev - " + sub;
}

//PiwikTracker.URL = config.PiwikConfig.Url;
//PiwikTracker tracker = new PiwikTracker(config.PiwikConfig.SiteId, config.PiwikConfig.Url);

//// Set Request Info
//tracker.setIp(clientIp);
//tracker.setTokenAuth(config.PiwikConfig.TokenAuth);

//tracker.setUserAgent(userAgent);

//// Set browser info
//tracker.setResolution(pixelWidth, pixelHeight);
//tracker.setBrowserHasCookies(hasCookies);
//if (!string.IsNullOrEmpty(acceptLang))
// tracker.setBrowserLanguage(acceptLang);
//tracker.setPlugins(new BrowserPlugins {java = hasJava});

//// Get Referral
//if (!string.IsNullOrEmpty(urlReferrer))
// tracker.setUrlReferrer(urlReferrer);

//if (!string.IsNullOrEmpty(url))
// tracker.setUrl(url);

//// Send the tracking request
//tracker.doTrackPageView(string.Format("{0}/{1}", sub, title));
}
}
catch (Exception ex)
{

}
}

public static void TrackDownload(Config config, string userAgent, string clientIp, string url, string urlReferrer)
{
//TrackAction(config. PiwikTracker.ActionType.download, userAgent, clientIp, url, urlReferrer);
}

public static void TrackLink(Config config, string userAgent, string clientIp, string url, string urlReferrer)
{
//TrackAction(config.PiwikTracker.ActionType.link, userAgent, clientIp, url, urlReferrer);
}

//private static void TrackAction(Config config, PiwikTracker.ActionType type, string userAgent, string clientIp, string url, string urlReferrer)
//{
// try
// {
// if (config.PiwikConfig.Enabled)
// {
// PiwikTracker tracker = new PiwikTracker(config.PiwikConfig.SiteId, config.PiwikConfig.Url);

// tracker.setUserAgent(userAgent);

// tracker.setIp(clientIp);
// tracker.setTokenAuth(config.PiwikConfig.TokenAuth);

// // Get Referral
// if (!string.IsNullOrEmpty(urlReferrer))
// tracker.setUrlReferrer(urlReferrer);

// if (!string.IsNullOrEmpty(url))
// tracker.setUrl(url);

// tracker.doTrackAction(url, type);
// }
// }
// catch (Exception ex)
// {

// }
//}
}
}

Utilities/Piwik/VisitorData.cs → Piwik/VisitorData.cs View File


+ 39
- 102
Teknik.sln View File

@@ -1,125 +1,62 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.15
VisualStudioVersion = 15.0.27512.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Teknik", "Teknik\Teknik.csproj", "{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Teknik", "Teknik\Teknik.csproj", "{1E52F0D0-9E89-4022-A905-C685EF3564E1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{725ABF52-FD44-4682-81BB-D93598787643}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
GitVersionConfig.yaml = GitVersionConfig.yaml
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerMaint", "ServerMaint\ServerMaint.csproj", "{E08975F9-1B84-41B0-875A-CEC9778C4F9E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{783361EC-DCD6-4A34-8479-5476DF752C34}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utilities", "Utilities\Utilities\Utilities.csproj", "{F45DE6FC-3754-4954-A20A-4277362CC6C1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Configuration", "Configuration\Configuration.csproj", "{7A1F40CA-7C37-4B7B-973A-CDCDD424F31F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logging", "Utilities\Logging\Logging.csproj", "{77E865FD-F08B-4F07-9676-BC2FDCC7244C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utilities", "Utilities\Utilities.csproj", "{DD521101-7F10-407A-9788-49283D946FDA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Piwik", "Utilities\Piwik\Piwik.csproj", "{C492C2C6-D45A-498B-84A2-6D4C8BF9DE77}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logging", "Logging\Logging.csproj", "{3CAB11F5-9B07-4D17-BB00-725149087AB0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Configuration", "Utilities\Configuration\Configuration.csproj", "{F0DA1B67-AF92-4B4A-8669-7E81645FF996}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeknikStreaming", "TeknikStreaming\TeknikStreaming.csproj", "{7695CE9A-A0DB-4D73-BC9B-2206481F0254}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{FAC9FE6E-9AA9-45AD-AA72-40DDF7DC44C6}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C208CBF0-078E-409D-A433-DC1BC15248CE}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UtilitiesTests", "UtilitiesTests\UtilitiesTests.csproj", "{88DEB506-3F7E-4B39-8264-861976DC7434}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Piwik", "Piwik\Piwik.csproj", "{F8823907-092C-4055-9F8E-D6756793C24A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeknikTests", "TeknikTests\TeknikTests.csproj", "{9D7A805E-2629-476E-B36A-040AD332C7DC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MailService", "MailService\MailService.csproj", "{03636C30-DA61-4307-8934-2FCC3BAC3255}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|x64.ActiveCfg = Debug|x64
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|x64.Build.0 = Debug|x64
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|x64.Deploy.0 = Debug|x64
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Release|Any CPU.Build.0 = Release|Any CPU
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Release|x64.ActiveCfg = Release|x64
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Release|x64.Build.0 = Release|x64
{E08975F9-1B84-41B0-875A-CEC9778C4F9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E08975F9-1B84-41B0-875A-CEC9778C4F9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E08975F9-1B84-41B0-875A-CEC9778C4F9E}.Debug|x64.ActiveCfg = Debug|Any CPU
{E08975F9-1B84-41B0-875A-CEC9778C4F9E}.Debug|x64.Build.0 = Debug|Any CPU
{E08975F9-1B84-41B0-875A-CEC9778C4F9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E08975F9-1B84-41B0-875A-CEC9778C4F9E}.Release|Any CPU.Build.0 = Release|Any CPU
{E08975F9-1B84-41B0-875A-CEC9778C4F9E}.Release|x64.ActiveCfg = Release|Any CPU
{E08975F9-1B84-41B0-875A-CEC9778C4F9E}.Release|x64.Build.0 = Release|Any CPU
{F45DE6FC-3754-4954-A20A-4277362CC6C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F45DE6FC-3754-4954-A20A-4277362CC6C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F45DE6FC-3754-4954-A20A-4277362CC6C1}.Debug|x64.ActiveCfg = Debug|Any CPU
{F45DE6FC-3754-4954-A20A-4277362CC6C1}.Debug|x64.Build.0 = Debug|Any CPU
{F45DE6FC-3754-4954-A20A-4277362CC6C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F45DE6FC-3754-4954-A20A-4277362CC6C1}.Release|Any CPU.Build.0 = Release|Any CPU
{F45DE6FC-3754-4954-A20A-4277362CC6C1}.Release|x64.ActiveCfg = Release|Any CPU
{F45DE6FC-3754-4954-A20A-4277362CC6C1}.Release|x64.Build.0 = Release|Any CPU
{77E865FD-F08B-4F07-9676-BC2FDCC7244C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77E865FD-F08B-4F07-9676-BC2FDCC7244C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77E865FD-F08B-4F07-9676-BC2FDCC7244C}.Debug|x64.ActiveCfg = Debug|Any CPU
{77E865FD-F08B-4F07-9676-BC2FDCC7244C}.Debug|x64.Build.0 = Debug|Any CPU
{77E865FD-F08B-4F07-9676-BC2FDCC7244C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77E865FD-F08B-4F07-9676-BC2FDCC7244C}.Release|Any CPU.Build.0 = Release|Any CPU
{77E865FD-F08B-4F07-9676-BC2FDCC7244C}.Release|x64.ActiveCfg = Release|Any CPU
{77E865FD-F08B-4F07-9676-BC2FDCC7244C}.Release|x64.Build.0 = Release|Any CPU
{C492C2C6-D45A-498B-84A2-6D4C8BF9DE77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C492C2C6-D45A-498B-84A2-6D4C8BF9DE77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C492C2C6-D45A-498B-84A2-6D4C8BF9DE77}.Debug|x64.ActiveCfg = Debug|Any CPU
{C492C2C6-D45A-498B-84A2-6D4C8BF9DE77}.Debug|x64.Build.0 = Debug|Any CPU
{C492C2C6-D45A-498B-84A2-6D4C8BF9DE77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C492C2C6-D45A-498B-84A2-6D4C8BF9DE77}.Release|Any CPU.Build.0 = Release|Any CPU
{C492C2C6-D45A-498B-84A2-6D4C8BF9DE77}.Release|x64.ActiveCfg = Release|Any CPU
{C492C2C6-D45A-498B-84A2-6D4C8BF9DE77}.Release|x64.Build.0 = Release|Any CPU
{F0DA1B67-AF92-4B4A-8669-7E81645FF996}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0DA1B67-AF92-4B4A-8669-7E81645FF996}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0DA1B67-AF92-4B4A-8669-7E81645FF996}.Debug|x64.ActiveCfg = Debug|Any CPU
{F0DA1B67-AF92-4B4A-8669-7E81645FF996}.Debug|x64.Build.0 = Debug|Any CPU
{F0DA1B67-AF92-4B4A-8669-7E81645FF996}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0DA1B67-AF92-4B4A-8669-7E81645FF996}.Release|Any CPU.Build.0 = Release|Any CPU
{F0DA1B67-AF92-4B4A-8669-7E81645FF996}.Release|x64.ActiveCfg = Release|Any CPU
{F0DA1B67-AF92-4B4A-8669-7E81645FF996}.Release|x64.Build.0 = Release|Any CPU
{7695CE9A-A0DB-4D73-BC9B-2206481F0254}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7695CE9A-A0DB-4D73-BC9B-2206481F0254}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7695CE9A-A0DB-4D73-BC9B-2206481F0254}.Debug|x64.ActiveCfg = Debug|Any CPU
{7695CE9A-A0DB-4D73-BC9B-2206481F0254}.Debug|x64.Build.0 = Debug|Any CPU
{7695CE9A-A0DB-4D73-BC9B-2206481F0254}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7695CE9A-A0DB-4D73-BC9B-2206481F0254}.Release|Any CPU.Build.0 = Release|Any CPU
{7695CE9A-A0DB-4D73-BC9B-2206481F0254}.Release|x64.ActiveCfg = Release|Any CPU
{7695CE9A-A0DB-4D73-BC9B-2206481F0254}.Release|x64.Build.0 = Release|Any CPU
{88DEB506-3F7E-4B39-8264-861976DC7434}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88DEB506-3F7E-4B39-8264-861976DC7434}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88DEB506-3F7E-4B39-8264-861976DC7434}.Debug|x64.ActiveCfg = Debug|Any CPU
{88DEB506-3F7E-4B39-8264-861976DC7434}.Debug|x64.Build.0 = Debug|Any CPU
{88DEB506-3F7E-4B39-8264-861976DC7434}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88DEB506-3F7E-4B39-8264-861976DC7434}.Release|Any CPU.Build.0 = Release|Any CPU
{88DEB506-3F7E-4B39-8264-861976DC7434}.Release|x64.ActiveCfg = Release|Any CPU
{88DEB506-3F7E-4B39-8264-861976DC7434}.Release|x64.Build.0 = Release|Any CPU
{9D7A805E-2629-476E-B36A-040AD332C7DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D7A805E-2629-476E-B36A-040AD332C7DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D7A805E-2629-476E-B36A-040AD332C7DC}.Debug|x64.ActiveCfg = Debug|Any CPU
{9D7A805E-2629-476E-B36A-040AD332C7DC}.Debug|x64.Build.0 = Debug|Any CPU
{9D7A805E-2629-476E-B36A-040AD332C7DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D7A805E-2629-476E-B36A-040AD332C7DC}.Release|Any CPU.Build.0 = Release|Any CPU
{9D7A805E-2629-476E-B36A-040AD332C7DC}.Release|x64.ActiveCfg = Release|Any CPU
{9D7A805E-2629-476E-B36A-040AD332C7DC}.Release|x64.Build.0 = Release|Any CPU
{1E52F0D0-9E89-4022-A905-C685EF3564E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E52F0D0-9E89-4022-A905-C685EF3564E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E52F0D0-9E89-4022-A905-C685EF3564E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E52F0D0-9E89-4022-A905-C685EF3564E1}.Release|Any CPU.Build.0 = Release|Any CPU
{7A1F40CA-7C37-4B7B-973A-CDCDD424F31F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A1F40CA-7C37-4B7B-973A-CDCDD424F31F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A1F40CA-7C37-4B7B-973A-CDCDD424F31F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A1F40CA-7C37-4B7B-973A-CDCDD424F31F}.Release|Any CPU.Build.0 = Release|Any CPU
{DD521101-7F10-407A-9788-49283D946FDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD521101-7F10-407A-9788-49283D946FDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD521101-7F10-407A-9788-49283D946FDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD521101-7F10-407A-9788-49283D946FDA}.Release|Any CPU.Build.0 = Release|Any CPU
{3CAB11F5-9B07-4D17-BB00-725149087AB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CAB11F5-9B07-4D17-BB00-725149087AB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CAB11F5-9B07-4D17-BB00-725149087AB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CAB11F5-9B07-4D17-BB00-725149087AB0}.Release|Any CPU.Build.0 = Release|Any CPU
{F8823907-092C-4055-9F8E-D6756793C24A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F8823907-092C-4055-9F8E-D6756793C24A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8823907-092C-4055-9F8E-D6756793C24A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8823907-092C-4055-9F8E-D6756793C24A}.Release|Any CPU.Build.0 = Release|Any CPU
{03636C30-DA61-4307-8934-2FCC3BAC3255}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03636C30-DA61-4307-8934-2FCC3BAC3255}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03636C30-DA61-4307-8934-2FCC3BAC3255}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03636C30-DA61-4307-8934-2FCC3BAC3255}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E08975F9-1B84-41B0-875A-CEC9778C4F9E} = {783361EC-DCD6-4A34-8479-5476DF752C34}
{88DEB506-3F7E-4B39-8264-861976DC7434} = {FAC9FE6E-9AA9-45AD-AA72-40DDF7DC44C6}
{9D7A805E-2629-476E-B36A-040AD332C7DC} = {FAC9FE6E-9AA9-45AD-AA72-40DDF7DC44C6}
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D5D09AC6-1E27-476C-BF7E-980E1640F432}
EndGlobalSection
EndGlobal

+ 0
- 54
Teknik/App_Start/BundleConfig.cs View File

@@ -1,54 +0,0 @@
using System.Web;
using System.Web.Optimization;
using Teknik.Configuration;
using Teknik.Utilities;

namespace Teknik
{
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
// Load the config options
Config config = Config.Load();

// Set if we are using Cdn
bundles.UseCdn = config.UseCdn;

BundleTable.EnableOptimizations = false;
#if !DEBUG
BundleTable.EnableOptimizations = true;
#endif

bundles.Add(new CdnStyleBundle("~/Content/Common", config.CdnHost).Include(
"~/Content/bootstrap.css",
"~/Content/font-awesome.css",
"~/Content/common.css"));

bundles.Add(new CdnScriptBundle("~/bundles/common", config.CdnHost).Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery.validate*",
"~/Scripts/bootstrap.js",
"~/Scripts/bootstrap-select.js",
"~/Scripts/common.js",
"~/Scripts/respond.js"));

bundles.Add(new CdnScriptBundle("~/bundles/jquery", config.CdnHost).Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery.validate*"));

// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new CdnScriptBundle("~/bundles/modernizr", config.CdnHost).Include(
"~/Scripts/modernizr-*"));

bundles.Add(new CdnScriptBundle("~/bundles/markdown", config.CdnHost).Include(
"~/Scripts/PageDown/Markdown.Converter.js",
"~/Scripts/PageDown/Markdown.Sanitizer.js"));

bundles.Add(new CdnScriptBundle("~/bundles/signalr", config.CdnHost).Include(
"~/Scripts/jquery.signalR-{version}.js"));
}
}
}

+ 0
- 51
Teknik/App_Start/CustomRazorViewEngine.cs View File

@@ -1,51 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace Teknik
{
public class CustomRazorViewEngine : RazorViewEngine
{
public CustomRazorViewEngine()
{
base.AreaViewLocationFormats = new string[]
{
"~/Areas/{2}/Views/{1}/{0}.cshtml",
"~/Areas/{2}/Views/Shared/{0}.cshtml"
};

base.AreaMasterLocationFormats = new string[]
{
"~/Areas/{2}/Views/{1}/{0}.cshtml",
"~/Areas/{2}/Views/Shared/{0}.cshtml"
};

base.AreaPartialViewLocationFormats = new string[]
{
"~/Areas/{2}/Views/{1}/{0}.cshtml",
"~/Areas/{2}/Views/Shared/{0}.cshtml"
};

base.ViewLocationFormats = new string[]
{
"~/Views/{1}/{0}.cshtml",
"~/Views/Shared/{0}.cshtml"
};

base.PartialViewLocationFormats = new string[]
{
"~/Views/{1}/{0}.cshtml",
"~/Views/Shared/{0}.cshtml"
};

base.MasterLocationFormats = new string[]
{
"~/Views/{1}/{0}.cshtml",
"~/Views/Shared/{0}.cshtml"
};
}
}
}

+ 0
- 17
Teknik/App_Start/FilterConfig.cs View File

@@ -1,17 +0,0 @@
using System.Web;
using System.Web.Mvc;
using Teknik.Attributes;
using Teknik.Filters;

namespace Teknik
{
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
//filters.Add(new HandleErrorAttribute());
//filters.Add(new TeknikAuthorizeAttribute());
filters.Add(new RequireHttpsAttribute());
}
}
}

+ 0
- 23
Teknik/App_Start/RouteConfig.cs View File

@@ -1,23 +0,0 @@
using System.Web.Mvc;
using System.Web.Routing;

namespace Teknik
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

// Add this code to handle non-existing urls
routes.MapRoute(
name: "404-PageNotFound",
// This will handle any non-existing urls
url: "{*url}",
// "Shared" is the name of your error controller, and "Error" is the action/page
// that handles all your custom errors
defaults: new { controller = "Default", action = "NotFound" }
);
}
}
}

+ 0
- 101
Teknik/App_Start/SubdomainRoute.cs View File

@@ -1,101 +0,0 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Teknik.Utilities;

namespace Teknik
{
public class SubdomainRoute : Route
{
public List<string> Subdomains { get; set; }

public List<string> Domains { get; set; }

public SubdomainRoute(List<string> subdomains, List<string> domains, string url, IRouteHandler handler)
: base(url, handler)
{
this.Subdomains = subdomains;
this.Domains = domains;
}
public SubdomainRoute(List<string> subdomains, List<string> domains, string url, RouteValueDictionary defaults, IRouteHandler handler)
: base(url, defaults, handler)
{
this.Subdomains = subdomains;
this.Domains = domains;
}

public SubdomainRoute(List<string> subdomains, List<string> domains, string url, RouteValueDictionary defaults, RouteValueDictionary constraints, IRouteHandler handler)
: base(url, defaults, constraints, handler)
{
this.Subdomains = subdomains;
this.Domains = domains;
}

public SubdomainRoute(List<string> subdomains, List<string> domains, string url, RouteValueDictionary defaults, RouteValueDictionary constraints, RouteValueDictionary dataTokens, IRouteHandler handler)
: base(url, defaults, constraints, dataTokens, handler)
{
this.Subdomains = subdomains;
this.Domains = domains;
}

public override RouteData GetRouteData(HttpContextBase httpContext)
{
var routeData = base.GetRouteData(httpContext);
if (routeData == null) return null; // Only look at the subdomain if this route matches in the first place.
string subdomain = httpContext.Request.QueryString["sub"]; // A subdomain specified as a query parameter takes precedence over the hostname.
string host = httpContext.Request.Headers["Host"];
if (host == null) return null; // no host, so don't process it
string domain = host.GetDomain();
string curSub = host.GetSubdomain();

// special consideration for 'dev' subdomain
if (subdomain == null || subdomain == "dev")
{
if (!string.IsNullOrEmpty(curSub) && curSub == "dev")
{
// if we are on dev, and the param is dev or empty, we need to initialize it to 'www'
subdomain = "www";
}
}

if (subdomain == null)
{
subdomain = curSub;
}
else
{
if (routeData.Values["sub"] == null)
{
routeData.Values["sub"] = subdomain;
}
else
{
subdomain = routeData.Values["sub"].ToString();
}
}

// Check if this route is valid for the current domain
if (httpContext.Request.IsLocal || Domains.Contains(domain))
{
// Check if this route is valid for the current subdomain ('*' means any subdomain is valid)
if (Subdomains.Contains("*") || Subdomains.Contains(subdomain))
{
routeData.Values["sub"] = subdomain;
return routeData;
}
}
return null;
}

public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
{
object subdomainParam = requestContext.HttpContext.Request.QueryString["sub"];
if (subdomainParam != null && values["sub"] == null)
values["sub"] = subdomainParam;
return base.GetVirtualPath(requestContext, values); // we now have the route based on subdomain
}
}
}

+ 0
- 154
Teknik/App_Start/SubdomainRouteExtension.cs View File

@@ -1,154 +0,0 @@
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;

namespace Teknik
{
public static class SubdomainRouteExtension
{
public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, List<string> subDomains, List<string> domains, string url, object defaults)
{
SubdomainRoute route = new SubdomainRoute(
subDomains,
domains,
url,
new RouteValueDictionary(defaults),
new MvcRouteHandler());
routes.Add(name, route);

return route;
}

public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, List<string> subDomains, List<string> domains, string url, object defaults, object constraints)
{
SubdomainRoute route = new SubdomainRoute(
subDomains,
domains,
url,
new RouteValueDictionary(defaults),
new RouteValueDictionary(constraints),
new MvcRouteHandler());
routes.Add(name, route);
return route;
}

public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, List<string> subDomains, List<string> domains, string area, string url, object defaults, string[] namespaces)
{
SubdomainRoute route = new SubdomainRoute(
subDomains,
domains,
url,
new RouteValueDictionary(defaults),
new RouteValueDictionary(new { }),
new RouteValueDictionary(new { Area = area, Namespaces = namespaces }),
new MvcRouteHandler());
routes.Add(name, route);
return route;
}

public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List<string> subDomains, List<string> domains, string url, object defaults)
{
SubdomainRoute route = new SubdomainRoute(
subDomains,
domains,
url,
new RouteValueDictionary(defaults),
new RouteValueDictionary(new {}),
new RouteValueDictionary(new {Area = context.AreaName}),
new MvcRouteHandler());

context.Routes.Add(name, route);
return route;
}

public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List<string> subDomains, List<string> domains, string url, object defaults, object constraints)
{
SubdomainRoute route = new SubdomainRoute(
subDomains,
domains,
url,
new RouteValueDictionary(defaults),
new RouteValueDictionary(constraints),
new RouteValueDictionary(new {Area = context.AreaName}),
new MvcRouteHandler());

context.Routes.Add(name, route);
return route;
}

public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List<string> subDomains, List<string> domains, string url, object defaults, string[] namespaces)
{
SubdomainRoute route = new SubdomainRoute(
subDomains,
domains,
url,
new RouteValueDictionary(defaults),
new RouteValueDictionary(new {}),
new RouteValueDictionary(new { Area = context.AreaName, Namespaces = namespaces }),
new MvcRouteHandler());

context.Routes.Add(name, route);
return route;
}

public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List<string> subDomains, List<string> domains, string url, object defaults, object constraints, string[] namespaces)
{
SubdomainRoute route = new SubdomainRoute(
subDomains,
domains,
url,
new RouteValueDictionary(defaults),
new RouteValueDictionary(constraints),
new RouteValueDictionary(new { Area = context.AreaName, Namespaces = namespaces }),
new MvcRouteHandler());

context.Routes.Add(name, route);
return route;
}

public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List<string> subDomains, List<string> domains, string url, string area, object defaults)
{
SubdomainRoute route = new SubdomainRoute(
subDomains,
domains,
url,
new RouteValueDictionary(defaults),
new RouteValueDictionary(new { }),
new RouteValueDictionary(new { Area = area }),
new MvcRouteHandler());

context.Routes.Add(name, route);
return route;
}

public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List<string> subDomains, List<string> domains, string url, string area, object defaults, object constraints)
{
SubdomainRoute route = new SubdomainRoute(
subDomains,
domains,
url,
new RouteValueDictionary(defaults),
new RouteValueDictionary(constraints),
new RouteValueDictionary(new { Area = area }),
new MvcRouteHandler());

context.Routes.Add(name, route);
return route;
}

public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List<string> subDomains, List<string> domains, string url, string area, object defaults, string[] namespaces)
{
SubdomainRoute route = new SubdomainRoute(
subDomains,
domains,
url,
new RouteValueDictionary(defaults),
new RouteValueDictionary(new { }),
new RouteValueDictionary(new { Area = area, Namespaces = namespaces }),
new MvcRouteHandler());

context.Routes.Add(name, route);
return route;
}
}
}

+ 0
- 70
Teknik/Areas/API/APIAreaRegistration.cs View File

@@ -1,70 +0,0 @@
using System.Collections.Generic;
using System.Web.Mvc;
using Teknik.Configuration;

namespace Teknik.Areas.API
{
public class APIAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "API";
}
}

public override void RegisterArea(AreaRegistrationContext context)
{
Config config = Config.Load();
#region API v1