diff --git a/EBS POC.sln b/EBS POC.sln
new file mode 100644
index 0000000..a8a909f
--- /dev/null
+++ b/EBS POC.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25123.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EBS POC", "EBS POC\EBS POC.csproj", "{984AA6FE-09F6-4CFB-ACB4-023CB59DFFAA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {984AA6FE-09F6-4CFB-ACB4-023CB59DFFAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {984AA6FE-09F6-4CFB-ACB4-023CB59DFFAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {984AA6FE-09F6-4CFB-ACB4-023CB59DFFAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {984AA6FE-09F6-4CFB-ACB4-023CB59DFFAA}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/EBS POC/App.config b/EBS POC/App.config
new file mode 100644
index 0000000..bae5d6d
--- /dev/null
+++ b/EBS POC/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/EBS POC/App.xaml b/EBS POC/App.xaml
new file mode 100644
index 0000000..66dc192
--- /dev/null
+++ b/EBS POC/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/EBS POC/App.xaml.cs b/EBS POC/App.xaml.cs
new file mode 100644
index 0000000..ee4341f
--- /dev/null
+++ b/EBS POC/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace EBS_POC
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/EBS POC/Controls/Connect_Page.xaml b/EBS POC/Controls/Connect_Page.xaml
new file mode 100644
index 0000000..0b38cc4
--- /dev/null
+++ b/EBS POC/Controls/Connect_Page.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
diff --git a/EBS POC/Controls/Connect_Page.xaml.cs b/EBS POC/Controls/Connect_Page.xaml.cs
new file mode 100644
index 0000000..d2836a4
--- /dev/null
+++ b/EBS POC/Controls/Connect_Page.xaml.cs
@@ -0,0 +1,53 @@
+using EBS_POC.Models;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Net.Sockets;
+using System.Net;
+
+namespace EBS_POC.Controls
+{
+ ///
+ /// Interaction logic for Connect_Page.xaml
+ ///
+ public partial class Connect_Page : UserControl
+ {
+ public Connect_Page()
+ {
+ InitializeComponent();
+ }
+
+ private async void buttonConnect_Click(object sender, RoutedEventArgs e)
+ {
+ if (!File.Exists(textBox.Text.Replace("\"", "")))
+ {
+ MessageBox.Show("File not found.");
+ return;
+ }
+ if (await Sockets.InitHostConnection(textBox.Text.Replace("\"", "")))
+ {
+ Sockets.ConnectAsHost();
+ }
+ else if (await Sockets.InitClientConnection(textBox.Text.Replace("\"", "")))
+ {
+ Sockets.ConnectAsClient();
+ }
+ else
+ {
+ MessageBox.Show("Couldn't connect.");
+ }
+ }
+ }
+}
diff --git a/EBS POC/Controls/Deploy_Page.xaml b/EBS POC/Controls/Deploy_Page.xaml
new file mode 100644
index 0000000..60f8e2d
--- /dev/null
+++ b/EBS POC/Controls/Deploy_Page.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
diff --git a/EBS POC/Controls/Deploy_Page.xaml.cs b/EBS POC/Controls/Deploy_Page.xaml.cs
new file mode 100644
index 0000000..47b6650
--- /dev/null
+++ b/EBS POC/Controls/Deploy_Page.xaml.cs
@@ -0,0 +1,70 @@
+using EBS_POC.Models;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace EBS_POC.Controls
+{
+ ///
+ /// Interaction logic for Deploy_Page.xaml
+ ///
+ public partial class Deploy_Page : UserControl
+ {
+ public Deploy_Page()
+ {
+ InitializeComponent();
+ }
+
+ private async void buttonDeploy_Click(object sender, RoutedEventArgs e)
+ {
+ if (File.Exists(textBox.Text.Replace("\"", "")))
+ {
+ MessageBox.Show("File already exists.");
+ return;
+ }
+ try
+ {
+ var masterFile = new Master_File();
+ masterFile.HostName = Environment.MachineName;
+ var filePath = textBox.Text.Replace("\"", "");
+ Main_Model.Current.EBSFilePath = filePath;
+ await FilePlus.WriteAllText(filePath, JsonHelper.Encode(masterFile));
+ Main_Model.Current.LockFS = File.Create(filePath + ".lock");
+ Main_Model.Current.IsHost = true;
+ Sockets.ConnectAsHost();
+ }
+ catch (DirectoryNotFoundException)
+ {
+ MessageBox.Show("Couldn't find the directory.");
+ }
+ catch (FileNotFoundException)
+ {
+ MessageBox.Show("Couldn't find the file.");
+ }
+ catch (UnauthorizedAccessException)
+ {
+ MessageBox.Show("Couldn't create file. Check your rights.");
+ }
+ catch (PathTooLongException)
+ {
+ MessageBox.Show("Path is too long. Pick another location.");
+ }
+ catch
+ {
+ MessageBox.Show("Something went wrong.");
+ }
+ }
+ }
+}
diff --git a/EBS POC/Controls/EBS_Page.xaml b/EBS POC/Controls/EBS_Page.xaml
new file mode 100644
index 0000000..09a4518
--- /dev/null
+++ b/EBS POC/Controls/EBS_Page.xaml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/EBS POC/Controls/EBS_Page.xaml.cs b/EBS POC/Controls/EBS_Page.xaml.cs
new file mode 100644
index 0000000..3557206
--- /dev/null
+++ b/EBS POC/Controls/EBS_Page.xaml.cs
@@ -0,0 +1,45 @@
+using EBS_POC.Models;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+
+namespace EBS_POC.Controls
+{
+ ///
+ /// Interaction logic for EBS_Page.xaml
+ ///
+ public partial class EBS_Page : UserControl
+ {
+ public static EBS_Page Current { get; set; }
+ public EBS_Page()
+ {
+ InitializeComponent();
+ this.DataContext = Main_Model.Current;
+ Current = this;
+ }
+
+ private void UserControl_Loaded(object sender, RoutedEventArgs e)
+ {
+ if (Main_Model.Current.IsHost)
+ {
+ textIsHost.Visibility = Visibility.Visible;
+ }
+ foreach (var worker in Main_Model.Current.EBSFile.WorkerList)
+ {
+ var workerWindow = new Worker_Window(worker);
+ stackWorkers.Children.Add(workerWindow);
+ }
+ }
+ }
+}
diff --git a/EBS POC/Controls/Start_Page.xaml b/EBS POC/Controls/Start_Page.xaml
new file mode 100644
index 0000000..3fea7a4
--- /dev/null
+++ b/EBS POC/Controls/Start_Page.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/EBS POC/Controls/Start_Page.xaml.cs b/EBS POC/Controls/Start_Page.xaml.cs
new file mode 100644
index 0000000..1716b95
--- /dev/null
+++ b/EBS POC/Controls/Start_Page.xaml.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace EBS_POC.Controls
+{
+ ///
+ /// Interaction logic for Start_Page.xaml
+ ///
+ public partial class Start_Page : UserControl
+ {
+ public Start_Page()
+ {
+ InitializeComponent();
+ }
+
+ private void button2_Click(object sender, RoutedEventArgs e)
+ {
+ MainWindow.Current.frameMain.Navigate(new Deploy_Page());
+ }
+
+ private void button_Click(object sender, RoutedEventArgs e)
+ {
+ MainWindow.Current.frameMain.Navigate(new Connect_Page());
+ }
+ }
+}
diff --git a/EBS POC/Controls/Worker_Window.xaml b/EBS POC/Controls/Worker_Window.xaml
new file mode 100644
index 0000000..e2d8030
--- /dev/null
+++ b/EBS POC/Controls/Worker_Window.xaml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/EBS POC/Controls/Worker_Window.xaml.cs b/EBS POC/Controls/Worker_Window.xaml.cs
new file mode 100644
index 0000000..eca4a07
--- /dev/null
+++ b/EBS POC/Controls/Worker_Window.xaml.cs
@@ -0,0 +1,87 @@
+using EBS_POC.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Timers;
+using System.IO;
+
+namespace EBS_POC.Controls
+{
+ ///
+ /// Interaction logic for Worker_Window.xaml
+ ///
+ public partial class Worker_Window : UserControl
+ {
+ public Worker ThisWorker { get; set; }
+ //private Timer TextChangeTimer { get; set; } = new Timer();
+
+ public Worker_Window(Worker Worker)
+ {
+ InitializeComponent();
+ ThisWorker = Worker;
+ this.Name = Worker.Name;
+ }
+ private void userControl_Loaded(object sender, RoutedEventArgs e)
+ {
+ textNotes.Text = ThisWorker.Notes;
+ textWorker.Text = ThisWorker.Name;
+ }
+
+ private async void textNotes_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ ThisWorker.Notes = (sender as TextBox).Text + e.Text;
+ if (Main_Model.Current.IsHost)
+ {
+ foreach (var client in Main_Model.Current.ClientList)
+ {
+ client.Value.Send(Encoding.UTF8.GetBytes(JsonHelper.Encode(ThisWorker)));
+ }
+ await FilePlus.WriteAllText(Main_Model.Current.EBSFilePath, JsonHelper.Encode(Main_Model.Current.EBSFile));
+ }
+ else
+ {
+ Main_Model.Current.ConnectionToServer.Client.Send(Encoding.UTF8.GetBytes(JsonHelper.Encode(ThisWorker)));
+ }
+ // * Use this to set a required input delay before the updated message will be sent. * //
+ //TextChangeTimer.Stop();
+ //TextChangeTimer = new Timer();
+ //TextChangeTimer.Elapsed += async (sen, arg) =>
+ //{
+ // if (Main_Model.Current.IsHost)
+ // {
+ // foreach (var client in Main_Model.Current.ClientList)
+ // {
+ // client.Value.Send(Encoding.UTF8.GetBytes(JsonHelper.Encode(ThisWorker)));
+ // }
+ // await FilePlus.WriteAllText(Main_Model.Current.EBSFilePath, JsonHelper.Encode(Main_Model.Current.EBSFile));
+ // }
+ // else
+ // {
+ // Main_Model.Current.ConnectionToServer.Client.Send(Encoding.UTF8.GetBytes(JsonHelper.Encode(ThisWorker)));
+ // }
+ //};
+ //TextChangeTimer.AutoReset = false;
+ //TextChangeTimer.Interval = 2000;
+ //TextChangeTimer.Start();
+ }
+
+ private void textNotes_KeyUp(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Delete || e.Key == Key.Back)
+ {
+ var tce = new TextCompositionEventArgs(Keyboard.PrimaryDevice, new TextComposition(InputManager.Current, textNotes, ""));
+ textNotes_PreviewTextInput(textNotes, tce);
+ }
+ }
+ }
+}
diff --git a/EBS POC/EBS POC.csproj b/EBS POC/EBS POC.csproj
new file mode 100644
index 0000000..f23ef99
--- /dev/null
+++ b/EBS POC/EBS POC.csproj
@@ -0,0 +1,149 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {984AA6FE-09F6-4CFB-ACB4-023CB59DFFAA}
+ WinExe
+ Properties
+ EBS_POC
+ EBS POC
+ v4.6.1
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Worker_Window.xaml
+
+
+
+
+
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ Connect_Page.xaml
+
+
+ Deploy_Page.xaml
+
+
+ EBS_Page.xaml
+
+
+ Start_Page.xaml
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EBS POC/MainWindow.xaml b/EBS POC/MainWindow.xaml
new file mode 100644
index 0000000..5750ea3
--- /dev/null
+++ b/EBS POC/MainWindow.xaml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/EBS POC/MainWindow.xaml.cs b/EBS POC/MainWindow.xaml.cs
new file mode 100644
index 0000000..ba173f0
--- /dev/null
+++ b/EBS POC/MainWindow.xaml.cs
@@ -0,0 +1,45 @@
+using EBS_POC.Controls;
+using EBS_POC.Models;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace EBS_POC
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ public static MainWindow Current { get; set; }
+ public MainWindow()
+ {
+ InitializeComponent();
+ Current = this;
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ if (!File.Exists("config.config"))
+ {
+ frameMain.Navigate(new Start_Page());
+ }
+ else
+ {
+ // Use config settings.
+ }
+ }
+ }
+}
diff --git a/EBS POC/Models/Main_Model.cs b/EBS POC/Models/Main_Model.cs
new file mode 100644
index 0000000..4b93ab5
--- /dev/null
+++ b/EBS POC/Models/Main_Model.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using System.Linq;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EBS_POC.Models
+{
+ public class Main_Model : INotifyPropertyChanged
+ {
+ public static Main_Model Current { get; set; } = new Main_Model();
+ public int Port { get; set; } = 33885;
+ public bool IsHost { get; set; }
+ public Master_File EBSFile { get; set; }
+ public string EBSFilePath { get; set; }
+ public FileStream LockFS { get; set; }
+ public TcpListener Listener { get; set; }
+ public TcpClient ConnectionToServer { get; set; }
+ public Dictionary ClientList { get; set; } = new Dictionary();
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ public void FirePropertyChanged(string PropertyName)
+ {
+ PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
+ }
+ }
+}
diff --git a/EBS POC/Models/Master_File.cs b/EBS POC/Models/Master_File.cs
new file mode 100644
index 0000000..de65ff8
--- /dev/null
+++ b/EBS POC/Models/Master_File.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EBS_POC.Models
+{
+ public class Master_File : INotifyPropertyChanged
+ {
+ public string HostName { get; set; } = "";
+ public string HostIP { get; set; } = "";
+ public List WorkerList { get; set; } = new List();
+ public event PropertyChangedEventHandler PropertyChanged;
+ public void FirePropertyChanged(string PropertyName)
+ {
+ PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
+ }
+ }
+}
diff --git a/EBS POC/Models/Worker.cs b/EBS POC/Models/Worker.cs
new file mode 100644
index 0000000..62a5271
--- /dev/null
+++ b/EBS POC/Models/Worker.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.Serialization;
+using System.ComponentModel;
+
+namespace EBS_POC.Models
+{
+ [DataContract]
+ public class Worker : INotifyPropertyChanged
+ {
+ public Worker (string WorkerName)
+ {
+ Name = WorkerName;
+ }
+ [DataMember]
+ public string Name { get; set; } = "";
+ [DataMember]
+ public string Notes { get; set; } = "";
+ public event PropertyChangedEventHandler PropertyChanged;
+ public void FirePropertyChanged(string PropertyName)
+ {
+ PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
+ }
+ }
+}
diff --git a/EBS POC/Properties/AssemblyInfo.cs b/EBS POC/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d04beb8
--- /dev/null
+++ b/EBS POC/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 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("EBS POC")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("EBS POC")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[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)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// 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/EBS POC/Properties/Resources.Designer.cs b/EBS POC/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..8141dc3
--- /dev/null
+++ b/EBS POC/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace EBS_POC.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EBS_POC.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/EBS POC/Properties/Resources.resx b/EBS POC/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/EBS POC/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/EBS POC/Properties/Settings.Designer.cs b/EBS POC/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..5f6e0a8
--- /dev/null
+++ b/EBS POC/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace EBS_POC.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/EBS POC/Properties/Settings.settings b/EBS POC/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/EBS POC/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EBS POC/Sockets.cs b/EBS POC/Sockets.cs
new file mode 100644
index 0000000..166a328
--- /dev/null
+++ b/EBS POC/Sockets.cs
@@ -0,0 +1,185 @@
+using EBS_POC.Controls;
+using EBS_POC.Models;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace EBS_POC
+{
+ public class Sockets
+ {
+ public static async Task InitHostConnection(string FilePath)
+ {
+ try
+ {
+ Main_Model.Current.LockFS = File.Create(FilePath + ".lock");
+ Main_Model.Current.EBSFilePath = FilePath;
+ var strMasterFile = await FilePlus.ReadAllText(FilePath);
+ Main_Model.Current.EBSFile = JsonHelper.Decode(strMasterFile);
+ Main_Model.Current.EBSFile.HostName = Environment.MachineName;
+ await FilePlus.WriteAllText(FilePath, JsonHelper.Encode(Main_Model.Current.EBSFile));
+ Main_Model.Current.Listener = new TcpListener(IPAddress.Any, Main_Model.Current.Port);
+ Main_Model.Current.Listener.Start();
+ ListenForConnections();
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+ public static async Task InitClientConnection(string FilePath)
+ {
+ try
+ {
+ var strMasterContents = await FilePlus.ReadAllText(FilePath);
+ Main_Model.Current.EBSFile = JsonHelper.Decode(strMasterContents);
+ var client = new TcpClient();
+ if (Main_Model.Current.EBSFile.HostName == Environment.MachineName)
+ {
+ await client.ConnectAsync(IPAddress.Loopback, Main_Model.Current.Port);
+ }
+ else
+ {
+ await client.ConnectAsync(Main_Model.Current.EBSFile.HostName, Main_Model.Current.Port);
+ }
+ Main_Model.Current.ConnectionToServer = client;
+ client.Client.Send(Encoding.UTF8.GetBytes(Environment.MachineName));
+ HandleServer(client);
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+ public static void ConnectAsHost()
+ {
+ Main_Model.Current.IsHost = true;
+ MainWindow.Current.frameMain.Navigate(new EBS_Page());
+ }
+ public static void ConnectAsClient()
+ {
+ if (Main_Model.Current.EBSFile.HostName == "")
+ {
+ // Wait for host or error.
+ }
+ Main_Model.Current.IsHost = false;
+ MainWindow.Current.frameMain.Navigate(new EBS_Page());
+ }
+
+ public static async void ListenForConnections()
+ {
+ var listener = Main_Model.Current.Listener;
+ while (listener != null)
+ {
+ var client = await listener.AcceptTcpClientAsync();
+ while (client.Available == 0)
+ {
+ await Task.Delay(50);
+ }
+ byte[] buffer = new byte[client.Available];
+ client.Client.Receive(buffer);
+
+ var strReceived = Encoding.UTF8.GetString(buffer);
+ var clientName = strReceived.Split('{')[0];
+ if (Main_Model.Current.ClientList.ContainsKey(clientName))
+ {
+ // Send error message to client.
+ client.Close();
+ return;
+ }
+ Main_Model.Current.ClientList.Add(clientName, client.Client);
+ if (strReceived.Length > clientName.Length)
+ {
+ ReceiveMessage(strReceived.Substring(clientName.Length));
+ }
+ HandleClient(clientName, client.Client);
+ }
+ }
+ public static async void HandleClient(string ClientName, Socket ClientSocket)
+ {
+ while (ClientSocket.Connected)
+ {
+ try
+ {
+ while (ClientSocket.Available == 0)
+ {
+ await Task.Delay(50);
+ }
+ var buffer = new byte[ClientSocket.Available];
+ ClientSocket.Receive(buffer);
+ var strReceived = Encoding.UTF8.GetString(buffer);
+ ReceiveMessage(strReceived);
+
+ foreach (var client in Main_Model.Current.ClientList.Where(kp => kp.Key != ClientName))
+ {
+ client.Value.Send(buffer);
+ }
+ await FilePlus.WriteAllText(Main_Model.Current.EBSFilePath, JsonHelper.Encode(Main_Model.Current.EBSFile));
+ }
+ catch
+ {
+ Main_Model.Current.ClientList.Remove(ClientName);
+ break;
+ }
+ }
+ }
+ public static async void HandleServer(TcpClient ServerConnection)
+ {
+ while (ServerConnection.Connected)
+ {
+ try
+ {
+ while (ServerConnection.Available == 0)
+ {
+ await Task.Delay(50);
+ }
+ var buffer = new byte[ServerConnection.Available];
+ ServerConnection.Client.Receive(buffer);
+ var strMessage = Encoding.UTF8.GetString(buffer);
+ ReceiveMessage(strMessage);
+ }
+ catch
+ {
+ // Instead, logic should be here for the next client to pick up hosting.
+ MessageBox.Show("Connection error.");
+ MainWindow.Current.frameMain.Navigate(new Start_Page());
+ }
+ }
+ }
+ public static void ReceiveMessage(string Received)
+ {
+ for (var i = 5; i < Received.Length; i++)
+ {
+ if (!Received.Remove(i).EndsWith("}") && i < Received.Length - 1 )
+ {
+ continue;
+ }
+ try
+ {
+ // This assumes only serialized Worker objects will be sent. If using
+ // additional DTO types, create a base DTO that can be used to determine the
+ // derived type, then deserialize again to the derived type.
+ var worker = JsonHelper.Decode(Received.Remove(i));
+ Main_Model.Current.EBSFile.WorkerList.Find(existing => existing.Name == worker.Name).Notes = worker.Notes;
+ var workerWindow = EBS_Page.Current.stackWorkers.Children.Cast().FirstOrDefault(ww => ww.Name == worker.Name);
+ MainWindow.Current.frameMain.Focus();
+ workerWindow.textNotes.Text = worker.Notes;
+ ReceiveMessage(Received.Substring(i));
+ }
+ catch
+ {
+ continue;
+ }
+ }
+
+ }
+ }
+}
diff --git a/EBS POC/Utilities/FilePlus.cs b/EBS POC/Utilities/FilePlus.cs
new file mode 100644
index 0000000..e303c4a
--- /dev/null
+++ b/EBS POC/Utilities/FilePlus.cs
@@ -0,0 +1,220 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.IO;
+using System.Threading.Tasks;
+
+public static class FilePlus
+{
+ public static async Task WriteAllText(string FilePath, string Contents)
+ {
+ var count = 0;
+ var success = false;
+ while (count < 20 && success == false)
+ {
+ if (count != 0)
+ {
+ await Task.Delay(1000);
+ }
+ try
+ {
+ var dir = Path.GetDirectoryName(FilePath);
+ if (!Directory.Exists(dir))
+ {
+ Directory.CreateDirectory(dir);
+ }
+ File.WriteAllText(FilePath, Contents);
+ success = true;
+ }
+ catch
+ {
+ count++;
+ }
+ }
+ if (!success)
+ {
+ File.WriteAllText(FilePath + " Write Failure " + DateTime.Now.ToString().Replace('/', '-').Replace(':', '.'), Contents);
+ }
+ }
+ public static async Task WriteAllLines(string FilePath, string[] Contents)
+ {
+ var count = 0;
+ var success = false;
+ while (count < 20 && success == false)
+ {
+ if (count != 0)
+ {
+ await Task.Delay(1000);
+ }
+ try
+ {
+ var dir = Path.GetDirectoryName(FilePath);
+ if (!Directory.Exists(dir))
+ {
+ Directory.CreateDirectory(dir);
+ }
+ var strContents = "";
+ foreach (var line in Contents)
+ {
+ strContents += line + Environment.NewLine;
+ }
+ File.WriteAllText(FilePath, strContents);
+ success = true;
+ }
+ catch
+ {
+ count++;
+ }
+ }
+ if (!success)
+ {
+ var strContents = "";
+ foreach (var line in Contents)
+ {
+ strContents += line + Environment.NewLine;
+ }
+ File.WriteAllText(FilePath + " Write Failure " + DateTime.Now.ToString().Replace('/', '-').Replace(':', '.'), strContents);
+ }
+ }
+ public static async Task AppendAllText(string FilePath, string Contents)
+ {
+ var count = 0;
+ var success = false;
+ while (count < 20 && success == false)
+ {
+ if (count != 0)
+ {
+ await Task.Delay(1000);
+ }
+ try
+ {
+ var dir = Path.GetDirectoryName(FilePath);
+ if (!Directory.Exists(dir))
+ {
+ Directory.CreateDirectory(dir);
+ }
+ File.AppendAllText(FilePath, Contents);
+ success = true;
+ }
+ catch
+ {
+ count++;
+ }
+ }
+ if (!success)
+ {
+ File.WriteAllText(FilePath + " Write Failure " + DateTime.Now.ToString().Replace('/', '-').Replace(':', '.'), Contents);
+ }
+ }
+ public static async Task AppendAllLines(string FilePath, string[] Contents)
+ {
+ var count = 0;
+ var success = false;
+ while (count < 20 && success == false)
+ {
+ if (count != 0)
+ {
+ await Task.Delay(1000);
+ }
+ try
+ {
+ var dir = Path.GetDirectoryName(FilePath);
+ if (!Directory.Exists(dir))
+ {
+ Directory.CreateDirectory(dir);
+ }
+ foreach (var line in Contents)
+ {
+ File.AppendAllText(FilePath, line + Environment.NewLine);
+ }
+ success = true;
+ }
+ catch
+ {
+ count++;
+ }
+ }
+ if (!success)
+ {
+ var strContents = "";
+ foreach (var line in Contents)
+ {
+ strContents += line + Environment.NewLine;
+ }
+ File.WriteAllText(FilePath + " Write Failure " + DateTime.Now.ToString().Replace('/', '-').Replace(':', '.'), strContents);
+ }
+ }
+ public static async Task ReadAllText(string FilePath)
+ {
+ var count = 0;
+ var success = false;
+ var contents = "";
+ while (count < 20 && success == false)
+ {
+ if (count != 0)
+ {
+ await Task.Delay(1000);
+ }
+ try
+ {
+ var dir = Path.GetDirectoryName(FilePath);
+ if (!Directory.Exists(dir))
+ {
+ Directory.CreateDirectory(dir);
+ }
+ if (!File.Exists(FilePath))
+ {
+ File.Create(FilePath).Close();
+ }
+ contents = File.ReadAllText(FilePath);
+ success = true;
+ }
+ catch
+ {
+ count++;
+ }
+ }
+ if (!success)
+ {
+ File.WriteAllText(FilePath + " Read Failure " + DateTime.Now.ToString().Replace('/', '-').Replace(':', '.'), "");
+ }
+ return contents;
+ }
+ public static async Task ReadAllLines(string FilePath)
+ {
+ var count = 0;
+ var success = false;
+ var contents = new string[0];
+ while (count < 20 && success == false)
+ {
+ if (count != 0)
+ {
+ await Task.Delay(1000);
+ }
+ try
+ {
+ var dir = Path.GetDirectoryName(FilePath);
+ if (!Directory.Exists(dir))
+ {
+ Directory.CreateDirectory(dir);
+ }
+ if (!File.Exists(FilePath))
+ {
+ File.Create(FilePath).Close();
+ }
+ contents = File.ReadAllLines(FilePath);
+ success = true;
+ }
+ catch
+ {
+ count++;
+ }
+ }
+ if (!success)
+ {
+ File.WriteAllText(FilePath + " Read Failure " + DateTime.Now.ToString().Replace('/', '-').Replace(':', '.'), "");
+ }
+ return contents;
+ }
+}
\ No newline at end of file
diff --git a/EBS POC/Utilities/JsonHelper.cs b/EBS POC/Utilities/JsonHelper.cs
new file mode 100644
index 0000000..a226286
--- /dev/null
+++ b/EBS POC/Utilities/JsonHelper.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.Serialization.Json;
+using System.IO;
+public static class JsonHelper
+{
+ public static string Encode(object DataObject)
+ {
+ try
+ {
+ var serializer = new DataContractJsonSerializer(DataObject.GetType());
+ string result;
+ using (var ms = new MemoryStream())
+ {
+ serializer.WriteObject(ms, DataObject);
+ ms.Position = 0;
+ using (var sr = new StreamReader(ms))
+ {
+ result = sr.ReadToEnd();
+ }
+ }
+ return result;
+ }
+ catch
+ {
+ return null;
+ }
+
+ }
+ public static T Decode(string DataString)
+ {
+ try
+ {
+ var serializer = new DataContractJsonSerializer(typeof(T));
+ T deserialized;
+ using (var ms = new MemoryStream())
+ {
+ using (var sw = new StreamWriter(ms))
+ {
+ sw.Write(DataString);
+ sw.Flush();
+ ms.Position = 0;
+ deserialized = (T)serializer.ReadObject(ms);
+ }
+ }
+ return deserialized;
+ }
+ catch
+ {
+ return default(T);
+ }
+ }
+}
\ No newline at end of file