Пример #1
0
        private void ExecuteAdministrativeScript(DatabaseServer server, string scriptUri)
        {
            Uri uri = new Uri(scriptUri);
            StreamResourceInfo resource = Application.GetResourceStream(uri);

            string sql = string.Empty;

            using (StreamReader reader = new StreamReader(resource.Stream))
            {
                sql = reader.ReadToEnd();
            }

            if (scriptUri == CREATE_PUBLIC_ENDPOINT_SCRIPT && server.ServiceBrokerPortNumber != 4022)
            {
                sql = sql.Replace("LISTENER_PORT = 4022", "LISTENER_PORT = " + server.ServiceBrokerPortNumber.ToString());
            }

            IMetadataService metadata = Services.GetService <IMetadataService>();

            metadata.Configure(server, null);

            IScriptingService scripting = Services.GetService <IScriptingService>();

            scripting.ExecuteBatch(sql, out IList <ParseError> errors);

            if (errors.Count > 0)
            {
                throw new InvalidOperationException(ExceptionHelper.GetParseErrorsText(errors));
            }
        }
Пример #2
0
 private static void ConfigureMetadataService(IMetadataService metadata, MetadataServiceSettings settings, IWebHostEnvironment environment)
 {
     if (string.IsNullOrWhiteSpace(settings.Catalog))
     {
         settings.Catalog = MetadataCatalogPath(environment);
     }
     metadata.Configure(settings);
 }