|
@@ -890,8 +890,10 @@ namespace UAS_LabelMachine
|
|
|
return "select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno = '" + pi_inoutno + "' and pib_outboxcode2 = " + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2) + GroupByCondition;
|
|
|
}
|
|
|
|
|
|
- public static void CustomerInit()
|
|
|
+ public static void CustomerInit(string oContent)
|
|
|
{
|
|
|
+ if (oContent == ""|| oContent=="null"|| oContent==" ")
|
|
|
+ return;
|
|
|
|
|
|
CSharpCodeProvider objCSharpCodePrivoder = new CSharpCodeProvider();
|
|
|
|
|
@@ -902,11 +904,9 @@ namespace UAS_LabelMachine
|
|
|
objCompilerParameters.GenerateInMemory = true;
|
|
|
|
|
|
|
|
|
- CompilerResults cr = objCSharpCodePrivoder.CompileAssemblyFromSource(objCompilerParameters, GenerateCode());
|
|
|
-
|
|
|
+ CompilerResults cr = objCSharpCodePrivoder.CompileAssemblyFromSource(objCompilerParameters, oContent);
|
|
|
if (cr.Errors.HasErrors)
|
|
|
{
|
|
|
- Console.WriteLine("编译错误:");
|
|
|
foreach (CompilerError err in cr.Errors)
|
|
|
{
|
|
|
Console.WriteLine(err.ErrorText);
|
|
@@ -916,43 +916,18 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
|
|
|
Assembly objAssembly = cr.CompiledAssembly;
|
|
|
- object objHelloWorld = objAssembly.CreateInstance("Test.TestClass");
|
|
|
- MethodInfo objMI = objHelloWorld.GetType().GetMethod("Test");
|
|
|
- Console.WriteLine(objMI.Invoke(objHelloWorld, null));
|
|
|
+ object objHelloWorld = objAssembly.CreateInstance("CustInitSpace.CustInitClass", true);
|
|
|
+ MethodInfo objMI = objHelloWorld.GetType().GetMethod("CustInit");
|
|
|
+ try
|
|
|
+ {
|
|
|
+ objMI.Invoke(objHelloWorld, null);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine(ex.StackTrace);
|
|
|
+ Console.WriteLine(ex.Message);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- static string GenerateCode()
|
|
|
- {
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append("using System; ");
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append("using System.Windows.Forms; ");
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append("namespace Test ");
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append("{ ");
|
|
|
- sb.Append(" public class TestClass");
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append(" {");
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append(" public void Test() ");
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append(" {");
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append(" Form f=Form.ActiveForm; if(f.Controls[\"cu_code\"].Text==\"C000027\"){");
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append(" (f.Controls[\"OutBoxLabel\"].Controls[\"DiffCustOutBoxCode\"] as CheckBox).Checked = false;}else {(f.Controls[\"OutBoxLabel\"].Controls[\"DiffCustOutBoxCode\"] as CheckBox).Checked = true;}");
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append(" }");
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append(" }");
|
|
|
- sb.Append(Environment.NewLine);
|
|
|
- sb.Append("}");
|
|
|
- string code = sb.ToString();
|
|
|
- Console.WriteLine(code);
|
|
|
- return sb.ToString();
|
|
|
- }
|
|
|
}
|
|
|
}
|