예제 #1
0
 public void PageMove(DateTime eventTime, PageBE oldPage, PageBE newPage, UserBE user)
 {
     try {
         XUri channel  = _channel.At(PAGES, MOVE);
         XUri resource = PageBL.GetUriCanonical(newPage).WithHost(_wikiid);
         var  origin   = new[] {
             PageBL.GetUriCanonical(newPage).AsServerUri().ToString(),
             XUri.Localhost + "/" + oldPage.Title.AsUiUriPath(),
             XUri.Localhost + "/" + newPage.Title.AsUiUriPath(),
         };
         Queue(eventTime, channel, resource, origin, new XDoc("deki-event")
               .Elem("channel", channel)
               .Elem("uri", PageBL.GetUriCanonical(newPage).AsServerUri().ToString())
               .Elem("pageid", newPage.ID)
               .Start("user")
               .Attr("id", user.ID)
               .Attr("anonymous", UserBL.IsAnonymous(user))
               .Elem("uri", UserBL.GetUri(user))
               .End()
               .Start("content.uri")
               .Attr("type", "application/xml")
               .Value(PageBL.GetUriContentsCanonical(newPage).AsServerUri().With("format", "xhtml").ToString())
               .End()
               .Elem("revision.uri", PageBL.GetUriRevisionCanonical(newPage).AsServerUri().ToString())
               .Elem("tags.uri", PageBL.GetUriCanonical(newPage).At("tags").AsServerUri().ToString())
               .Elem("comments.uri", PageBL.GetUriCanonical(newPage).At("comments").AsServerUri().ToString())
               .Elem("path", newPage.Title.AsUiUriPath())
               .Elem("previous-path", oldPage.Title.AsUiUriPath()));
     } catch (Exception e) {
         _log.WarnExceptionMethodCall(e, "PageMove", "event couldn't be created");
     }
 }
예제 #2
0
 private void PageChanged(DateTime eventTime, PageBE page, UserBE user, XDoc extra, params string[] path)
 {
     try {
         XUri     channel  = _channel.At(PAGES).At(path);
         XUri     resource = PageBL.GetUriCanonical(page).WithHost(_wikiid);
         string[] origin   = new string[] { PageBL.GetUriCanonical(page).AsServerUri().ToString(), XUri.Localhost + "/" + page.Title.AsUiUriPath() };
         XDoc     doc      = new XDoc("deki-event")
                             .Elem("channel", channel)
                             // BUGBUGBUG: This will generally generate a Uri based on the request that caused the event,
                             //            which may not really be canonical
                             .Elem("uri", PageBL.GetUriCanonical(page).AsPublicUri().ToString())
                             .Elem("pageid", page.ID)
                             .Start("user")
                             .Attr("id", user.ID)
                             .Attr("anonymous", UserBL.IsAnonymous(user))
                             .Elem("uri", UserBL.GetUri(user))
                             .End()
                             .Start("content.uri")
                             .Attr("type", "application/xml")
                             .Value(PageBL.GetUriContentsCanonical(page).With("format", "xhtml").AsServerUri().ToString())
                             .End()
                             .Elem("revision.uri", PageBL.GetUriRevisionCanonical(page).AsServerUri().ToString())
                             .Elem("tags.uri", PageBL.GetUriCanonical(page).At("tags").AsServerUri().ToString())
                             .Elem("comments.uri", PageBL.GetUriCanonical(page).At("comments").AsServerUri().ToString())
                             .Elem("path", page.Title.AsUiUriPath());
         if (extra != null)
         {
             doc.Add(extra);
         }
         Queue(eventTime, channel, resource, origin, doc);
         if (page.Title.IsTalk)
         {
             PageBE front = PageBL.GetPageByTitle(page.Title.AsFront());
             if ((front != null) && (front.ID > 0))
             {
                 PageChanged(eventTime, front, user, extra, ArrayUtil.Concat(new string[] { DEPENDENTS_CHANGED, TALK }, path));
             }
         }
     } catch (Exception e) {
         _log.WarnExceptionMethodCall(e, "PageChanged", "event couldn't be created");
     }
 }