/// <summary> /// Write session information to the workbook as a custom XML part /// </summary> /// <param name="session"> /// The <see cref="ISession"/> related with the the workbook. /// </param> /// <param name="iteration"> /// The <see cref="Iteration"/> that is written to the workbook /// </param> /// <param name="participant"> /// The <see cref="Participant"/> that is written to the workbook /// </param> private void WriteSessionInfoToWorkbook(ISession session, Iteration iteration, Participant participant) { var engineeringModel = (EngineeringModel)iteration.Container; var selectedDomainOfExpertise = session.QuerySelectedDomainOfExpertise(iteration); var workbookSession = new WorkbookSession(participant.Person, engineeringModel.EngineeringModelSetup, iteration.IterationSetup, selectedDomainOfExpertise); var workbookSessionDal = new WorkbookSessionDal(this.workbook); workbookSessionDal.Write(workbookSession); }
public void VerifyThatTheSessionDataIsWrittenToAWorkbookandCanBeRetrieved() { NetOffice.ExcelApi.Application application = null; Workbook workbook = null; try { application = new Application(); workbook = application.Workbooks.Open(this.testfilepath, false, false); var workbookSessionDal = new WorkbookSessionDal(workbook); workbookSessionDal.Write(this.workbookSession); workbook.Save(); var retrievedWbSession = workbookSessionDal.Read(); Assert.NotNull(retrievedWbSession); Assert.AreEqual(this.workbookSession.RebuildDateTime, retrievedWbSession.RebuildDateTime); Assert.AreEqual(this.workbookSession.Person.Iid, retrievedWbSession.Person.Iid); Assert.AreEqual(this.workbookSession.DomainOfExpertise.Iid, retrievedWbSession.DomainOfExpertise.Iid); } catch (Exception ex) { Console.WriteLine(ex); throw ex; } finally { if (workbook != null) { Console.WriteLine("Closing workbook {0}", this.testfilepath); workbook.Close(); workbook.Dispose(); } if (application != null) { Console.WriteLine("Closing Excel Application"); application.Quit(); application.Dispose(); } } }