UReport.xaml.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using SecsGem.Core;
  2. using SecsGem.Core.EnumData;
  3. using SecsGem.Core.Hsms;
  4. using SecsGem.Core.ItemModel;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace EapClientSimulator
  20. {
  21. /// <summary>
  22. /// UReport.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class UReport : UserControl
  25. {
  26. public UReport()
  27. {
  28. InitializeComponent();
  29. }
  30. public event EventHandler<string> OnSendMessage;
  31. private void btnReport_Click(object sender, RoutedEventArgs e)
  32. {
  33. if (string.IsNullOrEmpty(txtRpId.Text))
  34. {
  35. MessageBox.Show("rpid is empty");
  36. return;
  37. }
  38. string[] strAry = txtVID.Text.Split(';');
  39. SecsHsmsMessageHeader secsMessageHeader = new SecsHsmsMessageHeader()
  40. {
  41. Stream = 0x02,
  42. Function = 33,
  43. SType = SType.DataMessage,
  44. TransactionId = IdGenerator.GenerateTransactionId(),
  45. ReplyFlag = true,
  46. };
  47. Item item = new SecsGem.Core.ItemModel.ListItem();
  48. Item dataIdItem = new IntItem(1);
  49. item.AddItem(dataIdItem);
  50. Item rpsItem = new SecsGem.Core.ItemModel.ListItem();
  51. Item vdsItem = new SecsGem.Core.ItemModel.ListItem();
  52. for(int i=0;i<strAry.Length;i++)
  53. {
  54. if (!string.IsNullOrEmpty(strAry[i]))
  55. {
  56. if (int.TryParse(strAry[i], out int vdValue))
  57. {
  58. Item vdItem = new IntItem(vdValue);
  59. vdsItem.AddItem(vdItem);
  60. }
  61. else
  62. {
  63. return;
  64. }
  65. }
  66. }
  67. Item rpItem = new SecsGem.Core.ItemModel.ListItem();
  68. if (int.TryParse(txtRpId.Text, out int rpid))
  69. {
  70. Item rpidItem = new IntItem(rpid);
  71. rpItem.AddItem(rpidItem);
  72. }
  73. else
  74. {
  75. return;
  76. }
  77. rpItem.AddItem(vdsItem);
  78. rpsItem.AddItem(rpItem);
  79. item.AddItem(rpsItem);
  80. SecsMessage secsMessage = new SecsMessage(secsMessageHeader, item);
  81. if(GlobalData.Client!=null)
  82. {
  83. GlobalData.Client.SendMessage(secsMessage);
  84. if (OnSendMessage != null)
  85. {
  86. OnSendMessage(this, SmlSerializationUtil.SerializeItemToString(secsMessage));
  87. }
  88. }
  89. }
  90. }
  91. }