public static void BackupInRepo(string strProjectFolder) { // the project folder name has come here bogus at times... if (!Directory.Exists(strProjectFolder)) { return; } // if there's no repo yet, then create one (even if we aren't going // to ultimately push with an internet repo, we still want one locally) var projectConfig = new Chorus.sync.ProjectFolderConfiguration(strProjectFolder); projectConfig.IncludePatterns.Add("*.onestory"); projectConfig.IncludePatterns.Add("*.xml"); // the P7 key terms list projectConfig.IncludePatterns.Add("*.bad"); // if we write a bad file, commit that as well projectConfig.IncludePatterns.Add("*.ChorusNotes"); // the new conflict file // even if the user doesn't want to go to the internet, we // at least want to back up locally (when the user closes) using (var dlg = new SyncDialog(projectConfig, SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished, SyncUIFeatures.Minimal)) { dlg.Text = "OneStory Automatic Backup... Please wait"; dlg.SyncOptions.DoMergeWithOthers = false; dlg.SyncOptions.DoPullFromOthers = false; dlg.SyncOptions.DoSendToOthers = false; dlg.ShowDialog(); } }
public AnkiWebSync(MainPage mainPage) { this.mainPage = mainPage; syncStateDialog = new SyncDialog(mainPage.CurrentDispatcher); syncStateDialog.Opened += SyncStateDialogOpened; syncStateDialog.Closed += SyncStateDialogClosed; }
public FullSync(MainPage mainPage, ISyncInstance syncInstance) { this.mainPage = mainPage; syncStateDialog = new SyncDialog(mainPage.CurrentDispatcher); syncStateDialog.Opened += SyncStateDialogOpened; syncStateDialog.Closed += SyncStateDialogClosed; this.syncInstance = syncInstance; }
static void OpenNoteSyncWindow(object sender, EventArgs args) { if (sync_dlg == null) { sync_dlg = new SyncDialog(); sync_dlg.Response += OnSyncDialogResponse; } sync_dlg.Present(); }
private void OnSendReceive(object obj) { using (SyncDialog dlg = (SyncDialog)_chorusSystem.WinForms.CreateSynchronizationDialog()) { dlg.ShowDialog(); if (dlg.SyncResult.DidGetChangesFromOthers) { Invoke(ReopenCurrentProject); } } }
public void LaunchDialog_AutoWithMinimalUI() { using (var setup = new RepositorySetup("pedro")) { Application.EnableVisualStyles(); var dlg = new SyncDialog(setup.ProjectFolderConfig, SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished, SyncUIFeatures.Minimal); dlg.ShowDialog(); } }
private void syncDbButton_Click(object sender, EventArgs e) { using (var dlg = new SyncDialog()) { if (dlg.ShowDialog() != DialogResult.OK) { return; } } RefreshData(); }
public void MinimalCodeToLaunchSendReceiveUI() { var projectConfig = new ProjectFolderConfiguration("c:\\TokPisin"); projectConfig.IncludePatterns.Add("*.lift"); using (var dlg = new SyncDialog(projectConfig, SyncUIDialogBehaviors.Lazy, SyncUIFeatures.NormalRecommended)) { dlg.ShowDialog(); } }
public void LaunchDialog_BogusTarget_AdmitsError() { using (var setup = new RepositorySetup("pedro")) { Application.EnableVisualStyles(); using (var dlg = new SyncDialog(setup.ProjectFolderConfig, SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished, SyncUIFeatures.Minimal)) { dlg.SyncOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("bogus", @"z:/")); dlg.ShowDialog(); Assert.That(dlg.FinalStatus.WarningEncountered, Is.True); } } }
public void LaunchDialog_LazyWithAdvancedUI() { using (var setup = new RepositorySetup("pedro")) { Application.EnableVisualStyles(); using (var dlg = new SyncDialog(setup.ProjectFolderConfig, SyncUIDialogBehaviors.Lazy, SyncUIFeatures.Advanced)) { // dlg.SyncOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("bogus", @"z:/")); dlg.ShowDialog(); } } }
public void LaunchDialog_LazyWithNormalUI() { Thread.CurrentThread.SetApartmentState(ApartmentState.STA); using (var setup = new RepositorySetup("pedro")) { Application.EnableVisualStyles(); using (var dlg = new SyncDialog(setup.ProjectFolderConfig, SyncUIDialogBehaviors.Lazy, SyncUIFeatures.NormalRecommended)) { dlg.ShowDialog(); } } }
public void LaunchDialog_GoodForCancelTesting() { using (var setup = new RepositorySetup("pedro")) { Application.EnableVisualStyles(); setup.Repository.SetKnownRepositoryAddresses(new RepositoryAddress[] { RepositoryAddress.Create("language forge", "https://*****:*****@hg-public.languageforge.org/tpi"), }); setup.Repository.SetDefaultSyncRepositoryAliases(new[] { "language forge" }); using (var dlg = new SyncDialog(setup.ProjectFolderConfig, SyncUIDialogBehaviors.StartImmediately, SyncUIFeatures.NormalRecommended)) { dlg.ShowDialog(); } } }
public void LaunchDialog_ExampleForBob() { using (var setup = new RepositorySetup("pedro")) { Application.EnableVisualStyles(); setup.Repository.SetKnownRepositoryAddresses(new RepositoryAddress[] { RepositoryAddress.Create("language forge", "https://*****:*****@hg-public.languageforge.org"), }); setup.Repository.SetDefaultSyncRepositoryAliases(new[] { "language forge" }); using (var dlg = new SyncDialog(setup.ProjectFolderConfig, SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished, SyncUIFeatures.Minimal)) { dlg.ShowDialog(); } } }
public void ShowSyncDialog_InternetAndNetworkPaths() { Application.EnableVisualStyles(); using (var setup = new RepositorySetup("pedro")) { setup.Repository.SetKnownRepositoryAddresses(new RepositoryAddress[] { RepositoryAddress.Create("language forge", "https://hg-public.languageforge.org"), RepositoryAddress.Create("joe's mac", "//suzie-pc/public/chorusTest") }); using (var dlg = new SyncDialog(setup.ProjectFolderConfig, SyncUIDialogBehaviors.Lazy, SyncUIFeatures.NormalRecommended)) { dlg.ShowDialog(); } } }
public void Launch(Form parentForm, ProjectInfo projectInfo) { var configuration = (Chorus.sync.ProjectFolderConfiguration) projectInfo.ServiceProvider.GetService(typeof(Chorus.sync.ProjectFolderConfiguration)); using (var dlg = new SyncDialog(configuration, SyncUIDialogBehaviors.Lazy, SyncUIFeatures.NormalRecommended)) { dlg.Text = "WeSay Send/Receive"; dlg.SyncOptions.DoMergeWithOthers = true; dlg.SyncOptions.DoPullFromOthers = true; dlg.SyncOptions.DoSendToOthers = true; dlg.SetSynchronizerAdjunct(new LiftSynchronizerAdjunct(projectInfo.PathToLIFT)); // leave it with the default, for now... dlg.SyncOptions.RepositorySourcesToTry.Clear(); //dlg.SyncOptions.CheckinDescription = CheckinDescriptionBuilder.GetDescription(); dlg.ShowDialog(parentForm); if (dlg.SyncResult != null && dlg.SyncResult.DidGetChangesFromOthers) { // This loop is an attempt to handle a collection-modified-while-iterating exception that is thrown in Application.Restart, // which http://social.msdn.microsoft.com/Forums/windows/en-US/5ad73551-81bd-4525-aa40-fe2772817a99/applicationrestart-throw-exception-collection-was-modified-enumeration-operation-may-not // attributes to closing a window in its OnClosing event. I can't find where we're doing this, but a // plausible workaround seems to be to close all the windows, using a loop which carefully copies the collection // first, and also tries to avoid closing ones that are already closed. foreach (Form form in Application.OpenForms.Cast <object>().Cast <Form>().ToList()) { if (form.Visible) { form.Close(); } } Application.Restart(); } } }
public void CheckPointWithDialog(string dialogTitle) { if (SendReceiveDisabled) { return; //we don't do chorus on our source tree } try { using (var dlg = new SyncDialog(_chorusSystem.ProjectFolderConfiguration, SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished, SyncUIFeatures.Minimal)) { dlg.Text = dialogTitle; dlg.SyncOptions.DoMergeWithOthers = false; dlg.SyncOptions.DoPullFromOthers = false; dlg.SyncOptions.DoSendToOthers = false; dlg.SyncOptions.RepositorySourcesToTry.Clear(); dlg.SyncOptions.CheckinDescription = string.Format(BloomLabelForCheckins + " auto"); dlg.UseTargetsAsSpecifiedInSyncOptions = true; dlg.ShowDialog(); if (dlg.FinalStatus.WarningEncountered || //not finding the backup media only counts as a warning dlg.FinalStatus.ErrorEncountered) { ErrorReport.NotifyUserOfProblem(dlg.FinalStatus.LastException, "There was a problem while storing history in repository. Chorus said:\r\n\r\n" + dlg.FinalStatus.LastWarning + "\r\n" + dlg.FinalStatus.LastError); } } } catch (Exception error) { Palaso.Reporting.Logger.WriteEvent("Error while storing history in repository: {0}", error.Message); //TODO we need some passive way indicating the health of the backup system } }
public void BackupNow(string pathToProjectDirectory, string localizationLanguageId, string pathToLiftFile) { if (pathToProjectDirectory.ToLower().IndexOf(@"sampleprojects\pretend") >= 0) { return; //no way... if you want a unit test that includes CHorus, do it without //that now deprecated monstrosity. } _timeOfLastBackupAttempt = DateTime.Now; //nb: we're not really using the message yet, at least, not showing it to the user if (!string.IsNullOrEmpty(HgRepository.GetEnvironmentReadinessMessage(localizationLanguageId))) { Palaso.Reporting.Logger.WriteEvent("Backup not possible: {0}", HgRepository.GetEnvironmentReadinessMessage("en")); } try { var configuration = new ProjectFolderConfiguration(pathToProjectDirectory); LiftFolder.AddLiftFileInfoToFolderConfiguration(configuration); // projectFolder.IncludePatterns.Add(project.ProjectDirectoryPath); // if (!string.IsNullOrEmpty(PathToParentOfRepositories)) // { // if (!Directory.Exists(PathToParentOfRepositories)) // { // ErrorReport.NotifyUserOfProblem(new ShowOncePerSessionBasedOnExactMessagePolicy(), "There was a problem during auto backup: Could not Access the backup path, {0}", PathToParentOfRepositories); // //no, we still want to check in... return; // } // else // { // var projectName = Path.GetFileName(pathToProjectDirectory); // var backupSource = Chorus.VcsDrivers.RepositoryAddress.Create("backup", Path.Combine(PathToParentOfRepositories, projectName), // false); // options.RepositorySourcesToTry.Add(backupSource); // } // } using (var dlg = new SyncDialog(configuration, SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished, SyncUIFeatures.Minimal)) { dlg.Text = "WeSay Automatic Backup"; dlg.SyncOptions.DoMergeWithOthers = false; dlg.SyncOptions.DoPullFromOthers = false; dlg.SyncOptions.DoSendToOthers = true; dlg.SyncOptions.RepositorySourcesToTry.Clear(); dlg.SyncOptions.CheckinDescription = CheckinDescriptionBuilder.GetDescription(); dlg.UseTargetsAsSpecifiedInSyncOptions = true; dlg.SetSynchronizerAdjunct(new LiftSynchronizerAdjunct(pathToLiftFile)); //in addition to checking in, will we be doing a backup to another media (e.g. sd card)? if (!string.IsNullOrEmpty(PathToParentOfRepositories)) { var projectName = Path.GetFileName(pathToProjectDirectory); var backupSource = Chorus.VcsDrivers.RepositoryAddress.Create("test-backup-media", Path.Combine(PathToParentOfRepositories, projectName), false); dlg.SyncOptions.RepositorySourcesToTry.Add(backupSource); } dlg.ShowDialog(); if (dlg.FinalStatus.WarningEncountered || //not finding the backup media only counts as a warning dlg.FinalStatus.ErrorEncountered) { ErrorReport.NotifyUserOfProblem(new ShowOncePerSessionBasedOnExactMessagePolicy(), "There was a problem during auto backup. Chorus said:\r\n\r\n" + dlg.FinalStatus.LastWarning + "\r\n" + dlg.FinalStatus.LastError); } } CheckinDescriptionBuilder.Clear(); } catch (Exception error) { Palaso.Reporting.Logger.WriteEvent("Error during Backup: {0}", error.Message); //TODO we need some passive way indicating the health of the backup system } }
// e.g. http://bobeaton:[email protected]/snwmtn-test // or \\Bob-StudioXPS\Backup\Storying\snwmtn-test public static void SyncWithRepository(string strProjectFolder, bool bIsOpening) { // the project folder name has come here bogus at times... if (!Directory.Exists(strProjectFolder)) { return; } string strProjectName = Path.GetFileNameWithoutExtension(strProjectFolder); // if there's no repo yet, then create one (even if we aren't going // to ultimately push with an internet repo, we still want one locally) var projectConfig = new Chorus.sync.ProjectFolderConfiguration(strProjectFolder); projectConfig.IncludePatterns.Add("*.onestory"); projectConfig.IncludePatterns.Add("*.xml"); // the P7 key terms list projectConfig.IncludePatterns.Add("*.bad"); // if we write a bad file, commit that as well projectConfig.IncludePatterns.Add("*.conflict"); // include the conflicts file as well so we can fix them projectConfig.IncludePatterns.Add("*.ChorusNotes"); // the new conflict file string strHgUsername, strRepoUrl, strSharedNetworkUrl; if (GetHgRepoParameters(strProjectName, out strHgUsername, out strRepoUrl, out strSharedNetworkUrl)) { if (!String.IsNullOrEmpty(strRepoUrl)) { var nullProgress = new NullProgress(); var repo = new HgRepository(strProjectFolder, nullProgress); if (!repo.GetCanConnectToRemote(strRepoUrl, nullProgress)) { if (MessageBox.Show(Properties.Resources.IDS_ConnectToInternet, Properties.Resources.IDS_Caption, MessageBoxButtons.OKCancel) == DialogResult.Cancel) { strRepoUrl = null; if (String.IsNullOrEmpty(strSharedNetworkUrl)) { return; } } } } // for when we launch the program, just do a quick & dirty send/receive, // but for closing (or if we have a network drive also), then we want to // be more informative SyncUIDialogBehaviors suidb = SyncUIDialogBehaviors.Lazy; SyncUIFeatures suif = SyncUIFeatures.NormalRecommended; /* * if (bIsOpening && String.IsNullOrEmpty(strSharedNetworkUrl)) * { * suidb = SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished; * suif = SyncUIFeatures.Minimal; * } * else * { * suidb = SyncUIDialogBehaviors.Lazy; * suif = SyncUIFeatures.NormalRecommended; * } */ using (var dlg = new SyncDialog(projectConfig, suidb, suif)) { dlg.UseTargetsAsSpecifiedInSyncOptions = true; if (!String.IsNullOrEmpty(strRepoUrl)) { dlg.SyncOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create(CstrInternetName, strRepoUrl)); } if (!String.IsNullOrEmpty(strSharedNetworkUrl)) { dlg.SyncOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create(CstrNetworkDriveName, strSharedNetworkUrl)); } dlg.Text = "Synchronizing OneStory Project: " + strProjectName; dlg.ShowDialog(); } } else if (!bIsOpening) { // even if the user doesn't want to go to the internet, we // at least want to back up locally (when the user closes) using (var dlg = new SyncDialog(projectConfig, SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished, SyncUIFeatures.Minimal)) { dlg.Text = "OneStory Automatic Backup"; dlg.SyncOptions.DoMergeWithOthers = false; dlg.SyncOptions.DoPullFromOthers = false; dlg.SyncOptions.DoSendToOthers = false; dlg.ShowDialog(); } } }
static void OnSyncDialogResponse(object sender, Gtk.ResponseArgs args) { ((Gtk.Widget)sender).Destroy(); sync_dlg = null; }