Exemple #1
0
        private static void Init()
        {
            if (!_init)
            {
                //Register Hash schema and set as default
                _defs.Add(new AdoSchemaDefinition("Hash", "A schema that uses MD5 hash based indexes to provide better Node ID lookup speed",
                                                  new AdoSchemaScriptDefinition[]
                {
                    new AdoSchemaScriptDefinition(AdoSchemaScriptType.Create, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.CreateMicrosoftAdoHashStore.sql"),
                    new AdoSchemaScriptDefinition(AdoSchemaScriptType.Drop, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.DropMicrosoftAdoHashStore.sql")
                }));
                _default = _defs[0];

                //Register Simple schemas
                _defs.Add(new AdoSchemaDefinition("Simple", "A simple schema that uses partial value indexes to speed up Node ID lookups",
                                                  new AdoSchemaScriptDefinition[]
                {
                    new AdoSchemaScriptDefinition(AdoSchemaScriptType.Create, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.CreateMicrosoftAdoSimpleStore.sql"),
                    new AdoSchemaScriptDefinition(AdoSchemaScriptType.Drop, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.DropMicrosoftAdoSimpleStore.sql"),
                    //new AdoSchemaScriptDefinition(AdoSchemaScriptType.Create, AdoSchemaScriptDatabase.SqlServerCe, "VDS.RDF.Storage.CreateSqlServerCeAdoSimpleStore.sql"),
                    //new AdoSchemaScriptDefinition(AdoSchemaScriptType.Drop, AdoSchemaScriptDatabase.SqlServerCe, "VDS.RDF.Storage.DropSqlServerCeAdoSimpleStore.sql")
                }));
                _defs.Add(new AdoSchemaDefinition("Simple 2000", "A variant of the Simple schema that should work on pre-2005 SQL Server instances",
                                                  new AdoSchemaScriptDefinition[]
                {
                    new AdoSchemaScriptDefinition(AdoSchemaScriptType.Create, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.CreateMicrosoftAdoSimple2000Store.sql"),
                    new AdoSchemaScriptDefinition(AdoSchemaScriptType.Drop, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.DropMicrosoftAdoSimple2000Store.sql")
                }));
                _init = true;
            }
        }
Exemple #2
0
 /// <summary>
 /// Removes a Schema Definition
 /// </summary>
 /// <param name="def">Definition</param>
 public static void RemoveSchema(AdoSchemaDefinition def)
 {
     if (!_init)
     {
         Init();
     }
     _defs.Remove(def);
 }
Exemple #3
0
 /// <summary>
 /// Adds a new Schema Definition
 /// </summary>
 /// <param name="def">Definition</param>
 public static void AddSchema(AdoSchemaDefinition def)
 {
     if (!_init)
     {
         Init();
     }
     _defs.Add(def);
 }
Exemple #4
0
        protected override int EnsureSetup(Dictionary <string, string> parameters)
        {
            try
            {
                AdoSchemaHelper.DefaultSchema = AdoSchemaHelper.GetSchema("Simple");
                AdoSchemaDefinition definition = AdoSchemaHelper.DefaultSchema;
                if (definition == null)
                {
                    throw new RdfStorageException("Unable to setup ADO Store for SQL Server Compact as no default schema is currently available from AdoSchemaHelper.DefaultSchema");
                }
                if (!definition.HasScript(AdoSchemaScriptType.Create, AdoSchemaScriptDatabase.MicrosoftSqlServer))
                {
                    throw new RdfStorageException("Unable to setup ADO Store for SQL Server Compact as the current default schema does not provide a compatible creation script");
                }

                String resource = definition.GetScript(AdoSchemaScriptType.Create, AdoSchemaScriptDatabase.MicrosoftSqlServer);
                if (resource == null)
                {
                    throw new RdfStorageException("Unable to setup ADO Store for SQL Server Compact as the default schema returned a null resource for the creation script");
                }

                //Get the appropriate assembly
                Assembly assm;
                if (resource.Contains(","))
                {
                    //Assembly qualified name so need to do an Assembly.Load()
                    String assmName = resource.Substring(resource.IndexOf(",") + 1).TrimStart();
                    resource = resource.Substring(0, resource.IndexOf(",")).TrimEnd();
                    try
                    {
                        assm = Assembly.Load(assmName);
                    }
                    catch (Exception ex)
                    {
                        throw new RdfStorageException("Unable to setup ADO Store for SQL Server Compact as the creation script is the resource '" + resource + "' from assembly '" + assmName + "' but this assembly could not be loaded, please see inner exception for details", ex);
                    }
                }
                else
                {
                    //Assume executing assembly
                    assm = Assembly.GetExecutingAssembly();
                }

                Stream s = assm.GetManifestResourceStream(resource);
                if (s != null)
                {
                    try
                    {
                        this.ExecuteSql(s);

                        //Now try and add the user to the rdf_readwrite role
                        if (parameters["user"] != null)
                        {
                            try
                            {
                                SqlCeCommand cmd = new SqlCeCommand();
                                cmd.Connection  = this.Connection;
                                cmd.CommandText = "EXEC sp_addrolemember 'rdf_readwrite', @user;";
                                cmd.Parameters.Add(this.GetParameter("user"));
                                cmd.Parameters["user"].Value = parameters["user"];
                                cmd.ExecuteNonQuery();

                                //Succeeded - return 1
                                return(1);
                            }
                            catch (SqlCeException sqlEx)
                            {
                                throw new RdfStorageException("ADO Store database for SQL Server Compact was created successfully but we were unable to add you to an appropriate ADO Store role automatically.  Please manually add yourself to one of the following roles - rdf_admin, rdf_readwrite, rdf_readinsert or rdf_readonly - before attempting to use the store", sqlEx);
                            }
                        }
                        else
                        {
                            throw new RdfStorageException("ADO Store database for SQL Server Compact was created successfully but you are using a trusted connection so the system was unable to add you to an appropriate ADO Store role.  Please manually add yourself to one of the following roles - rdf_admin, rdf_readwrite, rdf_readinsert or rdf_readonly - before attempting to use the store");
                        }
                    }
                    catch (SqlCeException sqlEx)
                    {
                        throw new RdfStorageException("Failed to create ADO Store database for SQL Server Compact due to errors executing the creation script, please see inner exception for details.", sqlEx);
                    }
                }
                else
                {
                    throw new RdfStorageException("Unable to setup ADO Store for SQL Server Compact as database creation script is missing from the referenced assembly");
                }
            }
            finally
            {
                AdoSchemaHelper.DefaultSchema = AdoSchemaHelper.GetSchema("Hash");
            }
        }
Exemple #5
0
 /// <summary>
 /// Removes a Schema Definition
 /// </summary>
 /// <param name="def">Definition</param>
 public static void RemoveSchema(AdoSchemaDefinition def)
 {
     if (!_init) Init();
     _defs.Remove(def);
 }
Exemple #6
0
 /// <summary>
 /// Adds a new Schema Definition
 /// </summary>
 /// <param name="def">Definition</param>
 public static void AddSchema(AdoSchemaDefinition def)
 {
     if (!_init) Init();
     _defs.Add(def);
 }
Exemple #7
0
        private static void Init()
        {
            if (!_init)
            {
                //Register Hash schema and set as default
                _defs.Add(new AdoSchemaDefinition("Hash", "A schema that uses MD5 hash based indexes to provide better Node ID lookup speed",
                    new AdoSchemaScriptDefinition[] 
                    { 
                        new AdoSchemaScriptDefinition(AdoSchemaScriptType.Create, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.CreateMicrosoftAdoHashStore.sql"),
                        new AdoSchemaScriptDefinition(AdoSchemaScriptType.Drop, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.DropMicrosoftAdoHashStore.sql")
                    }));
                _default = _defs[0];

                //Register Simple schemas
                _defs.Add(new AdoSchemaDefinition("Simple", "A simple schema that uses partial value indexes to speed up Node ID lookups",
                    new AdoSchemaScriptDefinition[]
                    {
                        new AdoSchemaScriptDefinition(AdoSchemaScriptType.Create, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.CreateMicrosoftAdoSimpleStore.sql"),
                        new AdoSchemaScriptDefinition(AdoSchemaScriptType.Drop, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.DropMicrosoftAdoSimpleStore.sql"),
                        //new AdoSchemaScriptDefinition(AdoSchemaScriptType.Create, AdoSchemaScriptDatabase.SqlServerCe, "VDS.RDF.Storage.CreateSqlServerCeAdoSimpleStore.sql"),
                        //new AdoSchemaScriptDefinition(AdoSchemaScriptType.Drop, AdoSchemaScriptDatabase.SqlServerCe, "VDS.RDF.Storage.DropSqlServerCeAdoSimpleStore.sql")
                    }));
                _defs.Add(new AdoSchemaDefinition("Simple 2000", "A variant of the Simple schema that should work on pre-2005 SQL Server instances",
                    new AdoSchemaScriptDefinition[]
                    {
                        new AdoSchemaScriptDefinition(AdoSchemaScriptType.Create, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.CreateMicrosoftAdoSimple2000Store.sql"),
                        new AdoSchemaScriptDefinition(AdoSchemaScriptType.Drop, AdoSchemaScriptDatabase.MicrosoftSqlServer, "VDS.RDF.Storage.DropMicrosoftAdoSimple2000Store.sql")
                    }));
                _init = true;
            }
        }