FIX assisted tooling
Fix maintenances
This commit is contained in:
@@ -37,7 +37,7 @@ namespace Step.Database.Controllers
|
||||
where m1.MaintenanceId == maintenances.MaintenanceId
|
||||
select m1.Date
|
||||
).Max()
|
||||
select maintenances)
|
||||
select maintenances)
|
||||
.Include("Maintainer")
|
||||
.ToList();
|
||||
|
||||
@@ -362,11 +362,11 @@ namespace Step.Database.Controllers
|
||||
public bool CheckPassword(string password, string machineNumber, uint plcCounter, out int cw)
|
||||
{
|
||||
cw = -1;
|
||||
if (String.IsNullOrEmpty(password))
|
||||
|
||||
if (!GetDataFromMaintenancePassword(password, out int pwdMachineNumber, out int pwdHours, out cw))
|
||||
return false;
|
||||
|
||||
GetDataFromMaintenancePassword(password, out int pwdMachineNumber, out int pwdHours, out cw);
|
||||
// Check machine number
|
||||
// Check machine number
|
||||
if(machineNumber == pwdMachineNumber.ToString())
|
||||
{
|
||||
// Convert plcCounter in hours and check if password is expired
|
||||
@@ -379,13 +379,19 @@ namespace Step.Database.Controllers
|
||||
return false; // Invalid Password
|
||||
}
|
||||
|
||||
private void GetDataFromMaintenancePassword(string password, out int number, out int hours, out int cw)
|
||||
private bool GetDataFromMaintenancePassword(string password, out int number, out int hours, out int cw)
|
||||
{
|
||||
number = -1;
|
||||
hours = -1;
|
||||
cw = -1;
|
||||
|
||||
if (String.IsNullOrEmpty(password))
|
||||
return false;
|
||||
|
||||
string tmpPassword1 = "",
|
||||
tmpPassword3 = "",
|
||||
tmpPassword4 = "",
|
||||
tmpPassword5 = "";
|
||||
int controlNumber = 0;
|
||||
|
||||
Hashtable htCifrario = new Hashtable
|
||||
{
|
||||
@@ -411,7 +417,10 @@ namespace Step.Database.Controllers
|
||||
}
|
||||
|
||||
// Get control number
|
||||
controlNumber = Convert.ToInt32(Right(tmpPassword5, 1));
|
||||
var stringCw = Right(tmpPassword5, 1);
|
||||
if (!int.TryParse(stringCw, out int controlNumber))
|
||||
return false;
|
||||
|
||||
tmpPassword4 = tmpPassword5.Remove(tmpPassword5.Length - 1);
|
||||
|
||||
// Create tmpPassoword3
|
||||
@@ -437,6 +446,8 @@ namespace Step.Database.Controllers
|
||||
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
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string Right(string value, int size)
|
||||
|
||||
Reference in New Issue
Block a user