HardwareHandler.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using loadingForm;
  3. using Newtonsoft.Json.Linq;
  4. namespace prBrowser
  5. {
  6. public class HardwareHandler
  7. {
  8. public string DynamicLoadingDLL(string input)
  9. {
  10. JObject jObject = new JObject();
  11. string directory = "";
  12. string logString = "";
  13. try
  14. {
  15. JObject jsonObj = JObject.Parse(input);
  16. if (jsonObj["inputDir"] != null)
  17. {
  18. directory = jsonObj["inputDir"]!.ToString().Replace("/", ".").Replace("\\", ".");
  19. }
  20. logString = "调用开始0:------------------------------------------------------------------------------------------";
  21. Log.LogInfo(logString, directory);
  22. }
  23. catch (Exception ex2)
  24. {
  25. jObject.Add("errorCode", (JToken)"-1");
  26. jObject.Add("errorMessage", (JToken)ex2.Message);
  27. logString = "调用开始0:" + jObject.ToString();
  28. Log.LogInfo(logString, directory);
  29. }
  30. logString = "调用开始1:" + input;
  31. Log.LogInfo(logString, directory);
  32. string output = "";
  33. try
  34. {
  35. XYSLocalLoader xysll = new XYSLocalLoader();
  36. output = xysll.LoadAssembly(input);
  37. xysll.Unload();
  38. }
  39. catch (Exception ex)
  40. {
  41. output = ex.Message;
  42. logString = "调用异常2:" + output;
  43. Log.LogInfo(logString, directory);
  44. }
  45. Log.LogInfo("调用结束 :" + output, directory);
  46. Log.LogInfo("调用结束 :------------------------------------------------------------------------------------------", directory);
  47. return output;
  48. }
  49. }
  50. }