|
|
@@ -1,5 +1,4 @@
|
|
|
using LabelManager2;
|
|
|
-using Seagull.BarTender.Print;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
@@ -38,11 +37,14 @@ namespace UAS_MES_NEW.Make
|
|
|
int currentIndex = 0;
|
|
|
|
|
|
FileInfo info;
|
|
|
- Engine engine;
|
|
|
+ //Engine engine;
|
|
|
|
|
|
//ftpOperater ftp;
|
|
|
|
|
|
- LabelFormatDocument format;
|
|
|
+ //LabelFormatDocument format;
|
|
|
+
|
|
|
+ public BarTender.Application btApp;
|
|
|
+ public BarTender.Format btFormat;
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
@@ -69,12 +71,20 @@ namespace UAS_MES_NEW.Make
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- engine = new Engine(true);
|
|
|
+ btApp = new BarTender.Application();
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ catch (Exception)
|
|
|
{
|
|
|
- OperateResult.AppendText(ex.Message+ex.StackTrace, Color.Red);
|
|
|
+ OperateResult.AppendText("未正确安装BarTender软件\n", Color.Red);
|
|
|
}
|
|
|
+ //try
|
|
|
+ //{
|
|
|
+ // engine = new Engine(true);
|
|
|
+ //}
|
|
|
+ //catch (Exception ex)
|
|
|
+ //{
|
|
|
+ // OperateResult.AppendText(ex.Message+ex.StackTrace, Color.Red);
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
private void pr_code_KeyDown(object sender, KeyEventArgs e)
|
|
|
@@ -154,23 +164,26 @@ namespace UAS_MES_NEW.Make
|
|
|
string filechangetime = PrintFile.LastWriteTime.ToString();
|
|
|
if (filechangetime != filelastwritetime)
|
|
|
{
|
|
|
- engine = new Engine(true);
|
|
|
+ //engine = new Engine(true);
|
|
|
+ btApp = new BarTender.Application();
|
|
|
+
|
|
|
filechangetime = PrintFile.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
string update = "la_lastwritetime = to_date((regexp_substr('" + filechangetime + "','\\d+.+\\d+')),'yyyy-mm-dd hh24:mi:ss')";
|
|
|
dh.UpdateByCondition("label", update, "la_id = '" + listA.Rows[PrintLabel.SelectedIndex]["la_id"].ToString() + "'");
|
|
|
}
|
|
|
- format = engine.Documents.Open(listA.Rows[PrintLabel.SelectedIndex]["la_url"].ToString());
|
|
|
+ //format = engine.Documents.Open(listA.Rows[PrintLabel.SelectedIndex]["la_url"].ToString());
|
|
|
+ btFormat = btApp.Formats.Open(listA.Rows[PrintLabel.SelectedIndex]["la_url"].ToString());
|
|
|
}
|
|
|
//将值赋到format对应的变量
|
|
|
- for (int i = 0; i < format.SubStrings.Count; i++)
|
|
|
+ for (int i = 0; i < btFormat.NamedSubStrings.Count; i++)
|
|
|
{
|
|
|
//找到对应的变量名
|
|
|
- if (format.SubStrings[i].Name == paramsInfo.Rows[currentIndex - 1]["lp_name"].ToString())
|
|
|
+ if (btFormat.NamedSubStrings.Item(i).Name == paramsInfo.Rows[currentIndex - 1]["lp_name"].ToString())
|
|
|
{
|
|
|
//如果当时采集行的 lp_valuetype=’INPUT’,并且lp_sql 为空,则直接将采集的值赋给标签打印
|
|
|
if (paramsInfo.Rows[currentIndex - 1]["lp_valuetype"].ToString() == "INPUT" && paramsInfo.Rows[currentIndex - 1]["lp_sql"].ToString() == "")
|
|
|
{
|
|
|
- format.SubStrings[i].Value = inputText.Text;
|
|
|
+ btFormat.NamedSubStrings.Item(i).Value = inputText.Text;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -182,10 +195,10 @@ namespace UAS_MES_NEW.Make
|
|
|
string x = mch.Value.Trim();
|
|
|
sql = sql.Replace(x, "'" + inputText.Text + "'");
|
|
|
}
|
|
|
- format.SubStrings[i].Value = dh.GetLabelParam(sql).ToString();
|
|
|
- sb.AppendLine("打印参数【" + format.SubStrings[i].Name + "】赋值," + "取值SQL:" + sql + ",取到值" + format.SubStrings[i].Value);
|
|
|
+ btFormat.NamedSubStrings.Item(i).Value = dh.GetLabelParam(sql).ToString();
|
|
|
+ sb.AppendLine("打印参数【" + btFormat.NamedSubStrings.Item(i).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + btFormat.NamedSubStrings.Item(i).Value);
|
|
|
}
|
|
|
- inputValues[currentIndex - 1] = format.SubStrings[i].Value;
|
|
|
+ inputValues[currentIndex - 1] = btFormat.NamedSubStrings.Item(i).Value;
|
|
|
}
|
|
|
}
|
|
|
if (currentIndex == paramsInfo.Rows.Count)
|
|
|
@@ -195,12 +208,16 @@ namespace UAS_MES_NEW.Make
|
|
|
//打印
|
|
|
LogManager.DoLog(sb.ToString());
|
|
|
//保存本次赋值进行打印
|
|
|
- format.PrintSetup.PrinterName = Printer.Text;
|
|
|
- format.PrintSetup.IdenticalCopiesOfLabel = int.Parse(PrintNum.Text);
|
|
|
- format.Print();
|
|
|
- for (int i = 0; i < format.SubStrings.Count; i++)
|
|
|
+ //format.PrintSetup.PrinterName = Printer.Text;
|
|
|
+ //format.PrintSetup.IdenticalCopiesOfLabel = int.Parse(PrintNum.Text);
|
|
|
+ //format.Print();
|
|
|
+ btFormat.PrintSetup.Printer = Printer.Text;
|
|
|
+ btFormat.PrintSetup.IdenticalCopiesOfLabel = int.Parse(PrintNum.Text);
|
|
|
+ btFormat.PrintOut();
|
|
|
+
|
|
|
+ for (int i = 0; i < btFormat.NamedSubStrings.Count; i++)
|
|
|
{
|
|
|
- format.SubStrings[i].Value = null;
|
|
|
+ btFormat.NamedSubStrings.Item(i).Value = null;
|
|
|
}
|
|
|
//讲文件最后写入时间改成数据库中拿到的时间
|
|
|
//记录打印日志
|
|
|
@@ -274,36 +291,44 @@ namespace UAS_MES_NEW.Make
|
|
|
string filechangetime = PrintFile.LastWriteTime.ToString();
|
|
|
if (filechangetime != filelastwritetime)
|
|
|
{
|
|
|
- engine = new Engine(true);
|
|
|
+ //engine = new Engine(true);
|
|
|
+ btApp = new BarTender.Application();
|
|
|
+
|
|
|
BaseUtil.WriteLbl();
|
|
|
filechangetime = PrintFile.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
string update = "la_lastwritetime = to_date((regexp_substr('" + filechangetime + "','\\d+.+\\d+')),'yyyy-mm-dd hh24:mi:ss')";
|
|
|
dh.UpdateByCondition("label", update, "la_id = '" + listA.Rows[PrintLabel.SelectedIndex]["la_id"].ToString() + "'");
|
|
|
}
|
|
|
- format = engine.Documents.Open(listA.Rows[PrintLabel.SelectedIndex]["la_url"].ToString());
|
|
|
+ //format = engine.Documents.Open(listA.Rows[PrintLabel.SelectedIndex]["la_url"].ToString());
|
|
|
+ btFormat = btApp.Formats.Open(listA.Rows[PrintLabel.SelectedIndex]["la_url"].ToString());
|
|
|
+
|
|
|
sb = new StringBuilder();
|
|
|
//将值赋到format对应的变量
|
|
|
- for (int i = 0; i < format.SubStrings.Count; i++)
|
|
|
+ for (int i = 0; i < btFormat.NamedSubStrings.Count; i++)
|
|
|
{
|
|
|
for (int j = 0; j < paramsInfo.Rows.Count; j++)
|
|
|
{
|
|
|
//找到对应的变量名
|
|
|
- if (format.SubStrings[i].Name == paramsInfo.Rows[j]["lp_name"].ToString())
|
|
|
+ if (btFormat.NamedSubStrings.Item(i).Name == paramsInfo.Rows[j]["lp_name"].ToString())
|
|
|
{
|
|
|
//直接赋值
|
|
|
- format.SubStrings[i].Value = inputValues[j];
|
|
|
+ btFormat.NamedSubStrings.Item(i).Value = inputValues[j];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//打印
|
|
|
LogManager.DoLog(sb.ToString());
|
|
|
//保存本次赋值进行打印
|
|
|
- format.PrintSetup.PrinterName = Printer.Text;
|
|
|
- format.PrintSetup.IdenticalCopiesOfLabel = int.Parse(PrintNum.Text);
|
|
|
- format.Print();
|
|
|
- for (int i = 0; i < format.SubStrings.Count; i++)
|
|
|
+ //format.PrintSetup.PrinterName = Printer.Text;
|
|
|
+ //format.PrintSetup.IdenticalCopiesOfLabel = int.Parse(PrintNum.Text);
|
|
|
+ //format.Print();
|
|
|
+ btFormat.PrintSetup.Printer = Printer.Text;
|
|
|
+ btFormat.PrintSetup.IdenticalCopiesOfLabel = int.Parse(PrintNum.Text);
|
|
|
+ btFormat.PrintOut();
|
|
|
+
|
|
|
+ for (int i = 0; i < btFormat.NamedSubStrings.Count; i++)
|
|
|
{
|
|
|
- format.SubStrings[i].Value = null;
|
|
|
+ btFormat.NamedSubStrings.Item(i).Value = null;
|
|
|
}
|
|
|
//讲文件最后写入时间改成数据库中拿到的时间
|
|
|
//记录打印日志
|