Example #1
0
 private void CheckScales(Meta.Message source)
 {
     if (source.IsScaleNeeded && this.scales.Empty)
     {
         Meta.Message message = this.market.Tables.Find(Meta.TableType.Securities);
         if (message != null)
         {
             IntPtr ptr;
             string parameters = message.Encode(null, this.scales);
             int    code       = this.module.MTEOpenTable(this.handle, message.Name, parameters, 1, out ptr);
             this.CheckResult(code);
             try
             {
                 int structure = Marshal.ReadInt32(ptr);
                 ptr += Marshal.SizeOf(structure);
                 byte[] destination = new byte[structure];
                 Marshal.Copy(ptr, destination, 0, structure);
                 TableParser.Acquire(this, message, parameters, destination).Execute(null);
             }
             finally
             {
                 this.module.MTECloseTable(this.handle, code);
             }
         }
     }
 }
Example #2
0
        public Parser Load(string table, IDictionary <string, object> param)
        {
            IntPtr ptr;
            Parser parser;

            this.CheckClosed();
            Meta.Message source = this.market.Tables[table];
            if (source == null)
            {
                throw new ClientException(-17, "Table " + table + " is not listed");
            }
            this.CheckScales(source);
            string parameters = source.Encode(param, this.scales);
            int    code       = this.module.MTEOpenTable(this.handle, table, parameters, 1, out ptr);

            this.CheckResult(code);
            try
            {
                int structure = Marshal.ReadInt32(ptr);
                ptr += Marshal.SizeOf(structure);
                byte[] destination = new byte[structure];
                Marshal.Copy(ptr, destination, 0, structure);
                parser = TableParser.Acquire(this, source, parameters, destination);
            }
            finally
            {
                this.module.MTECloseTable(this.handle, code);
            }
            return(parser);
        }
Example #3
0
        private Parser Open(string table, IDictionary <string, object> param, bool complete, byte[] snapshot, out string marker)
        {
            this.CheckClosed();
            if ((snapshot != null) && (this.module.MTEOpenTableAtSnapshot == null))
            {
                throw new ClientException(-34, "MTEOpenTableAtSnapshot() not supported");
            }
            Meta.Message source = this.market.Tables[table];
            if (source == null)
            {
                throw new ClientException(-17, "Table " + table + " is not listed");
            }
            this.CheckScales(source);
            string parameters = source.Encode(param, this.scales);

            marker = source.Name + '@' + parameters;
            if (this.GetRequest(marker) == null)
            {
                IntPtr ptr;
                int    code = (snapshot == null) ? this.module.MTEOpenTable(this.handle, table, parameters, (complete || !source.IsUpdatable) ? 1 : 0, out ptr) : this.module.MTEOpenTableAtSnapshot(this.handle, table, parameters, snapshot, snapshot.Length, out ptr);
                this.CheckResult(code);
                try
                {
                    int structure = Marshal.ReadInt32(ptr);
                    ptr += Marshal.SizeOf(structure);
                    byte[] destination = new byte[structure];
                    Marshal.Copy(ptr, destination, 0, structure);
                    return(TableParser.Acquire(this, source, parameters, destination));
                }
                finally
                {
                    if (source.IsUpdatable)
                    {
                        this.CreateRequest(code, source, parameters, marker);
                    }
                    else
                    {
                        this.module.MTECloseTable(this.handle, code);
                    }
                }
            }
            return(Parser.Empty);
        }
Example #4
0
        public bool Execute(string transaction, IDictionary <string, object> param, out string report)
        {
            this.CheckClosed();
            Meta.Message source = this.market.Transactions[transaction];
            if (source == null)
            {
                throw new ClientException(-17, "Transaction " + transaction + " is not listed");
            }
            this.CheckScales(source);
            string        parameters = source.Encode(param, this.scales);
            StringBuilder builder    = new StringBuilder(0x400);
            int           code       = this.module.MTEExecTrans(this.handle, transaction, parameters, builder);

            report = builder.ToString();
            if ((code != 0) && (code != -18))
            {
                this.CheckResult(code, builder);
            }
            return(code == 0);
        }