public ogtable_deletor(U adaptor, data.database conn, data.dbname database_name, data.tbname table_name) { this.adaptor = adaptor; this.database_name = database_name; this.table_name = table_name; this.cur_conn = conn; }
public check_table(data.database curr_conn, data.tbname tbl_name, data.dbname db_name, diagram_rawdata profile) { this.curr_conn = curr_conn; this.tbl_name = tbl_name; this.db_name = db_name; this.profile = profile; }
public ogtable_writer(U data, data.database conn, data.dbname database_name, data.tbname table_name) { this.adaptor = data; this.curr_conn = conn; this.table_name = table_name; this.database_name = database_name; }
void create_alonewith_database_operation(workspace wspace) { var dst_tables = new List <string>(); foreach (var v in configed_tables) { var tbl_name = new data.tbname(v); new cmd_wraper.table_cmd(curr_conn, tbl_name, wspace.TargetDb).drop_table(true); new cnl_wrapper.nltable_cmd(curr_conn, wspace.TargetDb, tbl_name).clone_from(wspace.SchemaDatabase); dst_tables.Add(v); } profile.Simple_Tables = dst_tables; // save to disk new cpe_wraper.serialize_op <List <string> >().save(file_data_name, profile.Simple_Tables); }
public void main(workspace wspace) { var dr = new diagram_rawdata(); var watch = new System.Diagnostics.Stopwatch(); watch.Start(); foreach (var v in wspace.SourceDbs) { var tables = new cmd_wraper.database_cmd(data.database.Instance, v).show_tables(); foreach (var t in tables) { if (t.StartsWith(@"tbl_")) { var tbl = new data.tbname(t); new check_table(data.database.Instance, tbl, v, dr).search_table(); } } } watch.Stop(); Console.WriteLine("read database used seconds:" + watch.ElapsedMilliseconds / 1000); dr.save_to_disk("checked_tables.xml"); }
void create_alonewith_database_operation(workspace wspace) { var all_data = new List <TableIdNameInfoSet>(); foreach (var cfgtbl in configed_tables) { var table_name = new data.tbname(cfgtbl.Key); // drop , create new cmd_wraper.table_cmd(curr_conn, table_name, wspace.TargetDb).drop_table(true); new cnl_wrapper.nltable_cmd(curr_conn, wspace.TargetDb, table_name).copy_from(wspace.SchemaDatabase); // fill data foreach (var v in wspace.SourceDbs) { new cnl_wrapper.nltable_cmd(curr_conn, wspace.TargetDb, table_name).fill_from(v); } } // load data foreach (var cfgtbl in configed_tables) { var table_set = new TableIdNameInfoSet(); table_set.table_name = new data.tbname(cfgtbl.Key); table_set.Desc = new TableIdNameDesc(); table_set.Desc.left_name = cfgtbl.Value.Key; table_set.Desc.right_name = cfgtbl.Value.Value; var tinr = new cog_wraper.table_idname_remap_reader(table_set.Desc); new cmd_wraper.table_cmd(curr_conn, new data.tbname(cfgtbl.Key), wspace.TargetDb).load_records(tinr); table_set.Records = tinr.Values; all_data.Add(table_set); } // remap id / name foreach (var tins in all_data) { var desc = tins.Desc; for (int i = 0; i < tins.Records.Count; ++i) { var data = tins.Records[i]; var kvp = get_info_by_fakekey(data.record_id, data.serverid); tins.Records[i].record_id = kvp.Key; tins.Records[i].record_name = kvp.Value; } } // save all Action <TableIdNameDesc, List <TableIdNameInfo>, data.tbname> act = (x, y, z) => { var rinw = new cog_wraper.remap_idname_batch_writer(x, y); new cmd_wraper.table_cmd(curr_conn, z, wspace.TargetDb).update_record(rinw); }; var wait_for_saving = new List <TableIdNameInfo>(); int page_size = 1000; foreach (var tins in all_data) { var desc = tins.Desc; foreach (var v in tins.Records) { wait_for_saving.Add(v); if (wait_for_saving.Count > page_size) { act(desc, wait_for_saving, tins.table_name); wait_for_saving.Clear(); } } if (wait_for_saving.Count > 0) { act(desc, wait_for_saving, tins.table_name); wait_for_saving.Clear(); } } // data to local disk profile.Remaped_IdNameTables = all_data; new cpe_wraper.serialize_op <List <TableIdNameInfoSet> >().save(file_data_name, profile.Remaped_IdNameTables); }
public nltable_cmd(data.database conn, data.dbname dbname, data.tbname tblname) { this.conn = conn; this.database_name = dbname; this.table_name = tblname; }
private void create_alonewith_database_operation(workspace wspace) { var all_data = new List <TableIdInfoSet>(); foreach (var cfgtbl in configed_tables) { var table_name = new data.tbname(cfgtbl.Key); // create table new cmd_wraper.table_cmd(curr_conn, table_name, wspace.TargetDb).drop_table(true); new cnl_wrapper.nltable_cmd(curr_conn, wspace.TargetDb, table_name).copy_from(wspace.SchemaDatabase); // fill data foreach (var v in wspace.SourceDbs) { new cnl_wrapper.nltable_cmd(curr_conn, wspace.TargetDb, table_name).fill_from(v); } } // load datas foreach (var cfgtbl in configed_tables) { var table_set = new TableIdInfoSet(); table_set.table_name = new data.tbname(cfgtbl.Key); table_set.Desc = new TableIdInfoDesc(); table_set.Desc.columns = new List <string>(); foreach (var key_name in cfgtbl.Value) { table_set.Desc.columns.Add(key_name); } var tir = new cog_wraper.table_idremap_reader(table_set.Desc); new cmd_wraper.table_cmd(curr_conn, new data.tbname(cfgtbl.Key), wspace.TargetDb).load_records(tir); table_set.Records = tir.Values; all_data.Add(table_set); } // remap ids foreach (var tis in all_data) { var desc = tis.Desc; foreach (var record in tis.Records) { for (int i = 0; i < record.values.Count; ++i) { var curr_v = record.values[i]; var server_id = record.serverid; if (curr_v > 0) { var new_id = get_dbid_by_fakekey(curr_v, server_id); record.values[i] = new_id; } else { record.values[i] = 0; } } } } Action <TableIdInfoDesc, List <TableIdInfo>, data.tbname> act = (x, y, z) => { var rbw = new cog_wraper.remapid_batch_writer(x, y); new cmd_wraper.table_cmd(curr_conn, z, wspace.TargetDb).update_record(rbw); }; List <TableIdInfo> wait_for_saving = new List <TableIdInfo>(); int page_size = 1000; // change it if sql text is too long // save all ids foreach (var tis in all_data) { var desc = tis.Desc; foreach (var ti in tis.Records) { // todo batch update wait_for_saving.Add(ti); if (wait_for_saving.Count > page_size) { // save batch act(desc, wait_for_saving, tis.table_name); wait_for_saving.Clear(); } } if (wait_for_saving.Count > 0) { // save batch act(desc, wait_for_saving, tis.table_name); } } // data to loacal disk profile.Remaped_IdTables = all_data; new cpe_wraper.serialize_op <List <TableIdInfoSet> >().save(file_data_name, profile.Remaped_IdTables); }
void create_alonewith_database_operation(workspace wspace) { var all_data = new List <ScriptIdInfoSet>(); // load all foreach (var cfgtbl in configed_columns) { var tbl_name = new data.tbname(cfgtbl.Key); var column_name = cfgtbl.Value; var siis = new ScriptIdInfoSet(); siis.table_name = tbl_name; siis.Desc = new ScriptIdInfoDesc(); siis.Desc.column_name = cfgtbl.Value; // load data var sir = new cog_wraper.script_id_reader(siis.Desc); new cmd_wraper.table_cmd(curr_conn, tbl_name, wspace.TargetDb).load_records(sir); siis.Records = sir.Values; all_data.Add(siis); } // remap all(why not in same line? face to human is better than face to cpu) foreach (var s in all_data) { var desc = s.Desc; var table_name = s.table_name.table_name; var column_name = desc.column_name; var patterns = new cqx_wraper.qxtable_loader().load_pattern_by_script_id(config_file_name, table_name, column_name); foreach (var p in s.Records) { p.new_info = p.old_info; foreach (var pattern in patterns) { var oldinfo = p.new_info; var p1 = pattern.Key; var p2 = pattern.Value; var matches = System.Text.RegularExpressions.Regex.Matches(p.new_info, p1); foreach (System.Text.RegularExpressions.Match m in matches) { var secondinfo = m.Value; var m2 = System.Text.RegularExpressions.Regex.Matches(m.Value, p2); if (m2.Count > 1) { throw new Exception("too complex match,try a special method"); } var m3 = UInt64.Parse(((System.Text.RegularExpressions.Match)m2[0]).Value); var serverinfo = p.serverid; var m4 = get_dbid_by_fakekey(m3, serverinfo); var replaced_info = secondinfo.Replace(m3.ToString(), m4.ToString()); oldinfo = oldinfo.Replace(secondinfo, replaced_info); } p.new_info = oldinfo; } } } Action <ScriptIdInfoDesc, List <ScriptIdInfo>, data.tbname> act = (x, y, z) => { var siw = new cog_wraper.script_id_writer(x, y); new cmd_wraper.table_cmd(curr_conn, z, wspace.TargetDb).update_record(siw); }; // save to db all int page_size = 1000; foreach (var s in all_data) { var wait_for_saving = new List <ScriptIdInfo>(); foreach (var p in s.Records) { wait_for_saving.Add(p); if (wait_for_saving.Count > page_size) { act(s.Desc, wait_for_saving, s.table_name); wait_for_saving.Clear(); } } if (wait_for_saving.Count > 0) { act(s.Desc, wait_for_saving, s.table_name); wait_for_saving.Clear(); } } // save to local disk profile.RemapedScriptsTable = all_data; new cpe_wraper.serialize_op <List <ScriptIdInfoSet> >().save(file_data_name, profile.RemapedScriptsTable); }
public table_cmd(data.database db, data.tbname table_name, data.dbname db_name) { current_conn = db; this.table_name = table_name.table_name; this.db_name = db_name.database_name; }