using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
namespace print
{
class Program
{
private static void Main(string[] args)
{
//1.获取MES账户信息
String did = "did";
String password = "password";
String imei = "imei";
String date = "date";
String qrcode = "%7B%22did%22%3A701184104%2C%22password%22%3A%22716888%22%2C%22authkey%22%3Anull%2C%22keyId%22%3A%22861213050793238%22%7D";
if (args.Length > 0)
{
String urlArg = args[0];
String right = urlArg.Split("://")[1].Split("/")[0];
String[] urlArgs = right.Split(';');
if (urlArgs.Length == 5) {
did = urlArgs[0];
password = urlArgs[1];
imei = urlArgs[2];
date = urlArgs[3];
qrcode = urlArgs[4];
}
}
Console.WriteLine(did);
Console.WriteLine(password);
Console.WriteLine(imei);
Console.WriteLine(date);
Console.WriteLine(qrcode);
//1.打开bartender
BarTender.Application btapp = new BarTender.Application();
//2.选择模板
BarTender.Format btformat = btapp.Formats.Open(@"C:\bartender\print.btw", false, "");
String oldDid = btformat.GetNamedSubStringValue("did");
if (oldDid.Contains(did))
{
//本次打印的和上次相同,拒绝打印
Console.WriteLine("系统拦截重复打印");
btformat.Close();
btapp.Quit();
Thread.Sleep(5000);
return;
}
//传递参数
btformat.SetNamedSubStringValue("did", did);
btformat.SetNamedSubStringValue("password", password);
btformat.SetNamedSubStringValue("imei", imei);
btformat.SetNamedSubStringValue("date", date);
String code = System.Web.HttpUtility.UrlDecode(qrcode);
btformat.SetNamedSubStringValue("qrcode", code);
//3.打印一份
btformat.PrintSetup.NumberSerializedLabels = 1;
//4.执行打印
btformat.PrintOut(true, false);
//5.关闭模板
btformat.Save();
btformat.Close();
//6.退出bartender
btapp.Quit();
}
}文章来源:https://www.toymoban.com/news/detail-820659.html
}
文章来源地址https://www.toymoban.com/news/detail-820659.html
到了这里,关于bartender打印脚本的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!