From e690c1e6a94a1adbd55dcbedf3402e333c786af2 Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Fri, 28 Apr 2017 21:27:23 +0100 Subject: [PATCH] Initial Commit --- .gitignore | 5 + RaceLapTimer/Helpers.Encrytion/Hash.cs | 31 +++ .../Helpers.Encryption.csproj | 54 ++++++ .../Properties/AssemblyInfo.cs | 36 ++++ RaceLapTimer/Interfaces/IUserStorage.cs | 17 ++ RaceLapTimer/Interfaces/Interfaces.csproj | 55 ++++++ .../Interfaces/Properties/AssemblyInfo.cs | 36 ++++ RaceLapTimer/Interfaces/User.cs | 22 +++ RaceLapTimer/RaceLapTimer.sln | 40 ++++ .../ApiControllers/InfoController.cs | 18 ++ .../ApiControllers/LapTrackController.cs | 8 + .../ApiControllers/MonitorController.cs | 8 + .../ApiControllers/PilotController.cs | 8 + .../ApiControllers/RaceSessionController.cs | 9 + .../ApiControllers/SatelliteController.cs | 6 + .../ApiControllers/SoundController.cs | 8 + RaceLapTimer/RaceLapTimer/App.config | 28 +++ .../AuthenticationBootstrapper.cs | 57 ++++++ .../RaceLapTimer/Modules/HistoryModule.cs | 22 +++ .../RaceLapTimer/Modules/LoginModule.cs | 53 +++++ .../RaceLapTimer/Modules/MonitorModule.cs | 22 +++ .../RaceLapTimer/Modules/PilotModule.cs | 18 ++ .../RaceLapTimer/Modules/PilotsModule.cs | 22 +++ .../Modules/RaceDirectorModule.cs | 26 +++ .../RaceLapTimer/Modules/SoundfileModule.cs | 25 +++ .../RaceLapTimer/Modules/SystemModule.cs | 46 +++++ .../RaceLapTimer/Modules/UserModule.cs | 17 ++ .../RaceLapTimer/NancyRootPathProvider.cs | 15 ++ RaceLapTimer/RaceLapTimer/NancyUser.cs | 22 +++ RaceLapTimer/RaceLapTimer/Program.cs | 25 +++ .../RaceLapTimer/Properties/AssemblyInfo.cs | 36 ++++ .../RaceLapTimer/RaceLapTimer.Designer.cs | 37 ++++ RaceLapTimer/RaceLapTimer/RaceLapTimer.cs | 38 ++++ RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj | 181 ++++++++++++++++++ .../RaceLapTimer.csproj.DotSettings | 2 + .../RaceLapTimer/RaceLapTimer.csproj.user | 6 + RaceLapTimer/RaceLapTimer/Startup.cs | 26 +++ RaceLapTimer/RaceLapTimer/UserDatabase.cs | 96 ++++++++++ RaceLapTimer/RaceLapTimer/packages.config | 17 ++ .../www/Views/RaceDirector.cshtml | 28 +++ .../RaceLapTimer/www/Views/index.cshtml | 20 ++ .../RaceLapTimer/www/Views/login.cshtml | 25 +++ .../www/Views/razor-layout.cshtml | 96 ++++++++++ .../RaceLapTimer/www/Views/secure.cshtml | 17 ++ RaceLapTimer/RaceLapTimerHost/App.config | 29 +++ RaceLapTimer/RaceLapTimerHost/Program.cs | 16 ++ .../Properties/AssemblyInfo.cs | 36 ++++ .../RaceLapTimerHost/RaceLapTimerHost.csproj | 95 +++++++++ RaceLapTimer/RaceLapTimerHost/packages.config | 7 + 49 files changed, 1567 insertions(+) create mode 100644 .gitignore create mode 100644 RaceLapTimer/Helpers.Encrytion/Hash.cs create mode 100644 RaceLapTimer/Helpers.Encrytion/Helpers.Encryption.csproj create mode 100644 RaceLapTimer/Helpers.Encrytion/Properties/AssemblyInfo.cs create mode 100644 RaceLapTimer/Interfaces/IUserStorage.cs create mode 100644 RaceLapTimer/Interfaces/Interfaces.csproj create mode 100644 RaceLapTimer/Interfaces/Properties/AssemblyInfo.cs create mode 100644 RaceLapTimer/Interfaces/User.cs create mode 100644 RaceLapTimer/RaceLapTimer.sln create mode 100644 RaceLapTimer/RaceLapTimer/ApiControllers/InfoController.cs create mode 100644 RaceLapTimer/RaceLapTimer/ApiControllers/LapTrackController.cs create mode 100644 RaceLapTimer/RaceLapTimer/ApiControllers/MonitorController.cs create mode 100644 RaceLapTimer/RaceLapTimer/ApiControllers/PilotController.cs create mode 100644 RaceLapTimer/RaceLapTimer/ApiControllers/RaceSessionController.cs create mode 100644 RaceLapTimer/RaceLapTimer/ApiControllers/SatelliteController.cs create mode 100644 RaceLapTimer/RaceLapTimer/ApiControllers/SoundController.cs create mode 100644 RaceLapTimer/RaceLapTimer/App.config create mode 100644 RaceLapTimer/RaceLapTimer/AuthenticationBootstrapper.cs create mode 100644 RaceLapTimer/RaceLapTimer/Modules/HistoryModule.cs create mode 100644 RaceLapTimer/RaceLapTimer/Modules/LoginModule.cs create mode 100644 RaceLapTimer/RaceLapTimer/Modules/MonitorModule.cs create mode 100644 RaceLapTimer/RaceLapTimer/Modules/PilotModule.cs create mode 100644 RaceLapTimer/RaceLapTimer/Modules/PilotsModule.cs create mode 100644 RaceLapTimer/RaceLapTimer/Modules/RaceDirectorModule.cs create mode 100644 RaceLapTimer/RaceLapTimer/Modules/SoundfileModule.cs create mode 100644 RaceLapTimer/RaceLapTimer/Modules/SystemModule.cs create mode 100644 RaceLapTimer/RaceLapTimer/Modules/UserModule.cs create mode 100644 RaceLapTimer/RaceLapTimer/NancyRootPathProvider.cs create mode 100644 RaceLapTimer/RaceLapTimer/NancyUser.cs create mode 100644 RaceLapTimer/RaceLapTimer/Program.cs create mode 100644 RaceLapTimer/RaceLapTimer/Properties/AssemblyInfo.cs create mode 100644 RaceLapTimer/RaceLapTimer/RaceLapTimer.Designer.cs create mode 100644 RaceLapTimer/RaceLapTimer/RaceLapTimer.cs create mode 100644 RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj create mode 100644 RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj.DotSettings create mode 100644 RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj.user create mode 100644 RaceLapTimer/RaceLapTimer/Startup.cs create mode 100644 RaceLapTimer/RaceLapTimer/UserDatabase.cs create mode 100644 RaceLapTimer/RaceLapTimer/packages.config create mode 100644 RaceLapTimer/RaceLapTimer/www/Views/RaceDirector.cshtml create mode 100644 RaceLapTimer/RaceLapTimer/www/Views/index.cshtml create mode 100644 RaceLapTimer/RaceLapTimer/www/Views/login.cshtml create mode 100644 RaceLapTimer/RaceLapTimer/www/Views/razor-layout.cshtml create mode 100644 RaceLapTimer/RaceLapTimer/www/Views/secure.cshtml create mode 100644 RaceLapTimer/RaceLapTimerHost/App.config create mode 100644 RaceLapTimer/RaceLapTimerHost/Program.cs create mode 100644 RaceLapTimer/RaceLapTimerHost/Properties/AssemblyInfo.cs create mode 100644 RaceLapTimer/RaceLapTimerHost/RaceLapTimerHost.csproj create mode 100644 RaceLapTimer/RaceLapTimerHost/packages.config diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9ef596f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +**.suo +**/bin/** +**/obj/** +**/packages/** +**/.vs/** diff --git a/RaceLapTimer/Helpers.Encrytion/Hash.cs b/RaceLapTimer/Helpers.Encrytion/Hash.cs new file mode 100644 index 0000000..b41d056 --- /dev/null +++ b/RaceLapTimer/Helpers.Encrytion/Hash.cs @@ -0,0 +1,31 @@ +using System; +using System.Security.Cryptography; +using System.Text; + +namespace Helpers.Encryption +{ + public class Hash + { + public static string HashString(string stringToHash) + { + //var shaEngine = new SHA3.SHA3Managed(512); + //var hash = shaEngine.ComputeHash(Encoding.Unicode.GetBytes(stringToHash)); + //return Encoding.Unicode.GetString(hash); + + MD5 md5 = MD5.Create(); + + byte[] inputBytes = Encoding.ASCII.GetBytes(stringToHash); + + byte[] hash = md5.ComputeHash(inputBytes); + + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < hash.Length; i++) + { + sb.Append(hash[i].ToString("X2")); + } + + return sb.ToString(); + } + } +} diff --git a/RaceLapTimer/Helpers.Encrytion/Helpers.Encryption.csproj b/RaceLapTimer/Helpers.Encrytion/Helpers.Encryption.csproj new file mode 100644 index 0000000..75ad376 --- /dev/null +++ b/RaceLapTimer/Helpers.Encrytion/Helpers.Encryption.csproj @@ -0,0 +1,54 @@ + + + + + Debug + AnyCPU + {BC7DEA8B-5029-459A-AA54-EA81EB390F87} + Library + Properties + Helpers.Encryption + Helpers.Encryption + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RaceLapTimer/Helpers.Encrytion/Properties/AssemblyInfo.cs b/RaceLapTimer/Helpers.Encrytion/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7ba4948 --- /dev/null +++ b/RaceLapTimer/Helpers.Encrytion/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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: AssemblyTitle("Helpers.Encrytion")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Helpers.Encrytion")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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 +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("bc7dea8b-5029-459a-aa54-ea81eb390f87")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RaceLapTimer/Interfaces/IUserStorage.cs b/RaceLapTimer/Interfaces/IUserStorage.cs new file mode 100644 index 0000000..7ec0aa5 --- /dev/null +++ b/RaceLapTimer/Interfaces/IUserStorage.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Interfaces +{ + public interface IUserStorage + { + User GetUser(int id); + User GetUser(string guid); + bool DeleteUser(int id); + bool DeleteUser(string guid); + bool UpdateUser(User user); + bool CreateUser(User user); + } +} diff --git a/RaceLapTimer/Interfaces/Interfaces.csproj b/RaceLapTimer/Interfaces/Interfaces.csproj new file mode 100644 index 0000000..678e359 --- /dev/null +++ b/RaceLapTimer/Interfaces/Interfaces.csproj @@ -0,0 +1,55 @@ + + + + + Debug + AnyCPU + {5C6DCC59-19F3-46AD-A479-926610F36257} + Library + Properties + Interfaces + Interfaces + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RaceLapTimer/Interfaces/Properties/AssemblyInfo.cs b/RaceLapTimer/Interfaces/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7ebd61f --- /dev/null +++ b/RaceLapTimer/Interfaces/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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: AssemblyTitle("Interfaces")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Interfaces")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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 +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5c6dcc59-19f3-46ad-a479-926610f36257")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RaceLapTimer/Interfaces/User.cs b/RaceLapTimer/Interfaces/User.cs new file mode 100644 index 0000000..1e62209 --- /dev/null +++ b/RaceLapTimer/Interfaces/User.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; + +namespace Interfaces +{ + public class User + { + public string Id { get; set; } + public string Email { get; set; } + public string EncryptedPassword { get; set; } + public int SignInCount { get; set; } + public DateTime CurrentLoginTime { get; set; } + public DateTime LastLoginTime { get; set; } + public string CurrentLoginIp { get; set; } + public string LastLoginIp { get; set; } + public int FailedLoginAttempts { get; set; } + public bool AccountLocked { get; set; } + public DateTime LockedAt { get; set; } + public DateTime CreatedAt { get; set; } + public List Roles { get; set; } + } +} \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimer.sln b/RaceLapTimer/RaceLapTimer.sln new file mode 100644 index 0000000..b6633e1 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RaceLapTimer", "RaceLapTimer\RaceLapTimer.csproj", "{85A3CC28-096C-40A6-8C67-3AADE40EDF32}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RaceLapTimerHost", "RaceLapTimerHost\RaceLapTimerHost.csproj", "{763192F3-FDC4-409B-B7CF-1191DCBB14EB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interfaces", "Interfaces\Interfaces.csproj", "{5C6DCC59-19F3-46AD-A479-926610F36257}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Helpers.Encryption", "Helpers.Encrytion\Helpers.Encryption.csproj", "{BC7DEA8B-5029-459A-AA54-EA81EB390F87}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {85A3CC28-096C-40A6-8C67-3AADE40EDF32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85A3CC28-096C-40A6-8C67-3AADE40EDF32}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85A3CC28-096C-40A6-8C67-3AADE40EDF32}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85A3CC28-096C-40A6-8C67-3AADE40EDF32}.Release|Any CPU.Build.0 = Release|Any CPU + {763192F3-FDC4-409B-B7CF-1191DCBB14EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {763192F3-FDC4-409B-B7CF-1191DCBB14EB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {763192F3-FDC4-409B-B7CF-1191DCBB14EB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {763192F3-FDC4-409B-B7CF-1191DCBB14EB}.Release|Any CPU.Build.0 = Release|Any CPU + {5C6DCC59-19F3-46AD-A479-926610F36257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C6DCC59-19F3-46AD-A479-926610F36257}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C6DCC59-19F3-46AD-A479-926610F36257}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C6DCC59-19F3-46AD-A479-926610F36257}.Release|Any CPU.Build.0 = Release|Any CPU + {BC7DEA8B-5029-459A-AA54-EA81EB390F87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC7DEA8B-5029-459A-AA54-EA81EB390F87}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC7DEA8B-5029-459A-AA54-EA81EB390F87}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC7DEA8B-5029-459A-AA54-EA81EB390F87}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/RaceLapTimer/RaceLapTimer/ApiControllers/InfoController.cs b/RaceLapTimer/RaceLapTimer/ApiControllers/InfoController.cs new file mode 100644 index 0000000..3ee0012 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/ApiControllers/InfoController.cs @@ -0,0 +1,18 @@ +using System; +using System.Web.Http; + +namespace RaceLapTimer +{ + public class InfoController:ApiController + { + /// + /// returns the last transponder Id from the ir daemon. + /// + /// + [HttpGet] + public IHttpActionResult LastScannedId() + { + throw new NotImplementedException(); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/ApiControllers/LapTrackController.cs b/RaceLapTimer/RaceLapTimer/ApiControllers/LapTrackController.cs new file mode 100644 index 0000000..fbb070a --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/ApiControllers/LapTrackController.cs @@ -0,0 +1,8 @@ +using System.Web.Http; + +namespace RaceLapTimer +{ + public class LapTrackController:ApiController + { + } +} diff --git a/RaceLapTimer/RaceLapTimer/ApiControllers/MonitorController.cs b/RaceLapTimer/RaceLapTimer/ApiControllers/MonitorController.cs new file mode 100644 index 0000000..1f351a3 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/ApiControllers/MonitorController.cs @@ -0,0 +1,8 @@ +using System.Web.Http; + +namespace RaceLapTimer +{ + public class MonitorController:ApiController + { + } +} diff --git a/RaceLapTimer/RaceLapTimer/ApiControllers/PilotController.cs b/RaceLapTimer/RaceLapTimer/ApiControllers/PilotController.cs new file mode 100644 index 0000000..adeb572 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/ApiControllers/PilotController.cs @@ -0,0 +1,8 @@ +using System.Web.Http; + +namespace RaceLapTimer +{ + public class PilotController:ApiController + { + } +} diff --git a/RaceLapTimer/RaceLapTimer/ApiControllers/RaceSessionController.cs b/RaceLapTimer/RaceLapTimer/ApiControllers/RaceSessionController.cs new file mode 100644 index 0000000..38bd82f --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/ApiControllers/RaceSessionController.cs @@ -0,0 +1,9 @@ +using System.Web.Http; + +namespace RaceLapTimer +{ + public class RaceSessionController:ApiController + { + + } +} diff --git a/RaceLapTimer/RaceLapTimer/ApiControllers/SatelliteController.cs b/RaceLapTimer/RaceLapTimer/ApiControllers/SatelliteController.cs new file mode 100644 index 0000000..0781ac3 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/ApiControllers/SatelliteController.cs @@ -0,0 +1,6 @@ +namespace RaceLapTimer +{ + public class SatelliteController + { + } +} diff --git a/RaceLapTimer/RaceLapTimer/ApiControllers/SoundController.cs b/RaceLapTimer/RaceLapTimer/ApiControllers/SoundController.cs new file mode 100644 index 0000000..985ae4a --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/ApiControllers/SoundController.cs @@ -0,0 +1,8 @@ +using System.Web.Http; + +namespace RaceLapTimer +{ + public class SoundController:ApiController + { + } +} diff --git a/RaceLapTimer/RaceLapTimer/App.config b/RaceLapTimer/RaceLapTimer/App.config new file mode 100644 index 0000000..93999eb --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/App.config @@ -0,0 +1,28 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimer/AuthenticationBootstrapper.cs b/RaceLapTimer/RaceLapTimer/AuthenticationBootstrapper.cs new file mode 100644 index 0000000..30baeb6 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/AuthenticationBootstrapper.cs @@ -0,0 +1,57 @@ +using Interfaces; +using Nancy; +using Nancy.Authentication.Forms; +using Nancy.Bootstrapper; +using Nancy.Diagnostics; +using Nancy.TinyIoc; + +namespace RaceLapTimer +{ + public class FormsAuthBootstrapper : DefaultNancyBootstrapper + { + protected override void ConfigureApplicationContainer(TinyIoCContainer container) + { + // We don't call "base" here to prevent auto-discovery of + // types/dependencies + } + + protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context) + { + base.ConfigureRequestContainer(container, context); + + // Here we register our user mapper as a per-request singleton. + // As this is now per-request we could inject a request scoped + // database "context" or other request scoped services. + container.Register(); //register the storage provider.. + container.Register().AsSingleton(); + } + + protected override void RequestStartup(TinyIoCContainer requestContainer, IPipelines pipelines, NancyContext context) + { + // At request startup we modify the request pipelines to + // include forms authentication - passing in our now request + // scoped user name mapper. + // + // The pipelines passed in here are specific to this request, + // so we can add/remove/update items in them as we please. + var formsAuthConfiguration = + new FormsAuthenticationConfiguration() + { + RedirectUrl = "~/login", + UserMapper = requestContainer.Resolve(), + }; + + FormsAuthentication.Enable(pipelines, formsAuthConfiguration); + } + + protected override DiagnosticsConfiguration DiagnosticsConfiguration + { + get + { + return new DiagnosticsConfiguration { Password = "password" }; + } + } + + protected override IRootPathProvider RootPathProvider { get {return new NancyRootPathProvider();} } + } +} diff --git a/RaceLapTimer/RaceLapTimer/Modules/HistoryModule.cs b/RaceLapTimer/RaceLapTimer/Modules/HistoryModule.cs new file mode 100644 index 0000000..192b73a --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Modules/HistoryModule.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Nancy; + +namespace RaceLapTimer.Modules +{ + public class HistoryModule:NancyModule + { + public HistoryModule():base("/history") + { + Get[""] = args => GetHistoryHomePage(args); + } + + private dynamic GetHistoryHomePage(dynamic args) + { + throw new NotImplementedException(); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/Modules/LoginModule.cs b/RaceLapTimer/RaceLapTimer/Modules/LoginModule.cs new file mode 100644 index 0000000..0ab633f --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Modules/LoginModule.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Dynamic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Nancy; +using Nancy.Authentication.Forms; +using Nancy.Extensions; + +namespace RaceLapTimer.Modules +{ + public class LoginModule:NancyModule + { + public LoginModule() + { + Get["/login"] = args => GetLoginPage(args); + + Post["/login"] = args => PostLoginAttempt(args); + + Get["/logout"] = args => { + return this.LogoutAndRedirect("~/"); + }; + } + + private dynamic GetLoginPage(dynamic args) + { + dynamic model = new ExpandoObject(); + model.Errored = this.Request.Query.error.HasValue; + + return View["login", model]; + } + + private dynamic PostLoginAttempt(dynamic args) + { + var userGuid = UserDatabase.ValidateUser((string)this.Request.Form.Username, + (string)this.Request.Form.Password); + + if (userGuid == null) + { + return this.Context.GetRedirect("~/login?error=true&username=" + (string)this.Request.Form.Username); + } + + DateTime? expiry = null; + if (this.Request.Form.RememberMe.HasValue) + { + expiry = DateTime.Now.AddDays(7); + } + + return this.LoginAndRedirect(userGuid.Value, expiry); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/Modules/MonitorModule.cs b/RaceLapTimer/RaceLapTimer/Modules/MonitorModule.cs new file mode 100644 index 0000000..e02ed1b --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Modules/MonitorModule.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Nancy; + +namespace RaceLapTimer.Modules +{ + public class MonitorModule:NancyModule + { + public MonitorModule() : base("/monitor") + { + Get[""] = args => GetMonitorHomePage(args); + } + + private dynamic GetMonitorHomePage(dynamic args) + { + throw new NotImplementedException(); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/Modules/PilotModule.cs b/RaceLapTimer/RaceLapTimer/Modules/PilotModule.cs new file mode 100644 index 0000000..c9f53f4 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Modules/PilotModule.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Nancy; +using Nancy.Security; + +namespace RaceLapTimer.Modules +{ + public class PilotModule:NancyModule + { + public PilotModule() : base("/pilot") + { + this.RequiresAuthentication(); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/Modules/PilotsModule.cs b/RaceLapTimer/RaceLapTimer/Modules/PilotsModule.cs new file mode 100644 index 0000000..17a61f6 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Modules/PilotsModule.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Nancy; + +namespace RaceLapTimer.Modules +{ + public class PilotsModule:NancyModule + { + public PilotsModule() : base("/pilots") + { + Get[""] = args => GetPilotsListHomePage(args); + } + + private dynamic GetPilotsListHomePage(dynamic args) + { + throw new NotImplementedException(); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/Modules/RaceDirectorModule.cs b/RaceLapTimer/RaceLapTimer/Modules/RaceDirectorModule.cs new file mode 100644 index 0000000..616e550 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Modules/RaceDirectorModule.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Nancy; +using Nancy.Security; + +namespace RaceLapTimer.Modules +{ + public class RaceDirectorModule:NancyModule + { + public RaceDirectorModule() : base("/racedirector") + { + this.RequiresAuthentication(); + + Get[""] = args => GetRaceDirectoryHomePage(args); + //API METHOD - Get["lapTimes"] + } + + private dynamic GetRaceDirectoryHomePage(dynamic args) + { + return View["RaceDirector.cshtml"]; + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/Modules/SoundfileModule.cs b/RaceLapTimer/RaceLapTimer/Modules/SoundfileModule.cs new file mode 100644 index 0000000..e7f49b1 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Modules/SoundfileModule.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Nancy; +using Nancy.Security; + +namespace RaceLapTimer.Modules +{ + public class SoundfileModule:NancyModule + { + public SoundfileModule() : base("/soundfile") + { + this.RequiresAuthentication(); + + Get[""] = args => GetSoundfileHomePage(args); + } + + private dynamic GetSoundfileHomePage(dynamic args) + { + throw new NotImplementedException(); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/Modules/SystemModule.cs b/RaceLapTimer/RaceLapTimer/Modules/SystemModule.cs new file mode 100644 index 0000000..0c68e5a --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Modules/SystemModule.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Nancy; +using Nancy.Security; + +namespace RaceLapTimer.Modules +{ + public class SystemModule:NancyModule + { + //also needs to home system/start_race_session, this should probably be an api method with post arg. + public SystemModule() : base("/system") + { + this.RequiresAuthentication(); + + Get[""] = args => GetSystemHomePage(args); + Get["/pilot"] = args => GetSystemPilotPage(args); + Get["/soundfile"] = args => GetSystemSoundFilePage(args); + + } + + //this will return system configuration settings home page. + private dynamic GetSystemHomePage(dynamic args) + { + throw new NotImplementedException(); + } + + //system/pilot/create //api method + //system/pilot/delete/id //api method + //system/pilot/deactivate_token/pilotId //api method. + + //system/pilot page. + private dynamic GetSystemPilotPage(dynamic args) + { + throw new NotImplementedException(); + } + + //system/soundfile page + private dynamic GetSystemSoundFilePage(dynamic args) + { + throw new NotImplementedException(); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/Modules/UserModule.cs b/RaceLapTimer/RaceLapTimer/Modules/UserModule.cs new file mode 100644 index 0000000..f279162 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Modules/UserModule.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Nancy; + +namespace RaceLapTimer.Modules +{ + public class UserModule:NancyModule + { + public UserModule() : base("/user") + { + + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/NancyRootPathProvider.cs b/RaceLapTimer/RaceLapTimer/NancyRootPathProvider.cs new file mode 100644 index 0000000..68765d2 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/NancyRootPathProvider.cs @@ -0,0 +1,15 @@ +using System; +using System.IO; +using System.Reflection; +using Nancy; + +namespace RaceLapTimer +{ + public class NancyRootPathProvider:IRootPathProvider + { + public string GetRootPath() + { + return new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), "www")).LocalPath; + } + } +} \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimer/NancyUser.cs b/RaceLapTimer/RaceLapTimer/NancyUser.cs new file mode 100644 index 0000000..2939ee4 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/NancyUser.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using Nancy.Security; + +namespace RaceLapTimer +{ + public class NancyUser : IUserIdentity + { + public NancyUser(string username) + { + UserName = username; + } + + public string UserName { get; } + public string Email { get; set; } + public string Password { get; set; } + public int SignInCount { get; set; } + public bool AccountLocked { get; set; } + public DateTime LockedAt { get; set; } + public IEnumerable Claims { get; } + } +} \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimer/Program.cs b/RaceLapTimer/RaceLapTimer/Program.cs new file mode 100644 index 0000000..ef7f795 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Program.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.ServiceProcess; +using System.Text; +using System.Threading.Tasks; + +namespace RaceLapTimer +{ + static class Program + { + /// + /// The main entry point for the application. + /// + static void Main() + { + ServiceBase[] ServicesToRun; + ServicesToRun = new ServiceBase[] + { + new RaceLapTimer() + }; + ServiceBase.Run(ServicesToRun); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/Properties/AssemblyInfo.cs b/RaceLapTimer/RaceLapTimer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5de4411 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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: AssemblyTitle("RaceLapTimer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RaceLapTimer")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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 +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("85a3cc28-096c-40a6-8c67-3aade40edf32")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RaceLapTimer/RaceLapTimer/RaceLapTimer.Designer.cs b/RaceLapTimer/RaceLapTimer/RaceLapTimer.Designer.cs new file mode 100644 index 0000000..463db67 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/RaceLapTimer.Designer.cs @@ -0,0 +1,37 @@ +namespace RaceLapTimer +{ + partial class RaceLapTimer + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.ServiceName = "Service1"; + } + + #endregion + } +} diff --git a/RaceLapTimer/RaceLapTimer/RaceLapTimer.cs b/RaceLapTimer/RaceLapTimer/RaceLapTimer.cs new file mode 100644 index 0000000..fc89007 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/RaceLapTimer.cs @@ -0,0 +1,38 @@ +using System; +using System.ServiceProcess; +using Microsoft.Owin.Hosting; + +namespace RaceLapTimer +{ + public partial class RaceLapTimer : ServiceBase + { + private IDisposable _webService; + private readonly string _url = "http://*:8800"; + + public RaceLapTimer() + { + InitializeComponent(); + } + + public void Start() + { + OnStart(null); + } + + public void StopService() + { + OnStop(); + } + + protected override void OnStart(string[] args) + { + _webService = WebApp.Start(_url); + Console.WriteLine("Web Server is running on " + _url); + } + + protected override void OnStop() + { + _webService.Dispose(); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj b/RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj new file mode 100644 index 0000000..484b50a --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj @@ -0,0 +1,181 @@ + + + + + Debug + AnyCPU + {85A3CC28-096C-40A6-8C67-3AADE40EDF32} + WinExe + Properties + RaceLapTimer + RaceLapTimer + v4.5.2 + 512 + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.Owin.3.1.0\lib\net45\Microsoft.Owin.dll + True + + + ..\packages\Microsoft.Owin.Host.HttpListener.3.1.0\lib\net45\Microsoft.Owin.Host.HttpListener.dll + True + + + ..\packages\Microsoft.Owin.Hosting.3.1.0\lib\net45\Microsoft.Owin.Hosting.dll + True + + + ..\packages\Nancy.1.4.3\lib\net40\Nancy.dll + True + + + ..\packages\Nancy.Authentication.Forms.1.4.1\lib\net40\Nancy.Authentication.Forms.dll + True + + + ..\packages\Nancy.Owin.1.4.1\lib\net40\Nancy.Owin.dll + True + + + ..\packages\Nancy.Viewengines.Razor.1.4.3\lib\net40\Nancy.ViewEngines.Razor.dll + True + + + ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll + True + + + ..\packages\Owin.1.0\lib\net40\Owin.dll + True + + + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll + True + + + ..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Component + + + RaceLapTimer.cs + + + + + + + + + + + Always + + + Always + + + Always + + + Always + + + Always + + + + + + + + + + + {bc7dea8b-5029-459a-aa54-ea81eb390f87} + Helpers.Encryption + + + {5C6DCC59-19F3-46AD-A479-926610F36257} + Interfaces + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj.DotSettings b/RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj.DotSettings new file mode 100644 index 0000000..23810ed --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj.user b/RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj.user new file mode 100644 index 0000000..ca1d04b --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/RaceLapTimer.csproj.user @@ -0,0 +1,6 @@ + + + + ProjectFiles + + \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimer/Startup.cs b/RaceLapTimer/RaceLapTimer/Startup.cs new file mode 100644 index 0000000..c55d846 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/Startup.cs @@ -0,0 +1,26 @@ +using System.Web.Http; +using Owin; + +namespace RaceLapTimer +{ + public class Startup + { + public void Configuration(IAppBuilder app) + { + // Configure Web API for self-host. + var config = new HttpConfiguration(); + config.MapHttpAttributeRoutes(); + config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; + config.Routes.MapHttpRoute( + name: "DefaultApi", + routeTemplate: "api/{controller}/{id}", + defaults: new { id = RouteParameter.Optional } + ); + config.EnsureInitialized(); + + app.UseWebApi(config); + + app.UseNancy(); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/UserDatabase.cs b/RaceLapTimer/RaceLapTimer/UserDatabase.cs new file mode 100644 index 0000000..75037d1 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/UserDatabase.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Interfaces; +using Nancy; +using Nancy.Authentication.Forms; +using Nancy.Security; + +namespace RaceLapTimer +{ + public class UserDatabase : IUserMapper + { + private static List> users = new List>(); + private IUserStorage _storage; + + public UserDatabase(IUserStorage storage) + { + _storage = storage; + users.Add(new Tuple("admin", "password", new Guid("55E1E49E-B7E8-4EEA-8459-7A906AC4D4C0"))); + users.Add(new Tuple("user", "password", new Guid("56E1E49E-B7E8-4EEA-8459-7A906AC4D4C0"))); + } + + /// + /// Get the user from the database + /// + /// The Guid identifier for the user + /// NancyContext (injected) + /// + public IUserIdentity GetUserFromIdentifier(Guid identifier, NancyContext context) + { + var userRecord = users.FirstOrDefault(u => u.Item3 == identifier); + return userRecord == null + ? null + : new NancyUser(userRecord.Item1); + } + + /// + /// Validate that the user/password combo is a valid user. + /// + /// the username of the user attempting to authenticate + /// the password of the user to authenticate. + /// Returns Guid if valid user, null if not. + public static Guid? ValidateUser(string username, string password) + { + var pwHash = string.Empty; + if (!string.IsNullOrEmpty(password)) + { + pwHash = Helpers.Encryption.Hash.HashString(password); + } + + var userRecord = users.FirstOrDefault(u => u.Item1 == username && u.Item2 == password); + + return userRecord?.Item3; + } + } + + public class UserStorage : IUserStorage + { + public UserStorage() + { + } + + public User GetUser(int id) + { + throw new NotImplementedException(); + } + + public User GetUser(string guid) + { + throw new NotImplementedException(); + } + + public bool DeleteUser(int id) + { + throw new NotImplementedException(); + } + + public bool DeleteUser(string guid) + { + throw new NotImplementedException(); + } + + public bool UpdateUser(User user) + { + throw new NotImplementedException(); + } + + public bool CreateUser(User user) + { + throw new NotImplementedException(); + } + } +} diff --git a/RaceLapTimer/RaceLapTimer/packages.config b/RaceLapTimer/RaceLapTimer/packages.config new file mode 100644 index 0000000..720590a --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/packages.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimer/www/Views/RaceDirector.cshtml b/RaceLapTimer/RaceLapTimer/www/Views/RaceDirector.cshtml new file mode 100644 index 0000000..7b03cfc --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/www/Views/RaceDirector.cshtml @@ -0,0 +1,28 @@ +@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase +@{ + Layout = "razor-layout.cshtml"; + ViewBag.Title = "Race Director"; + ViewBag.CreateRaceApiEndpoint = "/api/racesession/create"; +} +

@ViewBag.Title

+ +

Last Scanned Id

+ + +

Current Race

+ + +

Last Lap Times

+ + +
+
+ + +
+
+ + +
+ +
\ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimer/www/Views/index.cshtml b/RaceLapTimer/RaceLapTimer/www/Views/index.cshtml new file mode 100644 index 0000000..f76ef75 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/www/Views/index.cshtml @@ -0,0 +1,20 @@ +@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase +@{ + Layout = "razor-layout.cshtml"; +} + + + + Forms Authentication Demo + + + Enter the "Secure Zone"!
+ + Enter the "Partly Secure Zone"!
+ @if (Html.IsAuthenticated) + { +

You are Logged in..

+ Log Out + } + + diff --git a/RaceLapTimer/RaceLapTimer/www/Views/login.cshtml b/RaceLapTimer/RaceLapTimer/www/Views/login.cshtml new file mode 100644 index 0000000..14003fa --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/www/Views/login.cshtml @@ -0,0 +1,25 @@ +@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase +@{ + Layout = "razor-layout.cshtml"; +} + + + + Login + + +
+ Username +
+ Password +
+ Remember Me +
+ +
+ @if (Model.Errored) + { +
Invalid Username or Password
+ } + + \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimer/www/Views/razor-layout.cshtml b/RaceLapTimer/RaceLapTimer/www/Views/razor-layout.cshtml new file mode 100644 index 0000000..3065e89 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/www/Views/razor-layout.cshtml @@ -0,0 +1,96 @@ +@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase + + + + + + + + Razor Localization Demo + + +
+ +
+ + + +
+
+
+
+
+ @RenderBody() +
+
+ + +
+ + \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimer/www/Views/secure.cshtml b/RaceLapTimer/RaceLapTimer/www/Views/secure.cshtml new file mode 100644 index 0000000..bca0364 --- /dev/null +++ b/RaceLapTimer/RaceLapTimer/www/Views/secure.cshtml @@ -0,0 +1,17 @@ +@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase +@{ + Layout = "razor-layout.cshtml"; +} + + + + Secure Page! + + + Welcome to the secure area @Model.Username ! + +
+
+ Logout + + \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimerHost/App.config b/RaceLapTimer/RaceLapTimerHost/App.config new file mode 100644 index 0000000..5e1fd16 --- /dev/null +++ b/RaceLapTimer/RaceLapTimerHost/App.config @@ -0,0 +1,29 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimerHost/Program.cs b/RaceLapTimer/RaceLapTimerHost/Program.cs new file mode 100644 index 0000000..d436906 --- /dev/null +++ b/RaceLapTimer/RaceLapTimerHost/Program.cs @@ -0,0 +1,16 @@ +using System; + +namespace RaceLapTimerHost +{ + class Program + { + static void Main(string[] args) + { + var service = new RaceLapTimer.RaceLapTimer(); + service.Start(); + Console.WriteLine("Press enter to exit"); + Console.ReadLine(); + service.StopService(); + } + } +} diff --git a/RaceLapTimer/RaceLapTimerHost/Properties/AssemblyInfo.cs b/RaceLapTimer/RaceLapTimerHost/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..89ca102 --- /dev/null +++ b/RaceLapTimer/RaceLapTimerHost/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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: AssemblyTitle("RaceLapTimerHost")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RaceLapTimerHost")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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 +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("763192f3-fdc4-409b-b7cf-1191dcbb14eb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RaceLapTimer/RaceLapTimerHost/RaceLapTimerHost.csproj b/RaceLapTimer/RaceLapTimerHost/RaceLapTimerHost.csproj new file mode 100644 index 0000000..8d31780 --- /dev/null +++ b/RaceLapTimer/RaceLapTimerHost/RaceLapTimerHost.csproj @@ -0,0 +1,95 @@ + + + + + Debug + AnyCPU + {763192F3-FDC4-409B-B7CF-1191DCBB14EB} + Exe + Properties + RaceLapTimerHost + RaceLapTimerHost + v4.5.2 + 512 + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.Owin.Host.HttpListener.3.1.0\lib\net45\Microsoft.Owin.Host.HttpListener.dll + True + + + ..\packages\Nancy.1.4.3\lib\net40\Nancy.dll + True + + + ..\packages\Nancy.Viewengines.Razor.1.4.3\lib\net40\Nancy.ViewEngines.Razor.dll + True + + + + + + ..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll + True + + + + + + + + + + + + + + + Designer + + + + + + {85A3CC28-096C-40A6-8C67-3AADE40EDF32} + RaceLapTimer + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/RaceLapTimer/RaceLapTimerHost/packages.config b/RaceLapTimer/RaceLapTimerHost/packages.config new file mode 100644 index 0000000..5ed326d --- /dev/null +++ b/RaceLapTimer/RaceLapTimerHost/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file