예제 #1
0
        public ActionResult ExportPDF(LabelPrintArg arg)
        {
            try
            {
                List <string> partNoList = (from a in arg.items select a.partNo).ToList();

                V_PLABEL_PRINT_BLL    pBLL      = new V_PLABEL_PRINT_BLL();
                List <V_PLABEL_PRINT> printData = pBLL.BatchGetLabelPrintData(partNoList, arg.labelCode);

                if (printData == null || printData.Count == 0)
                {
                    return(Json(new RequestResult(false, "Get no page data")));
                }


                string        basePath = Server.MapPath(CHubConstValues.ChubTempFolder);
                LabelPrintBLL lpBLL    = new LabelPrintBLL(basePath);
                string        fileName = lpBLL.BuildPDF(printData, arg.items);

                string webPath = "/temp/" + fileName;

                return(Json(new RequestResult(webPath)));
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("ExportPDF", ex);
                return(Json(new RequestResult(false, ex.Message)));
            }
        }
예제 #2
0
        public ActionResult PrintLabel(LabelPrintArg arg)
        {
            if (arg == null || arg.items == null || arg.items.Count == 0)
            {
                return(Json(new RequestResult(false, "No data in Arg")));
            }
            if (string.IsNullOrEmpty(arg.labelCode) || string.IsNullOrEmpty(arg.printer))
            {
                return(Json(new RequestResult(false, "No labelcode or printer info")));
            }

            try
            {
                V_PLABEL_PRINT_BLL pBLL = new V_PLABEL_PRINT_BLL();

                string        basePath = Server.MapPath(CHubConstValues.ChubTempFolder);
                LabelPrintBLL lpBLL    = new LabelPrintBLL(basePath);

                PrintHelper pHelper = new PrintHelper();
                foreach (var item in arg.items)
                {
                    List <V_PLABEL_PRINT> printData = pBLL.BatchGetLabelPrintData(new List <string> {
                        item.partNo
                    }, arg.labelCode);
                    if (printData == null || printData.Count == 0)
                    {
                        continue;
                    }
                    string fileName = lpBLL.BuildPDF(printData, arg.items);
                    string fullPath = basePath + fileName;
                    pHelper.PrintFileWithCopies(fullPath, arg.printer, item.copies);
                }

                return(Json(new RequestResult(true)));
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("PrintLabel", ex);
                return(Json(new RequestResult(false, ex.Message)));
            }
        }