Beispiel #1
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;
            }
        }
Beispiel #2
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;
            }
        }
Beispiel #3
0
        public SyncControlModel(ProjectFolderConfiguration projectFolderConfiguration, 
            SyncUIFeatures uiFeatureFlags,
            IChorusUser user)
        {
            _user = user;
            _progress = new MultiProgress();
            StatusProgress = new SimpleStatusProgress();
            _progress.Add(StatusProgress);
            Features = uiFeatureFlags;
            _synchronizer = Synchronizer.FromProjectConfiguration(projectFolderConfiguration, _progress);
            _backgroundWorker = new BackgroundWorker();
            _backgroundWorker.WorkerSupportsCancellation = true;
            _backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_backgroundWorker_RunWorkerCompleted);
            _backgroundWorker.DoWork += worker_DoWork;

            //clients will normally change these
            SyncOptions = new SyncOptions();
            SyncOptions.CheckinDescription = "[" + Application.ProductName + ": " + Application.ProductVersion + "] sync";
            SyncOptions.DoPullFromOthers = true;
            SyncOptions.DoMergeWithOthers = true;
            SyncOptions.RepositorySourcesToTry.AddRange(GetRepositoriesToList().Where(r => r.Enabled));
        }
Beispiel #4
0
        public SyncControlModel(ProjectFolderConfiguration projectFolderConfiguration,
                                SyncUIFeatures uiFeatureFlags,
                                IChorusUser user)
        {
            _user          = user;
            _progress      = new MultiProgress();
            StatusProgress = new SimpleStatusProgress();
            _progress.Add(StatusProgress);
            Features          = uiFeatureFlags;
            _synchronizer     = Synchronizer.FromProjectConfiguration(projectFolderConfiguration, _progress);
            _backgroundWorker = new BackgroundWorker();
            _backgroundWorker.WorkerSupportsCancellation = true;
            _backgroundWorker.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(_backgroundWorker_RunWorkerCompleted);
            _backgroundWorker.DoWork += worker_DoWork;

            //clients will normally change these
            SyncOptions = new SyncOptions();
            SyncOptions.CheckinDescription = "[" + Application.ProductName + ": " + Application.ProductVersion + "] sync";
            SyncOptions.DoPullFromOthers   = true;
            SyncOptions.DoMergeWithOthers  = true;
            SyncOptions.RepositorySourcesToTry.AddRange(GetRepositoriesToList().Where(r => r.Enabled));
        }
Beispiel #5
0
        public static void Inject(ContainerBuilder builder, string projectPath, SyncUIFeatures syncDialogFeatures)
        {
            //TODO: shouldn't we have people provide the whole project configuration? Otherwise, we have an empty set of
            //include/exlcude patterns, so new files aren't going to get added.  Maybe if we're going to do that, it
            //doesn't make sense for this to do the injecting at all... maybe the client should do it.  Similar issue
            //below, with SyncUIFeatures

            builder.Register <ProjectFolderConfiguration>(
                c => new ProjectFolderConfiguration(projectPath)).InstancePerLifetimeScope();

            builder.RegisterType <NavigateToRecordEvent>().InstancePerLifetimeScope();

            builder.RegisterInstance(new NullProgress()).As <IProgress>();
            builder.Register <Synchronizer>(c => Chorus.sync.Synchronizer.FromProjectConfiguration(
                                                c.Resolve <ProjectFolderConfiguration>(), new NullProgress()));
            builder.Register <HgRepository>(c => HgRepository.CreateOrUseExisting(projectPath, new NullProgress())).InstancePerLifetimeScope();


            //this is a sad hack... I don't know how to simly override the default using the container,
            //which I'd rather do, and just leave this to pushing in the "normal"
            builder.Register <SyncUIFeatures>(c => syncDialogFeatures).As <SyncUIFeatures>().SingleInstance();

            builder.RegisterInstance(new EmbeddedMessageContentHandlerRepository());

            builder.RegisterInstance(ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers()).SingleInstance();

            builder.RegisterType <SyncPanel>().InstancePerLifetimeScope();
            builder.RegisterType <SyncControlModel>().InstancePerLifetimeScope();
            builder.RegisterType <SyncDialog>().InstancePerDependency();           //NB: was FactoryScoped() before switch to autofac 2, which corresponds to this InstancePerDependency
            builder.RegisterGeneratedFactory <SyncDialog.Factory>().InstancePerLifetimeScope();
            builder.RegisterType <Chorus.UI.Misc.TroubleshootingView>().InstancePerLifetimeScope();

            RegisterSyncStuff(builder);
            RegisterReviewStuff(builder);
            RegisterSettingsStuff(builder);

            InjectNotesUI(builder);
        }
        public static void Inject(ContainerBuilder builder, string projectPath, SyncUIFeatures syncDialogFeatures)
        {
            //TODO: shouldn't we have people provide the whole project configuration? Otherwise, we have an empty set of
            //include/exlcude patterns, so new files aren't going to get added.  Maybe if we're going to do that, it
            //doesn't make sense for this to do the injecting at all... maybe the client should do it.  Similar issue
            //below, with SyncUIFeatures

            builder.Register<ProjectFolderConfiguration>(
               c => new ProjectFolderConfiguration(projectPath)).InstancePerLifetimeScope();

            builder.RegisterType<NavigateToRecordEvent>().InstancePerLifetimeScope();

            builder.RegisterInstance(new NullProgress()).As<IProgress>();
            builder.Register<Synchronizer>(c => Chorus.sync.Synchronizer.FromProjectConfiguration(
                                                    c.Resolve<ProjectFolderConfiguration>(), new NullProgress()));
            builder.Register<HgRepository>(c => HgRepository.CreateOrUseExisting(projectPath, new NullProgress())).InstancePerLifetimeScope();

            //this is a sad hack... I don't know how to simly override the default using the container,
            //which I'd rather do, and just leave this to pushing in the "normal"
            builder.Register<SyncUIFeatures>(c => syncDialogFeatures).As<SyncUIFeatures>().SingleInstance();

            builder.RegisterInstance(new EmbeddedMessageContentHandlerRepository());

            builder.RegisterInstance(ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers()).SingleInstance();

            builder.RegisterType<SyncPanel>().InstancePerLifetimeScope();
            builder.RegisterType<SyncControlModel>().InstancePerLifetimeScope();
            builder.RegisterType<SyncDialog>().InstancePerDependency();//NB: was FactoryScoped() before switch to autofac 2, which corresponds to this InstancePerDependency
            builder.RegisterGeneratedFactory<SyncDialog.Factory>().InstancePerLifetimeScope();
            builder.RegisterType<Chorus.UI.Misc.TroubleshootingView>().InstancePerLifetimeScope();

            RegisterSyncStuff(builder);
            RegisterReviewStuff(builder);
            RegisterSettingsStuff(builder);

            InjectNotesUI(builder);
        }
Beispiel #7
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();
                }
            }
        }
Beispiel #8
0
 public Form CreateSynchronizationDialog(SyncUIDialogBehaviors behavior, SyncUIFeatures uiFeaturesFlags)
 {
     return _container.Resolve<SyncDialog.Factory>()(behavior, uiFeaturesFlags);
 }
Beispiel #9
0
 public bool HasFeature(SyncUIFeatures feature)
 {
     return (Features & feature) == feature;
 }
Beispiel #10
0
 public bool HasFeature(SyncUIFeatures feature)
 {
     return((Features & feature) == feature);
 }
Beispiel #11
0
 public Form CreateSynchronizationDialog(SyncUIDialogBehaviors behavior, SyncUIFeatures uiFeaturesFlags)
 {
     return(_container.Resolve <SyncDialog.Factory>()(behavior, uiFeaturesFlags));
 }