예제 #1
0
        private void CopyFederationMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem            menuItem = (MenuItem)sender;
            FederationViewModel view     = (FederationViewModel)menuItem.DataContext;
            FederationInfo      info     = view.Federationinfo;
            SessionBase         session  = view.Session;
            var lDialog = new System.Windows.Forms.FolderBrowserDialog()
            {
                Description = "Choose Federation Copy Folder",
            };

            if (lDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string copyDir = lDialog.SelectedPath;
                if (session.InTransaction)
                {
                    session.Commit(); // must not be in transaction while copying databases
                }
                session.CopyAllDatabasesTo(copyDir);
                session = info.GetSession();
                session.BeginUpdate();
                FederationCopyInfo copyInfo = new FederationCopyInfo(Dns.GetHostName(), copyDir);
                session.Persist(copyInfo);
                info.Update();
                info.FederationCopies.Add(copyInfo);
                session.Commit();
                MessageBox.Show("Databases copied to " + copyDir + " at " + DateTime.Now);
            }
        }
예제 #2
0
        private void CopyFederationMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem            menuItem = (MenuItem)sender;
            FederationViewModel view     = (FederationViewModel)menuItem.DataContext;
            FederationInfo      info     = view.Federationinfo;
            SessionBase         session  = view.Session;
            var lDialog = new System.Windows.Forms.FolderBrowserDialog()
            {
                Description = "Choose Federation Copy Folder",
            };

            if (lDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string copyDir = lDialog.SelectedPath;
                session.CopyAllDatabasesTo(copyDir);
                session = info.Session;
                session.BeginUpdate();
                FederationCopyInfo copyInfo = new FederationCopyInfo(Dns.GetHostName(), copyDir);
                session.Persist(copyInfo);
                info.Update();
                info.FederationCopies.Add(copyInfo);
                session.Commit();
            }
        }