WIP maintenances
This commit is contained in:
+3
-3
@@ -19,8 +19,8 @@ namespace CMS_Client
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
//Set the Mutef of GUID
|
||||
static Mutex CmsStepMutex = new Mutex(true, "{66fa29db-925a-402b-a4c7-d3d780fb1bc3}");
|
||||
//Set the Mutex of GUID
|
||||
static Mutex CmsStepClientMutex = new Mutex(true, "{66fa29db-925a-402b-a4c7-d3d780fb1bc3}");
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -51,7 +51,7 @@ namespace CMS_Client
|
||||
|
||||
|
||||
//Check if is already running an instance of this application
|
||||
if (!CmsStepMutex.WaitOne(TimeSpan.Zero, true))
|
||||
if (!CmsStepClientMutex.WaitOne(TimeSpan.Zero, true))
|
||||
ShowAlarmAndClose("Only one istance of " + Application.ProductName + " can be executed!");
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<maintenance>
|
||||
<id>1</id>
|
||||
<localizedNames>
|
||||
<lang langKey="en">Test</lang>
|
||||
<lang langKey="it">Ita</lang>
|
||||
</localizedNames>
|
||||
<interval>5000</interval>
|
||||
</maintenance>
|
||||
<maintenance>
|
||||
<id>2</id>
|
||||
<localizedNames>
|
||||
<lang langKey="en">Test</lang>
|
||||
<lang langKey="it">Ita</lang>
|
||||
</localizedNames>
|
||||
<interval>5000</interval>
|
||||
</maintenance>
|
||||
</root>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="root">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="maintenance" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="id" type="xs:int"/>
|
||||
<xs:element name="localizedNames">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="lang" type="langType" minOccurs="0" maxOccurs="unbounded">
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:unique name="UniqueLangKey">
|
||||
<xs:selector xpath="lang" />
|
||||
<xs:field xpath="@langKey" />
|
||||
</xs:unique>
|
||||
|
||||
</xs:element>
|
||||
<xs:element name="interval" type="xs:int"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:unique name="UniqueId">
|
||||
<xs:selector xpath="maintenance" />
|
||||
<xs:field xpath="@id" />
|
||||
</xs:unique>
|
||||
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:complexType name="langType">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute name="langKey" use="required" type="xs:string"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
|
||||
</xs:schema>
|
||||
@@ -13,6 +13,7 @@ namespace Step.Config
|
||||
public static ServerConfigModel ServerStartupConfig;
|
||||
public static NcConfigModel NcConfig;
|
||||
public static MachineModel MachineConfig;
|
||||
public static List<MaintenanceConfigModel> MaintenancesConfig;
|
||||
|
||||
public static AreasConfigModel ProductionConfig;
|
||||
public static AreasConfigModel ToolingConfig;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using System;
|
||||
using System.Xml.Schema;
|
||||
using System.Xml.Linq;
|
||||
using System.Linq;
|
||||
using static Step.Config.ServerConfig;
|
||||
using Step.Model.ConfigModels;
|
||||
using static Step.Utils.Constants;
|
||||
using Step.Model.ConfigModels;
|
||||
using Step.Utils;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.Schema;
|
||||
using static Step.Config.ServerConfig;
|
||||
using static Step.Utils.Constants;
|
||||
|
||||
namespace Step.Config
|
||||
{
|
||||
@@ -52,6 +51,24 @@ namespace Step.Config
|
||||
.ToList()
|
||||
.ForEach(x => SetAreaValueByName(x)); // Loop through elements
|
||||
|
||||
// Get Maintenances file handler
|
||||
xmlConfigFile = GetXmlHandlerWithValidator(MAINTENANCES_CONFIG_SCHEMA_PATH, MAINTENANCES_CONFIG_PATH);
|
||||
|
||||
MaintenancesConfig = xmlConfigFile
|
||||
.Root
|
||||
.Elements()
|
||||
.ToList()
|
||||
.Select(x =>
|
||||
new MaintenanceConfigModel()
|
||||
{
|
||||
Id = Convert.ToInt32(x.Element("id").Value),
|
||||
LocalizedNames = x.Element("localizedNames").Elements().ToDictionary( // Read names list
|
||||
y => y.Attribute("langKey").Value, y => y.Value
|
||||
),
|
||||
count = Convert.ToInt32(x.Element("interval").Value)
|
||||
}
|
||||
)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -64,7 +81,7 @@ namespace Step.Config
|
||||
// Create new instance
|
||||
XmlSchemaSet readerSettings = new XmlSchemaSet();
|
||||
// Add Schema
|
||||
readerSettings.Add(null, BASE_PATH + "\\" + configSchemaFilePath );
|
||||
readerSettings.Add(null, BASE_PATH + "\\" + configSchemaFilePath);
|
||||
|
||||
// Open file reader
|
||||
XDocument xmlConfigFile = XDocument.Load(BASE_PATH + "\\" + configFilePath);
|
||||
@@ -82,21 +99,27 @@ namespace Step.Config
|
||||
case AREAS.PRODUCTION_KEY:
|
||||
SetAreaValue(ref ProductionConfig, element);
|
||||
break;
|
||||
|
||||
case AREAS.TOOLING_KEY:
|
||||
SetAreaValue(ref ToolingConfig, element);
|
||||
break;
|
||||
|
||||
case AREAS.REPORT_KEY:
|
||||
SetAreaValue(ref ReportConfig, element);
|
||||
break;
|
||||
|
||||
case AREAS.ALARMS_KEY:
|
||||
SetAreaValue(ref AlarmsConfig, element);
|
||||
break;
|
||||
|
||||
case AREAS.MAINTENANCE_KEY:
|
||||
SetAreaValue(ref MaintenanceConfig, element);
|
||||
break;
|
||||
|
||||
case AREAS.UTILITIES_KEY:
|
||||
SetAreaValue(ref UtilitiesConfig, element);
|
||||
break;
|
||||
|
||||
case AREAS.SCADA_KEY:
|
||||
SetAreaValue(ref ScadaConfig, element);
|
||||
break;
|
||||
@@ -133,23 +156,31 @@ namespace Step.Config
|
||||
{
|
||||
case AREAS.PRODUCTION_KEY:
|
||||
return ProductionConfig.Enabled;
|
||||
|
||||
case AREAS.TOOLING_KEY:
|
||||
return ToolingConfig.Enabled;
|
||||
|
||||
case AREAS.REPORT_KEY:
|
||||
return ProductionConfig.Enabled;
|
||||
|
||||
case AREAS.ALARMS_KEY:
|
||||
return AlarmsConfig.Enabled;
|
||||
|
||||
case AREAS.MAINTENANCE_KEY:
|
||||
return MaintenanceConfig.Enabled;
|
||||
|
||||
case AREAS.UTILITIES_KEY:
|
||||
return UtilitiesConfig.Enabled;
|
||||
|
||||
case AREAS.SCADA_KEY:
|
||||
return ScadaConfig.Enabled;
|
||||
|
||||
case AREAS.GENERAL_KEY:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,14 @@
|
||||
<Content Include="Config\areasConfig.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Config\maintenancesConfig.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<None Include="Config\maintenancesConfigValidator.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Include="Config\serverConfigValidator.xsd">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using Step.Model.DatabaseModels;
|
||||
using Step.Model.DTOModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static Step.Config.ServerConfig;
|
||||
|
||||
namespace Step.Database.Controllers
|
||||
{
|
||||
public class MaintenancesController : IDisposable
|
||||
{
|
||||
private DatabaseContext dbCtx;
|
||||
|
||||
public MaintenancesController()
|
||||
{
|
||||
// Initialize database context
|
||||
dbCtx = new DatabaseContext();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
dbCtx.Dispose();
|
||||
}
|
||||
|
||||
public DTOExpiredMaintenanceModel GetExpiredMaintenance()
|
||||
{
|
||||
return new DTOExpiredMaintenanceModel();
|
||||
}
|
||||
|
||||
public void CheckDifferencesFromDbAndXml()
|
||||
{
|
||||
List<MaintenanceModel> dbMaintenances = dbCtx
|
||||
.Maintenances
|
||||
.ToList();
|
||||
|
||||
// Find database rows that
|
||||
List<MaintenanceModel> toDeleteMaint = dbMaintenances.Where(x =>
|
||||
!MaintenancesConfig.Select(y => y.Id).Contains(x.MaintenanceId)
|
||||
).ToList();
|
||||
|
||||
// Find common data from
|
||||
List<MaintenanceModel> toUpdateMaint = dbMaintenances.Where(x =>
|
||||
MaintenancesConfig.Select(y => y.Id).Contains(x.MaintenanceId)
|
||||
).ToList();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using Step.Model.DatabaseModels;
|
||||
using Microsoft.Win32;
|
||||
using MySql.Data.Entity;
|
||||
using static Step.Utils.ExceptionManager;
|
||||
using static Step.Utils.Constants;
|
||||
using Step.Database.Migrations;
|
||||
using System.IO;
|
||||
using Step.Database.Controllers;
|
||||
using static Step.Config.ServerConfig;
|
||||
using Microsoft.Win32;
|
||||
using Step.Database.Migrations;
|
||||
using Step.Model.DatabaseModels;
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using static Step.Config.ServerConfig;
|
||||
using static Step.Utils.Constants;
|
||||
using static Step.Utils.ExceptionManager;
|
||||
|
||||
namespace Step.Database
|
||||
{
|
||||
@@ -23,7 +23,7 @@ namespace Step.Database
|
||||
public DbSet<RoleModel> Roles { get; set; }
|
||||
public DbSet<FunctionAccessModel> FunctionsAccess { get; set; }
|
||||
public DbSet<SessionModel> Sessions { get; set; }
|
||||
|
||||
public DbSet<MaintenanceModel> Maintenances { get; set; }
|
||||
|
||||
public DatabaseContext()
|
||||
: base("mySQLDatabaseConnection")
|
||||
@@ -56,6 +56,11 @@ namespace Step.Database
|
||||
}
|
||||
|
||||
FindOrCreateMachineUniqueId();
|
||||
|
||||
using (MaintenancesController maintenancesController = new MaintenancesController())
|
||||
{
|
||||
maintenancesController.CheckDifferencesFromDbAndXml();
|
||||
}
|
||||
}
|
||||
catch (MySql.Data.MySqlClient.MySqlException ex)
|
||||
{
|
||||
@@ -149,9 +154,8 @@ namespace Step.Database
|
||||
RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
|
||||
// Get ..//CMS/Step subkey
|
||||
key = key.CreateSubKey("Cms").CreateSubKey("Step");
|
||||
// Return value
|
||||
// Return value
|
||||
return (string)key.GetValue(REGISTER_MACHINE_ID_KEY_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// <auto-generated />
|
||||
namespace Step.Database.Migrations
|
||||
{
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Data.Entity.Migrations.Infrastructure;
|
||||
using System.Resources;
|
||||
|
||||
[GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")]
|
||||
public sealed partial class InitCreate : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(InitCreate));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "201802051555548_InitCreate"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
namespace Step.Database.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class InitCreate : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
CreateTable(
|
||||
"dbo.function_access",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
name = c.String(unicode: false),
|
||||
write_level_min = c.Int(nullable: false),
|
||||
read_level_min = c.Int(nullable: false),
|
||||
area = c.String(unicode: false),
|
||||
enabled = c.Boolean(nullable: false),
|
||||
plc_id = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.machine",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
name = c.String(unicode: false),
|
||||
unique_id = c.String(unicode: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.machine_user",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
machine_id = c.Int(nullable: false),
|
||||
user_id = c.Int(nullable: false),
|
||||
role_id = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id)
|
||||
.ForeignKey("dbo.machine", t => t.machine_id, cascadeDelete: true)
|
||||
.ForeignKey("dbo.role", t => t.role_id, cascadeDelete: true)
|
||||
.ForeignKey("dbo.user", t => t.user_id, cascadeDelete: true)
|
||||
.Index(t => new { t.machine_id, t.user_id }, unique: true, clustered: true, name: "unique_machine_user")
|
||||
.Index(t => t.role_id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.role",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
name = c.String(unicode: false),
|
||||
level = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.user",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
username = c.String(nullable: false, unicode: false),
|
||||
first_name = c.String(unicode: false),
|
||||
last_name = c.String(unicode: false),
|
||||
password = c.String(unicode: false),
|
||||
security_stamp = c.String(unicode: false),
|
||||
language = c.String(unicode: false),
|
||||
role_id = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.session",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
token = c.String(unicode: false),
|
||||
machine_user_id = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id)
|
||||
.ForeignKey("dbo.machine_user", t => t.machine_user_id, cascadeDelete: true)
|
||||
.Index(t => t.machine_user_id);
|
||||
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
DropForeignKey("dbo.session", "machine_user_id", "dbo.machine_user");
|
||||
DropForeignKey("dbo.machine_user", "user_id", "dbo.user");
|
||||
DropForeignKey("dbo.machine_user", "role_id", "dbo.role");
|
||||
DropForeignKey("dbo.machine_user", "machine_id", "dbo.machine");
|
||||
DropIndex("dbo.session", new[] { "machine_user_id" });
|
||||
DropIndex("dbo.machine_user", new[] { "role_id" });
|
||||
DropIndex("dbo.machine_user", "unique_machine_user");
|
||||
DropTable("dbo.session");
|
||||
DropTable("dbo.user");
|
||||
DropTable("dbo.role");
|
||||
DropTable("dbo.machine_user");
|
||||
DropTable("dbo.machine");
|
||||
DropTable("dbo.function_access");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
<?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="Target" xml:space="preserve">
|
||||
<value>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</value>
|
||||
</data>
|
||||
<data name="DefaultSchema" xml:space="preserve">
|
||||
<value>dbo</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -72,14 +72,11 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\FunctionsAccessController.cs" />
|
||||
<Compile Include="Controllers\MachinesController.cs" />
|
||||
<Compile Include="Controllers\MaintenancesController.cs" />
|
||||
<Compile Include="Controllers\SessionsController.cs" />
|
||||
<Compile Include="Controllers\UsersController.cs" />
|
||||
<Compile Include="Controllers\MachinesUsersController.cs" />
|
||||
<Compile Include="DatabaseContext.cs" />
|
||||
<Compile Include="Migrations\201802051555548_InitCreate.cs" />
|
||||
<Compile Include="Migrations\201802051555548_InitCreate.Designer.cs">
|
||||
<DependentUpon>201802051555548_InitCreate.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\Configuration.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
@@ -113,10 +110,5 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Migrations\201802051555548_InitCreate.resx">
|
||||
<DependentUpon>201802051555548_InitCreate.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.ConfigModels
|
||||
{
|
||||
public class MaintenanceConfigModel
|
||||
{
|
||||
public int Id;
|
||||
public Dictionary<string, string> LocalizedNames;
|
||||
public int count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DTOModels
|
||||
{
|
||||
public class DTOExpiredMaintenanceModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ExpirationDate { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
[Table("function_access")]
|
||||
|
||||
public class FunctionAccessModel
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int FunctionAccessId { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column("write_level_min")]
|
||||
public int WriteLevelMin { get; set; }
|
||||
|
||||
[Column("read_level_min")]
|
||||
public int ReadLevelMin { get; set; }
|
||||
|
||||
[Column("area")]
|
||||
public string Area { get; set; }
|
||||
|
||||
[Column("enabled")]
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
[Column("plc_id")]
|
||||
public int PlcId { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
@@ -14,9 +9,11 @@ namespace Step.Model.DatabaseModels
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int MachineId { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
public string Model { get; set; }
|
||||
|
||||
[Column("unique_id")]
|
||||
public string UniqueId { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
@@ -18,18 +13,21 @@ namespace Step.Model.DatabaseModels
|
||||
[Index("unique_machine_user", IsClustered = true, IsUnique = true, Order = 1)]
|
||||
[Column(name: "machine_id")]
|
||||
public int MachineId { get; set; }
|
||||
|
||||
[ForeignKey("MachineId")]
|
||||
public MachineModel Machine { get; set; }
|
||||
|
||||
[Index("unique_machine_user", IsClustered = true, IsUnique = true, Order = 2)]
|
||||
[Column(name: "user_id")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
public UserModel User { get; set; }
|
||||
|
||||
[Column(name: "role_id")]
|
||||
public int RoleId { get; set; }
|
||||
|
||||
[ForeignKey("RoleId")]
|
||||
public RoleModel Role { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
[Table("maintenance")]
|
||||
public class MaintenanceModel
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int MaintenanceId { get; set; }
|
||||
|
||||
[Column("intervall")]
|
||||
public TimeSpan Intervall { get; set; }
|
||||
|
||||
[Column("deadline")]
|
||||
public DateTime DeadLine { get; set; }
|
||||
|
||||
[Column("type")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[Column("counter_id")]
|
||||
public int CounterId { get; set; }
|
||||
|
||||
[Column("creation_date")]
|
||||
public DateTime CreationDate { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var item = obj as MaintenanceModel;
|
||||
|
||||
if (item == null)
|
||||
return false;
|
||||
|
||||
if (item.MaintenanceId != MaintenanceId)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
[Table("machine_user")]
|
||||
public class PerformedMaintenanceModel
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int PerformedMaintenanceId { get; set; }
|
||||
|
||||
[Column("date")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[Column("counter_value")]
|
||||
public int CounterValue { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
@@ -14,9 +9,11 @@ namespace Step.Model.DatabaseModels
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int RoleId { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column("level")]
|
||||
public int Level { get; set; }
|
||||
public int Level { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
@@ -14,12 +9,14 @@ namespace Step.Model.DatabaseModels
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int SessionId { get; set; }
|
||||
|
||||
[Column("token")]
|
||||
public string Token { get; set; }
|
||||
|
||||
[Column("machine_user_id")]
|
||||
public int MachineUserId { get; set; }
|
||||
|
||||
[ForeignKey("MachineUserId")]
|
||||
public MachineUserModel MachineUser { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
@@ -16,29 +10,38 @@ namespace Step.Model.DatabaseModels
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
[Column("first_name")]
|
||||
public string FirstName { get; set; }
|
||||
|
||||
[Column("last_name")]
|
||||
public string LastName { get; set; }
|
||||
|
||||
[Column("password")]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Column("security_stamp")]
|
||||
public string SecurityStamp { get; set; }
|
||||
|
||||
[Column("language")]
|
||||
public string _language { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public CultureInfo Language {
|
||||
get {
|
||||
public CultureInfo Language
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_language != null)
|
||||
return new CultureInfo(_language);
|
||||
else
|
||||
return new CultureInfo("en-US");
|
||||
}
|
||||
set {
|
||||
set
|
||||
{
|
||||
_language = value.TwoLetterISOLanguageName;
|
||||
}
|
||||
}
|
||||
@@ -46,4 +49,4 @@ namespace Step.Model.DatabaseModels
|
||||
[Column("role_id")]
|
||||
public int RoleId { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,12 +60,15 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConfigModels\MaintenanceConfigModel.cs" />
|
||||
<Compile Include="ConfigModels\ServerConfigModel.cs" />
|
||||
<Compile Include="ConfigModels\AreasConfigModel.cs" />
|
||||
<Compile Include="ConfigModels\NcConfigModel.cs" />
|
||||
<Compile Include="DatabaseModels\FunctionAccessModel.cs" />
|
||||
<Compile Include="ConfigModels\MessageModel.cs" />
|
||||
<Compile Include="DatabaseModels\MachineModel.cs" />
|
||||
<Compile Include="DatabaseModels\MaintenanceModel.cs" />
|
||||
<Compile Include="DatabaseModels\PerformedMaintenanceModel.cs" />
|
||||
<Compile Include="DatabaseModels\RoleModel.cs">
|
||||
<Generator>DtsGenerator</Generator>
|
||||
<LastGenOutput>RoleModel.cs.d.ts</LastGenOutput>
|
||||
@@ -75,6 +78,7 @@
|
||||
<Compile Include="DTOModels\DTOAlarmsModel.cs" />
|
||||
<Compile Include="DTOModels\DTOAxesModel.cs" />
|
||||
<Compile Include="DTOModels\DTOClientConfigurationModel.cs" />
|
||||
<Compile Include="DTOModels\DTOExpiredMaintenanceModel.cs" />
|
||||
<Compile Include="DTOModels\DTOLanguageModel.cs">
|
||||
<Generator>DtsGenerator</Generator>
|
||||
<LastGenOutput>DTOLanguageModel.cs.d.ts</LastGenOutput>
|
||||
|
||||
@@ -63,6 +63,9 @@ namespace Step.Utils
|
||||
public const string AREAS_CONFIG_SCHEMA_PATH = CONFIG_DIRECTORY + "areasConfigValidator.xsd";
|
||||
public const string AREAS_CONFIG_PATH = CONFIG_DIRECTORY + "areasConfig.xml";
|
||||
|
||||
public const string MAINTENANCES_CONFIG_SCHEMA_PATH = CONFIG_DIRECTORY + "maintenancesConfigValidator.xsd";
|
||||
public const string MAINTENANCES_CONFIG_PATH = CONFIG_DIRECTORY + "maintenancesConfig.xml";
|
||||
|
||||
public static string WEBSITE_DIRECTORY = Path.Combine(BASE_PATH, "..", "wwwroot");
|
||||
public static string LANGUAGE_PACK_DIRECTORY = BASE_PATH + "\\languages\\";
|
||||
public static string LANGUAGE_SCHEMA_PATH = BASE_PATH + "\\LanguageValidator.xsd";
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Xml.Linq;
|
||||
using System.Xml.Schema;
|
||||
using Step.Model.DTOModels;
|
||||
using static Step.Utils.Constants;
|
||||
|
||||
|
||||
namespace Step.Utils
|
||||
{
|
||||
|
||||
@@ -4,8 +4,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using Step.Model.ConfigModels;
|
||||
using Step.Model.DTOModels;
|
||||
using static Step.Utils.Constants;
|
||||
using static Step.Config.ServerConfig;
|
||||
using static Step.Utils.LanguageController;
|
||||
|
||||
namespace Step.Controllers.WebApi
|
||||
@@ -34,10 +35,38 @@ namespace Step.Controllers.WebApi
|
||||
|
||||
Dictionary<string, string> translations = GetTranslationsFromFile(language);
|
||||
|
||||
// Get Maintenance translations
|
||||
Dictionary<string, string> maintenance = GetLocalizeMaintenanceName(language, MaintenancesConfig);
|
||||
|
||||
// Concat 2 array
|
||||
translations = translations.Concat(maintenance).ToDictionary(x => x.Key, x => x.Value);
|
||||
|
||||
if (translations == null)
|
||||
return InternalServerError();
|
||||
|
||||
return Ok(translations);
|
||||
}
|
||||
|
||||
|
||||
public static Dictionary<string, string> GetLocalizeMaintenanceName(string language, List<MaintenanceConfigModel> maitenancesConfig)
|
||||
{
|
||||
Dictionary<string, string> returnDictionary = new Dictionary<string, string>();
|
||||
|
||||
return MaintenancesConfig
|
||||
.ToDictionary(
|
||||
x => "MANT_" + x.Id.ToString(),
|
||||
x => GetValueFromMaintenanceNameList(x.LocalizedNames, language, x.Id)
|
||||
);
|
||||
}
|
||||
|
||||
public static string GetValueFromMaintenanceNameList(Dictionary<string, string> localizedNames, string language, int maintenanceId)
|
||||
{
|
||||
var value = localizedNames.Where(y => y.Key == language).FirstOrDefault();
|
||||
|
||||
if (value.Key == null)
|
||||
return "Maintenance string not found for id: " + maintenanceId;
|
||||
else
|
||||
return value.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using Step.Database;
|
||||
using Step.Core;
|
||||
using Step.Listeners;
|
||||
using System;
|
||||
using Step.Utils;
|
||||
|
||||
namespace Step
|
||||
{
|
||||
@@ -17,12 +18,19 @@ namespace Step
|
||||
{
|
||||
|
||||
public static readonly ManualResetEvent StopRequest = new ManualResetEvent(false);
|
||||
//Set the Mutef of GUID
|
||||
private static Mutex CmsStepMutex = new Mutex(true, "{689e76ce-b845-49f0-919c-c26491079fca}");
|
||||
|
||||
public static int MessageService { get; private set; }
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
LogInfo("Application started");
|
||||
|
||||
//Check if is already running an instance of this application
|
||||
if (!CmsStepMutex.WaitOne(TimeSpan.Zero, true))
|
||||
ExceptionManager.Manage(ERROR_LEVEL.FATAL, "Only one istance of can be executed!");
|
||||
|
||||
ServerConfigController.ReadStartupConfig();
|
||||
|
||||
DatabaseContext.TestDatabaseConnection();
|
||||
|
||||
Reference in New Issue
Block a user