merge
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Logic.ProductionToProductMapper.Cordonel;
|
||||
using Common.Logic.Extensions.SQL;
|
||||
using Logic.ProductionToProductMapper.Cordonel;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
@@ -1270,6 +1271,71 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
return Request.CreateResponse(HttpStatusCode.ExpectationFailed, ex.ToString() + "<br >" + ex.InnerException.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[Route("CalibrationResults/{pcbId}")]
|
||||
public IHttpActionResult CalibrationResults(String pcbId)
|
||||
{
|
||||
var result = SQLConnection
|
||||
.CreateSQLConnection(GlobalConfig.ConnectionString.Value)
|
||||
.CreateCommand($@"
|
||||
SELECT TOP 1
|
||||
ID
|
||||
, PcbId
|
||||
, CalFactor1
|
||||
, CalFactor2
|
||||
, CalFactor3
|
||||
, ZeroOffset1
|
||||
, ZeroOffset2
|
||||
, ZeroOffset3
|
||||
, FirstHitUpdatePeriod
|
||||
, FirstHitShift
|
||||
, FirstHitPercent1
|
||||
, FirstHitPercent2
|
||||
, FirstHitPercent3
|
||||
, ToFTempOffset1
|
||||
, ToFTempOffset2
|
||||
, ToFTempOffset3
|
||||
, MeterSize
|
||||
, date
|
||||
, successful
|
||||
FROM CordonelMeterCalibrationResults
|
||||
WHERE successful = 1
|
||||
AND PcbId = @{nameof(pcbId)}
|
||||
ORDER BY date DESC")
|
||||
.SetParameter(nameof(pcbId), pcbId)
|
||||
.FirstOrDefault(x => new
|
||||
{
|
||||
Id = x.GetValue<Int32>(0),
|
||||
PcbId = x.GetValue<String>(1),
|
||||
CalFactor1 = x.GetValue<Int32>(2),
|
||||
CalFactor2 = x.GetValue<Int32>(3),
|
||||
CalFactor3 = x.GetValue<Int32>(4),
|
||||
ZeroOffset1 = x.GetValue<Int32>(5),
|
||||
ZeroOffset2 = x.GetValue<Int32>(6),
|
||||
ZeroOffset3 = x.GetValue<Int32>(7),
|
||||
FirstHitUpdatePeriod = x.GetValue<Int32>(8),
|
||||
FirstHitShift = x.GetValue<Int32>(9),
|
||||
FirstHitPercent1 = x.GetValue<Int32>(10),
|
||||
FirstHitPercent2 = x.GetValue<Int32>(11),
|
||||
FirstHitPercent3 = x.GetValue<Int32>(12),
|
||||
ToFTempOffset1 = x.GetValue<Int32>(13),
|
||||
ToFTempOffset2 = x.GetValue<Int32>(14),
|
||||
ToFTempOffset3 = x.GetValue<Int32>(15),
|
||||
MeterSize = x.GetValue<Int32>(16),
|
||||
Date = x.GetValue<DateTime>(17),
|
||||
Succeeded = x.GetValue<Boolean>(18),
|
||||
});
|
||||
|
||||
if (result is null)
|
||||
{
|
||||
return this.NotFound();
|
||||
}
|
||||
|
||||
return this.Json(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Common.Logic.Extensions.SQL;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -208,6 +209,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
JObject jsonData = new JObject();
|
||||
saveRssiToDb(SaveData);
|
||||
jsonData.Add("message", "ok");
|
||||
jsonData.Add("radiocheckid", saveRssiToDb(SaveData));
|
||||
return Json(JObject.FromObject(jsonData));
|
||||
}
|
||||
|
||||
@@ -215,32 +217,40 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
/// Speichert das SaveData Object
|
||||
/// </summary>
|
||||
/// <param name="SaveData"></param>
|
||||
private void saveRssiToDb(SaveDataClass SaveData)
|
||||
private Int64 saveRssiToDb(SaveDataClass SaveData)
|
||||
{
|
||||
var sql = new StringBuilder();
|
||||
var sqlConnection = SQLConnection.CreateSQLConnection(GlobalConfig.connectionString.Value);
|
||||
|
||||
sql.AppendLine($" Update [Cordonel_Radio_RSSI_History] Set IsLast = 0 WHERE [RadioAdress] = {SaveData.RadioAdress}");
|
||||
using (SqlCommand sqlcommand = new SqlCommand(sql.ToString(), connection))
|
||||
{
|
||||
sqlcommand.ExecuteNonQuery();
|
||||
}
|
||||
sqlConnection
|
||||
.CreateCommand($@"
|
||||
UPDATE Cordonel_Radio_RSSI_History
|
||||
SET IsLast = 0
|
||||
WHERE RadioAdress = @{nameof(SaveData.RadioAdress)}")
|
||||
.SetParameter(nameof(SaveData.RadioAdress), (Int64)SaveData.RadioAdress)
|
||||
.ExecuteNonQuery();
|
||||
|
||||
|
||||
sql = new StringBuilder();
|
||||
sql.AppendLine($" Insert into [Cordonel_Radio_RSSI_History] ");
|
||||
sql.AppendLine($" ([RadioAdress],[RSSI_PAM],[RSSI_SEMI],[LimitId],[Result]) VALUES ( ");
|
||||
sql.AppendLine($" {SaveData.RadioAdress},");
|
||||
sql.AppendLine($" {SaveData.RSSI_PAM},");
|
||||
sql.AppendLine($" {SaveData.RSSI_SEMI},");
|
||||
sql.AppendLine($" {SaveData.LimitId},");
|
||||
sql.AppendLine($" {SaveData.Result}");
|
||||
sql.AppendLine($" )");
|
||||
|
||||
using (SqlCommand sqlcommand = new SqlCommand(sql.ToString(), connection))
|
||||
{
|
||||
sqlcommand.ExecuteNonQuery();
|
||||
}
|
||||
return sqlConnection
|
||||
.CreateCommand($@"
|
||||
INSERT INTO Cordonel_Radio_RSSI_History
|
||||
( RadioAdress
|
||||
, RSSI_PAM
|
||||
, RSSI_SEMI
|
||||
, Datum
|
||||
, LimitId
|
||||
, Result)
|
||||
OUTPUT inserted.id
|
||||
VALUES (@{nameof(SaveData.RadioAdress)}
|
||||
, @{nameof(SaveData.RSSI_PAM)}
|
||||
, @{nameof(SaveData.RSSI_SEMI)}
|
||||
, CURRENT_TIMESTAMP
|
||||
, @{nameof(SaveData.LimitId)}
|
||||
, @{nameof(SaveData.Result)})")
|
||||
.SetParameter(nameof(SaveData.RadioAdress), (Int64)SaveData.RadioAdress)
|
||||
.SetParameter(nameof(SaveData.RSSI_PAM), SaveData.RSSI_PAM)
|
||||
.SetParameter(nameof(SaveData.RSSI_SEMI), SaveData.RSSI_SEMI)
|
||||
.SetParameter(nameof(SaveData.LimitId), SaveData.LimitId)
|
||||
.SetParameter(nameof(SaveData.Result), SaveData.Result)
|
||||
.ExecuteScalar(x => x.GetValue<Int64>(0));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@
|
||||
return this.BadRequest("Invalid data.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[Route("GetTestResults"), HttpGet]
|
||||
public IHttpActionResult GetTestResults(int SerialNr, int TestRunNr)
|
||||
@@ -357,22 +357,22 @@
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return this.Content(HttpStatusCode.OK, tr);
|
||||
}
|
||||
}
|
||||
|
||||
return this.Content(HttpStatusCode.OK, tr);
|
||||
public class CordonelCalibration
|
||||
{
|
||||
public int PcbId { get; set; }
|
||||
|
||||
public int TestRunNr { get; set; }
|
||||
|
||||
public double Offset { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class CordonelCalibration
|
||||
{
|
||||
public int PcbId { get; set; }
|
||||
|
||||
public int TestRunNr { get; set; }
|
||||
|
||||
public double Offset { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user