public void ThreadGet() { try { TsaBarcode tsaBarcode = new TsaBarcode(); this.MainStatus = "Try to connect ..."; tsaBarcode.Q_id1 = this.Q_id1; HttpOAuth httpOAuth = new HttpOAuth(); HttpResponseMessage httpResponseMessage = httpOAuth.TsaBarcodeRead(tsaBarcode); if (httpResponseMessage.IsSuccessStatusCode) { this.MainStatus = "label@" + tsaBarcode.Q_id1; this.MainStatus = "production_date@" + tsaBarcode.TsaLabel.attributes.production_date[0].value; this.MainStatus = "production_line@" + tsaBarcode.TsaLabel.attributes.production_line[0].value; this.MainStatus = "product_id@" + tsaBarcode.TsaLabel.attributes.product_id[0].value; this.MainStatus = "batch_number@" + tsaBarcode.TsaLabel.attributes.batch_number[0].value; this.MainStatus = "batch_serial@" + tsaBarcode.TsaLabel.attributes.batch_serial[0].value; this.MainStatus = "domino_code@" + tsaBarcode.TsaLabel.attributes.domino_code[0].value; this.MainStatus = "valid@" + tsaBarcode.TsaLabel.attributes.valid[0].value; } else { this.MainStatus = "Fail to read data from tesa server." + "\r\n" + httpResponseMessage.StatusCode.ToString() + " " + httpResponseMessage.ReasonPhrase; } this.MainStatus = ""; } catch (Exception exception) { this.MainStatus = exception.Message; } }
public void ThreadRoutine() { this.LoopRoutine = true; this.StartUpload(); try { TsaBarcode tsaBarcode = new TsaBarcode(); while (this.LoopRoutine) { if (this.OnUploading) { HttpOAuth httpOAuth = new HttpOAuth(); this.MainStatus = "Starting ..."; Thread.Sleep(200); IList <CartonAttribute> cartonAttributes = this.cartonService.GetCartonAttributes(GlobalVariables.FillingLineID, (int)GlobalVariables.SubmitStatus.Freshnew + "," + (int)GlobalVariables.SubmitStatus.Failed + "," + (int)GlobalVariables.SubmitStatus.Exported, null); foreach (CartonAttribute cartonAttribute in cartonAttributes) { //Random random = new Random(); //tsaBarcode.Q_id1 = "C4STR0L" + random.Next(1, 10).ToString("000"); tsaBarcode.Q_id1 = cartonAttribute.Label; tsaBarcode.TsaLabel.attributes.product_id = new List <ProductId>() { new ProductId() { value = cartonAttribute.OfficialCode } }; tsaBarcode.TsaLabel.attributes.batch_number = new List <BatchNumber>() { new BatchNumber() { value = cartonAttribute.BatchCode } }; tsaBarcode.TsaLabel.attributes.production_line = new List <ProductionLine>() { new ProductionLine() { value = cartonAttribute.FillingLineName } }; tsaBarcode.TsaLabel.attributes.production_date = new List <ProductionDate>() { new ProductionDate() { value = cartonAttribute.BatchEntryDate.ToString("yyyy-MM-dd") } }; tsaBarcode.TsaLabel.attributes.domino_code = new List <DominoCode>() { new DominoCode() { value = cartonAttribute.Code.Substring(0, cartonAttribute.Code.Length - 6).Trim() } }; tsaBarcode.TsaLabel.attributes.batch_serial = new List <BatchSerial>() { new BatchSerial() { value = cartonAttribute.Code.Substring(cartonAttribute.Code.Length - 6, 6).Trim() } }; tsaBarcode.TsaLabel.attributes.valid = new List <Valid>() { new Valid() { value = "1" } }; this.MainStatus = "Sending: " + tsaBarcode.TsaLabel.attributes.domino_code[0].value; HttpResponseMessage httpResponseMessage = httpOAuth.TsaBarcodeUpdate(tsaBarcode); this.MainStatus = httpResponseMessage.StatusCode.ToString() + " " + httpResponseMessage.ReasonPhrase + ": " + tsaBarcode.TsaLabel.attributes.domino_code[0].value; this.cartonService.UpdateSubmitStatus("" + cartonAttribute.CartonID, httpResponseMessage.IsSuccessStatusCode ? GlobalVariables.SubmitStatus.Created : GlobalVariables.SubmitStatus.Failed, "[" + (int)httpResponseMessage.StatusCode + "] " + httpResponseMessage.StatusCode.ToString() + " " + httpResponseMessage.ReasonPhrase); if (!this.OnUploading) { break; } } } this.MainStatus = "Idling"; this.StopUpload(); Thread.Sleep(100); } } catch (Exception exception) { this.LoopRoutine = false; this.MainStatus = exception.Message; this.setLED(this.LedGreenOn, this.LedAmberOn, true); } finally { } }