Esempio n. 1
0
        private void orderReceivedMessage()
        {
            while (true)
            {
                OpenApi.Spell.SpellOpt tmp;
                while (orderQueue.TryDequeue(out tmp))
                {
                    FileLog.PrintF("orderReceivedMessage");

                    waitOneOpt10081(tmp.sTrCode);    // 멈추기..    //그런데 이거 없으면 에러남 0.2초 딜레이에서 유지해야할듯.
                    lock (jijs) {
                        ReceiveTrDataFactory        rtf = ReceiveTrDataFactory.getClass1Instance();
                        ReceiveTrData.ReceiveTrData rt  = rtf.getReceiveTrData(tmp.sTrCode);
                        int nRet = rt.Run(axKHOpenAPI, tmp);
                        tmp.startRunTime = DateTime.Now;
                        setCurrentRunSellOpt(tmp);
                        this.EnqueueByRunQueue(tmp);    //실행중인 데이터크기를 대충알기위해서
                        this.InRanUniqStockCount();
                    }
                }
                Thread.Sleep(200); //0.2초에 한번씩 확인
            }
        }
Esempio n. 2
0
 private void CheckTimeCurrentRunSellOpt()
 {
     while (true)
     {
         lock (lockerCurrentRunSpellOpt)
         {
             if (this.CurrentRunSpellOpt != null)
             {
                 DateTime startRunTime = this.CurrentRunSpellOpt.startRunTime;
                 DateTime checkRunTime = DateTime.Now;
                 TimeSpan gap          = checkRunTime - startRunTime;
                 int      iGap         = gap.Seconds;
                 String   key          = "[ALERT]" + this.CurrentRunSpellOpt.sTrCode + "::" + this.CurrentRunSpellOpt.stockCode + "::" + this.CurrentRunSpellOpt.endDate + "::iGap=> " + iGap;
                 if (iGap > 30)
                 {
                     FileLog.PrintF(key);
                     OpenApi.Spell.SpellOpt      tmp = this.CurrentRunSpellOpt.ShallowCopy();
                     ReceiveTrDataFactory        rtf = ReceiveTrDataFactory.getClass1Instance();
                     ReceiveTrData.ReceiveTrData rt  = rtf.getReceiveTrData(tmp.sTrCode);
                     int nRet = rt.Run(axKHOpenAPI, tmp);  //연속조회시
                     tmp.startRunTime = DateTime.Now;
                     setCurrentRunSellOpt(tmp);
                     this.DequeueByRunQueue();    //안에 들어있는 걸빼고
                     this.EnqueueByRunQueue(tmp); //지금 생성한것을 넣음
                     /*장애가 났다는것을 알릴수있는 어떤 함수가 필요하다고 생각함*/
                 }
             }
             else
             {
                 String key = "[ALERT2] 진행중인 데이터가 없다.";
                 FileLog.PrintF(key);
             }
         }
         Thread.Sleep(300000); //5분에 한번씩 돔
     }
 }
Esempio n. 3
0
        private void  sendMessageReceived()
        {
            int sendCount = 0;

            OpenApi.Spell.SpellOpt prevTmp = null;
            while (true)
            {
                OpenApi.Spell.SpellOpt tmp;
                while (receivedQueue.TryDequeue(out tmp))
                {
                    FileLog.PrintF("sendMessageReceived");
                    printRunTime(tmp);
                    //이걸 바꿀수가 없네..
                    String ret = tmp.value;
                    String key = tmp.key;

                    if (prevTmp != null)
                    {
                        FileLog.PrintF("prevTmp.sTrCode=" + prevTmp.sTrCode + ",tmp.sTrCode=" + tmp.sTrCode);
                    }


                    if (prevTmp != null && !prevTmp.sTrCode.Equals(tmp.sTrCode))
                    {
                        String tmpPath = Config.GetPath() + prevTmp.GetCheckZipFileName();
                        System.IO.StreamWriter tmpFile = new System.IO.StreamWriter(tmpPath, true);
                        tmpFile.Write(endDateEos);
                        tmpFile.Close();
                    }
                    else if (prevTmp != null && prevTmp.sTrCode.Equals("OPT10059") && prevTmp.sTrCode.Equals(tmp.sTrCode)
                             &&
                             !(prevTmp.priceOrAmount + "_" + prevTmp.buyOrSell).Equals((tmp.priceOrAmount + "_" + tmp.buyOrSell))
                             )
                    {
                        String tmpPath = Config.GetPath() + prevTmp.GetCheckZipFileName();
                        System.IO.StreamWriter tmpFile = new System.IO.StreamWriter(tmpPath, true);
                        tmpFile.Write(endDateEos);
                        tmpFile.Close();
                    }

                    String path = Config.GetPath() + tmp.GetFileName();
                    System.IO.StreamWriter file = new System.IO.StreamWriter(path, true);
                    file.Write(ret.ToString());
                    file.Close();
                    this.DequeueByRunQueue();

                    //멈추는걸 풀기전에.. 하나가 더있어야해..
                    //.nPrevNext 가 2로 넘어오는건 받을게 더 있다는 것이기 때문에..
                    FileLog.PrintF("tmpSpell.isNext()=" + tmp.isNext());
                    if (tmp.isNext() == true)
                    {
                        //주문을 백터에 넣는게 아니고 바로 하기 때문에..
                        //슬립을 주자
                        Thread.Sleep(200);
                        lock (jijs)
                        {
                            FileLog.PrintF("tmpSpell.nPrevNext > 0  tmp.nPrevNext=" + tmp.nPrevNext);
                            FileLog.PrintF("tmpSpell.startDate=" + tmp.startDate);
                            FileLog.PrintF("sendMessageReceived tmp.sTrCode =" + tmp.sTrCode);
                            ReceiveTrDataFactory        rtf = ReceiveTrDataFactory.getClass1Instance();
                            ReceiveTrData.ReceiveTrData rt  = rtf.getReceiveTrData(tmp.sTrCode);
                            int nRet = rt.Run(axKHOpenAPI, tmp);  //연속조회시
                            tmp.startRunTime = DateTime.Now;
                            setCurrentRunSellOpt(tmp);
                            this.EnqueueByRunQueue(tmp);//실행중인 데이터크기를 대충알기위해서2
                        }
                    }
                    else
                    {
                        lock (jijs)
                        {
                            FileLog.PrintF("tmpSpell.nPrevNext == 0  tmp.nPrevNext=" + tmp.nPrevNext);
                            removeSpellDictionary(key);
                            int    position = key.LastIndexOf("|");
                            String key1     = key.Substring(0, position);
                            removeStockCodeDictionary(key1);
                            sendCount++;
                        }
                        setOpt10081(tmp.sTrCode); // ... 3/1쯤 느림  //그런데 이거 없으면 에러남 0.2초 딜레이에서
                    }

                    //처리하고 파일 압축을 위해
                    prevTmp = tmp.ShallowCopy();
                    if (sendCount == GetCntOrderedCodeCount() && iEOS == 1)
                    {
                        String tmpPath = Config.GetPath() + tmp.GetCheckZipFileName();
                        System.IO.StreamWriter tmpFile = new System.IO.StreamWriter(tmpPath, true);
                        tmpFile.Write(endDateEos);
                        tmpFile.Close();
                        iEOS = 0;
                    }

                    FileLog.PrintF("sendMessageReceived [receivedQueue.Count] =" + receivedQueue.Count);
                    FileLog.PrintF("sendMessageReceived [spellDictionary.Count]=" + spellDictionary.Count);
                    FileLog.PrintF("sendMessageReceived [stockCodeDictionary.Count]=" + stockCodeDictionary.Count);
                    FileLog.PrintF("sendMessageReceived [runQueue.Count]=" + runQueue.Count);
                    FileLog.PrintF("sendMessageReceived [sendCount]=" + sendCount);
                    FileLog.PrintF("sendMessageReceived [GetCntOrderedCodeCount]=" + this.GetCntOrderedCodeCount());
                    FileLog.PrintF("sendMessageReceived [GetRanUniqStockCount]=" + this.GetRanUniqStockCount());
                    FileLog.PrintF("sendMessageReceived [orderQueue.Count]=" + orderQueue.Count);
                    FileLog.PrintF("sendMessageReceived [iEOS]=" + iEOS);

                    if (sendCount == orderedCodeCount && iEOS == 1)
                    {
                        //  EOS_CompressZip();
                        //  iEOS = 0;
                    }
                }
                Thread.Sleep(200); //여기는 사실 지연이 없어도 되지않나요??
            }
        }