Some more work on displaying malfunctions

This commit is contained in:
Falkvinge
2017-03-17 08:24:41 +01:00
parent c4e42238e4
commit 39e4c6f56c
8 changed files with 372 additions and 2 deletions
+1
View File
@@ -60,6 +60,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="FrontendMalfunctions.cs" />
<Compile Include="FrontendServices.cs" />
<Compile Include="FrontendLoop.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+13 -2
View File
@@ -203,8 +203,9 @@ namespace Swarmops.Frontend.Socket
private static int _sandboxDummy1 = 500;
private static int _sandboxDummy2 = 50000;
/*
private static int _malfunctionTestCounter = 0;
private static string[] malfunctionStrings = {"One", "Two", "Three", "Four"};
private static string[] malfunctionStrings = {"One", "Two", "Three", "Four"};*/
private static void OnEveryTenSeconds()
{
@@ -222,6 +223,7 @@ namespace Swarmops.Frontend.Socket
_socketServer.WebSocketServices.Broadcast(data1.ToString());
/*
JArray malfunctionsArray = new JArray();
for (int loop = 0; loop < _malfunctionTestCounter; loop++)
{
@@ -244,7 +246,7 @@ namespace Swarmops.Frontend.Socket
JObject data2 = new JObject();
data2["MessageType"] = "Malfunctions";
data2["MalfunctionsList"] = malfunctionsArray;
_socketServer.WebSocketServices.Broadcast(data2.ToString());
_socketServer.WebSocketServices.Broadcast(data2.ToString());*/
}
}
@@ -298,11 +300,15 @@ namespace Swarmops.Frontend.Socket
public static void OnBackendClose(object sender, CloseEventArgs args)
{
Console.WriteLine(" - Backend socket closed: " + args.Code + " " + args.Reason);
// TODO: Try reconnecting
}
public static void OnBackendError(object sender, ErrorEventArgs args)
{
Console.WriteLine(" - Backend socket error: " + args.Message);
// TODO: Try reconnecting
}
@@ -319,6 +325,11 @@ namespace Swarmops.Frontend.Socket
}
public static void BroadcastMalfunctions()
{
}
// --------------------------------- LEGACY CODE BELOW THIS MARK -------------------------------
+15
View File
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Swarmops.Frontend.Socket
{
public enum FrontendMalfunctions
{
Unknown = 0,
BackendConnectionFault,
BackendHeartbeatLost
}
}
+10
View File
@@ -156,6 +156,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>Logic.Structure.Geography.resx</DependentUpon>
</Compile>
<Compile Include="Resources\Logic.Support.ErrorMessages.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Logic.Support.ErrorMessages.resx</DependentUpon>
</Compile>
<Compile Include="Resources\Logic.Swarm.DashboardTodos.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@@ -191,6 +196,7 @@
<Compile Include="Communications\Payload\NotificationPayload.cs" />
<Compile Include="Security\Impersonation.cs" />
<Compile Include="Support\BlockchainTransaction.cs" />
<Compile Include="Support\ErrorMessages.cs" />
<Compile Include="Support\LogEntries\ImpersonationLogEntry.cs" />
<Compile Include="Support\LogEntries\PersonalDataChangedLogEntry.cs" />
<Compile Include="Support\PayloadBase.cs" />
@@ -629,6 +635,10 @@
<EmbeddedResource Include="Resources\Logic.Structure.Geography.ru-RU.resx" />
<EmbeddedResource Include="Resources\Logic.Structure.Geography.sv-SE.resx" />
<EmbeddedResource Include="Resources\Logic.Structure.Geography.zh-CN.resx" />
<EmbeddedResource Include="Resources\Logic.Support.ErrorMessages.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Logic.Support.ErrorMessages.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Logic.Swarm.DashboardTodos.af-ZA.resx" />
<EmbeddedResource Include="Resources\Logic.Swarm.DashboardTodos.ar-SA.resx" />
<EmbeddedResource Include="Resources\Logic.Swarm.DashboardTodos.da-DK.resx" />
+153
View File
@@ -0,0 +1,153 @@
//------------------------------------------------------------------------------
// <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 Swarmops.Logic.Resources {
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 Logic_Support_ErrorMessages {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Logic_Support_ErrorMessages() {
}
/// <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("Swarmops.Logic.Resources.Logic.Support.ErrorMessages", typeof(Logic_Support_ErrorMessages).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;
}
}
/// <summary>
/// Looks up a localized string similar to The server has lost the connection to the bitcoin blockchain. Bitcoin transactions won&apos;t be detected in real time..
/// </summary>
internal static string Backend_BlockchainSocketLost_Text {
get {
return ResourceManager.GetString("Backend_BlockchainSocketLost_Text", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Blockchain Connection Lost.
/// </summary>
internal static string Backend_BlockchainSocketLost_Title {
get {
return ResourceManager.GetString("Backend_BlockchainSocketLost_Title", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The web browser is unable to hear the server&apos;s heartbeat..
/// </summary>
internal static string Client_ServerHeartbeatLost_Text {
get {
return ResourceManager.GetString("Client_ServerHeartbeatLost_Text", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Heartbeat Failure Level 1.
/// </summary>
internal static string Client_ServerHeartbeatLost_Title {
get {
return ResourceManager.GetString("Client_ServerHeartbeatLost_Title", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unable to connect to the server for real-time updates..
/// </summary>
internal static string Client_SocketConnectionFault_Text {
get {
return ResourceManager.GetString("Client_SocketConnectionFault_Text", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to WebSocket Failure.
/// </summary>
internal static string Client_SocketConnectionFault_Title {
get {
return ResourceManager.GetString("Client_SocketConnectionFault_Title", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The server is unable to connect to the backend process. Real-time updates will be largely unavailable..
/// </summary>
internal static string Frontend_BackendConnectionFault_Text {
get {
return ResourceManager.GetString("Frontend_BackendConnectionFault_Text", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Backend Connection Failure.
/// </summary>
internal static string Frontend_BackendConnectionFault_Title {
get {
return ResourceManager.GetString("Frontend_BackendConnectionFault_Title", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The server cannot hear the heartbeat from the backend process..
/// </summary>
internal static string Frontend_BackendHeartbeatLost_Text {
get {
return ResourceManager.GetString("Frontend_BackendHeartbeatLost_Text", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Heartbeat Failure Level 2.
/// </summary>
internal static string Frontend_BackendHeartbeatLost_Title {
get {
return ResourceManager.GetString("Frontend_BackendHeartbeatLost_Title", resourceCulture);
}
}
}
}
@@ -0,0 +1,150 @@
<?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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
<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" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</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" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Backend_BlockchainSocketLost_Text" xml:space="preserve">
<value>The server has lost the connection to the bitcoin blockchain. Bitcoin transactions won't be detected in real time.</value>
</data>
<data name="Backend_BlockchainSocketLost_Title" xml:space="preserve">
<value>Blockchain Connection Lost</value>
</data>
<data name="Client_ServerHeartbeatLost_Text" xml:space="preserve">
<value>The web browser is unable to hear the server's heartbeat.</value>
</data>
<data name="Client_ServerHeartbeatLost_Title" xml:space="preserve">
<value>Heartbeat Failure Level 1</value>
</data>
<data name="Client_SocketConnectionFault_Text" xml:space="preserve">
<value>Unable to connect to the server for real-time updates.</value>
</data>
<data name="Client_SocketConnectionFault_Title" xml:space="preserve">
<value>WebSocket Failure</value>
</data>
<data name="Frontend_BackendConnectionFault_Text" xml:space="preserve">
<value>The server is unable to connect to the backend process. Real-time updates will be largely unavailable.</value>
</data>
<data name="Frontend_BackendConnectionFault_Title" xml:space="preserve">
<value>Backend Connection Failure</value>
</data>
<data name="Frontend_BackendHeartbeatLost_Text" xml:space="preserve">
<value>The server cannot hear the heartbeat from the backend process.</value>
</data>
<data name="Frontend_BackendHeartbeatLost_Title" xml:space="preserve">
<value>Heartbeat Failure Level 2</value>
</data>
</root>
+1
View File
@@ -9,3 +9,4 @@ Logic.Structure.Geography.resx
Logic.Swarm.DashboardTodos.resx
Logic.Swarm.ParticipantTitle.resx
Logic.Swarm.Position.resx
Logic.Support.ErrorMessages.resx
+29
View File
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading.Tasks;
using Swarmops.Logic.Resources;
namespace Swarmops.Logic.Support
{
public class ErrorMessages
{
public static string Localize(string errorMessage, string culture = null)
{
if (String.IsNullOrEmpty(culture))
{
return @"<strong>" + Logic_Support_ErrorMessages.ResourceManager.GetString(errorMessage + "_Title") +
@":</strong> " +
Logic_Support_ErrorMessages.ResourceManager.GetString(errorMessage + "_Text");
}
else
{
return @"<strong>" + Logic_Support_ErrorMessages.ResourceManager.GetString(errorMessage + "_Title", CultureInfo.CreateSpecificCulture(culture)) +
@":</strong> " +
Logic_Support_ErrorMessages.ResourceManager.GetString(errorMessage + "_Text", CultureInfo.CreateSpecificCulture(culture));
}
}
}