/// <summary> /// Rebuild the parameter sheet of the specified iteration /// </summary> /// <param name="iterationId"> /// The unique id of the <see cref="Iteration"/> for which the workbook needs to be rebuild /// </param> private async Task RebuildWorkbook(string iterationId) { var application = this.officeApplicationWrapper.Excel; if (iterationId == string.Empty) { logger.Debug("The workbook cannot be rebuilt: the iteration id is empty"); return; } if (application != null) { var uniqueId = Guid.Parse(iterationId); var iteration = this.Iterations.SingleOrDefault(x => x.Iid == uniqueId); if (iteration == null) { logger.Debug("The workbook cannot be rebuilt: iteration {0} cannot be found", uniqueId); return; } var engineeringModel = iteration.Container as EngineeringModel; var activeParticipant = engineeringModel.EngineeringModelSetup.Participant.Single(x => x.Person == this.Session.ActivePerson); var workbook = this.QueryIterationWorkbook(this.officeApplicationWrapper.Excel, iteration); if (workbook == null) { var selectedDomainOfExpertise = this.Session.QuerySelectedDomainOfExpertise(iteration); var workbookSelectionViewModel = new WorkbookSelectionViewModel(application, engineeringModel.EngineeringModelSetup, iteration.IterationSetup, selectedDomainOfExpertise); this.DialogNavigationService.NavigateModal(workbookSelectionViewModel); var dialogResult = workbookSelectionViewModel.DialogResult; if (dialogResult.Result.HasValue && dialogResult.Result.Value) { workbook = ((WorkbookSelectionDialogResult)dialogResult).Workbook; } else { var message = "No workbook selected, the rebuild has been cancelled"; application.StatusBar = message; logger.Debug(message); return; } } try { var workbookOperator = new WorkbookOperator(application, workbook, this.DialogNavigationService); await workbookOperator.Rebuild(this.Session, iteration, activeParticipant); } catch (Exception ex) { logger.Error(ex); } } }
/// <summary> /// Submit all values sets that have changed on the parameter sheet of the active workbook /// </summary> private async Task SubmitAll() { var application = this.officeApplicationWrapper.Excel; var activeWorkbook = this.ExcelQuery.QueryActiveWorkbook(application); if (activeWorkbook == null) { return; } var workbookSessionDal = new WorkbookSessionDal(activeWorkbook); var workbookSession = workbookSessionDal.Read(); if (workbookSession == null) { return; } var iteration = this.Iterations.SingleOrDefault(x => x.Iid == workbookSession.IterationSetup.IterationIid); if (iteration == null) { logger.Debug("The values cannot be submitted: iteration {0} cannot be found", workbookSession.IterationSetup.IterationIid); return; } try { var workbookOperator = new WorkbookOperator(application, activeWorkbook, this.DialogNavigationService); await workbookOperator.SubmitAll(this.Session, iteration); } catch (Exception ex) { logger.Error(ex); } }