本文整理汇总了C#中MindTouch.Dream.DreamMessage.ToDocument方法的典型用法代码示例。如果您正苦于以下问题:C# DreamMessage.ToDocument方法的具体用法?C# DreamMessage.ToDocument怎么用?C# DreamMessage.ToDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MindTouch.Dream.DreamMessage
的用法示例。
在下文中一共展示了DreamMessage.ToDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostBans
public Yield PostBans(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
BanBE ban = BanningBL.SaveBan(request.ToDocument());
DekiContext.Current.Instance.EventSink.BanCreated(context.StartTime, ban);
response.Return(DreamMessage.Ok(BanningBL.GetBanXml(ban)));
yield break;
}
示例2: SetPageTags
public Yield SetPageTags(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
PageBE page = PageBL.AuthorizePage(DekiContext.Current.User, Permissions.UPDATE, false);
XUri href = DekiContext.Current.ApiUri.At("pages", page.ID.ToString(), "tags");
TagBL.PutTagsFromXml(page, request.ToDocument());
XDoc doc = TagBL.GetTagListXml(TagBL.GetTagsForPage(page), "tags", href, false);
response.Return(DreamMessage.Ok(doc));
yield break;
}
示例3: GetPageAllowedUsers
public Yield GetPageAllowedUsers(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
List<uint> userids = new List<uint>();
if(request.HasDocument) {
foreach(XDoc userid in request.ToDocument()["user/@id"]) {
uint? id = userid.AsUInt;
if(id.HasValue) {
userids.Add(id.Value);
} else {
throw new DreamBadRequestException(string.Format("'{0}' is not a valid userid", userid.AsText));
}
}
}
if(userids.Count == 0) {
throw new DreamBadRequestException("must provide at least one userid");
}
string permissionsList = context.GetParam("permissions");
bool filterDisabled = context.GetParam("filterdisabled", false);
if(filterDisabled) {
List<uint> activeUsers = new List<uint>();
foreach(UserBE user in DbUtils.CurrentSession.Users_GetByIds(userids)) {
if(user.UserActive) {
activeUsers.Add(user.ID);
}
}
userids = activeUsers;
if(userids.Count == 0) {
response.Return(DreamMessage.Ok(new XDoc("users")));
yield break;
}
}
Permissions permissions = Permissions.READ;
if(!string.IsNullOrEmpty(permissionsList)) {
bool first = true;
foreach(string perm in permissionsList.Split(',')) {
Permissions p;
if(!SysUtil.TryParseEnum(perm, out p)) {
throw new DreamBadRequestException(string.Format("'{0}' is not a valid permission value", perm));
}
if(first) {
permissions = p;
} else {
permissions |= p;
}
first = false;
}
}
uint[] filteredIds = PermissionsBL.FilterDisallowed(userids.ToArray(), context.GetParam<uint>("pageid"), false, permissions);
XDoc msg = new XDoc("users");
foreach(int userid in filteredIds) {
msg.Start("user").Attr("id", userid).End();
}
response.Return(DreamMessage.Ok(msg));
yield break;
}
示例4: QueueUpdateTemplates
internal IEnumerator<IYield> QueueUpdateTemplates(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
var doc = request.ToDocument();
var wikiId = doc["@wikiid"].AsText;
var channel = doc["channel"].AsText;
_log.DebugFormat("received event '{0}' from '{1}'", channel, wikiId);
if(!_processingQueue.TryEnqueue(doc)) {
throw new InvalidOperationException("Enqueue of update event failed.");
}
response.Return(DreamMessage.Ok());
yield break;
}
示例5: PostUpdateTemplates
internal IEnumerator<IYield> PostUpdateTemplates(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
var doc = request.ToDocument();
var wikiId = doc["@wikiid"].AsText;
var apiUri = doc["uri"].AsText;
var apiPlug = CreateApiPlug(apiUri, wikiId);
_log.DebugFormat("received manual tickle from '{0}' @ '{1}'", wikiId, apiUri);
XDoc importReport = null;
yield return GetInstance(wikiId, true).UpdatePackages(apiPlug, _apikey, new Result<XDoc>()).Set(x => importReport = x);
response.Return(DreamMessage.Ok(importReport));
yield break;
}
示例6: QueuePurge
internal Yield QueuePurge(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
XDoc doc = request.ToDocument();
XUri channel = doc["channel"].AsUri;
string action = channel.Segments[2];
// there are certain sub-events we don't use to trigger on
if(action != "view") {
_updateDelayQueue.Enqueue(doc);
}
response.Return(DreamMessage.Ok());
yield break;
}
示例7: PutUser
public Yield PutUser(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
UserBE user = GetUserFromUrl();
//Authorization is performed later.
if (user == null) {
throw new DreamAbortException(DreamMessage.NotFound(DekiResources.GIVEN_USER_NOT_FOUND_USE_POST));
}
string accountPassword = context.GetParam("accountpassword", null);
user = UserBL.PostUserFromXml(request.ToDocument(), user, accountPassword, context.GetParam("authusername", null), context.GetParam("authpassword", null));
response.Return(DreamMessage.Ok(UserBL.GetUserXmlVerbose(user, null, Utils.ShowPrivateUserInfo(user))));
yield break;
}
示例8: PostGroup
public Yield PostGroup(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
DreamMessage responseMsg = null;
GroupBE group = GroupBL.PostGroupFromXml(request.ToDocument(), null, context.GetParam("authusername", null), context.GetParam("authpassword", null));
responseMsg = DreamMessage.Ok(GroupBL.GetGroupXmlVerbose(group, null));
response.Return(responseMsg);
yield break;
}
示例9: PutConfig
protected virtual Yield PutConfig(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
XDoc config = request.ToDocument();
if(config.Name != "config") {
throw new DreamBadRequestException("bad document type");
}
if(IsStarted) {
throw new DreamBadRequestException("service must be stopped first");
}
_timerFactory = TaskTimerFactory.Create(this);
// configure service container
var lifetimeScope = _env.CreateServiceLifetimeScope(this, (c, b) => PreInitializeLifetimeScope(c, b, config));
// call container-less start (which contains shared start logic)
yield return Coroutine.Invoke(Start, request.ToDocument(), new Result());
// call start with container for sub-classes that want to resolve instances at service start
yield return Coroutine.Invoke(Start, config, lifetimeScope, new Result());
response.Return(DreamMessage.Ok(new XDoc("service-info")
.Start("private-key")
.Add(DreamCookie.NewSetCookie("service-key", PrivateAccessKey, Self.Uri).AsSetCookieDocument)
.End()
.Start("internal-key")
.Add(DreamCookie.NewSetCookie("service-key", InternalAccessKey, Self.Uri).AsSetCookieDocument)
.End()
));
}
示例10: rc_user_name_check
private void rc_user_name_check(DreamMessage msg, string user)
{
string userMeta = msg.ToDocument()["change/rc_user_name"].AsText.ToLower() ?? String.Empty;
Assert.AreEqual(user.ToLower(), userMeta.ToLower(), "Unexpected rc_user_name");
}
示例11: rc_moved_to_ns_check
private void rc_moved_to_ns_check(DreamMessage msg, int ns)
{
int nsMeta = msg.ToDocument()["change/rc_moved_to_ns"].AsInt ?? -1;
Assert.AreEqual(ns, nsMeta, "Unexpected rc_moved_to_ns");
}
示例12: cmnt_deleted_check
private void cmnt_deleted_check(DreamMessage msg, int deleted)
{
int delMeta = msg.ToDocument()["change/cmnt_deleted"].AsInt ?? -1;
Assert.AreEqual(deleted, delMeta, "Unexpected cmnt_deleted");
}
示例13: cmnt_content_mimetype_check
private void cmnt_content_mimetype_check(DreamMessage msg, string cmnt_content_mimetype)
{
string cmnt_content_mimetype_meta = msg.ToDocument()["change/cmnt_content_mimetype"].AsText ?? String.Empty;
Assert.AreEqual(cmnt_content_mimetype, cmnt_content_mimetype_meta, "Unexpected cmnt_content_mimetype");
}
示例14: cmnt_number_check
private void cmnt_number_check(DreamMessage msg, int cmnt_number)
{
int cmnt_number_meta = msg.ToDocument()["change/cmnt_number"].AsInt ?? 0;
Assert.AreEqual(cmnt_number, cmnt_number_meta, "Unexpected cmnt_number");
}
示例15: rc_summary_check
private void rc_summary_check(DreamMessage msg, string summary)
{
string sumMeta = msg.ToDocument()["change/rc_summary"].AsText ?? String.Empty;
Assert.AreEqual(summary.ToLower(), sumMeta.ToLower(), "Unexpected rc_summary");
}