Ejemplo n.º 1
0
        public int[] m_nABVolume;          //订单明细

        public void FromAPIOrderQueue(ref LibTDBWrap.TDBDefine_OrderQueue apiOrderQueue)
        {
            m_strWindCode = LibWrapHelper.AnsiArr2String(apiOrderQueue.chWindCode, 0, apiOrderQueue.chWindCode.Length);
            m_strCode     = LibWrapHelper.AnsiArr2String(apiOrderQueue.chCode, 0, apiOrderQueue.chCode.Length);
            m_nDate       = apiOrderQueue.nDate;
            m_nTime       = apiOrderQueue.nTime;
            m_nSide       = apiOrderQueue.nSide;
            m_nPrice      = apiOrderQueue.nPrice;
            m_nOrderItems = apiOrderQueue.nOrderItems;
            m_nABItems    = apiOrderQueue.nABItems;
            m_nABVolume   = LibWrapHelper.CopyIntArr(apiOrderQueue.nABVolume);
        }
Ejemplo n.º 2
0
        //委托队列
        public TDBErrNo GetOrderQueue(TDBReq reqOrderQueue, out TDBOrderQueue[] tdbOrderQueue)
        {
            TDBErrNo nVerifyRet = SimpleVerifyReqInput(reqOrderQueue);

            tdbOrderQueue = new TDBOrderQueue[0];
            if (nVerifyRet != TDBErrNo.TDB_SUCCESS)
            {
                return(nVerifyRet);
            }

            LibTDBWrap.TDBDefine_ReqTransaction reqAPIOrderQueue = reqOrderQueue.ToAPIReqTransaction();

            IntPtr pUnmanagedReqAPIOrderQueue = LibWrapHelper.CopyStructToGlobalMem(reqAPIOrderQueue, typeof(LibTDBWrap.TDBDefine_ReqTransaction));
            IntPtr ppOrderQueue = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
            IntPtr pCount       = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int32)));

            int nRet = LibTDBWrap.TDB_GetOrderQueue(m_hTdb, pUnmanagedReqAPIOrderQueue, ppOrderQueue, pCount);

            IntPtr pOrderQueue = (IntPtr)Marshal.PtrToStructure(ppOrderQueue, typeof(IntPtr));
            int    nCount      = (Int32)Marshal.PtrToStructure(pCount, typeof(Int32));

            if ((UInt64)pOrderQueue != 0 && nCount > 0 && nRet == 0)
            {
                tdbOrderQueue = new TDBOrderQueue[nCount];
                int nElemLen = Marshal.SizeOf(typeof(LibTDBWrap.TDBDefine_OrderQueue));
                for (int i = 0; i < nCount; i++)
                {
                    IntPtr pCurRecord = (IntPtr)((UInt64)pOrderQueue + (UInt64)(nElemLen * i));
                    LibTDBWrap.TDBDefine_OrderQueue apiOrderQueue = (LibTDBWrap.TDBDefine_OrderQueue)Marshal.PtrToStructure(pCurRecord, typeof(LibTDBWrap.TDBDefine_OrderQueue));
                    tdbOrderQueue[i] = new TDBOrderQueue();
                    tdbOrderQueue[i].FromAPIOrderQueue(ref apiOrderQueue);
                }
            }
            else
            {
                //如果网络连接断掉,则关闭连接
                if (nRet == (int)TDBErrNo.TDB_NETWORK_ERROR)
                {
                    DisConnect();
                }
            }

            if ((UInt64)pOrderQueue != 0)
            {
                LibTDBWrap.TDB_Free(pOrderQueue);
            }

            Marshal.FreeHGlobal(pUnmanagedReqAPIOrderQueue);
            Marshal.FreeHGlobal(ppOrderQueue);
            Marshal.FreeHGlobal(pCount);

            return((TDBErrNo)nRet);
        }