Exemple #1
0
        /// <summary>
        /// Print label.
        /// </summary>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public async Task <ActionResult> Print(PrintLabelViewModel parameters)
        {
            try
            {
                #region Parmeters validation

                if (parameters == null)
                {
                    parameters = new PrintLabelViewModel();
                    TryValidateModel(parameters);
                }

                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                #endregion

                // Export the template.
                var data = await _exportReportDomain.ExportToFlatFileAsync(parameters, _labelPrintService.PreProductLabelOrignalText);

                foreach (var preProductPrinter in _labelPrintService.PreProductPrinters)
                {
                    if (!preProductPrinter.IsEnabled)
                    {
                        continue;
                    }

                    try
                    {
                        if (preProductPrinter.IsUsbPrinter)
                        {
                            _exportReportDomain.ExportLabelPrint(preProductPrinter,
                                                                 _configurationService.ApplicationDataPath, data);
                        }
                        else
                        {
                            _labelPrintService.Print(
                                new IPEndPoint(IPAddress.Parse(preProductPrinter.Ip), preProductPrinter.Port),
                                data);
                        }
                    }
                    catch
                    {
                        // Suppress printing error.
                    }
                }
                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }
            catch (Exception exception)
            {
                _log.Error(exception.Message, exception);
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
        /// <summary>
        /// Export product shipping commands by using specific conditions
        /// </summary>
        /// <returns></returns>
        public async Task <ActionResult> ExportProductShippingCommands(ExportProductShippingCommandViewModel parameters)
        {
            try
            {
                if (parameters == null)
                {
                    parameters = new ExportProductShippingCommandViewModel();
                    TryValidateModel(parameters);
                }

                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find results.
                ConfigurationService configurationService = new ConfigurationService();
                var data = new
                {
                    items = await _productShippingCommandDomain.FindProductShippingCommandsForPrinting(parameters.ShippingNo,
                                                                                                       parameters.ProductCode, parameters.lstPalletNo, parameters.ProductLotNo, parameters.ProductLotNo, parameters.Settings,
                                                                                                       parameters.ShelfNo),
                    page        = parameters.Settings.PageIndex,
                    shippingNo  = parameters.ShippingNo,
                    productCode = parameters.ProductCode,
                    productName = parameters.ProductName,
                    currentTime = DateTime.Now.ToString("dd-MM-yyyy HH:mm"),
                    companyName = configurationService.CompanyName,
                };

                // Template file location detect.
                var file = Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.ProductShippingCommand));

                //Read the template.
                var template = await _exportReportDomain.ReadTemplateFileAsync(file);

                // Export the template.
                var render = await _exportReportDomain.ExportToFlatFileAsync(data, template);

                return(Json(new
                {
                    render
                }));
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Exemple #3
0
        public async Task <ActionResult> ExportPreProductRetrievalRecord(string from, string to)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find the list of records
                string exportMaterialNameAbsolutePath = "";
                // check status

                var result =
                    await _ManagementReportDomain.SearchPreProductRetrievalRecord(from, to);

                // Export the template.
                if (result.FindPrintManagementReportItem.Count > 0)
                {
                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.PreProductRetrievalRecord));
                }
                else
                {
                    //Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.PreProductRetrievalRecordEmpty));
                }
                // Read the template.
                var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);


                var render = await _exportReportDomain.ExportToFlatFileAsync(result, template);

                var jsonResult = Json(new
                {
                    render
                }, "application/json");
                jsonResult.MaxJsonLength = int.MaxValue;

                return(jsonResult);
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
        public async Task <ActionResult> Print(MaterialReqListSearchViewModel model)
        {
            // Parameters are invalid.
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            string renderedData;

            // Base on what user selects, print the related.

            // Find the template absolute path.
            var exportPreProductAbsolutePath =
                Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.MaterialRequirementList));

            // Read the template.
            var masterListPreProductTemplate =
                await _exportReportDomain.ReadTemplateFileAsync(exportPreProductAbsolutePath);

            // Find all records.
            var result        = _materialRequirementListDomain.SearchCriteria(ConvertHelper.ConvertToDateTimeFull("01/" + model.DateSearch), null);
            var lstPreProduct = new
            {
                Data = new
                {
                    result.Data.data,
                    currentDate = DateTime.Now.ToString("dd/MM/yyyy"),
                    yearMonth   = model.DateSearch,
                    companyName = WebConfigurationManager.AppSettings["CompanyName"]
                }
            };

            // Render template
            renderedData =
                await _exportReportDomain.ExportToFlatFileAsync(lstPreProduct.Data,
                                                                masterListPreProductTemplate);

            return(Json(new
            {
                render = renderedData,
            }));
        }
Exemple #5
0
        public async Task <ActionResult> ExportKneadingCommands(PrintInputKneadingCommandViewModel item)
        {
            try
            {
                // Request parameters haven't been initialized.
                if (item == null)
                {
                    item = new PrintInputKneadingCommandViewModel();
                    TryValidateModel(item);
                }

                // Request parameters are invalid.
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find the list of records
                var result =
                    await _inputOfKneadingCommandDomain.SearchRecordsForPrinting(item.PreProductCode, item.CommandNo);

                // Find the template file.
                var exportKneadingCommandAbsolutePath =
                    Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InputKneadingCommands));

                // Read the template.
                var template = await _exportReportDomain.ReadTemplateFileAsync(exportKneadingCommandAbsolutePath);

                // Export the template.
                var render = await _exportReportDomain.ExportToFlatFileAsync(result, template);

                return(Json(new
                {
                    render
                }));
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Exemple #6
0
        public async Task <ActionResult> ExportConsumerMaterial(string yearmonth)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find the list of records
                string exportMaterialNameAbsolutePath = "";
                // check status

                var result =
                    await _ProductCerfiticateConsumedListDomain.PrintConsumerCerfiticates(yearmonth);

                // Find the template file.
                exportMaterialNameAbsolutePath =
                    Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.ConsumerProduct));
                // Read the template.
                var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

                // Export the template.
                var render = await _exportReportDomain.ExportToFlatFileAsync(result, template);

                var jsonResult = Json(new
                {
                    render
                }, "application/json");
                jsonResult.MaxJsonLength = int.MaxValue;

                return(jsonResult);
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Exemple #7
0
        public async Task <ActionResult> ExportExtPreProductName(string status)
        {
            try
            {
                // Request parameters are invalid.
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find the list of records
                var exportExtPreProductNameAbsolutePath = "";
                var render = string.Empty;
                // check status
                if (status == "0")
                {
                    var printingNormalResult = new
                    {
                        normal      = await _inquiryByExternalPreProductNameDomain.SearchRecordsForPrintingNormal(),
                        companyName = _configurationService.CompanyName,
                        datetime    = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                    };
                    // Find the template file.
                    exportExtPreProductNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByExtPreProductNameNormal));
                    // Read the template.
                    var printingTemplateNormal = await _exportReportDomain.ReadTemplateFileAsync(exportExtPreProductNameAbsolutePath);

                    // Export the template.
                    render = await _exportReportDomain.ExportToFlatFileAsync(printingNormalResult, printingTemplateNormal);

                    return(Json(new
                    {
                        render
                    }));
                }
                else if (status == "1")
                {
                    var printingExternalResult = new
                    {
                        external    = await _inquiryByExternalPreProductNameDomain.SearchRecordsForPrintingExternal(),
                        companyName = _configurationService.CompanyName,
                        datetime    = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                    };
                    // Find the template file.
                    exportExtPreProductNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByExtPreProductNameExternal));
                    // Read the template.
                    var printingExternalTemplate = await _exportReportDomain.ReadTemplateFileAsync(exportExtPreProductNameAbsolutePath);

                    // Export the template.
                    render = await _exportReportDomain.ExportToFlatFileAsync(printingExternalResult, printingExternalTemplate);

                    return(Json(new
                    {
                        render
                    }));
                }
                var printingAllResult = new
                {
                    normal      = await _inquiryByExternalPreProductNameDomain.SearchRecordsForPrintingNormal(),
                    external    = await _inquiryByExternalPreProductNameDomain.SearchRecordsForPrintingExternal(),
                    companyName = _configurationService.CompanyName,
                    //datetime = DateTime.Today.ToString("g"),
                    datetime = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                };


//#if DEBUG

//                var externals = printingAllResult.external;
//                var normals = printingAllResult.normal;
//#endif
                // Find the template file.
                exportExtPreProductNameAbsolutePath =
                    Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByExtPreProductNameAll));

                // Read the template.
                var printingAllResultTemplate = await _exportReportDomain.ReadTemplateFileAsync(exportExtPreProductNameAbsolutePath);

                // Export the template.
                render = await _exportReportDomain.ExportToFlatFileAsync(printingAllResult, printingAllResultTemplate);

                return(Json(new
                {
                    render
                }));
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
        public async Task <ActionResult> Print(MasterListSearchViewModel masterListSearchViewModel)
        {
            try
            {
                var companyName = WebConfigurationManager.AppSettings["CompanyName"];
                // Parameter hasn't been initialized.
                if (masterListSearchViewModel == null)
                {
                    masterListSearchViewModel = new MasterListSearchViewModel();
                    TryValidateModel(masterListSearchViewModel);
                }

                // Parameters are invalid.
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                string renderedData;

                // Base on what user selects, print the related.
                switch (masterListSearchViewModel.SearchBy)
                {
                case 1:

                    // Find the template absolute path.
                    var exportPreProductAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.MasterListPreProduct));

                    // Read the template.
                    var masterListPreProductTemplate =
                        await _exportReportDomain.ReadTemplateFileAsync(exportPreProductAbsolutePath);

                    // Find all records.
                    var preProducts = _preProductDomain.MaterialListPrint(masterListSearchViewModel.MasterCode);

//#if DEBUG
//                        preProducts.Data.data = preProducts.Data.data.Take(10);
//#endif
                    var lstPreProduct = new
                    {
                        Data = new
                        {
                            preProducts.Data.data,
                            currentDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm"),
                            companyName
                        }
                    };
                    // Render template
                    renderedData =
                        await
                        _exportReportDomain.ExportToFlatFileAsync(lstPreProduct.Data,
                                                                  masterListPreProductTemplate);

                    break;

                case 2:
                    // Find the template absolute path.
                    var exportProductAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.MasterListProduct));

                    // Read the template.
                    var masterListProductTemplate =
                        await _exportReportDomain.ReadTemplateFileAsync(exportProductAbsolutePath);

                    // Find all records.
                    var products = _productDomain.SearchPrint(masterListSearchViewModel.MasterCode, null);

                    var lstproduct = new
                    {
                        Data = new
                        {
                            products.Data.data,
                            currentDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm"),
                            companyName
                        }
                    };
                    // Render template
                    renderedData =
                        await
                        _exportReportDomain.ExportToFlatFileAsync(lstproduct.Data,
                                                                  masterListProductTemplate);

                    break;

                default:
                    // Find the template absolute path.
                    var exportMaterialAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.MasterListMaterial));

                    // Read the template.
                    var masterListMaterialTemplate =
                        await _exportReportDomain.ReadTemplateFileAsync(exportMaterialAbsolutePath);



                    // Find all records.
                    var materials = _materialDomain.SearchCriteria(masterListSearchViewModel.MasterCode, null);
                    //   materials.Data.data = materials.Data.data.ToList();

                    var material = new
                    {
                        Data = new
                        {
                            materials.Data.data,
                            currentDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm"),
                            companyName
                        }
                    };
                    // Render template
                    renderedData =
                        await
                        _exportReportDomain.ExportToFlatFileAsync(material.Data,
                                                                  masterListMaterialTemplate);

                    break;
                }

                var jsonResult = Json(new
                {
                    render = renderedData,
                });
                jsonResult.MaxJsonLength = int.MaxValue;
                return(jsonResult);
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Exemple #9
0
        public async Task <ActionResult> ExportMaterialName(string status)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find the list of records
                string exportMaterialNameAbsolutePath = "";
                //DateTime saveUtcNow = DateTime.UtcNow;

                // check status
                if (status == "0")
                {
                    var result = new
                    {
                        normal      = await _inquiryByMaterialNameDomain.SearchRecordsForPrinting(),
                        companyName = _configurationService.CompanyName,
                        datetime    = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                    };

                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByMaterialNameNormal));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

                    // Export the template.
                    var render = await _exportReportDomain.ExportToFlatFileAsync(result, template);

                    return(Json(new
                    {
                        render
                    }));
                }
                else if (status == "1")
                {
                    var result = new
                    {
                        external    = await _inquiryByMaterialNameDomain.SearchRecordsForPrintingBailment(),
                        companyName = _configurationService.CompanyName,
                        datetime    = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                    };

                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByMaterialNameBailment));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

                    // Export the template.
                    var render = await _exportReportDomain.ExportToFlatFileAsync(result, template);

                    return(Json(new
                    {
                        render
                    }));
                }
                else
                {
                    var printingAllResult = new
                    {
                        normal      = await _inquiryByMaterialNameDomain.SearchRecordsForPrinting(),
                        external    = await _inquiryByMaterialNameDomain.SearchRecordsForPrintingBailment(),
                        companyName = _configurationService.CompanyName,
                        datetime    = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                    };
                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.InquiryByMaterialNameAll));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

                    // Export the template.
                    var render = await _exportReportDomain.ExportToFlatFileAsync(printingAllResult, template);

                    return(Json(new
                    {
                        render
                    }));
                }
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
Exemple #10
0
        public async Task <ActionResult> ExportMaterialName(string status)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                // Find the list of records
                string exportMaterialNameAbsolutePath = "";
                // check status
                if (status == "0")
                {
                    var result =
                        await _MaterialStockDomain.SearchRecordsForPrinting(status);

                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.ReportByMaterialNameNormal));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

                    // Export the template.
                    var render = await _exportReportDomain.ExportToFlatFileAsync(result, template);

                    return(Json(new
                    {
                        render
                    }));
                }
                else if (status == "1")
                {
                    var result =
                        await _MaterialStockDomain.SearchRecordsForPrinting(status);

                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.ReportByMaterialNameBailment));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

                    // Export the template.
                    var render = await _exportReportDomain.ExportToFlatFileAsync(result, template);

                    return(Json(new
                    {
                        render
                    }));
                }
                else
                {
                    var result =
                        await _MaterialStockDomain.SearchRecordsForPrintingAll();

                    // Find the template file.
                    exportMaterialNameAbsolutePath =
                        Server.MapPath(string.Format("~/{0}", Constants.ExportTemplate.ReportByMaterialNameAll));
                    // Read the template.
                    var template = await _exportReportDomain.ReadTemplateFileAsync(exportMaterialNameAbsolutePath);

                    // Export the template.
                    var render = await _exportReportDomain.ExportToFlatFileAsync(result, template);

                    return(Json(new
                    {
                        render
                    }));
                }
            }
            catch (Exception exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
        /// <summary>
        /// Print internal label using specific conditions.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="terminal"></param>
        /// <returns></returns>
        private async Task PrintInternalLabelAsync(ManagementOfProductLabelViewModel parameters, string terminal)
        {
            // No internal label is specified for printing.
            if (string.IsNullOrEmpty(parameters.InternalLabel) || "1".Equals(parameters.InternalLabel) && "0".Equals(parameters.CodeLabel))
            {
                return;
            }

            var  originalLabelContent = "";
            var  copies       = 1;
            var  vendorCode   = "";
            var  specificCode = "";
            var  codeHeading  = "";
            bool smallFont    = false;

            //! Check for Small Font
            if (parameters.SmallFont)
            {
                smallFont = true;
            }
            else
            {
                smallFont = false;
            }

            // Find number of copies from selected radio button.
            if (Constants.InternalLabel.Pieces.ToString("D").Equals(parameters.InternalLabel) ||
                Constants.InternalLabel.Atm2P.ToString("D").Equals(parameters.InternalLabel) ||
                Constants.InternalLabel.Buzen2P.ToString("D").Equals(parameters.InternalLabel) ||
                Constants.InternalLabel.Sts2P.ToString("D").Equals(parameters.InternalLabel) ||
                Constants.InternalLabel.Stlgg2P.ToString("D").Equals(parameters.InternalLabel) ||
                Constants.InternalLabel.Renesas2P.ToString("D").Equals(parameters.InternalLabel))
            {
                copies = 2;
            }

            // Find printer content.
            if (Constants.CodeLabel.Atm.ToString("D").Equals(parameters.CodeLabel))
            {
                //! Specific Code Label
                if (!string.IsNullOrEmpty(parameters.SpecificCodeLabel))
                {
                    specificCode = parameters.SpecificCodeLabel + " ";
                }
                else
                {
                    specificCode = "ATM ";
                }

                //! KAP Yes/No
                if (parameters.KAP)
                {
                    vendorCode = "KAP";
                }
                else
                {
                    vendorCode = "KCS";
                }

                if (!string.IsNullOrEmpty(parameters.CodeHeading))
                {
                    codeHeading = parameters.CodeHeading + " ";
                }
                else
                {
                    codeHeading = "";
                }

                originalLabelContent = _labelPrintService.FindInternalPrintContent(InternalLabelCollection.AtmKap);
            }
            else
            {
                if (Constants.InternalLabel.Piece.ToString("D").Equals(parameters.InternalLabel) ||
                    Constants.InternalLabel.Pieces.ToString("D").Equals(parameters.InternalLabel))
                {
                    if (smallFont)
                    {
                        originalLabelContent = _labelPrintService.FindInternalPrintContent(InternalLabelCollection.PieceSmallFont);
                    }
                    else
                    {
                        originalLabelContent = _labelPrintService.FindInternalPrintContent(InternalLabelCollection.Piece);
                    }
                }


                else if (Constants.InternalLabel.Atm1P.ToString("D").Equals(parameters.InternalLabel) ||
                         Constants.InternalLabel.Atm2P.ToString("D").Equals(parameters.InternalLabel))
                {
                    originalLabelContent = _labelPrintService.FindInternalPrintContent(InternalLabelCollection.Atm);
                }

                else if (Constants.InternalLabel.Buzen1P.ToString("D").Equals(parameters.InternalLabel) ||
                         Constants.InternalLabel.Buzen2P.ToString("D").Equals(parameters.InternalLabel))
                {
                    originalLabelContent = _labelPrintService.FindInternalPrintContent(InternalLabelCollection.Buzen);
                }

                else if (Constants.InternalLabel.Sts1P.ToString("D").Equals(parameters.InternalLabel) ||
                         Constants.InternalLabel.Sts2P.ToString("D").Equals(parameters.InternalLabel))
                {
                    originalLabelContent = _labelPrintService.FindInternalPrintContent(InternalLabelCollection.Sts);
                }

                else if (Constants.InternalLabel.Stlgg1P.ToString("D").Equals(parameters.InternalLabel) ||
                         Constants.InternalLabel.Stlgg2P.ToString("D").Equals(parameters.InternalLabel))
                {
                    originalLabelContent = _labelPrintService.FindInternalPrintContent(InternalLabelCollection.Stlgg);
                }

                else if (Constants.InternalLabel.Renesas.ToString("D").Equals(parameters.InternalLabel) ||
                         Constants.InternalLabel.Renesas2P.ToString("D").Equals(parameters.InternalLabel))
                {
                    originalLabelContent = _labelPrintService.FindInternalPrintContent(InternalLabelCollection.Renesas);
                }
            }

            if (parameters.CsNo2 < parameters.CsNo1)
            {
                parameters.CsNo2 = parameters.CsNo1;
            }

            var szSupplierName = "";

            if (parameters.SupplierName == "1")
            {
                szSupplierName = "KAP";
            }
            else
            {
                szSupplierName = "KCSP";
            }

            // Print piece by piece.
            for (var csNo = parameters.CsNo1; csNo <= parameters.CsNo2; csNo++)
            {
                var printParameters = new
                {
                    InternalModelName = parameters.ExternalModelName == null ? parameters.ExternalModelName : parameters.ExternalModelName.Trim(),
                    ProductionCode    = parameters.ProductionCode == null ? parameters.ProductionCode : parameters.ProductionCode.Trim(),
                    Productionname    = parameters.ProductionName == null ? parameters.ProductionName : parameters.ProductionName.Trim(),
                    InternalLotNo     = parameters.InternalLotNo == null ? parameters.InternalLotNo : parameters.InternalLotNo.Trim(),
                    parameters.ExternalLotNo,
                    InternalLabelType = parameters.InternalLabelType == null ? parameters.InternalLabelType : parameters.InternalLabelType.Trim(),
                    parameters.InternalSize1,
                    parameters.InternalSize2,
                    parameters.MfgDate,
                    CsNo         = csNo.ToString("D3"),
                    pieceCsNo    = csNo,
                    atmQuantity  = parameters.Quantity.ToString().PadLeft(3, '0').PadRight(5, '0'),
                    VendorCode   = vendorCode,
                    SupplierName = szSupplierName,
                    PartNo       = parameters.ScsPartNo,
                    parameters.Quantity,
                    CodeHeading       = codeHeading,
                    SpecificCodeLabel = specificCode
                };

                for (var piece = 0; piece < parameters.Pieces; piece++)
                {
                    // Find external label form.
                    var labelContent = await _exportReportDomain.ExportToFlatFileAsync(printParameters, originalLabelContent);

                    // Find all active printers in the list.
                    var internalLabelPrinters = _labelPrintService.InternalPrinters.Where(x => x.IsEnabled && x.Terminal.Equals(terminal));
                    foreach (var internalLabelPrinter in internalLabelPrinters)
                    {
                        for (var copy = 0; copy < copies; copy++)
                        {
                            if (internalLabelPrinter.IsUsbPrinter)
                            {
                                _exportReportDomain.ExportLabelPrint(internalLabelPrinter,
                                                                     _configurationService.ApplicationDataPath, labelContent);
                            }
                            else
                            {
                                _labelPrintService.Print(
                                    new IPEndPoint(IPAddress.Parse(internalLabelPrinter.Ip), internalLabelPrinter.Port),
                                    labelContent);
                            }
                        }
                    }
                }
            }
        }