Form1.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Security.Cryptography;
  5. using System.Text;
  6. using System.Windows.Forms;
  7. using UMESDLLService;
  8. namespace FileAnalysis
  9. {
  10. public partial class Form1 : Form
  11. {
  12. public Form1()
  13. {
  14. InitializeComponent();
  15. }
  16. TCPClient client;
  17. private void Analysis_Click(object sender, EventArgs e)
  18. {
  19. client.Send("A001H10G1111111111111111110111100111111111111111111111111111111111111111111111111111111111111111111111111111 ");
  20. }
  21. private string GETMD5(string password)
  22. {
  23. //初始化MD5对象
  24. MD5 md5 = MD5.Create();
  25. //将源字符串转化为byte数组
  26. Byte[] soucebyte = Encoding.Default.GetBytes(password);
  27. //soucebyte转化为mf5的byte数组
  28. Byte[] md5bytes = md5.ComputeHash(soucebyte);
  29. //将md5的byte数组再转化为MD5数组
  30. StringBuilder sb = new StringBuilder();
  31. foreach (Byte b in md5bytes)
  32. {
  33. //x表示16进制,2表示2位
  34. sb.Append(b.ToString("x2"));
  35. }
  36. return sb.ToString();
  37. }
  38. public static int[] GetDecimalData(string HexStr, int[] DataSize, int[] NotShow)
  39. {
  40. List<int> ReturnData = new List<int>();
  41. try
  42. {
  43. //去除前面的指令字符和数据长度字符
  44. HexStr = HexStr.Replace(":", "");
  45. if (HexStr != "")
  46. {
  47. int ValueDataSize = Convert.ToInt32("0x" + (HexStr.Substring(4, 2)), 16) * 2;
  48. string RealData = HexStr.Substring(6);
  49. RealData = RealData.Substring(0, ValueDataSize);
  50. int SubIndex = 0;
  51. for (int i = 0; i < DataSize.Length; i = i + 1)
  52. {
  53. if (SubIndex + DataSize[i] < RealData.Length)
  54. {
  55. bool notshow = false;
  56. for (int j = 0; j < NotShow.Length; j++)
  57. {
  58. if (i == NotShow[j])
  59. notshow = true;
  60. }
  61. if (notshow)
  62. {
  63. SubIndex += DataSize[i];
  64. continue;
  65. }
  66. if (DataSize[i] == 8)
  67. {
  68. Console.WriteLine("0x" + (RealData.Substring(SubIndex, DataSize[i]).Substring(4, 4)) + (RealData.Substring(SubIndex, DataSize[i]).Substring(0, 4)));
  69. ReturnData.Add(Convert.ToInt32("0x" + (RealData.Substring(SubIndex, DataSize[i]).Substring(4, 4)) + (RealData.Substring(SubIndex, DataSize[i]).Substring(0, 4)), 16));
  70. }
  71. else if (DataSize[i] == 4)
  72. {
  73. Console.WriteLine("0x" + (RealData.Substring(SubIndex, DataSize[i])));
  74. ReturnData.Add(Convert.ToInt32("0x" + (RealData.Substring(SubIndex, DataSize[i])), 16));
  75. }
  76. }
  77. SubIndex += DataSize[i];
  78. }
  79. }
  80. }
  81. catch (Exception ex)
  82. {
  83. Console.WriteLine(ex.Message);
  84. }
  85. return ReturnData.ToArray();
  86. }
  87. string nextLine;
  88. private void Form1_Load(object sender, EventArgs e)
  89. {
  90. client = new TCPClient("172.16.15.10", "1030", "", "");
  91. //label1.BackColor = Color.GreenYellow;
  92. //string json = "";
  93. //string json1 = "";
  94. //MESHelper mes = new MESHelper();
  95. //mes.GetMobileAllInfo("Q32024040002", out json1, out json);
  96. //////mes.GetMobileAllInfo("F45112235030001", out json1, out json);
  97. //Console.WriteLine(json1);
  98. //Console.WriteLine(json);
  99. //StreamReader sR = new StreamReader(@"C:\Users\callm\Desktop\Android\036653943B010A11-C.txt", Encoding.Default);
  100. //while ((nextLine = sR.ReadLine()) != null)
  101. //{
  102. // ReturnData.AppendText(nextLine.ToString() + "\n");
  103. //}
  104. }
  105. }
  106. }