Add project files.
parent
dddcc726da
commit
714fe735de
|
@ -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
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
</startup>
|
||||
</configuration>
|
|
@ -0,0 +1,9 @@
|
|||
<Application x:Class="EBS_POC.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:EBS_POC"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<UserControl x:Class="EBS_POC.Controls.Connect_Page"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:EBS_POC.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="EBS File Location:" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="textBox" Height="23" Margin="10,31,10,0" TextWrapping="Wrap" VerticalAlignment="Top"/>
|
||||
<Button x:Name="buttonConnect" Content="Connect" HorizontalAlignment="Right" Margin="0,59,10,0" VerticalAlignment="Top" Width="75" Click="buttonConnect_Click"/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Connect_Page.xaml
|
||||
/// </summary>
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<UserControl x:Class="EBS_POC.Controls.Deploy_Page"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:EBS_POC.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="EBS File Location:" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="textBox" Height="23" Margin="10,31,10,0" TextWrapping="Wrap" VerticalAlignment="Top"/>
|
||||
<Button x:Name="buttonDeploy" Content="Deploy" HorizontalAlignment="Right" Margin="0,59,10,0" VerticalAlignment="Top" Width="75" Click="buttonDeploy_Click"/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Deploy_Page.xaml
|
||||
/// </summary>
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<UserControl
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:EBS_POC.Controls"
|
||||
xmlns:Models="clr-namespace:EBS_POC.Models" x:Class="EBS_POC.Controls.EBS_Page"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300" Loaded="UserControl_Loaded">
|
||||
<UserControl.DataContext>
|
||||
<Models:Main_Model/>
|
||||
</UserControl.DataContext>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<Grid>
|
||||
<StackPanel HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Orientation="Horizontal">
|
||||
<TextBlock TextWrapping="Wrap" Text="Host:" Margin="0,0,5,0" />
|
||||
<TextBlock x:Name="textHost" TextWrapping="Wrap" Text="{Binding EBSFile.HostName}" Margin="0,0,5,0"/>
|
||||
<TextBlock x:Name="textIsHost" Text="(You)" Visibility="Collapsed"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="10,50,10,10" x:Name="stackWorkers">
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
|
||||
</UserControl>
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for EBS_Page.xaml
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<UserControl x:Class="EBS_POC.Controls.Start_Page"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:EBS_POC.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock x:Name="textBlock" TextWrapping="Wrap" Text="No configuration file found. Choose an option." TextAlignment="Center" Margin="0,0,0,20"/>
|
||||
<Button x:Name="button" Content="Connect to EBS File" Height="30" HorizontalAlignment="Center" Margin="0,0,0,10" Click="button_Click"/>
|
||||
<Button x:Name="button2" Content="Deploy New EBS File" Height="30" HorizontalAlignment="Center" Click="button2_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Start_Page.xaml
|
||||
/// </summary>
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<UserControl x:Name="userControl" x:Class="EBS_POC.Controls.Worker_Window"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:EBS_POC.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="200" Height="150" Loaded="userControl_Loaded">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
|
||||
<TextBlock Text="Worker Name: "></TextBlock>
|
||||
<TextBlock x:Name="textWorker"></TextBlock>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1">
|
||||
<TextBlock Text="Notes" Margin="0,10,0,0"></TextBlock>
|
||||
<TextBox x:Name="textNotes" Margin="0,30,0,30" TextWrapping="Wrap" PreviewTextInput="textNotes_PreviewTextInput" KeyUp="textNotes_KeyUp"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Worker_Window.xaml
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{984AA6FE-09F6-4CFB-ACB4-023CB59DFFAA}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>EBS_POC</RootNamespace>
|
||||
<AssemblyName>EBS POC</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Controls\Worker_Window.xaml.cs">
|
||||
<DependentUpon>Worker_Window.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\Main_Model.cs" />
|
||||
<Compile Include="Models\Master_File.cs" />
|
||||
<Compile Include="Sockets.cs" />
|
||||
<Compile Include="Utilities\FilePlus.cs" />
|
||||
<Compile Include="Utilities\JsonHelper.cs" />
|
||||
<Page Include="Controls\Connect_Page.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Controls\Deploy_Page.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Controls\EBS_Page.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Controls\Start_Page.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Controls\Worker_Window.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\Connect_Page.xaml.cs">
|
||||
<DependentUpon>Connect_Page.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\Deploy_Page.xaml.cs">
|
||||
<DependentUpon>Deploy_Page.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\EBS_Page.xaml.cs">
|
||||
<DependentUpon>EBS_Page.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\Start_Page.xaml.cs">
|
||||
<DependentUpon>Start_Page.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Models\Worker.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,10 @@
|
|||
<Window x:Class="EBS_POC.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:EBS_POC"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="350" Width="450" Loaded="Window_Loaded">
|
||||
<Frame x:Name="frameMain"></Frame>
|
||||
</Window>
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
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.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<string, Socket> ClientList { get; set; } = new Dictionary<string, Socket>();
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public void FirePropertyChanged(string PropertyName)
|
||||
{
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Worker> WorkerList { get; set; } = new List<Worker>();
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public void FirePropertyChanged(string PropertyName)
|
||||
{
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(PropertyName));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> 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")]
|
|
@ -0,0 +1,63 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace EBS_POC.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 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() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,26 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
|
@ -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<bool> 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<Master_File>(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<bool> InitClientConnection(string FilePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
var strMasterContents = await FilePlus.ReadAllText(FilePath);
|
||||
Main_Model.Current.EBSFile = JsonHelper.Decode<Master_File>(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<Worker>(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<Worker_Window>().FirstOrDefault(ww => ww.Name == worker.Name);
|
||||
MainWindow.Current.frameMain.Focus();
|
||||
workerWindow.textNotes.Text = worker.Notes;
|
||||
ReceiveMessage(Received.Substring(i));
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<string> 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<string[]> 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;
|
||||
}
|
||||
}
|
|
@ -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<T>(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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue