Пример #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);
             }
         }
     }
 }
Пример #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);
        }
Пример #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);
        }