本文整理汇总了C#中BsonDocument.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# BsonDocument.GetValue方法的具体用法?C# BsonDocument.GetValue怎么用?C# BsonDocument.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonDocument
的用法示例。
在下文中一共展示了BsonDocument.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCase
/// <summary>
/// 添加案件
/// </summary>
/// <param name="Options">添加信息</param>
/// <param name="ReceiveMessage">回掉消息</param>
public void AddCase(BsonDocument Options, BsonDocument ReceiveMessage)
{
String CaseName = Options.GetValue("CaseName").AsString;
String CaseDescription = Options.GetValue("CaseDescription").AsString;
ObjectId UserId = new ObjectId(Options.GetValue("AddUser").AsString);
int Type = Options.GetValue("Type").AsInt32;
if (cs.ExitCase(CaseName))
{
BsonDocument CaseDoc = new BsonDocument();
CaseDoc.Add("CaseName", CaseName);
CaseDoc.Add("CaseDescription", CaseDescription);
CaseDoc.Add("AddUser", UserId);
CaseDoc.Add("Type", Type);
CaseDoc.Add("AddTime", DateTime.Now);
if (cs.AddCase(CaseDoc))
{
ReceiveMessage.Add("StateCode", 0);
ReceiveMessage.Add("ReData", "案件添加成功!");
CallBack();
}
else
{
ReceiveMessage.Add("StateCode", -2);
ReceiveMessage.Add("ReData", "案件添加失败!");
CallBack();
}
}
else
{
ReceiveMessage.Add("StateCode", -1);
ReceiveMessage.Add("ReData", "案件已存在!");
CallBack();
}
}
示例2: AddRole
/// <summary>
/// 添加角色
/// </summary>
/// <param name="Options">添加参数</param>
/// <param name="ReceiveMessage">回调消息</param>
public void AddRole(BsonDocument Options, BsonDocument ReceiveMessage)
{
String RoleName = Options.GetValue("RoleName").AsString;
UserRole ur = new UserRole();
ur.UserRoleName = RoleName;
ur.PUserRole = new ObjectId(Options.GetValue("PUserRole").AsString);
ur.UserRolePowers = BsonHelper.StrinIdToObjectId(Options.GetValue("RolePowers").AsBsonArray);
if (urs.ExsitRole(RoleName))
{
Boolean IsSuccess = urs.AddRole(ur);
if (IsSuccess)
{
ReceiveMessage.Add("StateCode", 0);
ReceiveMessage.Add("ReData", IsSuccess);
CallBack();
}
else
{
ReceiveMessage.Add("StateCode", -2);
ReceiveMessage.Add("ReData", "添加失败");
CallBack();
}
}
else
{
ReceiveMessage.Add("StateCode", -1);
ReceiveMessage.Add("ReData", "角色名已存在!");
CallBack();
}
}
示例3: UpdateDocument
public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
ObjectId organizationId = document.GetValue(ProjectRepository.FieldNames.OrganizationId).AsObjectId;
var users = Database.GetCollection(UserRepository.CollectionName)
.Find(Query.In(UserRepository.FieldNames.OrganizationIds, new List<BsonValue> {
organizationId
}))
.SetFields(ProjectRepository.FieldNames.Id).ToList();
if (!document.Contains(ProjectRepository.FieldNames.NotificationSettings))
document.Add(ProjectRepository.FieldNames.NotificationSettings, new BsonDocument());
BsonDocument settings = document.GetValue(ProjectRepository.FieldNames.NotificationSettings).AsBsonDocument;
foreach (var user in users) {
var userId = user.GetValue(ProjectRepository.FieldNames.Id).AsObjectId.ToString();
if (!settings.Contains(userId))
settings.Add(userId, new BsonDocument());
var userSettings = settings.GetValue(userId).AsBsonDocument;
if (!userSettings.Contains("SendDailySummary"))
userSettings.Add("SendDailySummary", new BsonBoolean(true));
else
userSettings.Set("SendDailySummary", new BsonBoolean(true));
}
collection.Save(document);
}
示例4: MapDocumentToViewModel
public BaseCharacterViewModel MapDocumentToViewModel(BsonDocument character)
{
var newModel = new BaseCharacterViewModel
{
System = GameSystem.Dnd5,
CharacterID = character.GetValue("_id").AsObjectId.ToString(),
CharacterName = character.GetValue("characterName").AsString,
IsShared = character.GetValue("isShared").AsBoolean
};
return newModel;
}
示例5: RemoveMark
/// <summary>
/// 删除标记
/// </summary>
/// <param name="Data">删除条件</param>
/// <param name="ReceiveMessage">回调消息</param>
public void RemoveMark(BsonDocument Data, BsonDocument ReceiveMessage)
{
Data.Add("ForCase", CaseInfo.CaseName);
if (mm.RemoveMark(Data.GetValue("MarkName").AsString))
{
if (ms.RemoveMark(Data).IsAcknowledged)
{
ReceiveMessage.Add("StateCode", 0);
ReceiveMessage.Add("ReData", "标记已删除!");
CallBack();
}
else
{
ReceiveMessage.Add("StateCode", -1);
ReceiveMessage.Add("ReData", "标记删除失败!");
CallBack();
}
}
else
{
ReceiveMessage.Add("StateCode", -2);
ReceiveMessage.Add("ReData", "移除邮件标记失败!");
CallBack();
}
}
示例6: UpdateDocument
public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
string id = document.GetElement(MonthStackStatsRepository.FieldNames.Id).Value.AsString;
string[] parts = id.Split('/');
if (parts.Length > 0)
return;
string errorStackId = parts[0];
var stackCollection = Database.GetCollection(ErrorStackRepository.CollectionName);
var errorStack = stackCollection.FindOne(Query.EQ(ErrorStackRepository.FieldNames.Id, new BsonObjectId(new ObjectId(errorStackId))));
if (errorStack != null) {
var projectId = errorStack.GetElement(ErrorStackRepository.FieldNames.ProjectId).Value;
document.Set(MonthStackStatsRepository.FieldNames.ProjectId, projectId);
}
document.Set(MonthStackStatsRepository.FieldNames.ErrorStackId, new BsonObjectId(new ObjectId(errorStackId)));
var emptyBlocks = new List<BsonElement>();
BsonDocument dayBlocks = document.GetValue(MonthStackStatsRepository.FieldNames.DayStats).AsBsonDocument;
foreach (BsonElement b in dayBlocks.Elements) {
if (b.Value.AsInt32 == 0)
emptyBlocks.Add(b);
}
foreach (BsonElement b in emptyBlocks)
dayBlocks.RemoveElement(b);
collection.Save(document);
}
示例7: UpdateDocument
public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document)
{
var errorCollection = Database.GetCollection("error");
ObjectId stackId = document.GetValue("_id").AsObjectId;
if (stackId == ObjectId.Empty)
return;
BsonValue value;
bool isHidden = false;
if (document.TryGetValue("hid", out value))
isHidden = value.AsBoolean;
DateTime? dateFixed = null;
if (document.TryGetValue("fdt", out value))
dateFixed = value.ToNullableUniversalTime();
IMongoQuery query = Query.EQ("sid", new BsonObjectId(stackId));
var update = new UpdateBuilder();
if (isHidden)
update.Set("hid", true);
if (dateFixed.HasValue)
update.Set("fix", true);
if (isHidden || dateFixed.HasValue)
errorCollection.Update(query, update, UpdateFlags.Multi);
}
示例8: UpdateDocument
public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document)
{
var projectIds = document.GetValue("ProjectIds").AsBsonArray.Select(p => p.AsInt32).ToList();
document.Remove("ProjectIds");
document.Add("ProjectIds", new BsonArray(projectIds.Select(x => x.ToString())));
collection.Save(document);
}
示例9: UpdateDocument
public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
decimal price = 0m;
if (!document.Contains(OrganizationRepository.FieldNames.PlanId))
return;
switch (document.GetValue(OrganizationRepository.FieldNames.PlanId).AsString) {
case "EX_SMALL":
price = BillingManager.SmallPlan.Price;
break;
case "EX_MEDIUM":
price = BillingManager.MediumPlan.Price;
break;
case "EX_LARGE":
price = BillingManager.LargePlan.Price;
break;
}
if (price == 0m)
return;
if (!document.Contains(OrganizationRepository.FieldNames.BillingPrice))
document.Add(OrganizationRepository.FieldNames.BillingPrice, new BsonString(price.ToString()));
else
document.Set(OrganizationRepository.FieldNames.BillingPrice, new BsonString(price.ToString()));
collection.Save(document);
}
示例10: UpdateDocument
public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document)
{
if (document.Contains("ErrorCount"))
document.ChangeName("ErrorCount", "EventCount");
if (document.Contains("TotalErrorCount"))
document.ChangeName("TotalErrorCount", "TotalEventCount");
if (document.Contains("LastErrorDate"))
document.ChangeName("LastErrorDate", "LastEventDate");
if (document.Contains("MaxErrorsPerMonth"))
document.ChangeName("MaxErrorsPerMonth", "MaxEventsPerMonth");
if (document.Contains("SuspensionCode")) {
var value = document.GetValue("SuspensionCode");
document.Remove("SuspensionCode");
SuspensionCode suspensionCode;
if (value.IsString && Enum.TryParse(value.AsString, true, out suspensionCode))
document.Set("SuspensionCode", suspensionCode);
}
collection.Save(document);
}
示例11: UpdateDocument
public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
var errorCollection = Database.GetCollection(ErrorRepository.CollectionName);
ObjectId stackId = document.GetValue(ErrorStackRepository.FieldNames.Id).AsObjectId;
if (stackId == ObjectId.Empty)
return;
BsonValue value;
bool isHidden = false;
if (document.TryGetValue(ErrorStackRepository.FieldNames.IsHidden, out value))
isHidden = value.AsBoolean;
DateTime? dateFixed = null;
if (document.TryGetValue(ErrorStackRepository.FieldNames.DateFixed, out value))
dateFixed = value.ToNullableUniversalTime();
IMongoQuery query = Query.EQ(ErrorRepository.FieldNames.ErrorStackId, new BsonObjectId(stackId));
var update = new UpdateBuilder();
if (isHidden)
update.Set(ErrorRepository.FieldNames.IsHidden, true);
if (dateFixed.HasValue)
update.Set(ErrorRepository.FieldNames.IsFixed, true);
if (isHidden || dateFixed.HasValue)
errorCollection.Update(query, update);
}
示例12: UpdateDocument
public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
if (document.Contains("EmailNotificationsEnabled")) {
bool emailNotificationsEnabled = document.GetValue("EmailNotificationsEnabled").AsBoolean;
while (document.Contains("EmailNotificationsEnabled"))
document.Remove("EmailNotificationsEnabled");
document.Set("EmailNotificationsEnabled", emailNotificationsEnabled);
}
if (document.Contains("EmailAddress")) {
string emailAddress = document.GetValue("EmailAddress").AsString;
if (!String.IsNullOrWhiteSpace(emailAddress))
document.Set("EmailAddress", emailAddress.ToLowerInvariant().Trim());
}
collection.Save(document);
}
示例13: ProxyAPICallModels
/// <summary>
/// 建構子
/// </summary>
public ProxyAPICallModels(BsonDocument doc)
{
this.ID = doc.GetValue("_id", string.Empty).ToString().Replace("ObjectId(", "").Replace(")", "");
this.API_Name = doc.GetValue("API_Name", string.Empty).ToString();
this.Parameters = doc.GetValue("Parameters", string.Empty).ToString();
this.API_CName = doc.GetValue("API_CName", string.Empty).ToString();
this.ReturnCode = doc.GetValue("ReturnCode", string.Empty).ToString();
this.ReturnData = doc.GetValue("ReturnData", string.Empty).ToString();
this.Description = doc.GetValue("Description", string.Empty).ToString();
this.ExecuteUser = doc.GetValue("ExecuteUser", string.Empty).ToString();
DateTime tmp;
DateTime.TryParse(doc.GetValue("CTime", DateTime.UtcNow).ToString(), out tmp);
this.CTime = tmp.ToLocalTime();
}
示例14: UpdateDocument
public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
BsonValue organizationId = document.GetValue(ProjectRepository.FieldNames.OrganizationId);
BsonValue projectId = document.GetValue(ProjectRepository.FieldNames.Id);
var stackCount = Database.GetCollection(ErrorStackRepository.CollectionName).FindAs<ErrorStack>(Query.EQ(ErrorStackRepository.FieldNames.ProjectId, projectId)).Count();
long errorCount = Database.GetCollection(ErrorRepository.CollectionName).FindAs<Error>(Query.EQ(ErrorRepository.FieldNames.ProjectId, projectId)).Count();
document.Add(ProjectRepository.FieldNames.StackCount, new BsonInt64(stackCount));
document.Add(ProjectRepository.FieldNames.ErrorCount, new BsonInt64(errorCount));
document.Add(ProjectRepository.FieldNames.TotalErrorCount, new BsonInt64(errorCount));
collection.Save(document);
// Update the organization.
BsonDocument doc = Database.GetCollection(OrganizationRepository.CollectionName).FindOneById(organizationId);
if (!doc.Contains(OrganizationRepository.FieldNames.ProjectCount))
doc.Add(OrganizationRepository.FieldNames.ProjectCount, new BsonInt32(1));
else {
int count = doc.GetValue(OrganizationRepository.FieldNames.ProjectCount).AsInt32;
doc.Set(OrganizationRepository.FieldNames.ProjectCount, count + 1);
}
if (!doc.Contains(OrganizationRepository.FieldNames.StackCount))
doc.Add(OrganizationRepository.FieldNames.StackCount, new BsonInt64(stackCount));
else {
long count = doc.GetValue(OrganizationRepository.FieldNames.StackCount).AsInt64;
doc.Set(OrganizationRepository.FieldNames.StackCount, count + stackCount);
}
if (!doc.Contains(OrganizationRepository.FieldNames.ErrorCount))
doc.Add(OrganizationRepository.FieldNames.ErrorCount, new BsonInt64(errorCount));
else {
long count = doc.GetValue(OrganizationRepository.FieldNames.ErrorCount).AsInt64;
doc.Set(OrganizationRepository.FieldNames.ErrorCount, count + errorCount);
}
if (!doc.Contains(OrganizationRepository.FieldNames.TotalErrorCount))
doc.Add(OrganizationRepository.FieldNames.TotalErrorCount, new BsonInt64(errorCount));
else {
long count = doc.GetValue(OrganizationRepository.FieldNames.TotalErrorCount).AsInt64;
doc.Set(OrganizationRepository.FieldNames.TotalErrorCount, count + errorCount);
}
Database.GetCollection(OrganizationRepository.CollectionName).Save(doc);
}
示例15: Ins
private static string Ins(BsonDocument doc)
{
try
{
BsonValue id;
if (!doc.TryGetValue("_id", out id))
throw new Exception("fant ikke _id");
var exp = new ExpenseModel
{
IsCommon = doc.GetValue("IsCommon", true).ToBoolean(),
IsPossibleDuplicate = doc.GetValue("IsPossibleDuplicate", false).ToBoolean(),
Means = doc.GetValue("Means", string.Empty).ToString(),
Owner = doc.GetValue("Owner", string.Empty).ToString(),
Amount = doc.GetValue("Amount", 0).ToDouble(),
Description = doc.GetValue("Description", string.Empty).ToString(),
Date = doc.GetValue("Date").AsDateTime
};
var nu = ModelCollection<ExpenseModel>.InsertItem(exp);
return "insert " + nu.Id;
}
catch (Exception ex)
{
return ex.Message;
}
}