Ejemplo n.º 1
0
        private void StartSync_Click(object sender, EventArgs e)
        {
            // start the sync manager
            try
            {
                // Save settings
                connectionSettings.writeSetting("connection", "address", tAddress.Text);
                connectionSettings.writeSetting("connection", "port", tPort.Text);
                connectionSettings.writeSetting("account", "directory", tDirectory.Text);
                connectionSettings.writeSetting("connection", "syncTime", tTimeout.Text);

                bStart.IsEnabled = false;
                lDetails.Items.Clear();
                lFileVersions.Items.Clear();
                lDeletedFiles.Items.Clear();
                lDeletedFileVersions.Items.Clear();
                ControlloModifiche.Inizializza();
                this.GetFiles();
                this.GetDelFiles();
                bStop.IsEnabled      = true;
                bSyncNow.IsEnabled   = true;
                tDirectory.IsEnabled = false;
                tTimeout.IsEnabled   = false;
                bBrowse.IsEnabled    = false;
                tAddress.IsEnabled   = false;
                tPort.IsEnabled      = false;
                updateStatus("Started");
            }
            catch (Exception ex) when(ex is ServerException || ex is ClientException)
            {
                bStart.IsEnabled = true;
                updateStatus(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void lDeletedFileVersions_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DependencyObject obj = (DependencyObject)e.OriginalSource;

            while (obj != null && obj != lDeletedFiles)
            {
                if (obj.GetType() == typeof(System.Windows.Controls.ListViewItem))
                {
                    DateTime deletedVersion = ((FileVersionListViewItem)lDeletedFileVersions.SelectedItem).sTimestamp;

                    foreach (DateTime fv in deletedFileUtente.Items)
                    {
                        if (deletedVersion == fv)
                        {
                            deletedFileVersion = fv;
                        }
                    }

                    MessageBoxResult res = System.Windows.MessageBox.Show("Do you want to restore file \"" + deletedFileUtente.Nome + "\" with version " + deletedVersion + " ?", "Restore system", System.Windows.MessageBoxButton.YesNo);

                    if (res == MessageBoxResult.Yes)
                    {
                        try
                        {
                            if (Command.Logged == true)
                            {
                                ControlloModifiche.StopTimer();
                                Command getVersComm = new ComandoScaricaFile(deletedFileUtente.Nome, deletedFileUtente.Path, deletedFileVersion);
                                getVersComm.esegui();
                                this.GetDelFiles();
                                ControlloModifiche.Inizializza();
                            }
                            else
                            {
                                Command loginComm = new ComandoLogin(connectionSettings.readSetting("account", "username"), connectionSettings.readSetting("account", "password"));
                                loginComm.esegui();
                            }
                        }
                        catch (ServerException ex)
                        {
                            System.Windows.MessageBox.Show("Restore failed\n" + ex.Message, "Restoring system", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    break;
                }
                obj = VisualTreeHelper.GetParent(obj);
            }
        }