Aggiunto metodo x salvare bunk...

This commit is contained in:
Samuele E. Locatelli
2019-11-06 19:39:56 +01:00
parent bf6b28d594
commit cb604cf9bf
6 changed files with 300 additions and 148 deletions
Vendored
+1 -1
View File
@@ -17,7 +17,7 @@ pipeline {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=119']) {
withEnv(['NEXT_BUILD_NUMBER=121']) {
// env.versionNumber = VersionNumber(versionNumberString : '0.7.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2019-07-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '0.7.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2019-07-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.APP_NAME = 'NKC'
+45 -29
View File
@@ -1,34 +1,8 @@
using Newtonsoft.Json;
using System;
using System.Net;
namespace NKC_SDK
{
/// <summary>
/// Override metodo WebClient con gestione TimeOut corto
/// </summary>
public class WebClientWT : WebClient
{
/// <summary>
/// timeout da conf
/// </summary>
protected int urlCallTOut
{
get
{
// 5 sec timeout
return 10000;
}
}
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest wr = base.GetWebRequest(address);
wr.Timeout = urlCallTOut; // timeout in milliseconds (ms)
return wr;
}
}
public class NKC
{
#region utils comunicazione HTTP
@@ -49,7 +23,7 @@ namespace NKC_SDK
{
answ = client.DownloadString(URL);
}
catch (Exception exc)
catch
{ }
// restituisco valore!
return answ;
@@ -69,15 +43,37 @@ namespace NKC_SDK
{
answ = client.UploadString(URL, payload);
}
catch (Exception exc)
catch
{ }
// restituisco valore!
return answ;
}
/// <summary>
/// Effettua chiamata PUT
/// </summary>
/// <param name="URL"></param>
/// <param name="payload"></param>
/// <returns></returns>
public static string putData(string URL, string payload)
{
string answ = "";
var client = new WebClientWT();
client.Headers.Add("user-agent", "NKC_SDK");
try
{
answ = client.UploadString(URL, payload);
}
catch
{ }
// restituisco valore!
return answ;
}
#endregion
#region fon di base
#region URL di base
protected string urlCurrBunk
{
@@ -94,6 +90,10 @@ namespace NKC_SDK
{
return $"{_baseUrl}api/Bunk/{currBunkId}?showNext=true";
}
protected string urlPutBunk(int currBunkId)
{
return $"{_baseUrl}api/Bunk/{currBunkId}";
}
#endregion
@@ -171,6 +171,22 @@ namespace NKC_SDK
{ }
return answ;
}
/// <summary>
/// Effettua salvataggio del BUNK corrente su NKC
/// </summary>
/// <param name="currBunk"></param>
public void saveBunk(ProdBunk currBunk)
{
try
{
// serializzo oggetto
string rawdata = JsonConvert.SerializeObject(currBunk);
// invio con metodo put!
putData(urlPutBunk(currBunk.BunkId), rawdata);
}
catch
{ }
}
}
}
+2 -3
View File
@@ -47,11 +47,10 @@
<Link>VersGen.cs</Link>
</Compile>
<Compile Include="Enums.cs" />
<Compile Include="NKC.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="NKC.cs" />
<Compile Include="Objects.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
+33
View File
@@ -0,0 +1,33 @@
using System;
using System.Net;
namespace NKC_SDK
{
public class Utils
{
}
/// <summary>
/// Override metodo WebClient con gestione TimeOut corto
/// </summary>
public class WebClientWT : WebClient
{
/// <summary>
/// timeout da conf
/// </summary>
protected int urlCallTOut
{
get
{
// 5 sec timeout
return 10000;
}
}
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest wr = base.GetWebRequest(address);
wr.Timeout = urlCallTOut; // timeout in milliseconds (ms)
return wr;
}
}
}
+141 -80
View File
@@ -22,30 +22,36 @@ Partial Class Form1
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.btnReset = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.Button2 = New System.Windows.Forms.Button()
Me.Button3 = New System.Windows.Forms.Button()
Me.btnLoadBunk = New System.Windows.Forms.Button()
Me.btnPrintStart = New System.Windows.Forms.Button()
Me.cmbSheet = New System.Windows.Forms.ComboBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Button4 = New System.Windows.Forms.Button()
Me.Button5 = New System.Windows.Forms.Button()
Me.Button6 = New System.Windows.Forms.Button()
Me.Button7 = New System.Windows.Forms.Button()
Me.Button8 = New System.Windows.Forms.Button()
Me.btnPrintEnd = New System.Windows.Forms.Button()
Me.btnWorkStart = New System.Windows.Forms.Button()
Me.btnWorkEnd = New System.Windows.Forms.Button()
Me.btnUnlStart = New System.Windows.Forms.Button()
Me.btnUnlEnd = New System.Windows.Forms.Button()
Me.btnNextBunk = New System.Windows.Forms.Button()
Me.txtCurrBunk = New System.Windows.Forms.TextBox()
Me.lblNextBunk = New System.Windows.Forms.Label()
Me.txtPrintStart = New System.Windows.Forms.TextBox()
Me.txtWorkStart = New System.Windows.Forms.TextBox()
Me.txtUnlStart = New System.Windows.Forms.TextBox()
Me.txtUnlEnd = New System.Windows.Forms.TextBox()
Me.txtWorkEnd = New System.Windows.Forms.TextBox()
Me.txtPrintEnd = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'Button1
'btnReset
'
Me.Button1.Location = New System.Drawing.Point(86, 360)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseVisualStyleBackColor = True
Me.btnReset.Location = New System.Drawing.Point(86, 360)
Me.btnReset.Name = "btnReset"
Me.btnReset.Size = New System.Drawing.Size(75, 23)
Me.btnReset.TabIndex = 0
Me.btnReset.Text = "reset Date"
Me.btnReset.UseVisualStyleBackColor = True
'
'Label1
'
@@ -56,26 +62,27 @@ Partial Class Form1
Me.Label1.TabIndex = 1
Me.Label1.Text = "Label1"
'
'Button2
'btnLoadBunk
'
Me.Button2.Location = New System.Drawing.Point(64, 36)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(75, 23)
Me.Button2.TabIndex = 2
Me.Button2.Text = "Load BUNK"
Me.Button2.UseVisualStyleBackColor = True
Me.btnLoadBunk.Location = New System.Drawing.Point(64, 36)
Me.btnLoadBunk.Name = "btnLoadBunk"
Me.btnLoadBunk.Size = New System.Drawing.Size(75, 23)
Me.btnLoadBunk.TabIndex = 2
Me.btnLoadBunk.Text = "Load BUNK"
Me.btnLoadBunk.UseVisualStyleBackColor = True
'
'Button3
'btnPrintStart
'
Me.Button3.Location = New System.Drawing.Point(64, 165)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(75, 23)
Me.Button3.TabIndex = 3
Me.Button3.Text = "Start Paint"
Me.Button3.UseVisualStyleBackColor = True
Me.btnPrintStart.Location = New System.Drawing.Point(64, 165)
Me.btnPrintStart.Name = "btnPrintStart"
Me.btnPrintStart.Size = New System.Drawing.Size(75, 23)
Me.btnPrintStart.TabIndex = 3
Me.btnPrintStart.Text = "Start Paint"
Me.btnPrintStart.UseVisualStyleBackColor = True
'
'cmbSheet
'
Me.cmbSheet.DisplayMember = "SheetId"
Me.cmbSheet.FormattingEnabled = True
Me.cmbSheet.Location = New System.Drawing.Point(423, 38)
Me.cmbSheet.Name = "cmbSheet"
@@ -91,50 +98,50 @@ Partial Class Form1
Me.Label2.TabIndex = 5
Me.Label2.Text = "current sheet"
'
'Button4
'btnPrintEnd
'
Me.Button4.Location = New System.Drawing.Point(294, 165)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(75, 23)
Me.Button4.TabIndex = 6
Me.Button4.Text = "End Paint"
Me.Button4.UseVisualStyleBackColor = True
Me.btnPrintEnd.Location = New System.Drawing.Point(423, 165)
Me.btnPrintEnd.Name = "btnPrintEnd"
Me.btnPrintEnd.Size = New System.Drawing.Size(75, 23)
Me.btnPrintEnd.TabIndex = 6
Me.btnPrintEnd.Text = "End Paint"
Me.btnPrintEnd.UseVisualStyleBackColor = True
'
'Button5
'btnWorkStart
'
Me.Button5.Location = New System.Drawing.Point(64, 209)
Me.Button5.Name = "Button5"
Me.Button5.Size = New System.Drawing.Size(75, 23)
Me.Button5.TabIndex = 7
Me.Button5.Text = "Start Cut"
Me.Button5.UseVisualStyleBackColor = True
Me.btnWorkStart.Location = New System.Drawing.Point(64, 209)
Me.btnWorkStart.Name = "btnWorkStart"
Me.btnWorkStart.Size = New System.Drawing.Size(75, 23)
Me.btnWorkStart.TabIndex = 7
Me.btnWorkStart.Text = "Start Cut"
Me.btnWorkStart.UseVisualStyleBackColor = True
'
'Button6
'btnWorkEnd
'
Me.Button6.Location = New System.Drawing.Point(294, 209)
Me.Button6.Name = "Button6"
Me.Button6.Size = New System.Drawing.Size(75, 23)
Me.Button6.TabIndex = 8
Me.Button6.Text = "End Cut"
Me.Button6.UseVisualStyleBackColor = True
Me.btnWorkEnd.Location = New System.Drawing.Point(423, 209)
Me.btnWorkEnd.Name = "btnWorkEnd"
Me.btnWorkEnd.Size = New System.Drawing.Size(75, 23)
Me.btnWorkEnd.TabIndex = 8
Me.btnWorkEnd.Text = "End Cut"
Me.btnWorkEnd.UseVisualStyleBackColor = True
'
'Button7
'btnUnlStart
'
Me.Button7.Location = New System.Drawing.Point(64, 251)
Me.Button7.Name = "Button7"
Me.Button7.Size = New System.Drawing.Size(75, 23)
Me.Button7.TabIndex = 9
Me.Button7.Text = "Start Unload"
Me.Button7.UseVisualStyleBackColor = True
Me.btnUnlStart.Location = New System.Drawing.Point(64, 251)
Me.btnUnlStart.Name = "btnUnlStart"
Me.btnUnlStart.Size = New System.Drawing.Size(75, 23)
Me.btnUnlStart.TabIndex = 9
Me.btnUnlStart.Text = "Start Unload"
Me.btnUnlStart.UseVisualStyleBackColor = True
'
'Button8
'btnUnlEnd
'
Me.Button8.Location = New System.Drawing.Point(294, 251)
Me.Button8.Name = "Button8"
Me.Button8.Size = New System.Drawing.Size(75, 23)
Me.Button8.TabIndex = 10
Me.Button8.Text = "End Unload"
Me.Button8.UseVisualStyleBackColor = True
Me.btnUnlEnd.Location = New System.Drawing.Point(423, 251)
Me.btnUnlEnd.Name = "btnUnlEnd"
Me.btnUnlEnd.Size = New System.Drawing.Size(75, 23)
Me.btnUnlEnd.TabIndex = 10
Me.btnUnlEnd.Text = "End Unload"
Me.btnUnlEnd.UseVisualStyleBackColor = True
'
'btnNextBunk
'
@@ -163,25 +170,73 @@ Partial Class Form1
Me.lblNextBunk.Text = "---"
Me.lblNextBunk.Visible = False
'
'txtPrintStart
'
Me.txtPrintStart.Location = New System.Drawing.Point(159, 168)
Me.txtPrintStart.Name = "txtPrintStart"
Me.txtPrintStart.Size = New System.Drawing.Size(142, 20)
Me.txtPrintStart.TabIndex = 14
'
'txtWorkStart
'
Me.txtWorkStart.Location = New System.Drawing.Point(159, 211)
Me.txtWorkStart.Name = "txtWorkStart"
Me.txtWorkStart.Size = New System.Drawing.Size(142, 20)
Me.txtWorkStart.TabIndex = 15
'
'txtUnlStart
'
Me.txtUnlStart.Location = New System.Drawing.Point(159, 253)
Me.txtUnlStart.Name = "txtUnlStart"
Me.txtUnlStart.Size = New System.Drawing.Size(142, 20)
Me.txtUnlStart.TabIndex = 16
'
'txtUnlEnd
'
Me.txtUnlEnd.Location = New System.Drawing.Point(526, 252)
Me.txtUnlEnd.Name = "txtUnlEnd"
Me.txtUnlEnd.Size = New System.Drawing.Size(142, 20)
Me.txtUnlEnd.TabIndex = 19
'
'txtWorkEnd
'
Me.txtWorkEnd.Location = New System.Drawing.Point(526, 210)
Me.txtWorkEnd.Name = "txtWorkEnd"
Me.txtWorkEnd.Size = New System.Drawing.Size(142, 20)
Me.txtWorkEnd.TabIndex = 18
'
'txtPrintEnd
'
Me.txtPrintEnd.Location = New System.Drawing.Point(526, 167)
Me.txtPrintEnd.Name = "txtPrintEnd"
Me.txtPrintEnd.Size = New System.Drawing.Size(142, 20)
Me.txtPrintEnd.TabIndex = 17
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(800, 450)
Me.Controls.Add(Me.txtUnlEnd)
Me.Controls.Add(Me.txtWorkEnd)
Me.Controls.Add(Me.txtPrintEnd)
Me.Controls.Add(Me.txtUnlStart)
Me.Controls.Add(Me.txtWorkStart)
Me.Controls.Add(Me.txtPrintStart)
Me.Controls.Add(Me.lblNextBunk)
Me.Controls.Add(Me.txtCurrBunk)
Me.Controls.Add(Me.btnNextBunk)
Me.Controls.Add(Me.Button8)
Me.Controls.Add(Me.Button7)
Me.Controls.Add(Me.Button6)
Me.Controls.Add(Me.Button5)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.btnUnlEnd)
Me.Controls.Add(Me.btnUnlStart)
Me.Controls.Add(Me.btnWorkEnd)
Me.Controls.Add(Me.btnWorkStart)
Me.Controls.Add(Me.btnPrintEnd)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.cmbSheet)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.btnPrintStart)
Me.Controls.Add(Me.btnLoadBunk)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.btnReset)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
@@ -189,18 +244,24 @@ Partial Class Form1
End Sub
Friend WithEvents Button1 As Button
Friend WithEvents btnReset As Button
Friend WithEvents Label1 As Label
Friend WithEvents Button2 As Button
Friend WithEvents Button3 As Button
Friend WithEvents btnLoadBunk As Button
Friend WithEvents btnPrintStart As Button
Friend WithEvents cmbSheet As ComboBox
Friend WithEvents Label2 As Label
Friend WithEvents Button4 As Button
Friend WithEvents Button5 As Button
Friend WithEvents Button6 As Button
Friend WithEvents Button7 As Button
Friend WithEvents Button8 As Button
Friend WithEvents btnPrintEnd As Button
Friend WithEvents btnWorkStart As Button
Friend WithEvents btnWorkEnd As Button
Friend WithEvents btnUnlStart As Button
Friend WithEvents btnUnlEnd As Button
Friend WithEvents btnNextBunk As Button
Friend WithEvents txtCurrBunk As TextBox
Friend WithEvents lblNextBunk As Label
Friend WithEvents txtPrintStart As TextBox
Friend WithEvents txtWorkStart As TextBox
Friend WithEvents txtUnlStart As TextBox
Friend WithEvents txtUnlEnd As TextBox
Friend WithEvents txtWorkEnd As TextBox
Friend WithEvents txtPrintEnd As TextBox
End Class
+78 -35
View File
@@ -1,5 +1,4 @@
Imports NKC_SDK
Imports SteamWare
Public Class Form1
@@ -9,53 +8,50 @@ Public Class Form1
' DEV: https : http://localhost:44388/
Dim baseUrl As String = "http://seriate.steamware.net:8083/NKC/"
Dim currNKC As NKC = New NKC(baseUrl)
Dim currentBunk As ProdBunk = Nothing
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' invio notifica che c'è una busta da processare
Dim redKey = $"PROVA:CURR"
' scrivo su REDIS
memLayer.ML.setRSV(redKey, "ciao " & DateTime.Now.ToString())
'ComLib.sendMaterials()
Label1.Text = memLayer.ML.getRSV(redKey)
'Dim x As New Takt
'x = readTakt("PROD", "20190821.1")
'x.StackList(0).PanelsList(0).Printing()
'Dim d = memLayer.ML.connRedis.Configure.
'Dim h = memLayer.ML.connRedis
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnReset.Click
' resetto TUTTE le date e salvo il bunk!
currentBunk.SheetList(cmbSheet.SelectedIndex).Printing.DtStart = Nothing
currentBunk.SheetList(cmbSheet.SelectedIndex).Printing.DtEnd = Nothing
currentBunk.SheetList(cmbSheet.SelectedIndex).Machining.DtStart = Nothing
currentBunk.SheetList(cmbSheet.SelectedIndex).Machining.DtEnd = Nothing
currentBunk.SheetList(cmbSheet.SelectedIndex).Unloading.DtStart = Nothing
currentBunk.SheetList(cmbSheet.SelectedIndex).Unloading.DtEnd = Nothing
' salvo!
currNKC.saveBunk(currentBunk)
'' invio notifica che c'è una busta da processare
'Dim redKey = $"PROVA:CURR"
'' scrivo su REDIS
'memLayer.ML.setRSV(redKey, "ciao " & DateTime.Now.ToString())
''ComLib.sendMaterials()
'Label1.Text = memLayer.ML.getRSV(redKey)
''Dim x As New Takt
''x = readTakt("PROD", "20190821.1")
''x.StackList(0).PanelsList(0).Printing()
''Dim d = memLayer.ML.connRedis.Configure.
''Dim h = memLayer.ML.connRedis
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
' recupero BUNK!
Dim getFirstBunk = currNKC.getFirstBunk
'' chiamata diretta redis + DB
'Dim getFirstBunk = ComLib.prodGetFirstBunk()
' ho un bunk coi suoi pannelli...
Label1.Text = $"Trovato il bunk {getFirstBunk.BunkId} costituito da {getFirstBunk.SheetList.Count} pannelli"
' salvo bunk corrente
txtCurrBunk.Text = getFirstBunk.BunkId
' visualizzo btn nextBunk
btnNextBunk.Visible = True
lblNextBunk.Visible = True
lblNextBunk.Text = "..."
End Sub
Private Sub cmbSheet_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbSheet.SelectedIndexChanged
' selezione cambiata su elenco sheet (dal primo all'ultimo a runtime OBBLIGATORIO)
updateDataButtons()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles btnPrintStart.Click
' iniziato paint x sheet selezionato
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles btnPrintEnd.Click
' completato paint x sheet selezionato
End Sub
@@ -77,4 +73,51 @@ Public Class Form1
End If
End Sub
Private Sub btnLoadBunk_Click(sender As Object, e As EventArgs) Handles btnLoadBunk.Click
' recupero BUNK!
currentBunk = currNKC.getFirstBunk
'' chiamata diretta redis + DB
'Dim getFirstBunk = ComLib.prodGetFirstBunk()
' ho un bunk coi suoi pannelli...
Label1.Text = $"Trovato il bunk {currentBunk.BunkId} costituito da {currentBunk.SheetList.Count} pannelli"
' salvo bunk corrente
txtCurrBunk.Text = currentBunk.BunkId
' visualizzo btn nextBunk
btnNextBunk.Visible = True
lblNextBunk.Visible = True
lblNextBunk.Text = "..."
' popolo il selettore dei fogli...
cmbSheet.DataSource = currentBunk.SheetList
updateDataButtons()
End Sub
Private Sub updateDataButtons()
' imposto dateora ed in base ai valori dt del currBunk abilito o meno i buttons...
txtPrintStart.Text = currentBunk.SheetList(cmbSheet.SelectedIndex).Printing.DtStart.ToString()
txtPrintEnd.Text = currentBunk.SheetList(cmbSheet.SelectedIndex).Printing.DtEnd.ToString()
txtWorkStart.Text = currentBunk.SheetList(cmbSheet.SelectedIndex).Machining.DtStart.ToString()
txtWorkEnd.Text = currentBunk.SheetList(cmbSheet.SelectedIndex).Machining.DtEnd.ToString()
txtUnlStart.Text = currentBunk.SheetList(cmbSheet.SelectedIndex).Unloading.DtStart.ToString()
txtUnlEnd.Text = currentBunk.SheetList(cmbSheet.SelectedIndex).Unloading.DtEnd.ToString()
btnPrintStart.Enabled = String.IsNullOrWhiteSpace(txtPrintStart.Text)
btnPrintEnd.Enabled = String.IsNullOrWhiteSpace(txtPrintEnd.Text)
btnWorkStart.Enabled = String.IsNullOrWhiteSpace(txtWorkStart.Text)
btnWorkEnd.Enabled = String.IsNullOrWhiteSpace(txtWorkEnd.Text)
btnUnlStart.Enabled = String.IsNullOrWhiteSpace(txtUnlStart.Text)
btnUnlEnd.Enabled = String.IsNullOrWhiteSpace(txtUnlEnd.Text)
End Sub
End Class