예제 #1
0
파일: Class1.cs 프로젝트: arvicco/p2ruby
        static void Main(string[] args)
        {
            try
            {
                CP2Connection conn = new CP2ConnectionClass();
                conn.AppName = "AsyncOrdSend"; // адрес вашего приложения в коммуникациях РТС.
                conn.Host = "127.0.0.1"; //Адрес
                conn.Port = 4001; // и порт локального роутера

                conn.Connect();// устанавливаем соединение с локальным роутером
                string srvAddr = conn.ResolveService("FORTS_SRV"); // ищем адрес сервера приема заявок
                LogWriteLine("address is {0}", srvAddr);
                CP2BLMessageFactory msgs = new CP2BLMessageFactory();

                msgs.Init("p2fortsgate_messages.ini", "");

                CP2BLMessage msg = msgs.CreateMessageByName("FutAddOrder");

                msg.DestAddr = srvAddr;
                msg.set_Field("P2_Category", "FORTS_MSG");
                msg.set_Field("P2_Type", 1);
                msg.set_Field("isin", "RTS-6.10");
                msg.set_Field("price", "150000");
                msg.set_Field("amount", "1");
                msg.set_Field("client_code", "001");
                msg.set_Field("type", 1);
                msg.set_Field("dir", 1);

                msg.SendAsync(conn, 5000, new CP2AsyncMessageEvents());
                msg.SendAsync2(conn, 5000, new CP2SendAsync2Event(), 1234567890);

                while (true)
                {
                    uint cookie;
                    conn.ProcessMessage(out cookie, 100);
                }

            }
            catch (Exception e)
            {
                int hRes = Marshal.GetHRForException(e);
                Console.WriteLine("Exception {0}", e.Message);
                LogWriteLine("Exception {0} {1}", e.Message, hRes);
                if (hRes == -2147205116) // P2ERR_INI_FILE_NOT_FOUND
                {
                    string s = "Can't find one or both of ini file: P2ClientGate.ini, p2fortsgate_messages.ini";
                    Console.WriteLine("{0}", s);
                    LogWriteLine("{0}", s);
                }
                return;
            }
        }
예제 #2
0
        private object xQueueNotifyLock = new object(); // обьект для блокировки очереди поступивших сигналов

        #endregion Fields

        #region Constructors

        public OrdersThread(BaseStream bs,string host,uint port,string pass,string pgConStr,string shemeIni)
        {
            this.bs = bs;
            this.parent = bs.parent;
            this.m_Host = host;
            this.m_Port = port;
            this.m_Pass = pass;
            m_msgFactory = new CP2BLMessageFactory();
            m_msgFactory.Init(shemeIni,"");

            pgConNotify = new NpgsqlConnection(pgConStr);
            pgConSelect = new NpgsqlConnection(pgConStr);
            pgConUpdate = new NpgsqlConnection(pgConStr);

            this.queueMsg = new OrderedDictionary();
            this.queueNotify = new Hashtable();
            this.queueMsgHist = new OrderedDictionary();

            pgConNotify.Notification += new NotificationEventHandler(conNotify);
            pgConNotify.StateChange += new System.Data.StateChangeEventHandler(this.conStateChanged);

            this.mFutOrders = new Orders.futOrders(this);
            this.mFutChangeClientMoney = new Orders.changeClientMoney(this);
            this.mOptOrders = new Orders.optOrders(this);
            this.mOptChangeExp = new Orders.optChangeExpiration(this);
        }