当前位置: 首页>>代码示例>>C#>>正文


C# BsonDocument.GetValue方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:Zane0816,项目名称:Mail-.Net,代码行数:39,代码来源:CaseManager.cs

示例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();
     }
 }
开发者ID:Zane0816,项目名称:Mail-.Net,代码行数:35,代码来源:RoleManager.cs

示例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);
        }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:26,代码来源:v1.0.22.cs

示例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;
        }
开发者ID:qanwi1970,项目名称:dungeon-mart,代码行数:12,代码来源:Dnd5Mapper.cs

示例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();
     }
 }
开发者ID:Zane0816,项目名称:Mail-.Net,代码行数:30,代码来源:MarkManager.cs

示例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);
        }
开发者ID:GuilhermeMorais,项目名称:Exceptionless,代码行数:30,代码来源:v1.0.1-v1.0.8_Migration.cs

示例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);
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:29,代码来源:v1.0.28.cs

示例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);
 }
开发者ID:apxnowhere,项目名称:Encore,代码行数:7,代码来源:ChangeFieldProjectIdToString.cs

示例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);
        }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:27,代码来源:v1.0.23.cs

示例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);
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:25,代码来源:v1.0.32.cs

示例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);
        }
开发者ID:priestd09,项目名称:Exceptionless,代码行数:28,代码来源:v1.0.26.cs

示例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);
        }
开发者ID:aamarber,项目名称:Exceptionless,代码行数:17,代码来源:v1.0.34.cs

示例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();
 }
开发者ID:star0710,项目名称:ASP.Net4.5MongoDB,代码行数:17,代码来源:ProxyAPICallModels.cs

示例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);
        }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:45,代码来源:v1.0.15.cs

示例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;
            }
        }
开发者ID:pronning,项目名称:punch,代码行数:27,代码来源:Importer.cs


注:本文中的BsonDocument.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。