QuoteTik.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using Muchinfo.MTPClient.Data.Quote.Enum;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace Muchinfo.MTPClient.Data.Quote.Entities
  5. {
  6. /// <summary>
  7. /// Class QuoteTik. -- From Muchinfo.Quote.Messages.dll
  8. /// </summary>
  9. public class QuoteTik
  10. {
  11. private Dictionary<QuoteTikPart, object> _fields;
  12. private string _date;
  13. private string _time;
  14. public Dictionary<QuoteTikPart, object> Fields
  15. {
  16. get
  17. {
  18. return this._fields;
  19. }
  20. }
  21. public string ExchangeCode
  22. {
  23. get;
  24. set;
  25. }
  26. public string GoodsCode
  27. {
  28. get;
  29. set;
  30. }
  31. public int Sort
  32. {
  33. get;
  34. set;
  35. }
  36. public string Symbol
  37. {
  38. get
  39. {
  40. string text = this.ExchangeCode;
  41. string text2 = this.GoodsCode;
  42. if (text != null && string.IsNullOrEmpty(text) && text.Length > 3)
  43. {
  44. text = text.Substring(0, 3);
  45. }
  46. if (text2 != null && string.IsNullOrEmpty(text2) && text2.Length > 6)
  47. {
  48. text2 = text2.Substring(text2.Length - 6, 6);
  49. }
  50. string text3 = text.PadLeft(3, ' ') + text2.PadLeft(6, ' ');
  51. return text3.ToUpperInvariant();
  52. }
  53. }
  54. public DateTime AtTime
  55. {
  56. get;
  57. set;
  58. }
  59. public byte DecimalPlace
  60. {
  61. get;
  62. set;
  63. }
  64. public string Date
  65. {
  66. get
  67. {
  68. return this._date;
  69. }
  70. set
  71. {
  72. this._date = value;
  73. this.SetAtTime();
  74. }
  75. }
  76. public string Time
  77. {
  78. get
  79. {
  80. return this._time;
  81. }
  82. set
  83. {
  84. this._time = value;
  85. this.SetAtTime();
  86. }
  87. }
  88. public QuoteTik()
  89. {
  90. this._fields = new Dictionary<QuoteTikPart, object>();
  91. this.DecimalPlace = 4;
  92. }
  93. private void SetAtTime()
  94. {
  95. if (!string.IsNullOrEmpty(this.Date) && this.Date.Length >= 8)
  96. {
  97. int year = int.Parse(this._date.Substring(0, 4));
  98. int month = int.Parse(this._date.Substring(4, 2));
  99. int day = int.Parse(this._date.Substring(6, 2));
  100. this.AtTime = new DateTime(year, month, day, this.AtTime.Hour, this.AtTime.Minute, this.AtTime.Second);
  101. }
  102. if (string.IsNullOrEmpty(this.Time) || this.Time.Length < 6)
  103. {
  104. return;
  105. }
  106. int hour = int.Parse(this._time.Substring(0, 2));
  107. int minute = int.Parse(this._time.Substring(2, 2));
  108. int second = int.Parse(this._time.Substring(4, 2));
  109. this.AtTime = new DateTime(this.AtTime.Year, this.AtTime.Month, this.AtTime.Day, hour, minute, second);
  110. }
  111. }
  112. }