public string setLabelData(LabelModel label)
        {
            LabelData labelData = new LabelData();

            labelData.headerLines      = new List <string>();
            labelData.detailLines      = new List <string>();
            labelData.typeOfPrintMedia = "Label";
            labelData.headerLines.Add(label.productName);
            labelData.headerLines.Add(label.productAmount);
            labelData.detailLines.Add(label.productContents);
            labelData.detailLines.Add(label.productLawStr);
            labelData.detailLines.Add(label.productStoringCond);
            labelData.detailLines.Add(label.alerji);
            labelData.detailLines.Add(label.productLotNo);
            labelData.detailLines.Add("IMALAT TARİHİ: " + DateTime.Now.ToString("dd-MM-yyyy"));
            labelData.detailLines.Add(label.productShelfLife);
            labelData.footerLines.Add(label.companyInfo);
            if ((label.companyInfo != null) && label.companyInfo.Length > 0)
            {
                labelData.typeOfLabel = 1;
            }
            else
            {
                labelData.typeOfLabel = 0;
            }
            labelData.detailLines.Add(label.mensei);
            labelData.barcode        = label.productBarcodeID;
            labelData.numberOfCopies = label.numberOfCopies;
            String jsonOutput = JsonConvert.SerializeObject(labelData, Formatting.Indented);

            return(jsonOutput);
        }
Exemple #2
0
        public async Task <IActionResult> PrintConfirmed(string id, [Bind("productBarcodeID,numberOfCopies")] LabelModel labelModel)
        {
            int numberOfCopies = labelModel.numberOfCopies;
            var printModel     = await _context.labelmodels.FirstOrDefaultAsync(m => m.productBarcodeID == labelModel.productBarcodeID);

            printModel.numberOfCopies = labelModel.numberOfCopies;
            LabelData labelData = new LabelData();

            labelData.numberOfCopies   = numberOfCopies;
            labelData.headerLines      = new List <string>();
            labelData.detailLines      = new List <string>();
            labelData.footerLines      = new List <string>();
            labelData.barcode          = printModel.productBarcodeID;
            labelData.typeOfPrintMedia = "Label";
            labelData.typeOfLabel      = printModel.typeOfLabel;
            labelData.headerLines.Add(printModel.productName);
            labelData.headerLines.Add(printModel.productAmount);
            labelData.detailLines.Add(printModel.productContents);
            labelData.detailLines.Add(printModel.productLawStr);
            labelData.detailLines.Add(printModel.productStoringCond);
            labelData.detailLines.Add(printModel.alerji);
            labelData.detailLines.Add(printModel.productLotNo);
            labelData.detailLines.Add(printModel.mensei);
            labelData.detailLines.Add("İMALAT TARİHİ : " + DateTime.Now.ToString("dd-MM-yyyy"));
            printModel.productShelfLife = "SON KULLANMA TARİHİ : " + DateTime.Now.AddMonths(printModel.productDuration).ToString("dd-MM-yyyy");
            labelData.detailLines.Add(printModel.productShelfLife);

            labelData.footerLines.Add(printModel.companyInfo);
            SocketClient socketClient = new SocketClient();
            string       jsonStr      = JsonConvert.SerializeObject(labelData);
            string       error        = socketClient.StartClient(jsonStr);

            if (error != "")
            {
                ModelState.AddModelError("yazıcı", error);
            }
            else
            {
                return(RedirectToAction(nameof(Index)));
            }
            return(View(printModel));
        }
 public void sendToPrintServer(LabelModel label)
 {
     LabelData labelData = new LabelData();
     string    labelStr  = labelData.setLabelData(label);
 }