コード例 #1
0
        public void VerifyThatPropertiesAreSet()
        {
            var viewModel = new WorkbookRebuildViewModel(this.processedValueSets, ValueSetKind.All);

            Assert.AreEqual("Rebuild Workbook...", viewModel.DialogTitle);
            Assert.AreEqual(2, viewModel.ParameterOrOverrideWorkbookRebuildRowViewModels.Count);
            Assert.AreEqual(1, viewModel.ParameterSubscriptionWorkbookRebuildRowViewModels.Count);
        }
コード例 #2
0
        public void VerifyThatCancelCommandReturnsDialogResult()
        {
            var viewModel = new WorkbookRebuildViewModel(this.processedValueSets, ValueSetKind.All);

            viewModel.CancelCommand.Execute(null);

            var negativeDialogResult = viewModel.DialogResult;

            Assert.IsFalse(negativeDialogResult.Result.Value);

            viewModel.OkCommand.Execute(null);
            var positiviveDialogResult = (WorkbookRebuildDialogResult)viewModel.DialogResult;

            Assert.IsTrue(positiviveDialogResult.Result.Value);
            Assert.AreEqual(RebuildKind.Overwrite, positiviveDialogResult.RebuildKind);
        }
コード例 #3
0
        /// <summary>
        /// Rebuild the Parameter Sheet
        /// </summary>
        /// <param name="session">
        /// The current <see cref="ISession"/> that is rebuilding the parameter sheet
        /// </param>
        /// <param name="iteration">
        /// The <see cref="Iteration"/> that contains the <see cref="ElementDefinition"/>s, <see cref="ElementUsage"/>s and <see cref="Parameter"/>s that
        /// are being written to the workbook
        /// </param>
        /// <param name="participant">
        /// The active <see cref="Participant"/> for which the workbook is being rebuilt.
        /// </param>
        public async Task Rebuild(ISession session, Iteration iteration, Participant participant)
        {
            this.application.StatusBar = string.Empty;

            var workbookSession = await this.CreateWorkbookSession(session.Dal, session.Credentials);

            try
            {
                var sw = new Stopwatch();
                sw.Start();

                IReadOnlyDictionary <Guid, ProcessedValueSet> processedValueSets;

                var parameterSheetProcessor = new ParameterSheetProcessor(workbookSession, iteration);
                parameterSheetProcessor.ValidateValuesAndCheckForChanges(this.application, this.workbook, out processedValueSets);

                if (processedValueSets.Any())
                {
                    var workbookRebuildViewModel = new WorkbookRebuildViewModel(processedValueSets, ValueSetKind.All);
                    var dialogResult             = this.DialogNavigationService.NavigateModal(workbookRebuildViewModel);

                    if (dialogResult.Result.HasValue && dialogResult.Result.Value)
                    {
                        var rebuildKind = ((WorkbookRebuildDialogResult)dialogResult).RebuildKind;
                        switch (rebuildKind)
                        {
                        case RebuildKind.Overwrite:
                            processedValueSets = new Dictionary <Guid, ProcessedValueSet>();
                            break;

                        case RebuildKind.RestoreChanges:
                            // keep clones
                            break;
                        }
                    }
                    else
                    {
                        var parameterSheetRowHighligter = new ParameterSheetRowHighligter();
                        parameterSheetRowHighligter.HighlightRows(this.application, this.workbook, processedValueSets);

                        this.application.StatusBar = "Rebuild Parameter sheet has been cancelled";
                        return;
                    }
                }

                await this.RefreshSessionData(session);

                this.WriteParameterSheet(session, iteration, participant, processedValueSets);
                this.WriteOptionSheets(session, iteration, participant);

                this.WriteSessionInfoToWorkbook(session, iteration, participant);
                this.WriteWorkbookDataToWorkbook(iteration);

                this.ActivateParametersSheet();

                this.application.StatusBar = string.Format("Rebuild Parameter completed in [{0}] ms", sw.ElapsedMilliseconds);
            }
            catch (Exception ex)
            {
                this.application.StatusBar = "Rebuild Parameter sheet failed";
                Logger.Error(ex);
            }
            finally
            {
                this.application.Cursor = XlMousePointer.xlDefault;
            }
        }