Beispiel #1
0
        /// <summary>
        /// Verifying of People part element.
        /// </summary>
        /// <param name="filePath">Target file path.</param>
        /// <param name="log">Logger.</param>
        public void VerifyElements(string filePath, VerifiableLog log)
        {
            using (WordprocessingDocument package = WordprocessingDocument.Open(filePath, false))
            {
                WordprocessingPeoplePart peoplePart = package.MainDocumentPart.WordprocessingPeoplePart;
                W15.Person       person             = peoplePart.People.Descendants <W15.Person>().First();
                W15.PresenceInfo presenceInfo       = peoplePart.RootElement.Descendants <W15.PresenceInfo>().First();

                log.VerifyValue(person.Author.Value, this.editAuthor, "Person Author attribute is matched. Author={0}", person.Author);
                log.VerifyValue(presenceInfo.ProviderId.Value, this.editProviderId, "PresenceInfo ProviderId attribute is matched. ProviderId={0}", presenceInfo.ProviderId);
                log.VerifyValue(presenceInfo.UserId.Value, this.editUserId, "PresenceInfo UserId attribute is matched. UserId={0}", presenceInfo.UserId);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Editing of People part element.
        /// </summary>
        /// <param name="filePath">Target file path.</param>
        /// <param name="log">Logger.</param>
        public void EditElements(string filePath, VerifiableLog log)
        {
            using (WordprocessingDocument package = WordprocessingDocument.Open(filePath, true))
            {
                WordprocessingPeoplePart peoplePart = package.MainDocumentPart.WordprocessingPeoplePart;
                W15.Person       person             = peoplePart.People.Descendants <W15.Person>().First();
                W15.PresenceInfo presenceInfo       = person.Descendants <W15.PresenceInfo>().First();

                person.Author.Value           = this.editAuthor;
                presenceInfo.ProviderId.Value = this.editProviderId;
                presenceInfo.UserId.Value     = this.editUserId;

                log.Pass("PresenceInfo in PeoplePart is updated");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Reading of People part element.
        /// </summary>
        /// <param name="filePath">Target file path.</param>
        /// <param name="log">Logger.</param>
        public void ReadElements(string filePath, VerifiableLog log)
        {
            using (WordprocessingDocument package = WordprocessingDocument.Open(filePath, true))
            {
                try
                {
                    WordprocessingPeoplePart peoplePart = package.MainDocumentPart.WordprocessingPeoplePart;
                    W15.Person       person             = peoplePart.People.Descendants <W15.Person>().First();
                    W15.PresenceInfo presenceInfo       = person.Descendants <W15.PresenceInfo>().First();

                    log.VerifyValue(person.Author.Value, this.verifyAuthor, "Person Author attribute is matched. Author={0}", person.Author);
                    log.VerifyValue(presenceInfo.ProviderId.Value, this.verifyProviderId, "PresenceInfo ProviderId attribute is matched. ProviderId={0}", presenceInfo.ProviderId);
                    log.VerifyValue(presenceInfo.UserId.Value, this.verifyUserId, "PresenceInfo UserId attribute is matched. UserId={0}", presenceInfo.UserId);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }
            }
        }