From 20ca7d19c20d22b664a9ffa28f490bd654152760 Mon Sep 17 00:00:00 2001 From: Ben Olden-Cooligan Date: Sat, 22 Sep 2018 12:50:19 -0400 Subject: [PATCH] Add a server project --- NAPS2.DI/EntryPoints/ServerEntryPoint.cs | 48 ++++++++ NAPS2.DI/NAPS2.DI.csproj | 3 +- NAPS2.Server/.gitignore | 31 +++++ NAPS2.Server/App.config | 16 +++ NAPS2.Server/NAPS2.Server.csproj | 139 +++++++++++++++++++++++ NAPS2.Server/Program.cs | 20 ++++ NAPS2.Server/packages.config | 6 + NAPS2.sln | 12 ++ 8 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 NAPS2.DI/EntryPoints/ServerEntryPoint.cs create mode 100644 NAPS2.Server/.gitignore create mode 100644 NAPS2.Server/App.config create mode 100644 NAPS2.Server/NAPS2.Server.csproj create mode 100644 NAPS2.Server/Program.cs create mode 100644 NAPS2.Server/packages.config diff --git a/NAPS2.DI/EntryPoints/ServerEntryPoint.cs b/NAPS2.DI/EntryPoints/ServerEntryPoint.cs new file mode 100644 index 000000000..258a0bdb7 --- /dev/null +++ b/NAPS2.DI/EntryPoints/ServerEntryPoint.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Windows.Forms; +using NAPS2.DI.Modules; +using NAPS2.Util; +using NAPS2.Worker; +using Ninject; + +namespace NAPS2.DI.EntryPoints +{ + /// + /// The entry point for NAPS2.Server.exe, which exposes scanning devices over the network to other NAPS2 applications. + /// + public static class ServerEntryPoint + { + public static void Run(string[] args) + { + try + { + // Initialize Ninject (the DI framework) + var kernel = new StandardKernel(new CommonModule(), new WinFormsModule()); + + // Set up basic application configuration + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.ThreadException += UnhandledException; + + // Set up a form for the server process + var form = new BackgroundForm(); + Invoker.Current = form; + + // TODO: Listen for requests + } + catch (Exception ex) + { + Log.FatalException("An error occurred that caused the server application to close.", ex); + Environment.Exit(1); + } + } + + private static void UnhandledException(object sender, ThreadExceptionEventArgs threadExceptionEventArgs) + { + Log.FatalException("An error occurred that caused the server to close.", threadExceptionEventArgs.Exception); + } + } +} diff --git a/NAPS2.DI/NAPS2.DI.csproj b/NAPS2.DI/NAPS2.DI.csproj index ecaac62ae..fbfd0068f 100644 --- a/NAPS2.DI/NAPS2.DI.csproj +++ b/NAPS2.DI/NAPS2.DI.csproj @@ -81,6 +81,7 @@ + @@ -121,5 +122,5 @@ --> - + \ No newline at end of file diff --git a/NAPS2.Server/.gitignore b/NAPS2.Server/.gitignore new file mode 100644 index 000000000..a8a3b16a8 --- /dev/null +++ b/NAPS2.Server/.gitignore @@ -0,0 +1,31 @@ +Thumbs.db +*.obj +*.exe +*.pdb +*.user +*.aps +*.pch +*.vspscc +*_i.c +*_p.c +*.ncb +*.suo +*.sln.docstates +*.tlb +*.tlh +*.bak +*.cache +*.ilk +*.log +[Bb]in +[Dd]ebug*/ +*.lib +*.sbr +obj/ +[Rr]elease*/ +_ReSharper*/ +[Tt]est[Rr]esult* +*.vssscc +$tf*/ +publish/ +bin/ \ No newline at end of file diff --git a/NAPS2.Server/App.config b/NAPS2.Server/App.config new file mode 100644 index 000000000..3aab1227f --- /dev/null +++ b/NAPS2.Server/App.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/NAPS2.Server/NAPS2.Server.csproj b/NAPS2.Server/NAPS2.Server.csproj new file mode 100644 index 000000000..508922a4f --- /dev/null +++ b/NAPS2.Server/NAPS2.Server.csproj @@ -0,0 +1,139 @@ + + + + + Debug + AnyCPU + {BC0E3031-6C00-4707-A424-4FF04425D719} + WinExe + Properties + NAPS2.Server + NAPS2.Server + v4.0 + 512 + Client + latest + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + false + bin\InstallerEXE\ + TRACE + prompt + 4 + + + bin\InstallerMSI\ + TRACE + pdbonly + AnyCPU + latest + prompt + MinimumRecommendedRules.ruleset + + + bin\Standalone\ + TRACE + pdbonly + AnyCPU + latest + prompt + MinimumRecommendedRules.ruleset + + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + + + + + ..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll + + + + ..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll + + + ..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll + + + + + + + + + + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + {968378fa-a649-4058-a928-1fcd97b23070} + NAPS2.Core + + + {4d349529-149b-498b-8a55-373e6a67e1f0} + NAPS2.DI + + + + + + + + + + + \ No newline at end of file diff --git a/NAPS2.Server/Program.cs b/NAPS2.Server/Program.cs new file mode 100644 index 000000000..5031aa10f --- /dev/null +++ b/NAPS2.Server/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using NAPS2.DI.EntryPoints; + +namespace NAPS2.Server +{ + static class Program + { + /// + /// The NAPS2.Server.exe main method. + /// + [STAThread] + static void Main(string[] args) + { + // Use reflection to avoid antivirus false positives (yes, really) + typeof(ServerEntryPoint).GetMethod("Run").Invoke(null, new object[] { args }); + } + } +} diff --git a/NAPS2.Server/packages.config b/NAPS2.Server/packages.config new file mode 100644 index 000000000..bce178e00 --- /dev/null +++ b/NAPS2.Server/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/NAPS2.sln b/NAPS2.sln index 97137c9ce..112874320 100644 --- a/NAPS2.sln +++ b/NAPS2.sln @@ -33,6 +33,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAPS2.Worker", "NAPS2.Worke EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAPS2.Localization", "NAPS2.Localization\NAPS2.Localization.csproj", "{F6CD6C88-49EA-4443-BB45-69FB79788C61}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAPS2.Server", "NAPS2.Server\NAPS2.Server.csproj", "{BC0E3031-6C00-4707-A424-4FF04425D719}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -126,6 +128,16 @@ Global {F6CD6C88-49EA-4443-BB45-69FB79788C61}.InstallerMSI|x86.Build.0 = Debug|Any CPU {F6CD6C88-49EA-4443-BB45-69FB79788C61}.Standalone|x86.ActiveCfg = Debug|Any CPU {F6CD6C88-49EA-4443-BB45-69FB79788C61}.Standalone|x86.Build.0 = Debug|Any CPU + {BC0E3031-6C00-4707-A424-4FF04425D719}.Debug|x86.ActiveCfg = Debug|Any CPU + {BC0E3031-6C00-4707-A424-4FF04425D719}.Debug|x86.Build.0 = Debug|Any CPU + {BC0E3031-6C00-4707-A424-4FF04425D719}.DebugLang|x86.ActiveCfg = Debug|Any CPU + {BC0E3031-6C00-4707-A424-4FF04425D719}.DebugLang|x86.Build.0 = Debug|Any CPU + {BC0E3031-6C00-4707-A424-4FF04425D719}.InstallerEXE|x86.ActiveCfg = InstallerEXE|Any CPU + {BC0E3031-6C00-4707-A424-4FF04425D719}.InstallerEXE|x86.Build.0 = InstallerEXE|Any CPU + {BC0E3031-6C00-4707-A424-4FF04425D719}.InstallerMSI|x86.ActiveCfg = InstallerMSI|Any CPU + {BC0E3031-6C00-4707-A424-4FF04425D719}.InstallerMSI|x86.Build.0 = InstallerMSI|Any CPU + {BC0E3031-6C00-4707-A424-4FF04425D719}.Standalone|x86.ActiveCfg = Standalone|Any CPU + {BC0E3031-6C00-4707-A424-4FF04425D719}.Standalone|x86.Build.0 = Standalone|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE