示例#1
0
 /// <summary>
 /// Gets whether the definition has a specific script
 /// </summary>
 /// <param name="type">Script Type</param>
 /// <param name="db">Database Type</param>
 /// <returns></returns>
 public bool HasScript(AdoSchemaScriptType type, AdoSchemaScriptDatabase db)
 {
     return this._scripts.Any(s => s.ScriptType == type && s.Database == db);
 }
示例#2
0
 /// <summary>
 /// Gets the Script resource name (or null if it doesn't exist) for a specific script
 /// </summary>
 /// <param name="type">Script Type</param>
 /// <param name="db">Database Type</param>
 /// <returns></returns>
 public String GetScript(AdoSchemaScriptType type, AdoSchemaScriptDatabase db)
 {
     return this._scripts.Where(s => s.ScriptType == type && s.Database == db).Select(d => d.ScriptResource).FirstOrDefault();
 }
示例#3
0
 /// <summary>
 /// Creates a new Schema Script Definition
 /// </summary>
 /// <param name="type">Script Type</param>
 /// <param name="db">Database Type</param>
 /// <param name="resource">Resource Name</param>
 public AdoSchemaScriptDefinition(AdoSchemaScriptType type, AdoSchemaScriptDatabase db, String resource)
 {
     this.ScriptType = type;
     this.Database = db;
     this.ScriptResource = resource;
 }
示例#4
0
        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;
                }
            }
        }
示例#5
0
 /// <summary>
 /// Gets the Script resource name (or null if it doesn't exist) for a specific script
 /// </summary>
 /// <param name="type">Script Type</param>
 /// <param name="db">Database Type</param>
 /// <returns></returns>
 public String GetScript(AdoSchemaScriptType type, AdoSchemaScriptDatabase db)
 {
     return(this._scripts.Where(s => s.ScriptType == type && s.Database == db).Select(d => d.ScriptResource).FirstOrDefault());
 }
示例#6
0
 /// <summary>
 /// Gets whether the definition has a specific script
 /// </summary>
 /// <param name="type">Script Type</param>
 /// <param name="db">Database Type</param>
 /// <returns></returns>
 public bool HasScript(AdoSchemaScriptType type, AdoSchemaScriptDatabase db)
 {
     return(this._scripts.Any(s => s.ScriptType == type && s.Database == db));
 }
示例#7
0
 /// <summary>
 /// Creates a new Schema Script Definition
 /// </summary>
 /// <param name="type">Script Type</param>
 /// <param name="db">Database Type</param>
 /// <param name="resource">Resource Name</param>
 public AdoSchemaScriptDefinition(AdoSchemaScriptType type, AdoSchemaScriptDatabase db, String resource)
 {
     this.ScriptType     = type;
     this.Database       = db;
     this.ScriptResource = resource;
 }