Ejemplo n.º 1
0
        //autofac uses this
        public SyncDialog(ProjectFolderConfiguration projectFolderConfiguration,
			SyncUIDialogBehaviors behavior, SyncUIFeatures uiFeatureFlags)
        {
            InitializeComponent();
            try
            {
                Behavior = behavior;
                _syncControl.Model = new SyncControlModel(projectFolderConfiguration, uiFeatureFlags, null/*to do*/);
                AcceptButton = _syncControl._cancelButton;
                // CancelButton =  _syncControl._cancelOrCloseButton;

                _syncControl.Model.SynchronizeOver += new EventHandler(_syncControl_SynchronizeOver);

                //we don't want clients digging down this deeply, so we present it as one of our properties
                FinalStatus = _syncControl.Model.StatusProgress;

                //set the default based on whether this looks like a backup or local commit operation
                UseTargetsAsSpecifiedInSyncOptions = (Behavior == SyncUIDialogBehaviors.StartImmediately ||
                                                      Behavior == SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished);

                //in case the user cancels before the sync and the client doesn't check to see if the result is null
                if ((uiFeatureFlags & SyncUIFeatures.SimpleRepositoryChooserInsteadOfAdvanced) == SyncUIFeatures.SimpleRepositoryChooserInsteadOfAdvanced)
                {
                    SyncResult = new SyncResults();
                    SyncResult.Succeeded = false;

                    _syncStartControl.Init(HgRepository.CreateOrUseExisting(projectFolderConfiguration.FolderPath, new NullProgress()));

                    _syncControl.Dock = DockStyle.Fill;//in designer, we don't want it to cover up everything, but we do at runtime
                    _syncStartControl.Visible = true;
                    _syncControl.Visible = false;
                    Height = _syncStartControl.DesiredHeight;
                }
                else
                {
                    _syncStartControl.Visible = false;
                    _syncControl.Visible = true;
                    Height = _syncControl.DesiredHeight;
                }
                ResumeLayout(true);
                this.Text = string.Format("Send/Receive ({0})", _syncControl.Model.UserName);
            }
            catch (Exception)
            {
                _syncStartControl.Dispose();//without this, the usbdetector just goes on and on
                throw;
            }
        }
Ejemplo n.º 2
0
        public delegate SyncDialog Factory(SyncUIDialogBehaviors behavior, SyncUIFeatures uiFeatureFlags);        //autofac uses this

        public SyncDialog(ProjectFolderConfiguration projectFolderConfiguration,
                          SyncUIDialogBehaviors behavior, SyncUIFeatures uiFeatureFlags)
        {
            InitializeComponent();
            try
            {
                Behavior           = behavior;
                _syncControl.Model = new SyncControlModel(projectFolderConfiguration, uiFeatureFlags, null /*to do*/);
                AcceptButton       = _syncControl._cancelButton;
                // CancelButton =  _syncControl._cancelOrCloseButton;

                _syncControl.Model.SynchronizeOver += new EventHandler(_syncControl_SynchronizeOver);

                //we don't want clients digging down this deeply, so we present it as one of our properties
                FinalStatus = _syncControl.Model.StatusProgress;

                //set the default based on whether this looks like a backup or local commit operation
                UseTargetsAsSpecifiedInSyncOptions = (Behavior == SyncUIDialogBehaviors.StartImmediately ||
                                                      Behavior == SyncUIDialogBehaviors.StartImmediatelyAndCloseWhenFinished);

                //in case the user cancels before the sync and the client doesn't check to see if the result is null
                if ((uiFeatureFlags & SyncUIFeatures.SimpleRepositoryChooserInsteadOfAdvanced) == SyncUIFeatures.SimpleRepositoryChooserInsteadOfAdvanced)
                {
                    SyncResult           = new SyncResults();
                    SyncResult.Succeeded = false;

                    _syncStartControl.Init(HgRepository.CreateOrUseExisting(projectFolderConfiguration.FolderPath, new NullProgress()));

                    _syncControl.Dock         = DockStyle.Fill;            //in designer, we don't want it to cover up everything, but we do at runtime
                    _syncStartControl.Visible = true;
                    _syncControl.Visible      = false;
                    Height = _syncStartControl.DesiredHeight;
                }
                else
                {
                    _syncStartControl.Visible = false;
                    _syncControl.Visible      = true;
                    Height = _syncControl.DesiredHeight;
                }
                ResumeLayout(true);
                this.Text = string.Format("Send/Receive ({0})", _syncControl.Model.UserName);
            }
            catch (Exception)
            {
                _syncStartControl.Dispose();                //without this, the usbdetector just goes on and on
                throw;
            }
        }
Ejemplo n.º 3
0
        // 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();
                }
            }
        }
Ejemplo n.º 4
0
 public Form CreateSynchronizationDialog(SyncUIDialogBehaviors behavior, SyncUIFeatures uiFeaturesFlags)
 {
     return _container.Resolve<SyncDialog.Factory>()(behavior, uiFeaturesFlags);
 }
Ejemplo n.º 5
0
 public Form CreateSynchronizationDialog(SyncUIDialogBehaviors behavior, SyncUIFeatures uiFeaturesFlags)
 {
     return(_container.Resolve <SyncDialog.Factory>()(behavior, uiFeaturesFlags));
 }