/// <summary> /// Append the ThreadingInfo element /// </summary> /// <param name="filePath">Target excel faile path</param> /// <param name="log">Logger</param> public void AddElements(string filePath, VerifiableLog log) { using (PresentationDocument package = PresentationDocument.Open(filePath, true)) { try { Comment comment = GetComment(package.PresentationPart.SlideParts, 1); CommentExtension commentExtension = new CommentExtension() { Uri = this.ThreadingInfoExtUri }; P15.ThreadingInfo threadingInfo = new P15.ThreadingInfo() { TimeZoneBias = this.timeZoneBiasValue }; commentExtension.AppendChild <P15.ThreadingInfo>(threadingInfo); comment.CommentExtensionList.AppendChild <CommentExtension>(commentExtension); log.Pass("Added ThreadingInfo element."); } catch (Exception e) { log.Fail(e.Message); } } }
/// <summary> /// Verifying the ThreadingInfo element the existence /// </summary> /// <param name="filePath">Target Excel faile path</param> /// <param name="log">Logger</param> public void VerifyElements(string filePath, VerifiableLog log) { using (PresentationDocument package = PresentationDocument.Open(filePath, false)) { Comment comment = GetComment(package.PresentationPart.SlideParts, 1); P15.ThreadingInfo threadingInfo = comment.CommentExtensionList.Descendants <P15.ThreadingInfo>().Single(); log.Verify(threadingInfo.TimeZoneBias.Value == this.timeZoneBiasValue, "UnChanged in the ThreadingInfo element."); } }
/// <summary> /// Editing ThreadingInfo element /// </summary> /// <param name="filePath">Target Excel file path</param> /// <param name="log">Logger</param> public void EditElements(string filePath, VerifiableLog log) { using (PresentationDocument package = PresentationDocument.Open(filePath, true)) { Comment comment = GetComment(package.PresentationPart.SlideParts, 1); P15.ThreadingInfo threadingInfo = comment.CommentExtensionList.Descendants <P15.ThreadingInfo>().Single(); threadingInfo.TimeZoneBias.Value = this.timeZoneBiasValue; log.Pass("Edited ThreadingInfo value."); } }
/// <summary> /// Deleting ThreadingInfo element /// </summary> /// <param name="filePath">Target Excel faile path</param> /// <param name="log">Logger</param> public void DeleteElements(string filePath, VerifiableLog log) { using (PresentationDocument package = PresentationDocument.Open(filePath, true)) { Comment comment = GetComment(package.PresentationPart.SlideParts, 1); CommentExtension commentExtension = comment.CommentExtensionList.Descendants <CommentExtension>().Where(e => e.Uri == this.ThreadingInfoExtUri).Single(); P15.ThreadingInfo threadingInfo = commentExtension.Descendants <P15.ThreadingInfo>().Single(); threadingInfo.Remove(); log.Pass("Deleted ThreadingInfo element."); commentExtension.Remove(); log.Pass("Deleted ThreadingInfo extension element."); } }
/// <summary> /// Constructor /// Get URI attribute value of CommentExtension /// </summary> /// <param name="filePath">Generated file path</param> public TestEntities(string filePath) { using (PresentationDocument package = PresentationDocument.Open(filePath, false)) { //Get Extension Uri value Comment comment = GetComment(package.PresentationPart.SlideParts, 1); P15.ThreadingInfo threadingInfo = comment.CommentExtensionList.Descendants <P15.ThreadingInfo>().Single(); CommentExtension commentExtension = (CommentExtension)threadingInfo.Parent; this.ThreadingInfoExtUri = commentExtension.Uri;; if (string.IsNullOrEmpty(ThreadingInfoExtUri)) { throw new Exception("Uri attribute value in Extension element is not set."); } } }
/// <summary> /// Append the ThreadingInfo element /// </summary> /// <param name="filePath">Target excel faile path</param> /// <param name="log">Logger</param> public void AddElements(string filePath, VerifiableLog log) { using (PresentationDocument package = PresentationDocument.Open(filePath, true)) { try { Comment comment = GetComment(package.PresentationPart.SlideParts, 1); CommentExtension commentExtension = new CommentExtension() { Uri = this.ThreadingInfoExtUri }; P15.ThreadingInfo threadingInfo = new P15.ThreadingInfo() { TimeZoneBias = this.timeZoneBiasValue }; commentExtension.AppendChild<P15.ThreadingInfo>(threadingInfo); comment.CommentExtensionList.AppendChild<CommentExtension>(commentExtension); log.Pass("Added ThreadingInfo element."); } catch (Exception e) { log.Fail(e.Message); } } }