コード例 #1
0
ファイル: Program.cs プロジェクト: sillsdevarchive/onestory
        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();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sillsdevarchive/onestory
        // 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();
                }
            }
        }