Exemplo n.º 1
0
        public void ReadOffsetTables()
        {
            ScalarType = _file.GetUint32();

            var numTables = _file.GetUint16();


            SearchRange   = _file.GetUint16();
            EntrySelector = _file.GetUint16();
            RangeShift    = _file.GetUint16();


            for (var i = 0; i < numTables; i++)
            {
                var tag = _file.GetString(4);

                var table = new Table()
                {
                    Checksum = _file.GetUint32(),
                    Offset   = _file.GetUint32(),
                    Length   = _file.GetUint32()
                };


                TableList.Add(tag);
                Tables.Add(table);
            }
        }
        public void CreateTableList()
        {
            try
            {
                SampleData.Current.Tables.ForEach(t =>
                {
                    var orders = new ObservableCollection <OrderData>();

                    SampleData.Current.Orders.FindAll(o => o.TableId.Equals(t.Id)).ForEach(item =>
                    {
                        orders.Add(new OrderData()
                        {
                            OrderId = item.Id, OrderCost = item.AmountOwing, OrderStatus = item.OrderState.ToString(), OrderName = item.DisplayName
                        });
                    });

                    if (orders.Count > 0)
                    {
                        TableList.Add(new TableData {
                            Id = t.Id, OrderList = orders, TableName = t.DisplayName
                        });
                    }
                });
            }
            catch (Exception ex)
            {
                Log($"Error: {ex.Message}");
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public int Read(BinaryReader reader)
        {
            var byteCount = 0;
            var header    = reader.ReadBytes(MagicHead.Length);

            byteCount += MagicHead.Length;
            if (!CompareBytes(header, MagicHead))
            {
                throw new ConfigException("Invalid Header");
            }
            TableCount = reader.ReadUInt16();
            byteCount += sizeof(ushort);
            for (ushort i = 0; i < TableCount; ++i)
            {
                var tableItem = new TableItem {
                    TableIdx = i
                };
                byteCount += tableItem.Read(reader);
                TableList.Add(tableItem);
                var sep = reader.ReadBytes(TableSeparator.Length);
                byteCount += TableSeparator.Length;
                if (!CompareBytes(sep, GetHashedBytes(TableSeparator, i)))
                {
                    throw new ConfigException("Invalid Table Separator");
                }
            }
            var end = reader.ReadBytes(MagicEnd.Length);

            byteCount += MagicEnd.Length;
            if (!CompareBytes(end, MagicEnd))
            {
                throw new ConfigException("Invalid End");
            }
            return(byteCount);
        }
Exemplo n.º 4
0
        // Separates table by adding the two tables that were combined at first,
        // and adding them back to tableList.
        public void SeparateTables(CombinedTable <Table> combinedTable)
        {
            foreach (Table table in combinedTable.combinedTables)
            {
                TableList.Add(table);
            }

            TableList.Remove(combinedTable);
        }
Exemplo n.º 5
0
        private void BuildDomFromSchema(JsonData data, string tableName, JsonSchema schema = null)
        {
            // first, create a new table instance for the data
            JsonSchemaTable table = new JsonSchemaTable(tableName, data, this, schema);

            TableList.Add(table);

            JsonData objectToParse;

            if (data != null && data.IsArray)
            {
                objectToParse = data.Count > 0 ? data[0] : null;
            }
            else
            {
                objectToParse = data;
            }

            //enumerate all schema
            foreach (var property in schema.Properties)
            {
                string   propertyName = property.Key;
                JsonData objectData   = null;
                if (objectToParse != null && objectToParse.ContainsKey(propertyName))
                {
                    objectData = objectToParse[propertyName];
                }

                if (property.Value.Type == JsonObjectType.Object)
                {
                    if (IsFlattableR(property.Value))
                    {
                        continue;
                    }
                    else
                    {
                        string            newTableName = GetUniqueTableName(propertyName);
                        JsonTableRelation relation     = new JsonTableRelation(GetUniqueRelationName(tableName, newTableName), tableName, newTableName);
                        RelationList.Add(relation);
                        BuildDomFromSchema(objectData, newTableName, schema.Properties[propertyName]);
                    }
                }
                // schema.Properties[propertyName].Item may be null if schema has no other definitions for the array ("Item": { "type": "array" }) => we wont add this array since it will always be an empty array with no columns
                else if (property.Value.Type == JsonObjectType.Array && schema.Properties[propertyName].Item != null)
                {
                    // need to add a table anyway, either for a true object or just a fake table using "ArrayValue" as field name
                    string            newTableName = GetUniqueTableName(propertyName);
                    JsonTableRelation relation     = new JsonTableRelation(GetUniqueRelationName(tableName, newTableName), tableName, newTableName);
                    RelationList.Add(relation);

                    // see if there is an object underneath
                    BuildDomFromSchema(objectData, newTableName, schema.Properties[propertyName].Item);
                }
            }
        }
Exemplo n.º 6
0
        public Table AddTable(string name, string tableName = "")
        {
            var item = new Table(GenDataBase)
            {
                GenObject = ((GenObject)GenObject).CreateGenObject("Table"),
                Name      = name,
                TableName = tableName
            };

            TableList.Add(item);
            return(item);
        }
Exemplo n.º 7
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="dataSet"></param>
 public JsonDataSet(DataSet dataSet)
 {
     // 对DataSet里面的Table循环处理
     foreach (DataTable table in dataSet.Tables)
     {
         List <string> columnList = new List <string>();
         foreach (DataColumn item in table.Columns)
         {
             columnList.Add(item.ColumnName);
         }
         TableList.Add(table.TableName, columnList);
     }
     _dataSet = dataSet;
 }
Exemplo n.º 8
0
        public void LoadTableInfo()
        {
            SqlConnection connection = new SqlConnection();

            ConnectionStringSettings settings =
                ConfigurationManager.ConnectionStrings[ConnectionStringName];

            connection.ConnectionString = settings.ConnectionString;
            connection.Open();


            DataTable dataTable = connection.GetSchema("Tables", new[] { null, "dbo", null, null });

            DataColumn colTableName = dataTable.Columns["TABLE_NAME"];

            if (colTableName != null)
            {
                foreach (DataRow row in dataTable.Rows)
                {
                    String tableName = row[colTableName].ToString();
                    if (!tableName.StartsWith("sys"))
                    {
                        try
                        {
                            Table table = new Table(tableName);

                            DataTable dt = connection.GetSchema("Columns", new[] { null, null, tableName });

                            DataColumn colColumnName = dt.Columns["COLUMN_NAME"];
                            DataColumn colColumnType = dt.Columns["DATA_TYPE"];

                            foreach (DataRow row2 in dt.Rows)
                            {
                                table.Columns.Add(
                                    new Column(row2[colColumnName].ToString(), row2[colColumnType].ToString()));
                            }

                            TableList.Add(table);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Unexpected exception when processing table: " + e.Message);
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        protected void CreateElement(string name, enumVariousElement type, out Element e)
        {
            e             = null;
            Accessor.Name = name;
            Accessor.Type = type;
            if (!TableList.ContainsKey(Accessor))
            {
                e       = new Element();
                e.Key   = Accessor.Clone();
                e.Value = null;

                TableList.Add(e.Key, e);
            }
            else
            {
                e = TableList[Accessor];
            }
        }
Exemplo n.º 10
0
        private void GetTable(string item)
        {
            foreach (var table in item.GetSlices("CREATE TABLE", $"){NewLine};"))
            {
                var    t = new Table();
                string tName, tAlias;
                GetTableDefinition(table, "CREATE TABLE", $"{NewLine}(", out tName, out tAlias);

                t.Name  = tName;
                t.Alias = tAlias;

                foreach (var column in table.Substring(table.IndexOf($"{NewLine}(") + $"{NewLine}(".Length).Split(new string[] { NewLine }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()))
                {
                    GetTableColumn(t, column);
                }
                TableList.Add(t);
            }
        }
Exemplo n.º 11
0
 private void AddDataset(IDataset[] datasets)
 {
     foreach (IDataset aDataset in datasets)
     {
         if (aDataset.Type == esriDatasetType.esriDTTable)
         {
             if (aDataset.Name.IndexOf("_ATTACH") == -1)
             {
                 TableDropdownDataContext item = new TableDropdownDataContext {
                     TableName = Utility.ParseTableName(aDataset), Value = aDataset, Fields = Utility.ReturnFieldNames(aDataset)
                 };
                 if (!TableList.Any(x => x.TableName == item.TableName))
                 {
                     TableList.Add(item);
                 }
             }
         }
     }
 }
Exemplo n.º 12
0
 public void AddTableToList(Table table)
 {
     TableList.Add(table);
 }
Exemplo n.º 13
0
 public DataTableMsx Add(DataTableMsx dt)
 {
     TableList.Add(dt);
     return(dt);
 }