Example #1
0
        private void LODOP_PRINT(string printData, string barcode, string package_cout, string packageNum, List <string> paramList)
        {
            //BackgroundWorker bw = new BackgroundWorker();
            //bw.DoWork += new DoWorkEventHandler(DoPrintAsync);
            //bw.RunWorkerAsync(new PrintaParam() { PrintData = printData, Barcode = barcode, PackageNum = packageNum, Package_cout = package_cout, ValueList = paramList });
            Thread threadPrint = null;

            threadPrint = new Thread(delegate()
            {
                PrintCodeObj printCodeObj = PrintCodeObjDic[printData];
                List <object> objectList  = new List <object>
                {
                    barcode,
                    package_cout,
                    packageNum
                };
                objectList.AddRange(paramList.Cast <object>());
                printCodeObj.PrintCodeType.InvokeMember("LodopStrExec", BindingFlags.InvokeMethod, null,
                                                        printCodeObj.DestObj, objectList.ToArray());
            })
            {
                IsBackground = true
            };
            threadPrint.Start();
        }
Example #2
0
 private void AddPrintTpl(string printData, List <string> param)
 {
     if (!PrintCodeObjDic.ContainsKey(printData))
     {
         PrintCodeObj printCodeObj = new PrintCodeObj();
         // 4.CompilerResults
         string str = GenerateCode(printData, param);
         str = str.Replace("'", "\"");
         CompilerResults cr = CodeCompiler.CompileAssemblyFromSource(ObjCompilerParameters, str);
         if (cr.Errors.HasErrors)
         {
             //MessageBox.Show("编译错误:");
             //foreach (CompilerError err in cr.Errors)
             //{
             //    MessageBox.Show(err.ErrorText);
             //}
         }
         else
         {
             Assembly objAssembly = cr.CompiledAssembly;
             printCodeObj.PrintCodeType = objAssembly.GetType("DynamicCodeGenerate.LodopClass");
             printCodeObj.DestObj       = printCodeObj.PrintCodeType.InvokeMember(null, BindingFlags.CreateInstance, null, null, null);
         }
         PrintCodeObjDic.Add(printData, printCodeObj);
     }
 }