114 lines
3.8 KiB
C#
114 lines
3.8 KiB
C#
|
|
using Newtonsoft.Json;
|
|||
|
|
using System;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
using Xylem.Common.CommonCore.Configuration;
|
|||
|
|
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
|||
|
|
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
|
|||
|
|
using Xylem.Common.Logic.SoftwareAccessHelper;
|
|||
|
|
|
|||
|
|
namespace Xylem.Common.Ui.GenesisToolBox
|
|||
|
|
{
|
|||
|
|
public partial class FrmResearchMapping : Form
|
|||
|
|
{
|
|||
|
|
public FrmResearchMapping()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnStore_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
var url = $"{ServiceUrls.MeterProcessStateUrl()}SetPickingState?PcbID={txtPcbId.Text}&FertigungsauftragsNr={txtOrder.Text}";
|
|||
|
|
var retString = LocalWebRequest.PostRequestAsyncAndGetContent(url);
|
|||
|
|
|
|||
|
|
if (bool.TryParse(retString, out var result))
|
|||
|
|
{
|
|||
|
|
if (result)
|
|||
|
|
{
|
|||
|
|
url = $"{ServiceUrls.MarriageServiceUrl()}SetPcbToSerial?PcbId={txtPcbId.Text}&SerialNumber={txtSerialNr.Text}&returnMetroData=0";
|
|||
|
|
var resp = LocalWebRequest.GetRequest(url);
|
|||
|
|
|
|||
|
|
if (!string.IsNullOrEmpty(resp))
|
|||
|
|
{
|
|||
|
|
MessageBox.Show(@"Hat geklappt");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
result = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
if (!result)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show(@"Hat nicht geklappt");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnConnect_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (cbComSlot.SelectedItem != null) // && cbComSlot.SelectedValue is ListBoxItem)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) &&
|
|||
|
|
int.TryParse(cbComSlot.SelectedItem.ToString(), out var slot))
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (var meterBatch = new MeterBatch())
|
|||
|
|
{
|
|||
|
|
using (var currentGenesis = new GenesisMeter())
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
currentGenesis.SetupFromConfigFile(slot);
|
|||
|
|
meterBatch.AddMeter(currentGenesis);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show($@"Slot #{slot} failed: {ex.Message}");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
txtPcbId.Text = currentGenesis.GetPcbId();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show($@"failed: {ex.Message}");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnRead_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
txtSerialNr.Text = GetPcbMapping(txtPcbId.Text);
|
|||
|
|
}
|
|||
|
|
private String GetPcbMapping(String pcbId)
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(pcbId))
|
|||
|
|
{
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
var url = $"{ServiceUrls.MarriageServiceUrl()}GetSerialNumberAndOrderNumber?PcbId={pcbId}";
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var requestResponse = LocalWebRequest.GetRequest(url);
|
|||
|
|
|
|||
|
|
if (!string.IsNullOrEmpty(requestResponse))
|
|||
|
|
{
|
|||
|
|
var a = JsonConvert.DeserializeObject<String[]>(requestResponse);
|
|||
|
|
return a[0];
|
|||
|
|
}
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show(ex.Message);
|
|||
|
|
}
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|