Ejemplo n.º 1
0
    public void update()
    {
        int verzijaBaze = SqlCeUtilities.getDatabaseVersionNumber();

        if (verzijaBaze == Program.VERZIJA_PROGRAMA)
        {
            return;
        }

        if (verzijaBaze > Program.VERZIJA_PROGRAMA)
        {
            throw new Exception("Greska u programu. Verzija baze je veca od verzije programa.");
        }

        int  staraVerzijaBaze = verzijaBaze;
        bool converted        = false;

        if (verzijaBaze == -1 /*baza ne postoji*/)
        {
            SqlCeUtilities.ExecuteScript(ConfigurationParameters.DatabaseFile, ConfigurationParameters.Password,
                                         "Soko.Update.DatabaseUpdate_version1.txt", true);
            SqlCeUtilities.updateDatabaseVersionNumber(1);
            verzijaBaze = 1;
            converted   = true;
        }

        if (verzijaBaze == 1 && Program.VERZIJA_PROGRAMA > 1)
        {
            SqlCeUtilities.ExecuteScript(ConfigurationParameters.DatabaseFile, ConfigurationParameters.Password,
                                         "Soko.Update.DatabaseUpdate_version2.txt", true);
            SqlCeUtilities.updateDatabaseVersionNumber(2);
            UpdateDolazakNaTreningMesecni();
            verzijaBaze = 2;
            converted   = true;
        }

        if (verzijaBaze == 2 && Program.VERZIJA_PROGRAMA > 2)
        {
            SqlCeUtilities.updateDatabaseVersionNumber(3);
            UpdateDolazakNaTreningMesecniJedanDnevniTrening();
            verzijaBaze = 3;
            converted   = true;
        }

        if (converted)
        {
            string msg = String.Format("Baza podataka je konvertovana iz verzije {0} u verziju {1}.", staraVerzijaBaze,
                                       verzijaBaze);
            MessageBox.Show(msg, "Bilten");

            if (File.Exists("NHibernateConfig"))
            {
                File.Delete("NHibernateConfig");
            }
        }
    }
Ejemplo n.º 2
0
        public void TestFixtureSetUp()
        {
            // Export schema from BiltenPodaci.sdf using the ExportSqlCe.exe tool.
            string           schemaFile = "BiltenPodaciScript.sql";
            ProcessStartInfo startInfo  = new ProcessStartInfo();

            startInfo.FileName  = @"..\..\..\..\Bilten\Libs\ExportSqlCe.exe";
            startInfo.Arguments =
                String.Format("\"Data Source=..\\..\\..\\Bilten\\bin\\Debug\\BiltenPodaci.sdf\" {0} schemaonly",
                              schemaFile);
            var process = Process.Start(startInfo);

            process.WaitForExit();

            // Create database using the schema script, or (if database exists) delete data.
            string databaseFile = "BiltenPodaci.sdf";
            bool   createdNew   = SqlCeUtilities.CreateDatabase(databaseFile, "", false);

            if (createdNew)
            {
                // Kreiraj semu
                SqlCeUtilities.ExecuteScript(databaseFile, "", Path.GetFullPath(schemaFile), false);
            }
            else
            {
                // Brisi podatke
                SqlCeUtilities.ExecuteScript(databaseFile, "", Path.GetFullPath(@"..\..\BiltenPodaciDelete.sql"), false);
            }


            // Create configuration and build session factory.
            _configuration = new Configuration();
            _configuration.Configure();
            _configuration.AddAssembly(typeof(Klub).Assembly);
            _sessionFactory = _configuration.BuildSessionFactory();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                int verzijaBaze = SqlCeUtilities.getDatabaseVersionNumber();
                if (verzijaBaze != VERZIJA_PROGRAMA)
                {
                    if (verzijaBaze == 0)
                    {
                        string msg = "Bazu podataka je nemoguce konvertovati da radi sa trenutnom verzijom programa.";
                        MessageBox.Show(msg, "Registracija");
                        return;
                    }
                    if (verzijaBaze > VERZIJA_PROGRAMA)
                    {
                        string msg = "Greska u programu. Verzija baze je veca od verzije programa.";
                        MessageBox.Show(msg, "Registracija");
                        return;
                    }

                    bool converted = false;
                    if (verzijaBaze == 1 && VERZIJA_PROGRAMA > 1)
                    {
                        SqlCeUtilities.ExecuteScript(ConfigurationParameters.DatabaseFile, "",
                                                     "Registracija.Update.DatabaseUpdate_version2.sql", true);
                        verzijaBaze = 2;
                        converted   = true;
                    }

                    if (converted)
                    {
                        string msg = String.Format("Baza podataka je konvertovana u verziju {0}.", verzijaBaze);
                        MessageBox.Show(msg, "Bilten");

                        if (File.Exists("NHibernateConfig"))
                        {
                            File.Delete("NHibernateConfig");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            Language.SetKeyboardLanguage(Language.acKeyboardLanguage.hklSerbianLatin);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("sr-Latn-CS");
            // ili
            // Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("sr-Cyrl-CS");
            //Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);



            // Kreiranje prazne baze
            //new SqlCeUtilities().CreateDatabase(@"..\..\clanovi_podaci2.sdf", "sdv");

            //new DatabaseUpdater().updateDatabase();

            //MainForm mainForm = new MainForm();
            //Application.Run(mainForm);
            SingleInstanceApplication.Application.Run(args);
        }