WIP maintenances with password
Fix Siemens library
This commit is contained in:
Binary file not shown.
@@ -1003,7 +1003,7 @@ public static class ThreadsFunctions
|
||||
break;
|
||||
|
||||
case CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING:
|
||||
Manage(ERROR_LEVEL.FATAL, cmsError.localizationKey);
|
||||
Manage(ERROR_LEVEL.FATAL, "SIEMENS HMI NOT RUNNING");
|
||||
break;
|
||||
|
||||
case CMS_ERROR_CODES.INTERNAL_ERROR:
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Step.Database.Controllers
|
||||
.Where(x => x.MachineId == machineId && x.UserId == userId) // Find by machine id and user id, joining with role
|
||||
.FirstOrDefault();
|
||||
|
||||
if(machineUser != null)
|
||||
if (machineUser != null)
|
||||
{
|
||||
RoleModel role = machineUser.Role;
|
||||
return new DTORoleModel()
|
||||
@@ -83,7 +83,6 @@ namespace Step.Database.Controllers
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public bool UserIsCmsAdmin(int machineId, int userId)
|
||||
{
|
||||
MachineUserModel user = FindByUserId(machineId, userId);
|
||||
@@ -93,7 +92,6 @@ namespace Step.Database.Controllers
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public int CompareUsersRole(int firstUserId, int secondUserId, int machineId)
|
||||
{
|
||||
MachineUserModel firstUser = FindByUserId(machineId, firstUserId);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Step.Model.DTOModels;
|
||||
using Step.Model.DTOModels.MaintenanceModels;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.IO;
|
||||
@@ -356,5 +357,75 @@ namespace Step.Database.Controllers
|
||||
}
|
||||
|
||||
#endregion Attachment
|
||||
|
||||
|
||||
private void GetDataFromMaintenancePassword(string password, out int number, out int hours, out int cw)
|
||||
{
|
||||
string tmpPassword1 = "",
|
||||
tmpPassword3 = "",
|
||||
tmpPassword4 = "",
|
||||
tmpPassword5 = "";
|
||||
int controlNumber = 0;
|
||||
|
||||
Hashtable htCifrario = new Hashtable
|
||||
{
|
||||
{ "K", "0" },
|
||||
{ "M", "1" },
|
||||
{ "X", "2" },
|
||||
{ "N", "3" },
|
||||
{ "G", "4" },
|
||||
{ "V", "5" },
|
||||
{ "P", "6" },
|
||||
{ "Z", "7" },
|
||||
{ "H", "8" },
|
||||
{ "Q", "9" }
|
||||
};
|
||||
|
||||
// Create tmpPassword5 changing characters that matches with characters in the hashtable
|
||||
foreach (char c in password)
|
||||
{
|
||||
if (htCifrario.Contains(c))
|
||||
tmpPassword5 += htCifrario[c].ToString(); // Change character with hashtable val
|
||||
else
|
||||
tmpPassword5 += c;
|
||||
}
|
||||
|
||||
// Get control number
|
||||
controlNumber = Convert.ToInt32(Right(tmpPassword5, 1));
|
||||
tmpPassword4 = tmpPassword5.Remove(tmpPassword5.Length - 1);
|
||||
|
||||
// Create tmpPassoword3
|
||||
foreach(char c in tmpPassword4)
|
||||
{
|
||||
// If tmpPassword is empty copy the first character
|
||||
if(tmpPassword3.Length == 0)
|
||||
{
|
||||
tmpPassword3 = c.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if character is a number
|
||||
if (char.IsNumber(c))
|
||||
// Add first digit of -> Number + 10 - control number
|
||||
tmpPassword3 += Right((Convert.ToInt32(c) + 10 - controlNumber).ToString(), 1);
|
||||
else
|
||||
tmpPassword3 += c.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
tmpPassword1 = tmpPassword3.PadLeft(11, '0');
|
||||
hours = Convert.ToInt32(tmpPassword1.Substring(0, 5), 16); // Convert from hexadecimal
|
||||
number = Convert.ToInt32(tmpPassword1.Substring(5, 4), 16); // Convert from hexadecimal
|
||||
cw = Convert.ToInt32(tmpPassword1.Substring(9, 2), 16); // Convert from hexadecimal
|
||||
}
|
||||
|
||||
private static string Right(string value, int size)
|
||||
{
|
||||
// if length is greater than "size" resets "size"
|
||||
size = (value.Length < size ? value.Length : size);
|
||||
// Substring is the equivalent of VB NET RIGHT
|
||||
string newValue = value.Substring(value.Length - size);
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,8 @@ namespace Step.Utils
|
||||
Manage(errorLevel, exception.Message);
|
||||
}
|
||||
|
||||
private static bool MessageBoxShow = false;
|
||||
|
||||
public static void Manage(ERROR_LEVEL errorLevel, string message)
|
||||
{
|
||||
switch (errorLevel)
|
||||
@@ -70,16 +72,24 @@ namespace Step.Utils
|
||||
case ERROR_LEVEL.FATAL:
|
||||
{
|
||||
LogFatal(message);
|
||||
NotifyUsers(CreateMessageModel("Fatal Error!", message, ERROR_LEVEL.FATAL));
|
||||
// Close the application
|
||||
Environment.Exit(1);
|
||||
if (!MessageBoxShow)
|
||||
{
|
||||
MessageBoxShow = true;
|
||||
NotifyUsers(CreateMessageModel("Fatal Error!", message, ERROR_LEVEL.FATAL));
|
||||
// Close the application
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
LogFatal(message);
|
||||
NotifyUsers(CreateMessageModel("Generic Error!", message, ERROR_LEVEL.FATAL));
|
||||
// Close the application
|
||||
Environment.Exit(1);
|
||||
if (!MessageBoxShow)
|
||||
{
|
||||
MessageBoxShow = true;
|
||||
NotifyUsers(CreateMessageModel("Generic Error!", message, ERROR_LEVEL.FATAL));
|
||||
// Close the application
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -92,19 +102,12 @@ namespace Step.Utils
|
||||
NotifyUsers(error);
|
||||
}
|
||||
|
||||
private static bool MessageBoxShow = false;
|
||||
|
||||
private static void NotifyUsers(ErrorMessageModel error)
|
||||
{
|
||||
if (error.ErrorLevel > (int)ERROR_LEVEL.WARNING)
|
||||
{
|
||||
if (!MessageBoxShow)
|
||||
{
|
||||
MessageBoxShow = true;
|
||||
|
||||
// Notify user
|
||||
MessageBox.Show(error.Message, error.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
// Notify user
|
||||
MessageBox.Show(error.Message, error.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -53,7 +53,5 @@ namespace Step.Controllers.WebApi
|
||||
return Ok(favorite);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<modal :title="'modal_m155_title' | localize('Message from Process %d',process)" class="m155" :class="{'multiple': getType != REAL}" name="modal" >
|
||||
<div v-if="data">
|
||||
<h2 v-if="getType != SHOW_VAL">{{data.message}}</h2>
|
||||
<div class="content-real" v-if="getType == REAL">
|
||||
<h2>{{data.message}}</h2>
|
||||
<span>{{'modal_m155_value' | localize("Value: ")}}</span>
|
||||
<input type="number" min="0" max="4294967295" v-model="value">
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user