示例#1
0
        private void OnReceiveData(string szTrCode)
        {
            Sb = new StringBuilder(128);

            foreach (var block in Array.Find(catalog, o => o.ToString().Contains(szTrCode.Substring(1))).GetOutBlock(Query.GetResData()))
            {
                for (int i = 0; i < Query.GetBlockCount(block.Name); i++)
                {
                    Sb.Append(Query.GetFieldData(block.Name, block.Field, i)).Append(';');
                }
            }

            switch (szTrCode)
            {
            case "t9943":
                foreach (var str in Sb.ToString().Split(';'))
                {
                    if (str.Substring(0, 3).Equals("101"))
                    {
                        new Secret(str);
                        SendCount?.Invoke(this, new NotifyIconText(Query.GetAccountName(Secret.Account), Query.GetAcctDetailName(Secret.Account), Query.GetAcctNickname(Secret.Account), str));
                        SellOrder = new Dictionary <string, double>();
                        BuyOrder  = new Dictionary <string, double>();
                        Trend     = new Dictionary <string, string>();
                        Real      = new Dictionary <string, XARealClass>();
                        Total     = new Queue <string>();

                        if (Query.LoadFromResFile(string.Concat(Path, "t2105.res")))
                        {
                            foreach (var block in new T2105().GetInBlock(Query.GetResData()))
                            {
                                Query.SetFieldData(block.Name, block.Field, block.Occurs, block.Property);
                            }

                            Delay.delay = 1000 / Query.GetTRCountPerSec("t2105");
                            request.RequestTrData(new Task(() => SendErrorMessage(Query.Request(false))));
                        }
                        if (TimerBox.Show(Secret.OnReceiveData, Secret.GoblinBat, MessageBoxButtons.OK, MessageBoxIcon.Information, 13579).Equals(DialogResult.OK))
                        {
                            foreach (var kv in real)
                            {
                                SetAPI(kv);
                            }

                            LookUpTheBalance();
                            SendCount?.Invoke(this, new NotifyIconText(7));
                        }
                        return;
                    }
                }
                return;

            case "t2105":
                LookUpTheDeposit();
                var quotes = Sb.ToString().Split(';');
                Name = quotes[0];
                SendQuotes?.Invoke(this, new Quotes(new string[]
                {
                    quotes[32],
                    quotes[26],
                    quotes[20],
                    quotes[14],
                    quotes[8],
                    quotes[9],
                    quotes[15],
                    quotes[21],
                    quotes[27],
                    quotes[33]
                }, new string[]
                {
                    quotes[34],
                    quotes[28],
                    quotes[22],
                    quotes[16],
                    quotes[10],
                    quotes[11],
                    quotes[17],
                    quotes[23],
                    quotes[29],
                    quotes[35]
                }, new string[]
                {
                    quotes[36],
                    quotes[30],
                    quotes[24],
                    quotes[18],
                    quotes[12],
                    quotes[13],
                    quotes[19],
                    quotes[25],
                    quotes[31],
                    quotes[37]
                }, quotes[42], SellOrder, BuyOrder, string.Empty));
                return;

            case "CFOBQ10500":
                var temp = Sb.ToString().Split(';');
                SendDeposit?.Invoke(this, new Deposit(new string[]
                {
                    temp[5],
                    temp[6],
                    temp[7],
                    temp[14],
                    temp[15],
                    string.Empty,
                    temp[16],
                    temp[17],
                    string.Empty,
                    temp[18],
                    temp[19],
                    string.Empty,
                    temp[23],
                    temp[20],
                    temp[21],
                    temp[11],
                    temp[12],
                    temp[13],
                    temp[8],
                    temp[9],
                    temp[24],
                    string.Empty,
                    temp[10],
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty
                }));
                return;

            case "t0441":
                if (Query.IsNext)
                {
                    Console.WriteLine(Secret.Account + "\t" + Sb);
                    var bal = Sb.ToString().Split(';');
                    SendBalance?.Invoke(this, new Balance(new string[]
                    {
                        bal[10],
                        Name,
                        bal[11],
                        bal[12],
                        bal[14],
                        bal[19],
                        bal[21],
                        bal[13],
                        bal[15],
                        bal[20]
                    }));
                }
                else
                {
                    var cts = Sb.ToString().Split(';');

                    if (cts[1].Equals(string.Empty) && cts[2].Equals(string.Empty))
                    {
                        return;
                    }

                    new Secret(cts[1], cts[2]);

                    foreach (var block in new T0441().GetInBlock(Query.GetResData()))
                    {
                        Query.SetFieldData(block.Name, block.Field, block.Occurs, block.Property);
                    }

                    Delay.delay = 1000 / Query.GetTRCountPerSec("t0441");
                    request.RequestTrData(new Task(() => SendErrorMessage(Query.Request(true))));
                }
                return;
            }
        }
示例#2
0
        private void OnReceiveTrData(object sender, _DKHOpenAPIEvents_OnReceiveTrDataEvent e)
        {
            if (e.sTrCode.Equals("opt50028") || e.sTrCode.Equals("opt50066"))
            {
                var temp = axAPI.GetCommDataEx(e.sTrCode, e.sRQName);

                if (temp != null)
                {
                    string[,] ts = new string[((object[, ])temp).GetUpperBound(0) + 1, ((object[, ])temp).GetUpperBound(1) + 1];
                    int x, y, lx = ((object[, ])temp).GetUpperBound(0), ly = ((object[, ])temp).GetUpperBound(1);

                    for (x = 0; x <= lx; x++)
                    {
                        sb = new StringBuilder(64);

                        for (y = 0; y <= ly; y++)
                        {
                            ts[x, y] = (string)((object[, ])temp)[x, y];

                            if (ts[x, y].Length > 13 && e.sRQName.Substring(8).Equals(ts[x, y].Substring(2)))
                            {
                                sb          = new StringBuilder(it);
                                e.sPrevNext = "0";

                                break;
                            }
                            sb.Append(ts[x, y]).Append(';');
                        }
                        if (!it.Equals(sb.ToString()))
                        {
                            SendMemorize?.Invoke(this, new Memorize(sb));

                            continue;
                        }
                        if (it.Equals(sb.ToString()))
                        {
                            break;
                        }
                    }
                    if (e.sRQName.Substring(0, 3).Equals("101") && e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt50028 {
                            Value = e.sRQName.Substring(0, 8), RQName = e.sRQName, PrevNext = 2
                        })));

                        return;
                    }
                    if (e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt50066 {
                            Value = e.sRQName.Substring(0, 8), RQName = e.sRQName, PrevNext = 2
                        })));

                        return;
                    }
                    if (e.sPrevNext.Equals("0"))
                    {
                        SendMemorize?.Invoke(this, new Memorize(e.sPrevNext, e.sRQName.Substring(0, 8)));
                    }
                }
                Request(e.sRQName);
                return;
            }
            if (e.sTrCode.Contains("KOA"))
            {
                return;
            }

            sb = new StringBuilder(512);
            int i, cnt = axAPI.GetRepeatCnt(e.sTrCode, e.sRQName);

            for (i = 0; i < (cnt > 0 ? cnt : cnt + 1); i++)
            {
                foreach (string item in Array.Find(catalog, o => o.ToString().Contains(e.sTrCode.Substring(1))))
                {
                    sb.Append(axAPI.GetCommData(e.sTrCode, e.sRQName, i, item).Trim()).Append(';');
                }

                if (cnt > 0)
                {
                    sb.Append("*");

                    if (DeadLine && sb.ToString().Substring(0, 3).Equals("101"))
                    {
                        string[] temp = sb.ToString().Split(';');
                        Quantity = temp[2].Equals("1") ? -int.Parse(temp[3]) : int.Parse(temp[3]);
                        DeadLine = false;
                    }
                }
            }
            switch (Array.FindIndex(catalog, o => o.ToString().Contains(e.sTrCode.Substring(1))))
            {
            case 0:
                FixUp(sb.ToString().Split(';'), e.sRQName);
                break;

            case 1:
                SendDeposit?.Invoke(this, new Deposit(sb));
                break;

            case 2:
                SendHolding?.Invoke(this, new Holding(sb.ToString()));
                break;
            }
        }
示例#3
0
        void OnReceiveTrData(object sender, _DKHOpenAPIEvents_OnReceiveTrDataEvent e)
        {
            int index = Array.FindIndex(catalogTR, o => o.ToString().Contains(e.sTrCode.Substring(1)));

            if (index < 1)
            {
                new ExceptionMessage(e.sTrCode);

                return;
            }
            if (index < 5 && index > 0)
            {
                var temp = API.GetCommDataEx(e.sTrCode, e.sRQName);

                if (temp != null)
                {
                    string[,] ts = new string[((object[, ])temp).GetUpperBound(0) + 1, ((object[, ])temp).GetUpperBound(1) + 1];
                    int x, y, lx = ((object[, ])temp).GetUpperBound(0), ly = ((object[, ])temp).GetUpperBound(1);

                    for (x = 0; x <= lx; x++)
                    {
                        var sb = new StringBuilder(64);

                        for (y = 0; y <= ly; y++)
                        {
                            ts[x, y] = (string)((object[, ])temp)[x, y];

                            if (ts[x, y].Length > 13 && e.sRQName.Split(';')[1].Equals(ts[x, y].Substring(2)))
                            {
                                sb          = Exists;
                                e.sPrevNext = "0";

                                break;
                            }
                            sb.Append(ts[x, y]).Append(';');
                        }
                        if (Exists.Equals(sb) == false)
                        {
                            SendMemorize?.Invoke(this, new Memorize(sb));

                            continue;
                        }
                        if (Exists.Equals(sb))
                        {
                            break;
                        }
                    }
                    if (DeadLine && (e.sRQName.Split(';')[1].Length == 8 || e.sRQName.Split(';')[1].Equals("DoesNotExist")) && e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt10081
                        {
                            Value    = e.sRQName.Split(';')[0],
                            RQName   = e.sRQName,
                            PrevNext = 2
                        })));
                        return;
                    }
                    if (DeadLine == false && e.sRQName.Split(';')[0].Length == 6 && e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt10079
                        {
                            Value    = e.sRQName.Split(';')[0],
                            RQName   = e.sRQName,
                            PrevNext = 2
                        })));
                        return;
                    }
                    if (DeadLine == false && e.sRQName.Substring(5, 3).Equals("000") && e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt50028
                        {
                            Value    = e.sRQName.Substring(0, 8),
                            RQName   = e.sRQName,
                            PrevNext = 2
                        })));
                        return;
                    }
                    if (DeadLine == false && e.sRQName.Split(';')[0].Length == 8 && e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt50066
                        {
                            Value    = e.sRQName.Substring(0, 8),
                            RQName   = e.sRQName,
                            PrevNext = 2
                        })));
                        return;
                    }
                    if (e.sPrevNext.Equals("0"))
                    {
                        SendMemorize?.Invoke(this, new Memorize(e.sPrevNext, e.sRQName.Split(';')[0]));
                    }
                }
                SetScreenNumber(9000, 9031);
                SendMemorize?.Invoke(this, new Memorize("Clear"));
                Request(GetRandomCode(new Random().Next(0, CodeList.Count)));

                return;
            }
            var str = new StringBuilder(512);
            int i, cnt = API.GetRepeatCnt(e.sTrCode, e.sRQName);

            for (i = 0; i < (cnt > 0 ? cnt : cnt + 1); i++)
            {
                foreach (string item in Array.Find(catalogTR, o => o.ToString().Contains(e.sTrCode.Substring(1))))
                {
                    str.Append(API.GetCommData(e.sTrCode, e.sRQName, i, item).Trim()).Append(';');
                }

                if (cnt > 0)
                {
                    str.Append("*");
                }
            }
            switch (Array.FindIndex(catalogTR, o => o.ToString().Contains(e.sTrCode.Substring(1))))
            {
            case 5:
                FixUp(str.ToString().Split(';'), e.sRQName);
                return;

            case 6:
                foreach (string info in str.ToString().Split('*'))
                {
                    FixUp(info.Split(';'));
                }

                return;

            case 7:
            case 8:
                if (str.Length > 1 && e.sRQName.Equals("DoNotRollOver") == false)
                {
                    if (e.sScrNo.Substring(0, 1).Equals("1"))
                    {
                        SellOrder[str.ToString().Split(';')[0]] = double.Parse(e.sRQName.Split(';')[0]);
                    }

                    else if (e.sScrNo.Substring(0, 1).Equals("2"))
                    {
                        BuyOrder[str.ToString().Split(';')[0]] = double.Parse(e.sRQName.Split(';')[0]);
                    }
                }
                SendState?.Invoke(this, new State(OnReceiveBalance, SellOrder.Count, Quantity, BuyOrder.Count, ScreenNumber));
                return;

            case 9:
                SendState?.Invoke(this, new State(OnReceiveBalance, SellOrder.Count, Quantity, BuyOrder.Count, ScreenNumber));
                return;

            case 10:
                SendDeposit?.Invoke(this, new Deposit(str.ToString().Split(';')));
                break;

            case 11:
                new Task(() =>
                {
                    var temporary = str.ToString().Split('*');

                    for (i = 0; i < temporary.Length; i++)
                    {
                        if (temporary[i].Length > 0 && temporary[i].Substring(0, 8).Equals(API.GetFutureCodeByIndex(0)))
                        {
                            var quantity = temporary[i].Split(';');
                            Quantity     = quantity[2].Equals("1") ? -int.Parse(quantity[3]) : int.Parse(quantity[3]);
                            AvgPurchase  = (double.Parse(quantity[4]) / 100).ToString("F2");
                        }
                    }
                    SendBalance?.Invoke(this, new Balance(temporary));
                }).Start();
                break;
            }
        }