public override void Loading() { ICollection <LavieIndex> lavieIndexes = this.lavieAPIs.GetLavieIndexes(); //this.fastLavieIndex.SetObjects(lavieIndexes); REMARK HERE base.Loading(); this.LavieIndexes.RaiseListChangedEvents = false; this.LavieIndexes.Clear(); if (lavieIndexes.Count > 0) { int lineIndex = 0; lavieIndexes.Each(lavieIndex => { LavieIndexDTO lavieIndexDTO = Mapper.Map <LavieIndex, LavieIndexDTO>(lavieIndex); lavieIndexDTO.LineIndex = ++lineIndex; this.LavieIndexes.Add(lavieIndexDTO); }); } this.LavieIndexes.RaiseListChangedEvents = true; this.LavieIndexes.ResetBindings(); }
public void ThreadRoutine() { try { this.showStatus(this.buttonStart, 0, "Connecting ...", "", ""); this.ionetSocket.Connect(); //this.ioserialPort.Connect(); //////string curFile = @"c:\temp\PrintGo.txt"; string finishFile = @"c:\temp\Finish.txt"; //////if (!File.Exists(finishFile)) System.IO.File.WriteAllText(finishFile, ""); this.OnRunning = true; this.showStatus(this.buttonStart, 0, "Connected!", "#", "#"); int lavieIndex = this.LavieIndexes.Where(w => w.PrintedTimes == 0).First().LineIndex; int i = 0; while (this.OnRunning) { if (lavieIndex < (this.LavieIndexes.Count + 1)) { LavieIndexDTO lavieIndexDTO = this.LavieIndexes[lavieIndex - 1]; if (this.waitforReady()) { if (i++ <= 20 || this.lavieAPIs.SystemInfoValidate()) { //string[] lines = { "[Label 1]", "Label=LABEL", "Quantity=0", "Dyn01=" + lavieIndexDTO.ItemNumber, "Dyn02=" + lavieIndexDTO.ProductName, "Dyn03=" + lavieIndexDTO.GTIN, "Dyn04=" + lavieIndexDTO.PalletID, "Dyn05=" + lavieIndexDTO.BatchNumber, "Dyn06=" + ((DateTime)lavieIndexDTO.ExpirationDate).ToString("dd/MM/yyyy"), "Dyn07=" + ((decimal)lavieIndexDTO.Qty).ToString("N0"), "Dyn08=" + ((decimal)lavieIndexDTO.Layers).ToString("N0"), "Dyn09=" + lavieIndexDTO.GTINBarcode, "Dyn10=" + lavieIndexDTO.Barcode, "Dyn11=" + lavieIndexDTO.SerialID }; //string[] lines = { "[Label 1]", "PrinterIP=101.208.14.100:9100", "Label=LABEL", "Quantity=0", "Dyn01=" + lavieIndexDTO.ItemNumber, "Dyn02=" + lavieIndexDTO.ProductName, "Dyn03=" + lavieIndexDTO.GTIN, "Dyn04=" + lavieIndexDTO.PalletID, "Dyn05=" + lavieIndexDTO.BatchNumber, "Dyn06=" + ((DateTime)lavieIndexDTO.ExpirationDate).ToString("dd/MM/yyyy"), "Dyn07=" + ((decimal)lavieIndexDTO.Qty).ToString("N0"), "Dyn08=" + ((decimal)lavieIndexDTO.Layers).ToString("N0"), "Dyn09=" + lavieIndexDTO.GTINBarcode, "Dyn10=" + lavieIndexDTO.Barcode, "Dyn11=" + lavieIndexDTO.SerialID, SystemInfos.GetSystemInfos(true) }; //System.IO.File.WriteAllLines(curFile, lines); this.writeToBuffer(lavieIndexDTO);; Thread.Sleep(500); this.showStatus(this, lavieIndexDTO.LavieID, "#", "No: " + lavieIndexDTO.SerialID + "; Pallet ID: " + lavieIndexDTO.PalletID, "Printing"); } else { throw new Exception("Invalid version. Please contact your vendor for more information."); } } if (this.waitforPrinted()) { this.lavieAPIs.LavieUpdate(lavieIndexDTO.LavieID); lavieIndexDTO.PrintedTimes = 1; lavieIndex++; } } else { this.showStatus(this, -1, "#", "Finished!", "#"); //REACH THE LAST ROW => TO FINISH } Thread.Sleep(500); } } catch (Exception exception) { this.showStatus(this, 0, "Error", "#", exception.Message); this.buttonStop_Click(this, new EventArgs()); } finally { this.ionetSocket.Disconnect(); //this.ioserialPort.Disconnect(); this.showStatus(this.buttonStop, 0, "Disconnected!", "#", "#"); } }
private bool writeToBuffer(LavieIndexDTO lavieIndexDTO) { try { this.ionetSocket.WritetoStream(GlobalVariables.charSTX + "/0/41/C1/E1/" + GlobalVariables.charETB + "/D/" + lavieIndexDTO.ItemNumber + GlobalVariables.charLF + lavieIndexDTO.ProductName + GlobalVariables.charLF + lavieIndexDTO.GTIN + GlobalVariables.charLF + lavieIndexDTO.PalletID + GlobalVariables.charLF + lavieIndexDTO.BatchNumber + GlobalVariables.charLF + ((DateTime)lavieIndexDTO.ExpirationDate).ToString("dd/MM/yyyy") + GlobalVariables.charLF + ((decimal)lavieIndexDTO.Qty).ToString("N0") + GlobalVariables.charLF + ((decimal)lavieIndexDTO.Layers).ToString("N0") + GlobalVariables.charLF + lavieIndexDTO.GTINBarcode + GlobalVariables.charLF + lavieIndexDTO.Barcode + GlobalVariables.charLF + lavieIndexDTO.SerialID + "/??" + GlobalVariables.charCR); Thread.Sleep(20); string receivedFeedback = ""; if (this.waitforMSeries(ref receivedFeedback) && receivedFeedback != null & receivedFeedback != "") { if (receivedFeedback.Length >= 8 && receivedFeedback.ElementAt(0) == GlobalVariables.charSOH && receivedFeedback.ElementAt(7) == GlobalVariables.charCR && receivedFeedback.Substring(1, 4) == "0A41") { return(true); } else { this.showStatus(this, 0, "#", "#", "Error: " + (receivedFeedback.Substring(1, 2) == "0D" ? receivedFeedback.Substring(2, 4) : receivedFeedback.Substring(2, 3))); //Show ERROR } } return(false); } catch (Exception exception) { throw exception; } }
public void ThreadRoutine() { try { //this.ionetSocket.Connect(); //this.ioserialPort.Connect(); this.OnRunning = true; string curFile = @"c:\temp\PrintGo.txt"; string finishFile = @"c:\temp\Finish.txt"; if (!File.Exists(finishFile)) { System.IO.File.WriteAllText(finishFile, ""); } int lavieIndex = this.LavieIndexes.Where(w => w.PrintedTimes == 0).First().LineIndex; int i = 0; this.ABC(this.buttonStart, 0); while (this.OnRunning) { if (!File.Exists(curFile) && File.Exists(finishFile) && lavieIndex < (this.LavieIndexes.Count + 1)) { //CHECK PRINTER READY //this.ionetSocket.WritetoStream(GlobalVariables.charESC + "/S/001/" + "stringMessage" + "/" + GlobalVariables.charEOT); //this.ioserialPort.WritetoSerial(GlobalVariables.charSTX + "30/30/30/3F/3F" + GlobalVariables.charCR, true); //this.labelProgress.Text = "SEND OK"; //Thread.Sleep(1000); //if (this.waitforMSeries()) //{ if (i++ <= 1 || this.lavieAPIs.SystemInfoValidate()) { File.Delete(finishFile); lavieIndex = this.LavieIndexes.Where(w => w.PrintedTimes == 0).First().LineIndex; LavieIndexDTO lavieIndexDTO = this.LavieIndexes[lavieIndex - 1]; //"PrinterIP=10.208.14.100:9100", string[] lines = { "[Label 1]", "Label=LABEL", "Quantity=0", "Dyn01=" + lavieIndexDTO.ItemNumber, "Dyn02=" + lavieIndexDTO.ProductName, "Dyn03=" + lavieIndexDTO.GTIN, "Dyn04=" + lavieIndexDTO.PalletID, "Dyn05=" + lavieIndexDTO.BatchNumber, "Dyn06=" + ((DateTime)lavieIndexDTO.ExpirationDate).ToString("dd/MM/yyyy"), "Dyn07=" + ((decimal)lavieIndexDTO.Qty).ToString("N0"), "Dyn08=" + ((decimal)lavieIndexDTO.Layers).ToString("N0"), "Dyn09=" + lavieIndexDTO.GTINBarcode, "Dyn10=" + lavieIndexDTO.Barcode, "Dyn11=" + lavieIndexDTO.SerialID }; //string[] lines = { "[Label 1]", "PrinterIP=101.208.14.100:9100", "Label=LABEL", "Quantity=0", "Dyn01=" + lavieIndexDTO.ItemNumber, "Dyn02=" + lavieIndexDTO.ProductName, "Dyn03=" + lavieIndexDTO.GTIN, "Dyn04=" + lavieIndexDTO.PalletID, "Dyn05=" + lavieIndexDTO.BatchNumber, "Dyn06=" + ((DateTime)lavieIndexDTO.ExpirationDate).ToString("dd/MM/yyyy"), "Dyn07=" + ((decimal)lavieIndexDTO.Qty).ToString("N0"), "Dyn08=" + ((decimal)lavieIndexDTO.Layers).ToString("N0"), "Dyn09=" + lavieIndexDTO.GTINBarcode, "Dyn10=" + lavieIndexDTO.Barcode, "Dyn11=" + lavieIndexDTO.SerialID, SystemInfos.GetSystemInfos(true) }; System.IO.File.WriteAllLines(curFile, lines); this.lavieAPIs.LavieUpdate(lavieIndexDTO.LavieID, 1); this.ABC(this, lavieIndexDTO.LavieID); } else { throw new Exception(); } //} } Thread.Sleep(1000); } } catch (Exception exception) { this.labelProgress.Text = exception.Message; this.buttonStop_Click(this, new EventArgs()); } finally { //this.ionetSocket.Disconnect(); //this.ioserialPort.Disconnect(); this.ABC(this.buttonStop, 0); } }