protected override void Run <TConn, TCommand, TParameter, TAdaptor, TException>(BaseAdoStore <TConn, TCommand, TParameter, TAdaptor, TException> manager) { try { String schema = manager.CheckSchema(); AdoSchemaDefinition def = AdoSchemaHelper.SchemaDefinitions.Where(d => d.Name.Equals(schema)).FirstOrDefault(); if (def != null) { String script = def.GetScript(AdoSchemaScriptType.Drop, AdoSchemaScriptDatabase.MicrosoftSqlServer); if (script != null) { manager.ExecuteSqlFromResource(script); } else { Console.Error.WriteLine("rdfSqlStorage: Error: Schema " + schema + " does not have a drop script associated with it so cannot be dropped with this tool"); } } else { Console.Error.WriteLine("rdfSqlStorage: Error: Schema " + schema + " is not a built-in schema so cannot be created/dropped with this tool"); } } finally { manager.Dispose(); } }
public override void Run(string[] args) { if (args.Length < 2) { this.ShowUsage(); return; } if (args[1].Equals("-help")) { this.ShowUsage(); return; } String schema = args[1]; AdoSchemaDefinition def = AdoSchemaHelper.SchemaDefinitions.Where(d => d.Name.Equals(schema)).FirstOrDefault(); if (def == null) { Console.Error.WriteLine("rdfSqlStorage: Error: There is no built-in schema named '" + schema + "', use the listschemas mode to view available built-in schemas"); return; } else { Console.WriteLine("rdfSqlStorage: There are " + def.ScriptDefinitions.Count() + " scripts available for the '" + schema + "' schema:"); foreach (AdoSchemaScriptDefinition scriptDef in def.ScriptDefinitions) { String type = scriptDef.ScriptType.ToString(); type = type.Substring(type.LastIndexOf(".") + 1); Console.WriteLine(type + " -> " + scriptDef.ScriptResource); } } }
public override void Run(string[] args) { if (args.Length < 4) { this.ShowUsage(); return; } if (args[1].Equals("-help")) { this.ShowUsage(); return; } //Get the arguments AdoSchemaScriptDatabase db = AdoSchemaScriptDatabase.MicrosoftSqlServer; switch (args[1].ToLower()) { case "sql": case "azure": db = AdoSchemaScriptDatabase.MicrosoftSqlServer; break; default: Console.Error.WriteLine("rdfSqlStorage: Error: '" + args[1] + "' is not a supported database type, supported types are: sql, azure"); return; } String schema = args[2]; AdoSchemaDefinition def = AdoSchemaHelper.SchemaDefinitions.Where(d => d.Name.Equals(schema)).FirstOrDefault(); if (def == null) { Console.Error.WriteLine("rdfSqlStorage: Error: There is no built-in schema named '" + schema + "', use the listschemas mode to view available built-in schemas"); return; } else { AdoSchemaScriptType scriptType = AdoSchemaScriptType.Create; switch (args[3].ToLower()) { case "create": scriptType = AdoSchemaScriptType.Create; break; case "drop": scriptType = AdoSchemaScriptType.Drop; break; default: Console.Error.WriteLine("rdfSqlStorage: Error: '" + args[3] + "' is not a supported script, supported values are: Create, Drop"); return; } if (def.HasScript(scriptType, db)) { String scriptResource = def.GetScript(scriptType, db); if (scriptResource != null) { Stream stream = Assembly.GetAssembly(typeof(AdoSchemaDefinition)).GetManifestResourceStream(scriptResource); if (stream != null) { using (StreamReader reader = new StreamReader(stream)) { Console.WriteLine(reader.ReadToEnd()); reader.Close(); } } else { Console.Error.WriteLine("rdfSqlStorage: Error: Schema '" + schema + "' has a " + args[3] + " available for database type " + args[1] + " but it the script resource could not be extracted from the DLL"); return; } } else { Console.Error.WriteLine("rdfSqlStorage: Error: Schema '" + schema + "' does not have a " + args[3] + " available for database type " + args[1]); return; } } else { Console.Error.WriteLine("rdfSqlStorage: Error: Schema '" + schema + "' does not have a " + args[3] + " available for database type " + args[1]); return; } } }