public SolutionComponentsViewModel(IAsyncJobScheduler scheduler, ILog log, IMessenger messenger)
        {
            this.scheduler = scheduler ?? throw new System.ArgumentNullException(nameof(scheduler));
            this.log       = log ?? throw new System.ArgumentNullException(nameof(log));
            this.messenger = messenger ?? throw new System.ArgumentNullException(nameof(messenger));

            this.Connections = new ObservableCollection <ConnectionModel>();

            this.messenger.WhenObject <MainViewModel>()
            .ChangesProperty(_ => _.AllowRequests)
            .Execute(m => this.AllowRequests = (bool)m.NewValue);


            this.WhenChanges(() => AllowRequests)
            .ChangesAlso(() => CanExecuteComparison);
            this.WhenChanges(() => Solution)
            .ChangesAlso(() => CanExecuteComparison)
            .ChangesAlso(() => SolutionName);

            this.Connections.CollectionChanged += (s, e) => this.OnPropertyChanged(nameof(CanExecuteComparison), this.CanExecuteComparison);

            this.messenger.Register <SolutionSelectedMessage>(OnSolutionSelected);
            this.messenger.Register <ConnectionAddedMessage>(obj => this.Connections.Insert(obj.Index, obj.Model));
            this.messenger.Register <ConnectionRemovedMessage>(obj => this.Connections.Remove(obj.Model));
        }
예제 #2
0
        public ResultTreeViewModel(IAsyncJobScheduler scheduler, IMessenger messenger, ILog log)
        {
            this.messenger = messenger;

            this.DownloadExcelCommand  = new DownloadExcelCommand(scheduler, messenger, log);
            this.CopyToEnv1Command     = new CopyRowCommand(messenger, o => o.AreAllLeftMissingOrDifferentAndNotActioned(), log);
            this.CopyToEnv2Command     = new CopyRowCommand(messenger, o => o.AreAllRightMissingOrDifferentAndNotActioned(), log);
            this.DeleteFromEnv1Command = new DeleteRowCommand(messenger, o => o.AreAllRightMissingOrDifferentAndNotActioned(), log);
            this.DeleteFromEnv2Command = new DeleteRowCommand(messenger, o => o.AreAllLeftMissingOrDifferentAndNotActioned(), log);

            this.WhenChanges(() => SelectedNode)
            .ChangesAlso(() => IsMarkOKEnabled)
            .ChangesAlso(() => IsUnmrkOKEnabled);

            this.WhenChanges(() => this.SelectedResults)
            .Execute(_ => this.messenger.Send(new CompareResultGroupSelected(this.SelectedResults)))
            .Execute(_ => this.CopyToEnv1Command.SelectedResults     = this.SelectedResults)
            .Execute(_ => this.CopyToEnv2Command.SelectedResults     = this.SelectedResults)
            .Execute(_ => this.DeleteFromEnv1Command.SelectedResults = this.SelectedResults)
            .Execute(_ => this.DeleteFromEnv2Command.SelectedResults = this.SelectedResults);



            this.messenger.Register <ResultUpdatedMessage>(o =>
            {
                this.CopyToEnv1Command.RefreshCanExecute();
                this.CopyToEnv2Command.RefreshCanExecute();
                this.DeleteFromEnv1Command.RefreshCanExecute();
                this.DeleteFromEnv2Command.RefreshCanExecute();
            });
        }
예제 #3
0
        public ActionsViewModel(ILog log, IMessenger messenger, IAsyncJobScheduler scheduler)
        {
            this.log       = log ?? throw new System.ArgumentNullException(nameof(log));
            this.messenger = messenger ?? throw new System.ArgumentNullException(nameof(messenger));
            this.scheduler = scheduler ?? throw new System.ArgumentNullException(nameof(scheduler));


            this.Actions = new ActionQueue();
            this.messenger.Register <SubmitActionMessage>(OnActionReceived);

            this.WhenChanges(() => this.Crm1)
            .ChangesAlso(() => CanApplyActions);
            this.WhenChanges(() => this.Crm2)
            .ChangesAlso(() => CanApplyActions);

            this.Actions.ListChanged += (s, e) => OnListChanged();
            this.OnListChanged();

            this.messenger.WhenObject <EnvironmentComparerViewModel>()
            .ChangesProperty(_ => _.Crm1)
            .Execute(e =>
            {
                this.Crm1 = e.GetNewValue <IOrganizationService>();
            });

            this.messenger.WhenObject <EnvironmentComparerViewModel>()
            .ChangesProperty(_ => _.Crm2)
            .Execute(e =>
            {
                this.Crm2 = e.GetNewValue <IOrganizationService>();
            });
        }
예제 #4
0
        public ResultTreeView(
            IThemeProvider themeProvider,
            IAsyncJobScheduler scheduler,
            IMessenger messenger,
            ILog log)
        {
            InitializeComponent();

            this.RegisterHelp(messenger, Topics.ResultTree);

            this.themeProvider = themeProvider ?? throw new ArgumentNullException(nameof(themeProvider));
            this.messenger     = messenger ?? throw new ArgumentNullException(nameof(messenger));
            this.viewModel     = new ResultTreeViewModel(scheduler, messenger, log);


            this.ApplyTheme();

            this.messenger.Register <CompareResultSetAvailable>(m =>
            {
                this.CompareResult = m.CompareResultSet;
            });

            this.cmiMarkOK.Bind(_ => _.Visible, this.viewModel, _ => _.IsMarkOKEnabled);
            this.cmiUnmarkOK.Bind(_ => _.Visible, this.viewModel, _ => _.IsUnmrkOKEnabled);

            this.cmiMarkOK.Bind(_ => _.Enabled, this.viewModel, _ => _.IsMarkOKEnabled);
            this.cmiUnmarkOK.Bind(_ => _.Enabled, this.viewModel, _ => _.IsUnmrkOKEnabled);

            this.tDownloadExcelFile.BindCommand(() => this.viewModel.DownloadExcelCommand);

            this.cmiCopyToEnv1.BindCommand(() => this.viewModel.CopyToEnv1Command, () => 1, CommandExecuteBehavior.EnabledAndVisible);
            this.cmiCopyToEnv2.BindCommand(() => this.viewModel.CopyToEnv2Command, () => 2, CommandExecuteBehavior.EnabledAndVisible);

            this.cmiDeleteFromEnv1.BindCommand(() => this.viewModel.DeleteFromEnv1Command, () => 1, CommandExecuteBehavior.EnabledAndVisible);
            this.cmiDeleteFromEnv2.BindCommand(() => this.viewModel.DeleteFromEnv2Command, () => 2, CommandExecuteBehavior.EnabledAndVisible);


            this.messenger.WhenObject <EnvironmentComparerViewModel>()
            .ChangesProperty(_ => _.ConnectionName1)
            .Execute(e =>
            {
                this.env1                   = e.GetNewValue <string>();
                this.CompareResult          = null;
                this.cmiCopyToEnv1.Text     = "Copy to " + env1;
                this.cmiDeleteFromEnv1.Text = "Delete from " + env1;
            });

            this.messenger.WhenObject <EnvironmentComparerViewModel>()
            .ChangesProperty(_ => _.ConnectionName2)
            .Execute(e =>
            {
                this.env2                   = e.GetNewValue <string>();
                this.CompareResult          = null;
                this.cmiCopyToEnv2.Text     = "Copy to " + env2;
                this.cmiDeleteFromEnv2.Text = "Delete from " + env2;
            });
        }
예제 #5
0
        public EntityTreeViewModel(ILog log, IMessenger messenger, IAsyncJobScheduler scheduler)
        {
            this.log       = log ?? throw new ArgumentNullException(nameof(log));
            this.scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));

            this.LoadEntitiesCommand   = new LoadEntitiesCommand(log, messenger, scheduler);
            this.LoadAttributesCommand = new LoadAttributesCommand(log, messenger, scheduler);

            messenger.Register <EntitiesLoadedMessage>(OnEntitiesLoaded);
        }
예제 #6
0
        public LoadAttributesCommand(ILog log, IMessenger messenger, IAsyncJobScheduler scheduler)
        {
            this.log       = log ?? throw new ArgumentNullException(nameof(log));
            this.messenger = messenger ?? throw new ArgumentNullException(nameof(messenger));
            this.scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));

            this.messenger.Register <ConnectionUpdatedMessage>(OnConnectionUpdated);
            this.messenger.WhenObject <MainViewModel>()
            .ChangesProperty(_ => _.AllowRequests)
            .Execute(x => this.AllowRequests = (bool)x.NewValue);
        }
예제 #7
0
        public SolutionProgressView(
            IAsyncJobScheduler scheduler,
            IImportJobRepository importJobRepository,
            PluginViewModel viewModel,
            TimelineView timeline)
        {
            InitializeComponent();

            this.scheduler           = scheduler ?? throw new System.ArgumentNullException(nameof(scheduler));
            this.importJobRepository = importJobRepository ?? throw new System.ArgumentNullException(nameof(importJobRepository));
            this.viewModel           = viewModel;
            this.timeline            = timeline;
        }
예제 #8
0
        public ActionsView(IThemeProvider themeProvider, IAsyncJobScheduler scheduler, IMessenger messenger, ILog log)
        {
            InitializeComponent();

            this.RegisterHelp(messenger, Topics.Actions);

            this.themeProvider = themeProvider ?? throw new ArgumentNullException(nameof(themeProvider));
            this.viewModel     = new ActionsViewModel(log, messenger, scheduler);

            this.Bind(_ => _.Text, this.viewModel, _ => _.Title);
            this.Bind(_ => _.TabText, this.viewModel, _ => _.Title);

            this.ApplyTheme();

            this.chlActionList.DataSource = viewModel.Actions;
        }
예제 #9
0
        public EntityTreeView(ILog log, IMessenger messenger, IAsyncJobScheduler scheduler)
        {
            this.InitializeComponent();

            this.viewModel = new EntityTreeViewModel(log, messenger, scheduler);
            this.viewModel.PropertyChanged += OnViewModelPropertyChanged;

            this.tLoadEntities.BindCommand(() => this.viewModel.LoadEntitiesCommand);

            messenger.WhenObject <MainViewModel>()
            .ChangesProperty(_ => _.AllowRequests)
            .Execute(m =>
            {
                this.tree.Enabled = m.GetNewValue <bool>();
            });


            messenger.Register <RefreshEntityMessage>(OnRefreshEntity);
        }
        public SolutionManagerPluginControl()
        {
            InitializeComponent();

            var importJobRepository = ImportJob.GetRepository();

            this.scheduler = new AsyncJobScheduler(this, this.viewModel);

            this.dataTreeView = new Views.DataTree.DataTreeView(this.viewModel);
            this.dataTreeView.Show(this.dockPanel, DockState.DockRight);

            this.timelineView = new Views.Timeline.TimelineView();
            this.timelineView.Show(this.dockPanel, DockState.DockBottom);

            this.solutionProgressView = new Views.SolutionProgress.SolutionProgressView(this.scheduler, importJobRepository, this.viewModel, this.timelineView);
            this.solutionProgressView.Show(this.dockPanel, DockState.Document);

            this.tStartMonitoring.DataBindings.Add(nameof(this.tStartMonitoring.Enabled), this.viewModel, nameof(this.viewModel.CanStartMonitoring));
            this.tStopMonitoring.DataBindings.Add(nameof(this.tStopMonitoring.Enabled), this.viewModel, nameof(this.viewModel.CanStopMonitoring));
            this.tStoppingLabel.DataBindings.Add(nameof(this.tStoppingLabel.Visible), this.viewModel, nameof(this.viewModel.StopMonitoringRequested));
        }
예제 #11
0
        public DownloadExcelCommand(IAsyncJobScheduler scheduler, IMessenger messenger, ILog log)
        {
            this.scheduler = scheduler;
            this.messenger = messenger;
            this.log       = log;

            this.messenger.Register <CompareResultSetAvailable>(m =>
            {
                this.CompareResult = m.CompareResultSet;
            });
            this.messenger.WhenObject <EnvironmentComparerViewModel>()
            .ChangesProperty(_ => _.ConnectionName1)
            .Execute(e =>
            {
                this.env1 = e.GetNewValue <string>();
            });

            this.messenger.WhenObject <EnvironmentComparerViewModel>()
            .ChangesProperty(_ => _.ConnectionName2)
            .Execute(e =>
            {
                this.env2 = e.GetNewValue <string>();
            });
        }
예제 #12
0
        public SolutionsViewModel(ILog log, IMessenger messenger, IAsyncJobScheduler scheduler)
        {
            this.log       = log;
            this.messenger = messenger ?? throw new ArgumentNullException(nameof(messenger));
            this.scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));

            this.Grid          = new SolutionGrid();
            this.AllowRequests = true;

            this.messenger.WhenObject <MainViewModel>()
            .ChangesProperty(_ => _.AllowRequests)
            .Execute(m => this.AllowRequests = (bool)m.NewValue);

            this.WhenChanges(() => this.AllowRequests).ChangesAlso(() => CanExport);
            this.WhenChanges(() => this.ShowOnlyVisibleSolutions)
            .ChangesAlso(() => this.ShowOnlyVisibleSolutionsText)
            .Execute(o => this.RefreshGrid?.Invoke(this, EventArgs.Empty));

            this.RefreshGrid += (s, e) => this.OnPropertyChanged(nameof(CanExport), CanExport);


            this.messenger.Register <ConnectionAddedMessage>(OnConnectionAdded);
            this.messenger.Register <ConnectionRemovedMessage>(OnConnectionRemoved);
        }
예제 #13
0
        public ConfiguratorView(
            IThemeProvider themeProvider,
            IAsyncJobScheduler asyncJobScheduler,
            IMessenger messenger,
            ILog log)
        {
            InitializeComponent();

            this.RegisterHelp(messenger, Topics.Configurator);

            this.tAdd.Enabled      = false;
            this.viewModel         = new ConfiguratorViewModel(log, messenger);
            this.asyncJobScheduler = asyncJobScheduler ?? throw new ArgumentNullException(nameof(asyncJobScheduler));
            this.themeProvider     = themeProvider ?? throw new ArgumentNullException(nameof(themeProvider));
            this.messenger         = messenger ?? throw new ArgumentNullException(nameof(messenger));
            this.log = log;
            this.mLoadEntities.Bind(_ => _.Enabled, this.viewModel, _ => _.CanLoadEntities);
            this.tLoadEntities.Bind(_ => _.Enabled, this.viewModel, _ => _.CanLoadEntities);

            this.mNew.Bind(_ => _.Enabled, this.viewModel, _ => _.CanNewMemento);
            this.tNew.Bind(_ => _.Enabled, this.viewModel, _ => _.CanNewMemento);
            this.mOpen.Bind(_ => _.Enabled, this.viewModel, _ => _.CanOpenMemento);
            this.tOpen.Bind(_ => _.Enabled, this.viewModel, _ => _.CanOpenMemento);
            this.mSave.Bind(_ => _.Enabled, this.viewModel, _ => _.CanSaveMemento);
            this.tSave.Bind(_ => _.Enabled, this.viewModel, _ => _.CanSaveAsMemento);
            this.mSaveAs.Bind(_ => _.Enabled, this.viewModel, _ => _.CanSaveAsMemento);

            this.mAdd.Bind(_ => _.Enabled, this.viewModel, _ => _.CanAdd);
            this.mEdit.Bind(_ => _.Enabled, this.viewModel, _ => _.CanEdit);
            this.mEdit.Bind(_ => _.Text, this.viewModel, _ => _.EditLabel);
            this.mRemove.Bind(_ => _.Enabled, this.viewModel, _ => _.CanRemove);
            this.mRemove.Bind(_ => _.Text, this.viewModel, _ => _.RemoveLabel);
            this.tAdd.Bind(_ => _.Enabled, this.viewModel, _ => _.CanAdd);
            this.tEdit.Bind(_ => _.Enabled, this.viewModel, _ => _.CanEdit);
            this.tEdit.Bind(_ => _.ToolTipText, this.viewModel, _ => _.EditLabel);
            this.tRemove.Bind(_ => _.Enabled, this.viewModel, _ => _.CanRemove);
            this.tRemove.Bind(_ => _.ToolTipText, this.viewModel, _ => _.RemoveLabel);

            this.mExecute.Bind(_ => _.Enabled, this.viewModel, _ => _.CanExecuteComparison);
            this.tExecute.Bind(_ => _.Enabled, this.viewModel, _ => _.CanExecuteComparison);

            this.messenger.Register <ResetEntityList>(m => this.viewModel.EntityMetadataList      = null);
            this.messenger.Register <LoadEntitiesResponse>(m => this.viewModel.EntityMetadataList = m.Entities);

            // If one or more actions have been applied successfully, reexecute the comparison
            this.messenger.Register <ApplyActionsResult>(m =>
            {
                if (m.SucceededCount == 0)
                {
                    return;
                }

                var entitiesToRefresh = m.Select(_ => _.Action.EntityName).Distinct().ToList();

                ExecuteComparison(entitiesToRefresh);
            });


            messenger.WhenObject <EnvironmentComparerViewModel>()
            .ChangesProperty(_ => _.Crm1)
            .Execute(m =>
            {
                this.Show();
            });

            messenger.WhenObject <EnvironmentComparerViewModel>()
            .ChangesProperty(_ => _.Crm2)
            .Execute(m =>
            {
                this.Show();
            });

            this.ApplyTheme();


            this.viewModel.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(this.viewModel.Memento))
                {
                    OnMementoChanged();
                }
            };

            this.viewModel.Initialize();
        }
예제 #14
0
        public SolutionComponentsView(ILog log, IThemeProvider themeProvider, IMessenger messenger, IAsyncJobScheduler scheduler)
        {
            InitializeComponent();


            var theme = themeProvider.GetCurrentTheme();

            this.tree.Font = theme.PanelFont;

            this.viewModel = new SolutionComponentsViewModel(scheduler, log, messenger);
            this.tCompareComponents.Bind(_ => _.Enabled, this.viewModel, _ => _.CanExecuteComparison);
            this.tCompareComponents.Click += (s, e) => this.viewModel.CompareAsync();

            this.tSolutionName.Bind(_ => _.Text, this.viewModel, _ => _.SolutionName);

            this.viewModel.Connections.CollectionChanged += OnConnectionListChanged;

            this.viewModel.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(viewModel.Grid))
                {
                    RefreshGrid();
                }
            };

            this.tree.ParentGetter    = _ => ((SolutionComponentNode)_).Parent;
            this.tree.CanExpandGetter = _ => (_ is SolutionComponentComposite c) && c.Count > 0;
            this.tree.ChildrenGetter  = _ => (_ is SolutionComponentComposite c) ? c : (IReadOnlyCollection <SolutionComponentNode>)Array.Empty <SolutionComponentNode>();

            this.ResetGridColumns();
        }
예제 #15
0
        public SolutionsView(ILog log, IThemeProvider themeProvider, IMessenger messenger, IAsyncJobScheduler scheduler)
        {
            InitializeComponent();


            var theme = themeProvider.GetCurrentTheme();

            theme.ApplyTo(this.listView);

            this.lSuccess.BackColor = Constants.SuccessBackColor;
            this.lSuccess.ForeColor = Constants.SuccessForeColor;
            this.lSuccess.Font      = theme.PanelFont;
            this.lSuccess.Text      = "All envs, same version";

            this.lWarn.BackColor = Constants.WarnBackColor;
            this.lWarn.ForeColor = Constants.WarnForeColor;
            this.lWarn.Font      = theme.PanelFont;
            this.lWarn.Text      = "Differences between envs";

            this.lError.BackColor = Constants.ErrorBackColor;
            this.lError.ForeColor = Constants.ErrorForeColor;
            this.lError.Font      = theme.PanelFont;
            this.lError.Text      = "Missing from env";

            this.lGray.BackColor = Constants.GrayBackColor;
            this.lGray.ForeColor = Constants.GrayForeColor;
            this.lGray.Font      = theme.PanelFont;
            this.lGray.Text      = "Present but not visible";


            this.viewModel              = new SolutionsViewModel(log, messenger, scheduler);
            this.viewModel.RefreshGrid += OnRefreshGrid;

            this.tExport.Bind(_ => _.Enabled, this.viewModel, _ => _.CanExport);
            this.tExport.Click += (s, e) => this.viewModel.Export();

            this.tShowOnlyVisible.Bind(_ => _.Text, this.viewModel, _ => _.ShowOnlyVisibleSolutionsText);
            this.tShowOnlyVisible.Click += (s, e) => this.viewModel.ShowOnlyVisibleSolutions = !this.viewModel.ShowOnlyVisibleSolutions;


            this.listView.SelectedIndexChanged += (s, e) =>
            {
                if (this.listView.SelectedItems.Count == 0)
                {
                    return;
                }

                var item = (SolutionRow)this.listView.SelectedItems[0].Tag;
                messenger.Send(new SolutionSelectedMessage(item));
            };
        }