Пример #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (Directory.Exists(Application.StartupPath))
            {
                assemblies.Clear();
                namespaces.Clear();
                Sqo.Siaqodb siaqodb = new Sqo.Siaqodb(Application.StartupPath);
                try
                {
                    siaqodb.DropType <ReferenceItem>();
                    siaqodb.DropType <NamespaceItem>();
                    foreach (object o in listBox1.Items)
                    {
                        ReferenceItem refItem = o as ReferenceItem;
                        if (refItem == null)
                        {
                            refItem = new ReferenceItem(o.ToString());
                        }
                        assemblies.Add(refItem);
                        siaqodb.StoreObject(refItem);

                        if (File.Exists(refItem.Item))
                        {
                            try
                            {
                                File.Copy(refItem.Item, Application.StartupPath + Path.DirectorySeparatorChar + Path.GetFileName(refItem.Item), true);
                            }
                            catch
                            {
                            }
                        }
                    }
                    foreach (string s in textBox1.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        NamespaceItem nobj = new NamespaceItem(s);
                        namespaces.Add(nobj);
                        siaqodb.StoreObject(nobj);
                    }
                }
                finally
                {
                    siaqodb.Close();
                }
            }

            this.DialogResult = DialogResult.OK;
        }
Пример #2
0
        static void Main(string[] args)
        {
            //in the folder ..\..\database\ there it is saved Company objects with Siaqodb 4.X
            //Now we'll migrate those objects to Siaqodb 5.0
            Sqo.Siaqodb siaqodb5 = new Sqo.Siaqodb(@"..\..\database\");
            siaqodb5.DropType <Company>();

            SiaqodbUtil.Migrate(siaqodb5);


            var all5 = siaqodb5.LoadAll <Company>();

            if (all5.Count == 10)
            {
                Console.WriteLine("All objects are migrated to Siaqodb 5.0 database.");
            }
            else
            {
                Console.WriteLine("Something wrong with the migration process or you imported twice or more.");
            }
            siaqodb5.Close();

            //you can still see Siaqodb 4.X objects by using Dotissi namespace
            //This is just for backward compatibility, it should not be used for other scopes
            Dotissi.Siaqodb siaqodb4 = new Dotissi.Siaqodb(@"..\..\database\");

            var all4 = siaqodb4.LoadAll <Company>();

            if (all4.Count == 10)
            {
                Console.WriteLine("All objects of Siaqodb 4.X are still here... ");
            }
            else
            {
                Console.WriteLine("Something wrong and Siaqodb4.X objects cannot be find anymore.");
            }
            Console.ReadLine();
        }