KeyMethodReturnValues.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace LYFZ.WinAPI
  5. {
  6. public class KeyMethodReturnValues
  7. {
  8. public KeyMethodReturnValues() {
  9. }
  10. /// <summary>
  11. /// 设置授权码
  12. /// </summary>
  13. /// <param name="grantNumber"></param>
  14. public bool SetGrantNumberValue(string grantNumber)
  15. {
  16. try
  17. {
  18. this.D1 = 888888888;
  19. this.S2 = grantNumber.Substring(0, 49);
  20. this.S3 = grantNumber.Substring(49, 49);
  21. this.S4 = grantNumber.Substring(98, 49);
  22. this.S5 = grantNumber.Substring(147, 49);
  23. this.S6 = grantNumber.Substring(196, 49);
  24. this.S7 = grantNumber.Substring(245);
  25. return true;
  26. }
  27. catch { return false; }
  28. }
  29. /// <summary>
  30. /// 设置初始值
  31. /// </summary>
  32. /// <param name="grantNumber"></param>
  33. public bool SetInitialValue(string valueSring)
  34. {
  35. this.D1 = 999999999;
  36. try
  37. {
  38. string[] values = valueSring.Split('&');
  39. this.S2 = values[0];
  40. this.S5 = values[1];
  41. this.S6 = values[2];
  42. this.D2 = Convert.ToInt32(values[3]);
  43. this.D3 = Convert.ToInt32(values[4]);
  44. this.D4 = Convert.ToInt32(values[5]);
  45. return true;
  46. }
  47. catch {return false; }
  48. }
  49. /// <summary>
  50. /// 设置UpdateSeat
  51. /// </summary>
  52. /// <param name="grantNumber"></param>
  53. public bool SetUpdateSeatValue(string valueSring)
  54. {
  55. try
  56. {
  57. string[] SeatCountGrantNumber = LYFZ.WinAPI.SDKSecurity.Decode16Hex(valueSring.Trim().Substring(256)).Split('|');
  58. this.D4 = Convert.ToInt32(SeatCountGrantNumber[0]);
  59. this.S7 = SeatCountGrantNumber[1];
  60. return true;
  61. }
  62. catch { return false; }
  63. }
  64. /// <summary>
  65. /// 设置时间初始值
  66. /// </summary>
  67. /// <param name="grantNumber"></param>
  68. public bool SetTimeRegisterValue(string valueSring)
  69. {
  70. try
  71. {
  72. this.S5 = valueSring.Substring(0, 16)
  73. + valueSring.Substring(56, 16);
  74. this.S6 = valueSring.Substring(16, 40);
  75. this.S7 = valueSring.Substring(72, 40);
  76. this.S2 = valueSring.Substring(112);
  77. if (LYFZ.WinAPI.SDKSecurity.Checking16(this.S2))
  78. {
  79. this.S2 = LYFZ.WinAPI.SDKSecurity.Decode16Hex(this.S2);
  80. try
  81. {
  82. string[] tempTimes = this.S2.Split(' ');
  83. string[] Year_Month_Day = tempTimes[0].Split('-');
  84. string[] Hour_Minuts = tempTimes[1].Split(':');
  85. int _Year = Convert.ToInt32(Year_Month_Day[0]);
  86. int _Month = Convert.ToInt32(Year_Month_Day[1]);
  87. int _Day = Convert.ToInt32(Year_Month_Day[2]);
  88. int _Hour = Convert.ToInt32(Hour_Minuts[0]);
  89. int _Minuts = 0;
  90. try
  91. {
  92. _Minuts = Convert.ToInt32(Hour_Minuts[1]);
  93. }
  94. catch { }
  95. }
  96. catch
  97. {
  98. return false;
  99. }
  100. }
  101. else
  102. {
  103. return false;
  104. }
  105. return true;
  106. }
  107. catch { return false; }
  108. }
  109. int _D0 = 0;
  110. int _D1 = 0;
  111. int _D2 = 0;
  112. int _D3 = 0;
  113. int _D4 = 0;
  114. int _D5 = 0;
  115. int _D6 = 0;
  116. int _D7 = 0;
  117. double _F0 = 0;
  118. double _F1 = 0;
  119. double _F2 = 0;
  120. double _F3 = 0;
  121. double _F4 = 0;
  122. double _F5 = 0;
  123. double _F6 = 0;
  124. double _F7 = 0;
  125. string _S0 = "";
  126. string _S1 = "";
  127. string _S2 = "";
  128. string _S3 = "";
  129. string _S4 = "";
  130. string _S5 = "";
  131. string _S6 = "";
  132. string _S7 = "";
  133. public int D0{ get { return _D0; }set { _D0 = value; }}
  134. public int D1 { get { return _D1; } set { _D1 = value; } }
  135. public int D2 { get { return _D2; } set { _D2 = value; } }
  136. public int D3 { get { return _D3; } set { _D3 = value; } }
  137. public int D4 { get { return _D4; } set { _D4 = value; } }
  138. public int D5 { get { return _D5; } set { _D5 = value; } }
  139. public int D6 { get { return _D6; } set { _D6 = value; } }
  140. public int D7 { get { if (_D7 == 0) { _D7 = 99999; }; return _D7; } set { _D7 = value; } }
  141. public double F0 { get { return _F0; } set { _F0 = value; } }
  142. public double F1 { get { return _F1; } set { _F1 = value; } }
  143. public double F2 { get { return _F2; } set { _F2 = value; } }
  144. public double F3 { get { return _F3; } set { _F3 = value; } }
  145. public double F4 { get { return _F4; } set { _F4 = value; } }
  146. public double F5 { get { return _F5; } set { _F5 = value; } }
  147. public double F6 { get { return _F6; } set { _F6 = value; } }
  148. public double F7 { get { return _F7; } set { _F7 = value; } }
  149. public string S0 { get { return _S0; } set { _S0 = value; } }
  150. public string S1 { get { return _S1; } set { _S1 = value; } }
  151. public string S2 { get { return _S2; } set { _S2 = value; } }
  152. public string S3 { get { return _S3; } set { _S3 = value; } }
  153. public string S4 { get { return _S4; } set { _S4 = value; } }
  154. public string S5 { get { return _S5; } set { _S5 = value; } }
  155. public string S6 { get { return _S6; } set { _S6 = value; } }
  156. public string S7 { get { return _S7; } set { _S7 = value; } }
  157. /// <summary>
  158. ///
  159. /// </summary>
  160. /// <param name="_fromString"></param>
  161. /// <param name="len"></param>
  162. /// <returns></returns>
  163. public static string GetStringBuilderToString(StringBuilder _fromString, int len)
  164. {
  165. string _string = "";
  166. try
  167. {
  168. int EffectiveLength = len - 1;
  169. if (_fromString.Capacity >= len && _fromString.Length >= EffectiveLength)
  170. {
  171. _string = _fromString.ToString().Substring(0, EffectiveLength).Trim().Replace("", "");
  172. }
  173. else
  174. {
  175. _string = _fromString.ToString().Trim().Replace("", "");
  176. }
  177. }
  178. catch { _string = _fromString.ToString().Trim().Replace("", ""); }
  179. return _string;
  180. }
  181. }
  182. }