Exemplo n.º 1
0
        public static Database Clone(Database oldDatabase)
        {
            Database db = new Database();

            db.SetName(oldDatabase.GetName());
            db.tables = new List <Table>();
            for (int i = 0; i < oldDatabase.tables.Count; i++)
            {
                Table tab = new Table();
                tab.SetId(oldDatabase.tables[i].GetId());
                tab.SetName(oldDatabase.tables[i].GetName());
                tab.columns = new List <Column>();
                for (int j = 0; j < oldDatabase.tables[i].columns.Count; j++)
                {
                    Column col = new Column();
                    col.SetId(oldDatabase.tables[i].columns[j].GetId());
                    col.SetName(oldDatabase.tables[i].columns[j].GetName());
                    col.SetColor(oldDatabase.tables[i].columns[j].GetColor());
                    col.SetType(oldDatabase.tables[i].columns[j].GetType());
                    col.fields = new List <string>();
                    for (int k = 0; k < oldDatabase.tables[i].columns[j].fields.Count; k++)
                    {
                        col.AddField(oldDatabase.tables[i].columns[j].fields[k]);
                    }
                    tab.AddColumn(col);
                }
                db.AddTable(tab);
            }
            return(db);
        }
Exemplo n.º 2
0
        // Get Analytic 2 database (datatype proportions)
        public static Database GetDataTypeDB()
        {
            Database db = new Database();

            db.SetName("Analytic_2");
            db.tables = new List <Table>();
            Table tab = new Table();

            tab.SetId("A-2");
            tab.SetName("DataTypes in Proportion");
            tab.columns = new List <Column>();


            for (int i = 0; i < VedicDatabase.db.tables.Count; i++)
            {
                for (int j = 0; j < VedicDatabase.db.tables[i].columns.Count; j++)
                {
                    if (dataTypeDic.ContainsKey(VedicDatabase.db.tables[i].columns[j].GetType()))
                    {
                        dataTypeDic[VedicDatabase.db.tables[i].columns[j].GetType()]++;
                    }
                    else
                    {
                        dataTypeDic.Add(VedicDatabase.db.tables[i].columns[j].GetType(), 1);
                    }
                }
            }

            Dictionary <string, int> .KeyCollection keyColl = dataTypeDic.Keys;

            int total = 0;

            foreach (string s in keyColl)
            {
                total += dataTypeDic[s];
            }

            foreach (string s in keyColl)
            {
                Column col = new Column();
                col.SetName(s);
                col.SetId(s + "-2");
                col.SetColor(VariableColorTable.GetVariableColor(s));
                col.SetType(s);
                col.fields = new List <string>();
                col.fields.Add(((double)dataTypeDic[s] / (double)total).ToString());
                tab.columns.Add(col);
            }
            db.tables.Add(tab);
            return(db);
        }