Пример #1
0
        //---------------------------------------------------------------------
        void _loadTable(string table_name)
        {
            string str_query_select = string.Format("SELECT * FROM {0};", table_name);

            try
            {
                Dictionary <int, List <DataInfo> > map_data = Sqlite.getTableData(str_query_select);
                if (map_data.Count <= 0)
                {
                    return;
                }

                EbTableBuffer table = new EbTableBuffer(table_name);

                foreach (var i in map_data)
                {
                    //int data_id = i.Key;
                    //table.WriteInt(data_id);

                    List <DataInfo> list_data_info = i.Value;
                    foreach (var data_info in list_data_info)
                    {
                        object data_value = data_info.data_value;
                        string data_name  = data_info.data_name;

                        switch (data_info.data_type)
                        {
                        case 1:
                            table.WriteInt((int)data_value);
                            break;

                        case 2:
                            table.WriteFloat((float)(double)data_value);
                            break;

                        case 3:
                            table.WriteString((string)data_value);
                            break;
                        }
                    }
                }

                table.WriteEnd();

                mMapTable[table.TableName] = table;
            }
            catch (Exception e)
            {
                EbLog.Error(str_query_select + "_______" + e.ToString());
            }
        }
Пример #2
0
        //---------------------------------------------------------------------
        void _loadTable(string table_name)
        {
            string str_query_select = string.Format("SELECT * FROM {0};", table_name);

            try
            {
                List <TbDataInfo> list_data = Sqlite.getTableData(str_query_select);
                if (list_data.Count <= 0)
                {
                    return;
                }

                EbTableBuffer table = new EbTableBuffer(table_name);

                foreach (var i in list_data)
                {
                    //int data_id = i.Key;
                    //table.WriteInt(data_id);
                    TbDataInfo      d_info         = i;
                    List <DataInfo> list_data_info = d_info.ListDataInfo;
                    foreach (var data_info in list_data_info)
                    {
                        object data_value = data_info.data_value;
                        //string data_name = data_info.data_name;

                        switch (data_info.data_type)
                        {
                        case 1:
                            table.WriteInt((int)data_value);
                            break;

                        case 2:
                            table.WriteFloat((float)(double)data_value);
                            break;

                        case 3:
                            table.WriteString((string)data_value);
                            break;
                        }
                    }
                }

                table.WriteEnd();

                mMapTable[table.TableName] = table;
            }
            catch (Exception)
            {
            }
        }
Пример #3
0
        //---------------------------------------------------------------------
        void _loadTable(string table_name)
        {
            string str_query_select = string.Format("SELECT * FROM {0};", table_name);
            Dictionary <int, List <DataInfo> > map_data = Sqlite.getTableData(str_query_select);

            if (map_data.Count <= 0)
            {
                return;
            }

            EbTable table = new EbTable();

            table.Name = table_name;

            foreach (var i in map_data)
            {
                EbPropSet       prop_set       = new EbPropSet();
                int             data_id        = i.Key;
                List <DataInfo> list_data_info = i.Value;
                foreach (var data_info in list_data_info)
                {
                    object data_value = data_info.data_value;
                    string data_name  = data_info.data_name;

                    switch (data_info.data_type)
                    {
                    case 1:
                    {
                        PropDef prop_def = table.getPropDef(data_name);
                        if (prop_def == null)
                        {
                            PropDef d = new PropDef(data_name, typeof(int), false);
                            table._addPropDef(d);
                        }
                        Prop <int> prop = new Prop <int>(null, prop_def, 0);
                        prop.set((int)data_value);
                        prop_set._addProp(data_name, prop);
                    }
                    break;

                    case 2:
                    {
                        PropDef prop_def = table.getPropDef(data_name);
                        if (prop_def == null)
                        {
                            PropDef d = new PropDef(data_name, typeof(float), false);
                            table._addPropDef(d);
                        }
                        Prop <float> prop = new Prop <float>(null, prop_def, 0f);
                        prop.set(((float)(double)data_value));
                        prop_set._addProp(data_name, prop);
                    }
                    break;

                    case 3:
                    {
                        PropDef prop_def = table.getPropDef(data_name);
                        if (prop_def == null)
                        {
                            PropDef d = new PropDef(data_name, typeof(string), false);
                            table._addPropDef(d);
                        }
                        Prop <string> prop = new Prop <string>(null, prop_def, "");
                        prop.set((string)data_value);
                        prop_set._addProp(data_name, prop);
                    }
                    break;
                    }
                }

                IProp prop_id = prop_set.getProp("Id");
                if (prop_id == null)
                {
                    EbLog.Error("EbDataMgr._loadTable() Error! Key=Id not exist, TableName=" + table_name);
                    continue;
                }
                Prop <int> p = (Prop <int>)prop_id;
                prop_set.Id = data_id;
                table._addPropSet(prop_set);
            }

            Db._addTable(table);
        }