public static Notice FromAtomEntry(AtomEntry entry) { Notice notice = new Notice(); notice.DatePublished = entry.Published; notice.DateUpdated = entry.Updated; notice.Id = entry.Id.Uri.Content; notice.ContentType = entry.Content.Type; notice.Content = entry.Content.Content; notice.Subject = entry.Title.Text; IExtensionElementFactory factory = entry.FindExtension("ContinuityOfCareRecord", "urn:astm-org:CCR"); if (factory != null) { XmlExtension extension = factory as XmlExtension; XmlSerializer serializer = new XmlSerializer(typeof(ContinuityOfCareRecord)); XmlTextReader reader = new XmlTextReader(new StringReader(extension.Node.OuterXml)); notice.CareRecord = serializer.Deserialize(reader) as ContinuityOfCareRecord; } return notice; }
/// <summary> /// Posts a notice to the default profile on the register feed. Usable /// for the AuthSub profile feed. /// </summary> /// <param name="notice"></param> public void PostNotice(Notice notice) { PostNoticeUrl(notice, DefaultRegisterFeed); }
private void PostNoticeUrl(Notice notice, string url) { AtomEntry entry = new AtomEntry(); entry.Title.Text = notice.Subject; entry.Content.Content = notice.Subject; entry.Content.Type = notice.ContentType; if (notice.CareRecord != null) { XmlSerializer serializer = new XmlSerializer(typeof(ContinuityOfCareRecord)); using (StringWriter strWriter = new StringWriter()) { XmlTextWriter writer = new XmlTextWriter(new StringWriter()); serializer.Serialize(writer, notice.CareRecord); XmlDocument doc = new XmlDocument(); doc.LoadXml(strWriter.ToString()); entry.ExtensionElements.Add(new XmlExtension(doc.DocumentElement)); } } notice = Notice.FromAtomEntry(this.Insert(new Uri(url), entry)); }
/// <summary> /// Posts a notice to the particular profile on the register feed. Available /// under ClientLogin only. /// </summary> /// <param name="notice"></param> /// <param name="profileId"></param> public void PostNotice(Notice notice, string profileId) { PostNoticeUrl(notice, RegisterFeed + profileId); }