Cordonel EOL API
This commit is contained in:
+115
-29
@@ -1,46 +1,132 @@
|
||||
namespace CommonConsole
|
||||
{
|
||||
using OmniPlus;
|
||||
using OmniPlus.Features;
|
||||
using OmniPlus.Features.Enums;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Xylem.Common.Logic.SoftwareAccessHelper;
|
||||
|
||||
public class Program
|
||||
{
|
||||
const string BASE_URL = "http://localhost:52822/LaaProductionWeb/api/cordonels/eolprogress";
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
var connection = new OmniIrdaConnection("COM26");
|
||||
connection.StateChenged += Console.WriteLine;
|
||||
var pcbid = 1000000001;
|
||||
var model = new EOLProgressModel { PcbId = pcbid };
|
||||
var response = $"{BASE_URL}/{pcbid}".GetAsJson<EOLProgressModel>();
|
||||
|
||||
connection.Open();
|
||||
model = response.Value ?? new EOLProgressModel();
|
||||
|
||||
Console.WriteLine(connection.ViewBuildInformation().Value);
|
||||
Console.WriteLine(connection.ViewFactoryCorrection().Value);
|
||||
LogErrors(response.Errors);
|
||||
LogModel(model);
|
||||
|
||||
var rs = connection.ViewRegisterSettings();
|
||||
//connection.ViewBuildInformation();
|
||||
//connection.ViewFactoryCorrection();
|
||||
//var defaults = connection.ViewInputVolume();
|
||||
//connection.Set(new RegisterSettings
|
||||
//{
|
||||
// IntPart = defaults.IntPart,
|
||||
// Fraction = defaults.Fraction,
|
||||
// Size = defaults.Size,
|
||||
// Range = defaults.Range,
|
||||
// VolumePerPulseUnit = 0,
|
||||
// MeterUnits = (byte)MessurementUnits.CubicMeters,
|
||||
// FlowUnits = (byte)MessurementUnits.CubicMeters,
|
||||
// FlowRate = (byte)TimeUnits.Hours,
|
||||
// FactoryCorrection = 0,
|
||||
// FieldCorrection = 0,
|
||||
// PulseWeight = 0,
|
||||
// PulseWidth = 7,
|
||||
// PulseUpdate = 0,
|
||||
//});
|
||||
model.RebootDone = "OK";
|
||||
model.ExportDone = "OK";
|
||||
model.ParameterizationDone = "OK";
|
||||
model.ProductionStatusChecked = "FAIL";
|
||||
|
||||
response = model.PutAsJson<EOLProgressModel>(BASE_URL);
|
||||
|
||||
connection.Close();
|
||||
model = response.Value ?? new EOLProgressModel();
|
||||
|
||||
LogErrors(response.Errors);
|
||||
LogModel(model);
|
||||
|
||||
model.RebootDone = "FAIL";
|
||||
model.ExportDone = "FAIL";
|
||||
model.ParameterizationDone = "FAIL";
|
||||
model.ProductionStatusChecked = "OK";
|
||||
|
||||
response = model.PutAsJson<EOLProgressModel>(BASE_URL);
|
||||
|
||||
model = response.Value ?? new EOLProgressModel();
|
||||
|
||||
LogErrors(response.Errors);
|
||||
LogModel(model);
|
||||
|
||||
model.SentinelDate = DateTime.Now;
|
||||
model.PasswordFileInstalled = "OK";
|
||||
model.RequirementChecked = "OK";
|
||||
model.StoreConfigurationDone = "NA";
|
||||
|
||||
response = model.PutAsJson<EOLProgressModel>(BASE_URL);
|
||||
|
||||
model = response.Value ?? new EOLProgressModel();
|
||||
|
||||
LogErrors(response.Errors);
|
||||
LogModel(model);
|
||||
|
||||
response = $"{BASE_URL}/{model.PcbId}/OK".PostAsJson<EOLProgressModel>();
|
||||
|
||||
model = response.Value ?? new EOLProgressModel();
|
||||
|
||||
LogErrors(response.Errors);
|
||||
LogModel(model);
|
||||
|
||||
response = $"{BASE_URL}/{model.PcbId}".DeleteAsJson<EOLProgressModel>();
|
||||
|
||||
model = response.Value ?? new EOLProgressModel();
|
||||
|
||||
LogErrors(response.Errors);
|
||||
LogModel(model);
|
||||
}
|
||||
|
||||
private static void LogModel(EOLProgressModel model)
|
||||
{
|
||||
if (model != null)
|
||||
{
|
||||
Console.WriteLine(JsonConvert.SerializeObject(model, Formatting.Indented));
|
||||
}
|
||||
}
|
||||
|
||||
private static void LogErrors(Dictionary<String, String> errors)
|
||||
{
|
||||
if (errors != null)
|
||||
{
|
||||
foreach (var kvp in errors)
|
||||
{
|
||||
Console.WriteLine($"{kvp.Key}: {kvp.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EOLProgressModel
|
||||
{
|
||||
public Int32 Id { get; set; }
|
||||
|
||||
public Int32 PcbId { get; set; }
|
||||
|
||||
public Int32? RequirementId { get; set; }
|
||||
|
||||
public String RequirementChecked { get; set; }
|
||||
|
||||
public String PasswordFileInstalled { get; set; }
|
||||
|
||||
public String ProductionStatusChecked { get; set; }
|
||||
|
||||
public String ParameterizationDone { get; set; }
|
||||
|
||||
public String RebootDone { get; set; }
|
||||
|
||||
public String StoreConfigurationDone { get; set; }
|
||||
|
||||
public String ExportDone { get; set; }
|
||||
|
||||
public Int64? RaioCheckId { get; set; }
|
||||
|
||||
public DateTime? SentinelDate { get; set; }
|
||||
|
||||
public String Completed { get; set; }
|
||||
|
||||
public DateTime? CompleteDate { get; set; }
|
||||
|
||||
public String CompleteHost { get; set; }
|
||||
|
||||
public DateTime AddDate { get; set; }
|
||||
|
||||
public String AddHost { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user