static void Main(string[] paramas) { /*ISettingService service = new SettingService(); * if (paramas.Length > 0) { * string filename = paramas[0]; * if (!string.IsNullOrEmpty(filename)) * { * service.SetFileName(filename); * } * }*/ PrintInfoVo vo = new PrintInfoVo(); string timeStamp = getTimeStamp(); string uuid = Guid.NewGuid().ToString(); vo.startTime = timeStamp; vo.endTime = timeStamp; vo.fileName = "hello.pdf"; vo.filePath = "D:/TEMP/PDF"; vo.printerName = "clawPDF"; vo.printStatus = Printststus.printing; vo.jobId = uuid; string printInfoStr = JsonConvert.SerializeObject(vo); string url = "http://127.0.0.1:12246/receivePrintRecord"; string reuslt = HttpUtil.Post(url, printInfoStr); }
public bool sendPrintInfo(PrintInfoVo printInfoVo) { string printInfoStr = JsonConvert.SerializeObject(printInfoVo); string url = "http://127.0.0.1:12246/receivePrintRecord"; string reuslt = HttpUtil.Post(url, printInfoStr); return(true); }
private void DoWorkflowWork() { WorkflowStep = WorkflowStep.Init; Logger.Debug("Starting conversion..."); Logger.Debug("clawPDF Version: " + VersionHelper.Instance.FormatWithBuildNumber()); Logger.Debug("OSVersion: " + new OsHelper().GetWindowsVersion()); var originalMetadata = JobInfo.Metadata.Copy(); Job.InitMetadata(); Job.OnEvaluateActionResult += EvaluateActionResult; Job.OnRetypeSmtpPassword += RetypeSmtpPassword; WorkflowStep = WorkflowStep.SelectTarget; Logger.Debug("Querying the place to save the file"); //待转换文件 IList <SourceFileInfo> sourceFiles = JobInfo.SourceFiles; SourceFileInfo sourceFileInfo = sourceFiles[0]; String printerName = sourceFileInfo.PrinterName; //设置打印文件信息到注册表 FileName.Init(); FileInfo info = FileName.getFileInfoNoPrint(); String servicePrinter = ""; try { servicePrinter = VmPrintersEnum.getPrinterMap()[printerName]; } catch (Exception) { servicePrinter = ""; } //注册表模式 if (null != info && !string.IsNullOrEmpty(info.Name) && String.IsNullOrEmpty(servicePrinter)) { Logger.Debug("注册表匹配打印文件名成功" + info.Name); string jobId = System.Guid.NewGuid().ToString(); JobInfo.IsRegedit = 1; info.JobId = jobId; info.PrintState = "1"; info.EndTime = ""; FileName.modifyFileInfo(info); Job.OutFileName = info.Name; } //服务模式 if (!String.IsNullOrEmpty(servicePrinter)) { JobInfo.IsRegedit = 2; } try { QueryTargetFile(); } catch (ManagePrintJobsException) { // revert metadata changes and rethrow exception //还原元数据更改并重新引发异常 JobInfo.Metadata = originalMetadata; throw; } if (Cancel) { return; } var preCheck = ProfileChecker.ProfileCheck(Job.Profile); if (!EvaluateActionResult(preCheck)) { return; } Logger.Debug("Output filename template is: {0}", Job.OutputFilenameTemplate); Logger.Debug("Output format is: {0}", Job.Profile.OutputFormat); if (!SetActions()) { return; } //开始转换 WorkflowStep = WorkflowStep.Convert; Logger.Info("Converting " + Job.OutputFilenameTemplate); string strTime = DateUtil.nowDate2Str(); //将文件信息写到注册表 if (JobInfo.IsRegedit == 1) { info.StartTime = strTime; info.EndTime = ""; info.PrintState = "1"; FileName.Init(); FileName.modifyFileInfo(info); Logger.Info("注册表打印中信息:" + JsonConvert.SerializeObject(info)); } //通知开始打印中 PrintInfoVo serviecOutFile = new PrintInfoVo(); if (JobInfo.IsRegedit == 2) { string jobid = System.Guid.NewGuid().ToString(); string filePath = Job.OutputFilenameTemplate; PrintService = new ProcessPrintInfoService(); try { if (!String.IsNullOrEmpty(servicePrinter)) { serviecOutFile.jobId = jobid; serviecOutFile.printerName = printerName; serviecOutFile.printStatus = Printststus.printing; serviecOutFile.fileName = Job.OutFileName; serviecOutFile.filePath = filePath; serviecOutFile.startTime = strTime; Logger.Info("服务打印中信息:" + JsonConvert.SerializeObject(serviecOutFile)); PrintService.sendPrintInfo(serviecOutFile); } } catch (Exception ex) { Logger.Error(ex); } } //是否展示转换进度 if (Job.Profile.ShowProgress) { ShowConversionProgress(); } //开始转换 Job.RunJob(); //转换失败提示 if (!Job.Success) { NotifyUserAboutFailedJob(); } //写入注册表 string entTime = DateUtil.nowDate2Str(); if (JobInfo.IsRegedit == 1) { Logger.Info("注册打印结束信息:" + JsonConvert.SerializeObject(info)); if (Job.Success) { info.PrintState = "2"; info.EndTime = entTime; } else { info.PrintState = "-1"; info.EndTime = entTime; } FileName.Init(); FileName.modifyFileInfo(info); } //通知打印完成 if (JobInfo.IsRegedit == 2) { if (!String.IsNullOrEmpty(servicePrinter)) { if (Job.Success) { serviecOutFile.printStatus = Printststus.success; serviecOutFile.endTime = entTime; } else { serviecOutFile.printStatus = Printststus.fails; serviecOutFile.endTime = entTime; } PrintService.sendPrintInfo(serviecOutFile); } } WorkflowStep = WorkflowStep.Finished; OnJobFinished(EventArgs.Empty); }