private void MoveToOutput(PrintTaskDetail model, string uid, string tmpfile) { Guid guid = Guid.NewGuid(); var outdoc = guid.ToString() + Path.GetExtension(tmpfile); var ticket = Template.ticketPdf .Replace("$USERID$", uid) .Replace("$PATH$", outdoc) .Replace("$FILENAME$", Path.GetFileName(model.Document)) .Replace("$COPIES$", model.Copies.ToString()) .Replace("$COLORMODE$", model.ColorMode.ToString()) .Replace("$PAPERSIZE$", ((int)model.PaperSize).ToString()) .Replace("$DUPLEX$", model.PaperMode.ToString()); var tempxml = tmpfile + ".xml"; System.IO.File.WriteAllText(tempxml, ticket); var targetPaths = settings["UniflowService:TaskTargetPath"]; foreach (var targetPath in targetPaths.Split(';')) { var targetdoc = Path.Combine(targetPath.Trim(), outdoc); var targetxml = Path.Combine(targetPath.Trim(), guid.ToString() + ".xml"); System.IO.File.Copy(tmpfile, targetdoc); System.IO.File.Copy(tempxml, targetxml); } System.IO.File.Delete(tmpfile); System.IO.File.Delete(tempxml); }
private static PrintTaskDetail ToPrintTaskDetail(string tmpfile, PrintJob printJob, string reqId) { var copies = 1; var copiesSetting = printJob.setting_list.Where(t => t.key == "份数").FirstOrDefault(); if (copiesSetting != null && copiesSetting.value.Length > 0) { int.TryParse(copiesSetting.value[0], out copies); } var color = ColorMode.BW; var colorSetting = printJob.setting_list.Where(t => t.key == "颜色").FirstOrDefault(); if (colorSetting != null && colorSetting.value.Length > 0 && colorSetting.value[0].Equals(ColorMode.Color.GetDisplayName())) { color = ColorMode.Color; } var paperSizeSetting = printJob.setting_list.Where(t => t.key == "纸型").FirstOrDefault(); var pageSize = PaperSize.A4; if (paperSizeSetting != null && paperSizeSetting.value.Length > 0 && paperSizeSetting.value[0] == PaperSize.A3.GetDisplayName()) { pageSize = PaperSize.A3; } var paperModeSetting = printJob.setting_list.Where(t => t.key == "模式").FirstOrDefault(); var paperMode = PaperMode.Simplex; if (paperModeSetting != null && paperModeSetting.value.Length > 0) { if (paperModeSetting.value[0] == PaperMode.LongEdge.GetDisplayName()) { paperMode = PaperMode.LongEdge; } else if (paperModeSetting.value[0] == PaperMode.ShortEdge.GetDisplayName()) { paperMode = PaperMode.ShortEdge; } } var printModel = new PrintTaskDetail { Path = tmpfile, RequestId = reqId, Document = printJob.doc_name, Copies = copies, Orientation = Orientation.Landscape, ColorMode = color, PaperMode = paperMode, PaperSize = pageSize, }; return(printModel); }