/// <summary> /// 预加载Bartender /// </summary> /// <param name="executePrintRequest">执行打印请求</param> /// <param name="CurrentDirectory">当前路径</param> /// <param name="TemplateFolder">模板文件夹名</param> /// <param name="BartendExePath">Bartender执行路径</param> /// <returns></returns> public static string PreLoadBartender(this ExecutePrintRequest executePrintRequest, string CurrentDirectory, string TemplateFolder, string BartendExePath) { //Step-1,产生预加载任务 string rtn = new StringBuilder("") .Append(BartendExePath) .Append(" /F=").Append(string.Format(@"{0}{1}{2}{3}", CurrentDirectory.getPath(), TemplateFolder.getPath(), "blank", ".btw")) .ToString(); return(rtn); }
/// <summary> /// 生成打印任务图片结果 /// </summary> /// <param name="executePrintRequest">执行打印请求</param> /// <param name="CurrentDirectory">当前路径</param> /// <param name="TemplateFolder">模板文件夹名</param> /// <returns></returns> public static bool ExportPrintPreviewToImage(this ExecutePrintRequest executePrintRequest, string CurrentDirectory, string TemplateFolder) { bool rtn = false; string path = string.Format(@"{0}{1}{2}_{3}_{4}{5}", CurrentDirectory.getPath(), TemplateFolder.getPath(), executePrintRequest.TaskId, "Preview_Label", "1", ".jpg"); if (FileHelper.Exists(path)) { rtn = true; } return(rtn); }
public ActionResult <ExecutePrintResponse> PostExecutePrint(ExecutePrintRequest executePrintRequest) { //更新TodoItem string taskId = executePrintRequest.TaskId; string printName = executePrintRequest.PrintName; string printType = executePrintRequest.PrintType; int printCount = executePrintRequest.PrintCount; string fileName = executePrintRequest.FileName; ExecutePrintResponse executePrintResponse = new ExecutePrintResponse { TaskId = taskId, FileName = fileName, PrintName = printName, PrintType = printType, PrintCount = printCount, Result = true, Msg = "PreLoad Success" }; if (PrinterHelper.GetPrinterStatus(printName) == -1) { executePrintResponse.Result = false; executePrintResponse.Msg = "Not Such Printer In The Server"; } else { TodoItem todoItem = _context.TodoItems.Find(taskId); todoItem.PrintName = printName; todoItem.PrintType = printType; todoItem.PrintCount = printCount; todoItem.FileName = fileName; todoItem.IsComplete = true; _context.Entry(todoItem).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); if (printType == "Bartend") { //生成预加载Bartender任务 string preLoadBartender = executePrintRequest.PreLoadBartender(_hostingEnvironment.WebRootPath, this.TemplateFolder, this.BartendExePath); LogHelper.WriteLog(preLoadBartender, new Exception("PostExecutePrint")); //预加载Bartender //DosCommandOutputHelper.Execute(preLoadBartender, 3000); } else if (printType == "Excel") { Configurator.Put(".xlsx", new WorkbookLoader()); } } //执行打印结果 return(executePrintResponse); }