Program.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using Common.Request;
  2. using Common.Request.Electronic;
  3. using Common.Request.Label;
  4. using Newtonsoft.Json.Linq;
  5. using Newtonsoft.Json;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Reflection;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. using Utils;
  15. using static System.Net.WebRequestMethods;
  16. namespace Demo
  17. {
  18. static class Program
  19. {
  20. /// <summary>
  21. /// 应用程序的主入口点。
  22. /// </summary>
  23. [STAThread]
  24. static void Main(string[] args)
  25. {
  26. if (args == null || args.Length < 2) return;
  27. string rFlag = args[0];
  28. string rparam = args[1];
  29. string rBody = Base64Helper.DecodeBase64(rparam);
  30. if (string.Compare(rFlag, "order") == 0)
  31. {
  32. OrderParam op = new OrderParam();
  33. ImputOrderParam(rBody, ref op);
  34. string order = API.GeneLabelOrder(op);
  35. WriteTxt(order, "order.txt");
  36. }
  37. else
  38. if (string.Compare(rFlag, "printOld") == 0)
  39. {
  40. }
  41. }
  42. #region 初始化OrderParam变量
  43. private static void ImputOrderParam(string rbody, ref OrderParam op)
  44. {
  45. op = JsonConvert.DeserializeObject<OrderParam>(rbody);
  46. }
  47. #endregion
  48. #region 将字符串写入txt文档
  49. private static void WriteTxt(string rIOParam,string rFileName)
  50. {
  51. string rFilePath = System.Environment.CurrentDirectory + "\\"+ rFileName;
  52. FileStream fs = new FileStream(rFilePath, FileMode.Create);
  53. byte[] data = Encoding.Default.GetBytes(rIOParam);
  54. try
  55. {
  56. fs.Write(data, 0, data.Length);
  57. fs.Flush();
  58. fs.Close();
  59. }
  60. catch (Exception)
  61. {
  62. throw;
  63. }
  64. }
  65. #endregion
  66. }
  67. }