internal override void QueryExcute() { if (LoadFromResFile(GetResFileName(GetType().Name))) { foreach (var param in GetInBlocks(GetType().Name)) { SetFieldData(param.Block, param.Field, param.Occurs, param.Data); InBlock = new InBlock { Block = param.Block, Field = param.Field, Occurs = param.Occurs, Data = param.Data }; } SendErrorMessage(GetType().Name, Request(false)); } Stack = new Stack <StringBuilder>(); }
protected internal override void OnReceiveData(string szTrCode) { var enumerable = GetOutBlocks(); var list = new List <string[]>(); var index = int.MinValue; var code = string.Empty; while (enumerable.Count > 0) { var param = enumerable.Dequeue(); switch (enumerable.Count) { case int count when count > 0x1C: var block = InBlock.First(o => o.Field.Equals(param.Field)); SetFieldData(block.Block, block.Field, block.Occurs, block.Data); continue; case int count when count < 7 || count == 7 && Decompress(param.Block) > 0: var bCount = GetBlockCount(param.Block); var array = new string[bCount]; for (int i = 0; i < bCount; i++) { array[i] = GetFieldData(param.Block, param.Field, i); } list.Add(array); break; case int count when count == 0xD || count == 0xC: var data = GetFieldData(param.Block, param.Field, 0); var refresh = InBlock.First(o => o.Field.Equals(param.Field)); SetFieldData(refresh.Block, refresh.Field, refresh.Occurs, data); continue; case 0x1A: var temp = InBlock.First(o => o.Field.Equals(param.Field)); SetFieldData(temp.Block, temp.Field, temp.Occurs, temp.Data); continue; case 0x19: code = GetFieldData(param.Block, param.Field, 0); continue; case 8: if (int.TryParse(GetFieldData(param.Block, param.Field, 0), out int rCount)) { index = rCount; } continue; } } var span = WaitForTheLimitTime(GetTRCountRequest(szTrCode)); SendMessage(span); if (span.TotalSeconds > 0xC5 && span.TotalSeconds < 0xC8) { Milliseconds = (int)span.TotalMilliseconds; } else { Milliseconds = 0x3EB / GetTRCountPerSec(szTrCode); } if (index > 0) { for (int i = index - 1; i >= 0; i--) { var temp = string.Concat(list[0][i].Substring(2), list[1][i].Substring(0, 6)); if (string.IsNullOrEmpty(Retention) || string.Compare(temp, Retention) > 0) { Charts.Push(string.Concat(temp, ";", list[5][i], ";", list[6][i])); } else { new Task(() => { Thread.Sleep(Milliseconds); Send?.Invoke(this, new SendSecuritiesAPI(code, Charts)); }).Start(); return; } } } new Task(() => { Thread.Sleep(Milliseconds); if (IsNext && Array.Exists(Retention.ToCharArray(), o => char.IsLetter(o)) == false) { SendErrorMessage(GetType().Name, Request(IsNext)); } else { Send?.Invoke(this, new SendSecuritiesAPI(code, Charts)); } }).Start(); }
protected internal override void OnReceiveData(string szTrCode) { var enumerable = GetOutBlocks(); var list = new List <string[]>(); while (enumerable.Count > 0) { var param = enumerable.Dequeue(); switch (enumerable.Count) { case int count when count > 0x17: var block = InBlock.First(o => o.Field.Equals(param.Field)); SetFieldData(block.Block, block.Field, block.Occurs, block.Data); continue; case 0x17: continue; case 0x16: var data = GetFieldData(param.Block, param.Field, 0); var refresh = InBlock.First(o => o.Field.Equals(param.Field)); SetFieldData(refresh.Block, refresh.Field, refresh.Occurs, data); continue; default: var bCount = GetBlockCount(param.Block); var array = new string[bCount]; for (int i = 0; i < bCount; i++) { array[i] = GetFieldData(param.Block, param.Field, i); } list.Add(array); break; } } var span = WaitForTheLimitTime(GetTRCountRequest(szTrCode)); SendMessage(span); if (span.TotalSeconds > 0xC5 && span.TotalSeconds < 0xC8) { Delay.Milliseconds = (int)span.TotalMilliseconds; } else { Delay.Milliseconds = 0x3E8 / GetTRCountPerSec(szTrCode); } for (int i = list[0].Length - 1; i >= 0; i--) { var temp = string.Concat(list[0][i].Substring(2), list[1][i].Substring(0, 6)); if (string.IsNullOrEmpty(Retention.LastDate) || string.Compare(temp, Retention.LastDate) > 0) { Charts.Push(string.Concat(temp, ";", list[5][i], ";", list[6][i])); } else { Send?.Invoke(this, new SendSecuritiesAPI(Retention.Code, Charts)); return; } } if (IsNext) { Connect.GetInstance().Request.RequestTrData(new Task(() => SendErrorMessage(GetType().Name, Request(IsNext)))); } else { Send?.Invoke(this, new SendSecuritiesAPI(Retention.Code, Charts)); } }