예제 #1
0
        static void Main(string[] args)
        {
            ObjectFactory.Initialize(x =>
            {
                x.Scan(y =>
                {
                    y.WithDefaultConventions();
                    y.LookForRegistries();
                    //y.AssembliesFromPath(Environment.CurrentDirectory, a => a.FullName.StartsWith("Lending"));
                    y.AssembliesFromPath(Environment.CurrentDirectory, Blah);
                });
            });

            ObjectFactory.AssertConfigurationIsValid();
            string blah = ObjectFactory.WhatDoIHave();

            SchemaUpdater.UpdateSchema();

            //using (var host = new NancyHost(new Uri("http://localhost:8080")))
            //{
            //    host.Start();
            //    Console.WriteLine("Nancy has started");
            //    Console.ReadLine();
            //}


            var host = new AppHost();

            host.Init();
            host.Start("http://localhost:8085/");
            Console.WriteLine("Listening, GO!");
            Console.ReadLine();
        }
        public void Import(MigrationToolOptions settings)
        {
            var sourceImportFilePath = Path.Combine(settings.SourceDirectory, "localization-resource-translations.sql");

            if (!File.Exists(sourceImportFilePath))
            {
                throw new IOException($"Import source file '{sourceImportFilePath}' not found!");
            }

            // create DB structures in target database
            var updater = new SchemaUpdater();

            updater.Execute(new UpdateSchema.Command());

            var fileInfo = new FileInfo(sourceImportFilePath);
            var script   = fileInfo.OpenText().ReadToEnd();

            using (var connection = new SqlConnection(settings.ConnectionString))
            {
                connection.Open();

                using (var command = new SqlCommand(script, connection))
                {
                    command.ExecuteNonQuery();
                }
            }
        }
예제 #3
0
 private void InitializeDb(MigrationToolOptions settings)
 {
     try
     {
         var updater = new SchemaUpdater();
         updater.Execute(new UpdateSchema.Command());
     }
     catch
     {
         // it's OK to have exception here
     }
 }
예제 #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, SchemaUpdater schemaUpdater)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();


            schemaUpdater.UpdateSchema(CancellationToken.None).GetAwaiter().GetResult();
        }
        public void CanRunMigration()
        {
            using (var connection = GetDbConnection("TestDb"))
            {
                var schemaUpdater = new SchemaUpdater
                                        {
                                            Assembly = Assembly.GetExecutingAssembly(),
                                            Namespace = "Cheezburger.SchemaManager.Tests",
                                            Mappings = { new SchemaMapping { Name = "Schema.xml" } }
                                        };

                connection.Open();
                schemaUpdater.Upgrade(connection, true, Log.Write);
                connection.Close();
            }

            AssertTableExists("Category");
        }
예제 #6
0
        public void CanRunMigration()
        {
            using (var connection = GetDbConnection("TestDb"))
            {
                var schemaUpdater = new SchemaUpdater
                {
                    Assembly  = Assembly.GetExecutingAssembly(),
                    Namespace = "Cheezburger.SchemaManager.Tests",
                    Mappings  = { new SchemaMapping {
                                      Name = "Schema.xml"
                                  } }
                };

                connection.Open();
                schemaUpdater.Upgrade(connection, true, Log.Write);
                connection.Close();
            }

            AssertTableExists("Category");
        }
예제 #7
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            var settings = Properties.Settings.Default;

            settings.DefaultMaxFDR       = Convert.ToDouble(maxQValueComboBox.Text) / 100;
            settings.DefaultMaxImportFDR = Convert.ToDouble(maxImportFdrComboBox.Text) / 100;
            settings.DefaultMinSpectraPerDistinctMatch   = Convert.ToInt32(minSpectraPerMatchTextBox.Text);
            settings.DefaultMinSpectraPerDistinctPeptide = Convert.ToInt32(minSpectraPerPeptideTextBox.Text);
            settings.DefaultMaxPrecursorMzError          = maxPrecursorMzToleranceTextBox.Text.Length > 0 ? maxPrecursorMzToleranceTextBox.Text + " " + maxPrecursorMzToleranceUnitsComboBox.SelectedItem.ToString() : String.Empty;
            settings.DefaultMaxProteinGroupsPerPeptide   = Convert.ToInt32(maxProteinGroupsTextBox.Text);
            settings.DefaultMinDistinctPeptides          = Convert.ToInt32(minDistinctPeptidesTextBox.Text);
            settings.DefaultMinSpectra            = Convert.ToInt32(minSpectraTextBox.Text);
            settings.DefaultMinAdditionalPeptides = Convert.ToInt32(minAdditionalPeptidesTextBox.Text);
            settings.DefaultDecoyPrefix           = defaultDecoyPrefixTextBox.Text;
            settings.DefaultMaxRank = Convert.ToInt32(maxImportRankTextBox.Text);
            settings.DefaultIgnoreUnmappedPeptides = ignoreUnmappedPeptidesCheckBox.Checked;

            settings.DefaultGeneLevelFiltering         = filterByGeneCheckBox.Checked;
            settings.DefaultChargeIsDistinct           = chargeIsDistinctCheckBox.Checked;
            settings.DefaultAnalysisIsDistinct         = analysisIsDistinctCheckBox.Checked;
            settings.DefaultModificationsAreDistinct   = modificationsAreDistinctCheckbox.Checked;
            settings.DefaultModificationRoundToNearest = Convert.ToDecimal(modificationRoundToMassTextBox.Text);

            settings.FastaPaths.Clear(); settings.FastaPaths.AddRange(lbFastaPaths.Items.OfType <string>().ToArray());
            settings.SourcePaths.Clear(); settings.SourcePaths.AddRange(lbSourcePaths.Items.OfType <string>().ToArray());

            settings.SourceExtensions     = sourceExtensionsTextBox.Text;
            settings.GroupConcatSeparator = groupSeparatorTextBox.Text;
            SchemaUpdater.SetGroupConcatSeparator(settings.GroupConcatSeparator);

            Properties.GUI.Settings.Default.QuantitationRollupMethod = (QuantitationRollupMethod)(quantitationRollupMethodComboBox.SelectedIndex + 1);

            Properties.GUI.Settings.Default.WarnAboutNonFixedDrive  = nonFixedDriveWarningCheckBox.Checked;
            Properties.GUI.Settings.Default.WarnAboutNoGeneMetadata = embedGeneMetadataWarningCheckBox.Checked;
            Properties.GUI.Settings.Default.Save();

            settings.Save();
        }
예제 #8
0
        public static ISessionFactory CreateSessionFactory (string path, SessionFactoryConfig config)
        {
            string uncCompatiblePath = Util.GetSQLiteUncCompatiblePath(path);

            // update the existing database's schema if necessary, and if updated, recreate the indexes
            if (path != ":memory:" &&
                File.Exists(path) &&
                IsValidFile(path) &&
                SchemaUpdater.Update(path, null))
            {
                using (var conn = new SQLiteConnection(String.Format("Data Source={0};Version=3", uncCompatiblePath)))
                {
                    conn.Open();
                    conn.ExecuteNonQuery(@"PRAGMA journal_mode=DELETE;
                                           PRAGMA synchronous=OFF;
                                           PRAGMA automatic_indexing=OFF;
                                           PRAGMA cache_size=30000;
                                           PRAGMA temp_store=MEMORY;
                                           PRAGMA page_size=32768;
                                           PRAGMA mmap_size=70368744177664; -- 2^46");
                    DropIndexes(conn);
                    CreateIndexes(conn);
                }
            }

            bool pooling = path == ":memory:";

            var configuration = new Configuration()
                .SetProperty("show_sql", config.WriteSqlToConsoleOut ? "true" : "false")
                .SetProperty("dialect", typeof(CustomSQLiteDialect).AssemblyQualifiedName)
                .SetProperty("hibernate.cache.use_query_cache", "true")
                //.SetProperty("adonet.batch_size", batchSize.ToString())
                .SetProperty("connection.connection_string", String.Format("Data Source={0};Version=3;{1}", uncCompatiblePath, (pooling ? "Pooling=True;Max Pool Size=1;" : "")))
                .SetProperty("connection.driver_class", typeof(NHibernate.Driver.SQLite20Driver).AssemblyQualifiedName)
                .SetProperty("connection.provider", typeof(NHibernate.Connection.DriverConnectionProvider).AssemblyQualifiedName)
                .SetProperty("connection.release_mode", "on_close")
                ;

            ConfigureMappings(configuration);

            if (config.UseUnfilteredTables)
            {
                configuration.ClassMappings.Single(o => o.Table.Name == "Protein").Table.Name = "UnfilteredProtein";
                configuration.ClassMappings.Single(o => o.Table.Name == "Peptide").Table.Name = "UnfilteredPeptide";
                configuration.ClassMappings.Single(o => o.Table.Name == "PeptideInstance").Table.Name = "UnfilteredPeptideInstance";
                configuration.ClassMappings.Single(o => o.Table.Name == "PeptideSpectrumMatch").Table.Name = "UnfilteredPeptideSpectrumMatch";
                configuration.ClassMappings.Single(o => o.Table.Name == "Spectrum").Table.Name = "UnfilteredSpectrum";
            }

            ISessionFactory sessionFactory = null;
            lock(mutex)
                sessionFactory = configuration.BuildSessionFactory();

            sessionFactory.OpenStatelessSession().CreateSQLQuery(@"PRAGMA cache_size=10000;
                                                                   PRAGMA temp_store=MEMORY;
                                                                   PRAGMA page_size=32768;
                                                                   PRAGMA mmap_size=70368744177664; -- 2^46").ExecuteUpdate();

            if (config.CreateSchema)
                CreateFile(path);

            return sessionFactory;
        }
예제 #9
0
        public void CreateTable_ShouldSucceed_ForNonEmptyTableName()
        {
            using var schemaUpdater = new SchemaUpdater(new NpgsqlConnection(ConnectionString));

            Assert.NotEqual(0, schemaUpdater.CreateTable("testTable"));
        }
 public TestPostgresUsage(string connectionString)
 {
     schemaUpdater = new SchemaUpdater(new NpgsqlConnection(connectionString));
 }
예제 #11
0
 public OtherTestPostgresUsage(NpgsqlConnection connection)
 {
     schemaUpdater = new SchemaUpdater(connection);
 }