private void PropertyChanged(DateTime eventTime, PropertyBE prop, UserBE user, ResourceBE.Type parentType, XUri parentUri, params string[] path) { try { string parent = string.Empty; switch(parentType) { case ResourceBE.Type.PAGE: parent = PAGES; break; case ResourceBE.Type.FILE: parent = FILES; break; case ResourceBE.Type.USER: parent = USERS; break; case ResourceBE.Type.SITE: parent = SITE; break; } XUri channel = _channel.At(parent).At(PROPERTY).At(path); XUri resource = prop.UriInfo(parentUri); string[] origin = new string[] { resource.ToString() }; XDoc doc = new XDoc("deki-event") .Elem("channel", channel) .Elem("name", prop.Name) .Elem("uri", resource) .Start("content") .Attr("mime-type", prop.MimeType.FullType) .Attr("size", prop.Size) .Attr("href", prop.UriContent(parentUri)); if(prop.MimeType.MainType == MimeType.TEXT.MainType && prop.Size < 256) { doc.Value(prop.Content.ToText()); } doc.End(); if(parentType == ResourceBE.Type.PAGE) { doc.Elem("pageid", prop.ParentPageId ?? 0); } else if(parentType == ResourceBE.Type.USER) { doc.Elem("userid", prop.ParentUserId ?? 0); } else if(parentType == ResourceBE.Type.FILE) { AttachmentBE attachment = (AttachmentBE)prop.ParentResource; doc.Elem("fileid", attachment.FileId ?? 0); PageDependentChanged(eventTime, ((PageWrapperBE)attachment.ParentResource).Page, user, ArrayUtil.Concat(new string[] { FILES, PROPERTY }, path)); } Queue(eventTime, channel, resource, origin, doc); } catch(Exception e) { _log.WarnExceptionMethodCall(e, "PropertyChanged", "event couldn't be created"); } }
private void PropertyExport(PageBE page, AttachmentBE file, PropertyBE property) { // Export the property XUri propertyUri = null; string filename = null; if(null != file) { propertyUri = property.UriContent(AttachmentBL.Instance.GetUri(file)); filename = file.Name; } else { propertyUri = property.UriContent(PageBL.GetUriCanonical(page)); } if(!_uris.ContainsKey(propertyUri)) { _uris.Add(propertyUri, null); XDoc manifestDoc = new XDoc("property").Elem("name", property.Name) .Elem("filename", filename) .Elem("path", page.Title.AsRelativePath(_relToTitle)) .Start("contents").Attr("type", property.MimeType.ToString()).End(); Add(propertyUri, manifestDoc); } }