You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB
C#

using BarTenderPrint.codeType;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace BarTenderPrint
{
public class barcodePrintEquip : PrintEquip
{
public override bool AddPara()
{
var para = base.ParaClass as barcodLable;
if (para != null)
{
try
{
ICodeType equip = DynamicClass(para.codeType);
if (equip == null)
{
Console.WriteLine("未找到动态生成类");
return false;
}
string barcode = equip.GetBarcode(para);
base.EngineFormat.SubStrings["code0"].Value = barcode;
return true;
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
}
else
{
return false;
}
}
private ICodeType DynamicClass(string codeType)
{
//根据类型,动态生成业务类
Assembly assembly = Assembly.GetExecutingAssembly(); // 获取当前程序集
string AssemName = "BarTenderPrint.codeType.codeType" + codeType;
Console.WriteLine("动态生成类:"+ AssemName);
var obj = assembly.CreateInstance(AssemName, true);
return obj as ICodeType;
}
}
}