// empty #region GeneratorDataCollectionCreate #if !NCORE // FIXME: THIS DOES NOTHING?! /// <summary> /// this is a template method—as in that it is generally an empty method. /// </summary> static public void GeneratorDataCollectionCreate() { sfd.Filter = "xconfig|*.xconfig|xml|*.xml|all files|*"; #if WPF4 if (!sfd.ShowDialog().Value) { return; } #elif !NCORE if (sfd.ShowDialog() != DialogResult.OK) { return; } #endif List <string> list = new List <string>(); string fname = sfd.FileName; DatabaseCollection c = DatabaseCollection.Load(fname); int dbid = 1, tid = 1; foreach (DatabaseElement elmDb in c.Databases) { using (var ct = new System.Cor3.Data.Context.SQLiteContext()) { foreach (TableElement elmT in elmDb.Items) { foreach (FieldElement elmF in elmT.Fields) { } tid++; } } dbid++; } // string output = string.Empty; // using (SQLiteContext c0 = new SQLiteContext()) // { // c.Select("select * from sqlite_master"); // using (DataView v = c.Data.GetDataView(0)) // { // foreach (DataRowView row in v) // { // list.Add(string.Format("# {0}",row["name"])); // list.Add(""); // list.Add(row["sql"].ToString()); // list.Add(""); // } // } // } }
void RunMatcherBenchmark() { #if !MONO if (Options.RenderGraph) { AccuracyStatistics.GraphDrawer = (curve, file) => { WpfIO.Save(RocGraph.Render(curve), file); } } ; #endif string dbPath = Path.Combine("Extractor", "Templates.dat"); if (File.Exists(dbPath)) { TestDatabase.Load(dbPath); } else { RunExtractorBenchmark(); } Console.WriteLine("Running matcher benchmark"); MatcherReport report = MatcherBenchmark.Run(); Console.WriteLine("Saving matcher report"); report.Save("Matcher"); } void RunOptimizer() { Optimizer.OnException += delegate(Exception e) { Console.WriteLine("Optimizer iteration failed: {0}", e.ToString()); }; Optimizer.Mutations.OnMutation += delegate(ParameterValue initial, ParameterValue mutated) { Console.WriteLine("Mutated {0}, {1} -> {2}", initial.FieldPath, initial.Value.Double, mutated.Value.Double); }; Optimizer.NicheSlot.OnAccepted += message => { Console.WriteLine("-----> Accepted: " + message); Optimizer.NicheSlot.Save("Optimizer"); }; Optimizer.NicheSlot.OnRejected += message => { Console.WriteLine("Rejected: " + message); }; Console.WriteLine("Running optimizer"); Optimizer.Run(); }
void InitializeConfiguration(object o, RoutedEventArgs a) { // try { Model.Databases = DatabaseCollection.Load(Model.Configuration.datafile); Model.Templates = TemplateCollection.Load(Model.Configuration.templatefile); // why is this necessary? Model.Databases.Rechild(); a.Handled = true; // } catch (Exception e) { // throw e; // } finally { if (InitializeCompleteAction != null) { InitializeCompleteAction.Invoke(); } // } }
/// <summary> /// <para>1. Iterate through the databases and tables inserting them as it goes.</para> /// <para> /// Data contained in the database file is destroyed/replaced if there were /// any database configuration elements. /// </para> /// <para> /// TODO: Support will be added to append (even a duplicate) data-configs to an /// existing configuration. /// </para> /// </summary> /// <param name="xmlDataConfig"></param> /// <param name="databaseFile"></param> static public void XmlToDatabaseConfiguration(string xmlDataConfig, string databaseFile) { // we need to ensure that the tables exist. DatabaseCollection c = DatabaseCollection.Load(xmlDataConfig); int countdb = 0, counttable = 0, countfield = 0; foreach (DatabaseElement elmDb in c.Databases) { string query = null; using (SQLiteDb db = new SQLiteDb(databaseFile)) { using (SQLiteConnection C = db.Connection) { query = "insert into [gen-data-db] ([crd],[mod],[Name],[PrimaryKey],[ConnectionType]) values(@crd,@mod,@Name,@PrimaryKey,@ConnectionType);"; using (SQLiteDataAdapter A = new SQLiteDataAdapter(string.Empty, C)) { C.Open(); A.InsertCommand = new SQLiteCommand(query, C); A.InsertCommand.Parameters.AddWithValue("@crd", DateTime.Now); A.InsertCommand.Parameters.AddWithValue("@mod", DateTime.Now); A.InsertCommand.Parameters.AddWithValue("@Name", elmDb.Name); A.InsertCommand.Parameters.AddWithValue("@PrimaryKey", elmDb.PrimaryKey); A.InsertCommand.Parameters.AddWithValue("@ConnectionType", elmDb.ConnectionType == ConnectionType.None?"":elmDb.ConnectionType.ToString()); try { A.InsertCommand.ExecuteNonQuery(); countdb++; } catch (Exception exc) { System.Diagnostics.Debug.Assert(false, exc.ToString()); } C.Close(); } // we can iterate again foreach (TableElement tpl in elmDb.Items) { using (SQLiteDataAdapter A = new SQLiteDataAdapter(string.Empty, C)) { query = "insert into [gen-data-table] ([pid],[crd],[mod],[Name],[DbType],[Description],[PrimaryKey]) values(@pid,@crd,@mod,@Name,@DbType,@Description,@PrimaryKey);"; C.Open(); A.InsertCommand = new SQLiteCommand(query, C); A.InsertCommand.Parameters.AddWithValue("@crd", DateTime.Now); A.InsertCommand.Parameters.AddWithValue("@mod", DateTime.Now); A.InsertCommand.Parameters.AddWithValue("@pid", countdb); A.InsertCommand.Parameters.AddWithValue("@Name", tpl.Name); A.InsertCommand.Parameters.AddWithValue("@DbType", tpl.DbType == "Unspecified"?"":tpl.DbType.ToString()); A.InsertCommand.Parameters.AddWithValue("@Description", tpl.Description); A.InsertCommand.Parameters.AddWithValue("@PrimaryKey", tpl.PrimaryKey); try { A.InsertCommand.ExecuteNonQuery(); counttable++; } catch (Exception exc) { System.Diagnostics.Debug.Assert(false, exc.ToString()); // if (MessageBox.Show(exc.ToString(),"table")== MessageBoxResult.OK) return; ; } C.Close(); } foreach (FieldElement fld in tpl.Fields) { query = @" insert into [gen-data-field] ( [crd], [mod], [pid], [BlockAction], [CodeBlock], [DataName], [Name], [DataType], [DataTypeNative], [DefaultValue], [Description], [FormatString], [FormType], [IsNullable], [MaxLength], [Tags], [UseFormat] ) VALUES ( @crd, @mod, @pid, @BlockAction, @CodeBlock, @DataName, @DataName, @DataType, @DataTypenative, @DefaultValue, @Description, @FormatString, @FormType, @IsNullable, @MaxLength, @Tags, @UseFormat);" ; using (SQLiteDataAdapter A = new SQLiteDataAdapter(string.Empty, C)) { C.Open(); A.InsertCommand = new SQLiteCommand(query, C); A.InsertCommand.Parameters.AddWithValue("@crd", DateTime.Now); A.InsertCommand.Parameters.AddWithValue("@mod", DateTime.Now); A.InsertCommand.Parameters.AddWithValue("@pid", counttable); A.InsertCommand.Parameters.AddWithValue("@BlockAction", fld.BlockAction); A.InsertCommand.Parameters.AddWithValue("@CodeBlock", fld.CodeBlock); A.InsertCommand.Parameters.AddWithValue("@DataName", fld.DataName); A.InsertCommand.Parameters.AddWithValue("@DataType", fld.DataType); A.InsertCommand.Parameters.AddWithValue("@DataTypeNative", fld.DataTypeNative); A.InsertCommand.Parameters.AddWithValue("@DefaultValue", fld.DefaultValue); A.InsertCommand.Parameters.AddWithValue("@Description", fld.Description); A.InsertCommand.Parameters.AddWithValue("@FormatString", fld.FormatString); A.InsertCommand.Parameters.AddWithValue("@FormType", fld.FormType); A.InsertCommand.Parameters.AddWithValue("@IsNullable", fld.IsNullable); A.InsertCommand.Parameters.AddWithValue("@MaxLength", fld.MaxLength); A.InsertCommand.Parameters.AddWithValue("@Tags", fld.Tags); // A.InsertCommand.Parameters.AddWithValue("@ToolTip",fld.ToolTip); A.InsertCommand.Parameters.AddWithValue("@UseFormat", fld.UseFormat); // A.InsertCommand.Parameters.AddWithValue("@DataName",fld.); try { A.InsertCommand.ExecuteNonQuery(); countfield++; } catch (Exception exc) { System.Diagnostics.Debug.Assert(false, exc.ToString()); // if (MessageBox.Show(exc.ToString(),"gen-data-field")== MessageBoxResult.OK) return; ; } C.Close(); } } } } } } }