QAP Request for VB6
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
{
|
{
|
||||||
private readonly Queue<Equipment> equipments = new Queue<Equipment>();
|
private readonly Queue<Equipment> equipments = new Queue<Equipment>();
|
||||||
|
|
||||||
|
public Error Error { get; set; }
|
||||||
|
|
||||||
public bool Succeeded => this.Error is null;
|
public bool Succeeded => this.Error is null;
|
||||||
|
|
||||||
public int Count => this.equipments.Count;
|
public int Count => this.equipments.Count;
|
||||||
@@ -24,8 +26,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Error Error { get; set; }
|
|
||||||
|
|
||||||
internal void AddRange(IEnumerable<Equipment> equipments)
|
internal void AddRange(IEnumerable<Equipment> equipments)
|
||||||
{
|
{
|
||||||
if (equipments is null)
|
if (equipments is null)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
<Compile Include="LoginModel.cs" />
|
<Compile Include="LoginModel.cs" />
|
||||||
<Compile Include="EquipmentsResult.cs" />
|
<Compile Include="EquipmentsResult.cs" />
|
||||||
<Compile Include="Programm.cs" />
|
<Compile Include="Programm.cs" />
|
||||||
<Compile Include="Equipments.cs" />
|
<Compile Include="LaaProductionAPI.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Error.cs" />
|
<Compile Include="Error.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -10,13 +10,16 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
[ClassInterface(ClassInterfaceType.AutoDual)]
|
[ClassInterface(ClassInterfaceType.AutoDual)]
|
||||||
public partial class Equipments
|
public partial class LaaProductionAPI
|
||||||
{
|
{
|
||||||
|
private const string Bearer = nameof(Bearer);
|
||||||
|
private const string RoutePrefix = "/LaaProductionWeb/API";
|
||||||
|
|
||||||
private readonly HttpClient httpClient;
|
private readonly HttpClient httpClient;
|
||||||
|
|
||||||
private string bearer;
|
private string bearer;
|
||||||
|
|
||||||
public Equipments()
|
public LaaProductionAPI()
|
||||||
{
|
{
|
||||||
this.httpClient = new HttpClient()
|
this.httpClient = new HttpClient()
|
||||||
{
|
{
|
||||||
@@ -46,7 +49,7 @@
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, new Uri("/LaaProductionWeb/api/Login/Local", UriKind.Relative)))
|
using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, new Uri($"{RoutePrefix}/Login/Local", UriKind.Relative)))
|
||||||
{
|
{
|
||||||
httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
|
httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
@@ -105,18 +108,19 @@
|
|||||||
return default(string);
|
return default(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EquipmentsResult PendingInspections()
|
public EquipmentsResult GetPendingInspections()
|
||||||
{
|
{
|
||||||
var result = new EquipmentsResult();
|
var result = new EquipmentsResult();
|
||||||
var uri = new Uri($"/LaaProductionWeb/api/Personalization/Software/PendingInspections", UriKind.Relative);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var uri = new Uri($"{RoutePrefix}/Personalization/Software/PendingInspections", UriKind.Relative);
|
||||||
|
|
||||||
using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri))
|
using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri))
|
||||||
{
|
{
|
||||||
httpRequestMessage
|
httpRequestMessage
|
||||||
.Headers
|
.Headers
|
||||||
.Authorization = new AuthenticationHeaderValue("Bearer", this.bearer);
|
.Authorization = new AuthenticationHeaderValue(Bearer, this.bearer);
|
||||||
|
|
||||||
var httpResponseMessage = this.httpClient
|
var httpResponseMessage = this.httpClient
|
||||||
.SendAsync(httpRequestMessage)
|
.SendAsync(httpRequestMessage)
|
||||||
@@ -174,5 +178,51 @@
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Error TryRequestQAP(int auftragNr, int positionNr)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var uri = new Uri($"{RoutePrefix}/Production/VFM/QAPReady/{auftragNr}/{positionNr}", UriKind.Relative);
|
||||||
|
|
||||||
|
using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri))
|
||||||
|
{
|
||||||
|
httpRequestMessage
|
||||||
|
.Headers
|
||||||
|
.Authorization = new AuthenticationHeaderValue(Bearer, this.bearer);
|
||||||
|
|
||||||
|
var httpResponseMessage = this.httpClient
|
||||||
|
.SendAsync(httpRequestMessage)
|
||||||
|
.ConfigureAwait(true)
|
||||||
|
.GetAwaiter()
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
|
using (httpResponseMessage)
|
||||||
|
{
|
||||||
|
if (httpResponseMessage.IsSuccessStatusCode == false)
|
||||||
|
{
|
||||||
|
var responseContent = httpResponseMessage
|
||||||
|
.Content
|
||||||
|
.ReadAsStringAsync()
|
||||||
|
.ConfigureAwait(true)
|
||||||
|
.GetAwaiter()
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
|
return JsonConvert.DeserializeObject<Error>(responseContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return new Error
|
||||||
|
{
|
||||||
|
Message = e.Message,
|
||||||
|
MessageDetail = e.StackTrace
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return default(Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,11 +4,10 @@
|
|||||||
//{
|
//{
|
||||||
// static void Main()
|
// static void Main()
|
||||||
// {
|
// {
|
||||||
// var equipmentsManager = new Equipments();
|
// var api = new LaaProductionAPI();
|
||||||
// var state = equipmentsManager.Login("Druckpruefung", 1, 0, 130, "zlatev", "rd");
|
// var login = api.Login("Druckpruefung", 1, 0, 130, "zlatev", "rd");
|
||||||
// var count = equipmentsManager.PendingInspections();
|
// var inspections = api.GetPendingInspections();
|
||||||
|
// var requestQAP = api.SendQAPReady(0, 0);
|
||||||
// System.Console.WriteLine(state);
|
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
{
|
{
|
||||||
var existing = this.equipments.FindById(pruefmittelId);
|
var existing = this.equipments.FindById(pruefmittelId);
|
||||||
|
|
||||||
if (existing is null || existing.PruefdatumIst >= DateTime.Now)
|
if (existing is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
|
|
||||||
//[Authorize]
|
[Authorize]
|
||||||
[RoutePrefix("API/Production/VFM")]
|
[RoutePrefix("API/Production/VFM")]
|
||||||
public class VFMController : ApiController
|
public class VFMController : ApiController
|
||||||
{
|
{
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
.SetParameter(nameof(positionNr), positionNr)
|
.SetParameter(nameof(positionNr), positionNr)
|
||||||
.FirstOrDefault(x => x.GetInt());
|
.FirstOrDefault(x => x.GetInt());
|
||||||
|
|
||||||
|
// TODO: Change to ... > 0 for production.
|
||||||
if (rowsCount >= 0)
|
if (rowsCount >= 0)
|
||||||
{
|
{
|
||||||
var statusFertigung = this.sqlConnection
|
var statusFertigung = this.sqlConnection
|
||||||
@@ -81,6 +82,7 @@
|
|||||||
.From("Stoyan.Zlatev@xylem.com")
|
.From("Stoyan.Zlatev@xylem.com")
|
||||||
.To("Roland.Drabesch@xylem.com")
|
.To("Roland.Drabesch@xylem.com")
|
||||||
.CC("Stoyan.Zlatev@xylem.com")
|
.CC("Stoyan.Zlatev@xylem.com")
|
||||||
|
// TODO: use below addresses for production
|
||||||
//.To("Peter.Roth@xylem.com", "Benjamin.Job@xylem.com")
|
//.To("Peter.Roth@xylem.com", "Benjamin.Job@xylem.com")
|
||||||
//.CC("Jens.Schulz@xylem.com", "Thomas.Quedenbaum@xylem.com", "Stoyan.Zlatev@xylem.com")
|
//.CC("Jens.Schulz@xylem.com", "Thomas.Quedenbaum@xylem.com", "Stoyan.Zlatev@xylem.com")
|
||||||
.Subject($"QAP: {auftragNr}/{positionNr} ist durch versandfertigmachen abgeschlossen.")
|
.Subject($"QAP: {auftragNr}/{positionNr} ist durch versandfertigmachen abgeschlossen.")
|
||||||
|
|||||||
Reference in New Issue
Block a user