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


C# BsonArray.Add方法代码示例

本文整理汇总了C#中BsonArray.Add方法的典型用法代码示例。如果您正苦于以下问题:C# BsonArray.Add方法的具体用法?C# BsonArray.Add怎么用?C# BsonArray.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BsonArray的用法示例。


在下文中一共展示了BsonArray.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRolesByDBName

 /// <summary>
 /// 获得数据库角色
 /// </summary>
 /// <param name="DatabaseName"></param>
 /// <returns></returns>
 public BsonArray GetRolesByDBName(String DatabaseName)
 {
     BsonArray roles = new BsonArray();
     //当前DB的System.user的角色
     if (UserList.ContainsKey(DatabaseName)) {
         roles = UserList[DatabaseName].roles;
     }
     ///Admin的OtherDBRoles和当前数据库角色合并
     BsonArray adminRoles = GetOtherDBRoles(DatabaseName);
     foreach (String item in adminRoles)
     {
         if (!roles.Contains(item)) {
             roles.Add(item);
         }
     }
     ///ADMIN的ANY系角色的追加
     if (UserList.ContainsKey(MongoDBHelper.DATABASE_NAME_ADMIN)) {
         if (UserList[MongoDBHelper.DATABASE_NAME_ADMIN].roles.Contains(MongoDBHelper.UserRole_dbAdminAnyDatabase)){
             roles.Add(MongoDBHelper.UserRole_dbAdminAnyDatabase);
         }
         if (UserList[MongoDBHelper.DATABASE_NAME_ADMIN].roles.Contains(MongoDBHelper.UserRole_readAnyDatabase))
         {
             roles.Add(MongoDBHelper.UserRole_readAnyDatabase);
         }
         if (UserList[MongoDBHelper.DATABASE_NAME_ADMIN].roles.Contains(MongoDBHelper.UserRole_readWriteAnyDatabase))
         {
             roles.Add(MongoDBHelper.UserRole_readWriteAnyDatabase);
         }
         if (UserList[MongoDBHelper.DATABASE_NAME_ADMIN].roles.Contains(MongoDBHelper.UserRole_userAdminAnyDatabase))
         {
             roles.Add(MongoDBHelper.UserRole_userAdminAnyDatabase);
         }
     }
     return roles;
 }
开发者ID:huchao007,项目名称:MagicMongoDBTool,代码行数:40,代码来源:EachDatabaseUser.cs

示例2: AddLogToCollection

        public static void AddLogToCollection(string jsonDocument,string collectionName)
        {
            try
            {
                var document = BsonDocument.Parse(jsonDocument);

                document = CorrectDateField(document);

                var keyValue = document.First().Value.ToString();

                var result = new BsonDocument();
                result.Add("_id", keyValue);

                var mongoRepo = new MongoDBRepository<MongoDBContext>();
                var fResult = mongoRepo.FinObjectByKey(collectionName, keyValue).ToList();

                if (fResult != null && fResult.Count == 1)
                {
                    var value = fResult.First().Last().Value as BsonArray;
                    if (value != null)
                    {
                        var doc = fResult.First().Last().Value as BsonArray;
                        doc.Add(document.Last().Value);
                        CopyMidelElmentInResult(document, result);
                        result.Add(document.Last().Name, doc);
                        mongoRepo.ReplaceOne(keyValue, collectionName, result);
                    }
                    else
                    {
                        var doc = fResult.First().Last().Value as BsonDocument;
                        var list = new BsonArray();
                        list.Add(doc);
                        list.Add(document.Last().Value);
                        CopyMidelElmentInResult(document, result);
                        result.Add(doc.Last().Name, list);
                        mongoRepo.ReplaceOne(keyValue, collectionName, result);
                    }
                }
                else
                {

                    CopyMidelElmentInResult(document, result);
                    var list = new BsonArray();
                    list.Add(document.Last().Value);
                    result.Add(document.Last().Name, list);
                    mongoRepo.AddOne(collectionName, result);
                }

            }
            catch(Exception ex)
            {
                APILogger.Write(ex.Message, LogLevel.Error);
            }
           
        }
开发者ID:ylasmak,项目名称:SQLi.NoSql.API,代码行数:55,代码来源:Wafacash.Logger.Moddel.cs

示例3: get_depth_all

    public string get_depth_all()
    {
        string sql = "select max(id) from depth_log where website='btcchina' and type='sell' ";
        string max_id = SQLServerHelper.get_table(sql).Rows[0][0].ToString();

        sql = "select * from depth_log where id={0}";
        sql = string.Format(sql, max_id);
        string result_sell = SQLServerHelper.get_table(sql).Rows[0]["text"].ToString();

        sql = "select max(id) from depth_log where website='btcchina' and type='buy' ";
        max_id = SQLServerHelper.get_table(sql).Rows[0][0].ToString();

        sql = "select * from depth_log where id={0}";
        sql = string.Format(sql, max_id);
        string result_buy = SQLServerHelper.get_table(sql).Rows[0]["text"].ToString();

        BsonArray array_sell = MongoHelper.get_array_from_str(result_sell);
        BsonArray array_buy = MongoHelper.get_array_from_str(result_buy);

        BsonArray list = new BsonArray();

        BsonDocument doc_buy = new BsonDocument();
        doc_buy.Add("name", "SELL");
        BsonArray list_buy = new BsonArray();
        for (int i = array_buy.Count-1; i >=0; i--)
        {
            BsonDocument doc_item = new BsonDocument();
            doc_item.Add("x", array_buy[i][0]);
            doc_item.Add("y", array_buy[i][1]);
            list_buy.Add(doc_item);
        }
        doc_buy.Add("data", list_buy);

        BsonDocument doc_sell = new BsonDocument();
        doc_sell.Add("name", "SELL");
        BsonArray list_sell = new BsonArray();
        for (int i =array_sell.Count-1; i>=0; i--)
        {
            BsonDocument doc_item = new BsonDocument();
            doc_item.Add("x", array_sell[i][0]);
            doc_item.Add("y", array_sell[i][1]);
            list_sell.Add(doc_item);
        }
        doc_sell.Add("data", list_sell);

        list.Add(doc_buy);
        list.Add(doc_sell);

        return list.ToString();
    }
开发者ID:topomondher,项目名称:web_helper,代码行数:50,代码来源:response.aspx.cs

示例4: Build

        public override void Build(MongoDB.Bson.BsonDocument bsonPanelSetOrder, int panelSetId)
        {
            base.Build(bsonPanelSetOrder, panelSetId);

            string reportNo = bsonPanelSetOrder.GetValue("ReportNo").ToString();
            MongoCollection surgicalSpecimenTable = this.m_SQLTransferDatabase.GetCollection<BsonDocument>("tblSurgicalSpecimen");
            MongoCursor mongoCursor = surgicalSpecimenTable.FindAs<BsonDocument>(Query.EQ("ReportNo", reportNo));

            BsonArray bsonArray = new BsonArray();
            foreach (BsonDocument bsonSurgicalSpecimen in mongoCursor)
            {
                string surgicalSpecimenId = bsonSurgicalSpecimen.GetValue("SurgicalSpecimenId").AsString;
                this.BuildIC(bsonSurgicalSpecimen, surgicalSpecimenId);
                this.BuildStainResult(bsonSurgicalSpecimen, surgicalSpecimenId);
                this.BuildICD9BillingCode(bsonSurgicalSpecimen, surgicalSpecimenId);

                bsonArray.Add(bsonSurgicalSpecimen);
            }

            bsonPanelSetOrder.Add("SurgicalSpecimenCollection", bsonArray);

            MongoCollection surgicalAuditTable = this.m_SQLTransferDatabase.GetCollection<BsonDocument>("tblSurgicalAudit");
            MongoCursor surgicalAuditCursor = surgicalAuditTable.FindAs<BsonDocument>(Query.EQ("ReportNo", reportNo));

            BsonArray surgicalAuditArray = new BsonArray();
            foreach (BsonDocument bsonSurgicalAudit in surgicalAuditCursor)
            {
                string surgicalAuditId = bsonSurgicalAudit.GetValue("SurgicalAuditId").AsString;
                this.BuildSurgicalSpecimenAudit(bsonSurgicalAudit, surgicalAuditId);

                surgicalAuditArray.Add(bsonSurgicalAudit);
            }

            bsonPanelSetOrder.Add("SurgicalAuditCollection", surgicalAuditArray);
        }
开发者ID:WilliamCopland,项目名称:YPILIS,代码行数:35,代码来源:PSOSurgicalTransferBuilder.cs

示例5: Post

        public void Post(UserModel model)
        {
            var mongoDbClient = new MongoClient("mongodb://127.0.0.1:27017");
            var mongoDbServer = mongoDbClient.GetDatabase("SocialNetworks");
            BsonArray arr = new BsonArray();            
            dynamic jobj = JsonConvert.DeserializeObject<dynamic>(model.Movies.ToString());
            foreach (var item in jobj)
            {
                foreach(var subitem in item)
                {
                    arr.Add(subitem.Title.ToString());
                }
            }

            var document = new BsonDocument
            {
                { "Facebook_ID",  model.Facebook_ID },
                { "Ime",  model.Ime  },
                { "Prezime",  model.Prezime  },
                { "Email",  model.Email  },
                { "DatumRodjenja",  model.DatumRodjenja  },
                { "Hometown", model.Hometown},
                { "ProfilePictureLink", model.ProfilePictureLink  },
                { "Movies",  arr },
            };

            var collection = mongoDbServer.GetCollection<BsonDocument>("UserInfo");
            collection.InsertOneAsync(document);
        }
开发者ID:IvanKresic,项目名称:SocialNetworkRecommander,代码行数:29,代码来源:UserInfoController.cs

示例6: insert_trade

    public static void insert_trade(string result, string pair)
    {
        StringBuilder sb = new StringBuilder();
        BsonArray list = MongoHelper.get_array_from_str(result);
        BsonArray sell=new BsonArray();
        BsonArray buy=new BsonArray();
        for (int i = 0; i < list.Count; i++)
        {
            BsonDocument doc_item = new BsonDocument();
            doc_item["id"] = list[i]["tid"].ToString();
            doc_item["time"] = list[i]["date"].ToString();
            doc_item["price"] = list[i]["price"].ToString();
            doc_item["qty"] = list[i]["amount"].ToString();

            if (list[i]["type"].ToString() == "sell")
            {
                sell.Add(doc_item);
            }
            if (list[i]["type"].ToString() == "buy")
            {
                buy.Add(doc_item);
            }
        }
        BtcHelper.insert_trade_log("btcchina", pair, "sell", "btc", sell.ToString());
        BtcHelper.insert_trade_log("btcchina", pair, "buy", "btc", buy.ToString());
    }
开发者ID:topomondher,项目名称:web_helper,代码行数:26,代码来源:BtcchinaData.cs

示例7: Deserialize

        // public methods
        /// <summary>
        /// Deserializes an object from a BsonReader.
        /// </summary>
        /// <param name="bsonReader">The BsonReader.</param>
        /// <param name="nominalType">The nominal type of the object.</param>
        /// <param name="actualType">The actual type of the object.</param>
        /// <param name="options">The serialization options.</param>
        /// <returns>An object.</returns>
        public override object Deserialize(
            BsonReader bsonReader,
            Type nominalType,
            Type actualType,
            IBsonSerializationOptions options)
        {
            VerifyTypes(nominalType, actualType, typeof(BsonArray));

            var bsonType = bsonReader.GetCurrentBsonType();
            switch (bsonType)
            {
                case BsonType.Array:
                    bsonReader.ReadStartArray();
                    var array = new BsonArray();
                    while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
                    {
                        var value = (BsonValue)BsonValueSerializer.Instance.Deserialize(bsonReader, typeof(BsonValue), null);
                        array.Add(value);
                    }
                    bsonReader.ReadEndArray();
                    return array;
                default:
                    var message = string.Format("Cannot deserialize BsonArray from BsonType {0}.", bsonType);
                    throw new FileFormatException(message);
            }
        }
开发者ID:robinNode,项目名称:mongo-csharp-driver,代码行数:35,代码来源:BsonArraySerializer.cs

示例8: TestAddNull

 public void TestAddNull()
 {
     var array = new BsonArray();
     var value = (BsonValue)null;
     array.Add(value);
     Assert.AreEqual(0, array.Count);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonArrayTests.cs

示例9: AddField

		public static void AddField(this BsonDocument doc, string name, object value)
		{
			if (value == null) return;

			var unifiedName = name.ToLower();
			switch (unifiedName)
			{
				case "exception":
					doc[name] = BuildExceptionBsonDocument((Exception)value); break;

				case "properties":
					var properties = (IDictionary<object, object>)value;
					if (properties.Count > 0)
						doc[name] = BuildPropertiesBsonDocument(properties);
					break;

				case "parameters":
					var parameters = (object[])value;
                    BsonArray array = new BsonArray();
                    foreach (var param in parameters)
                    {
                        array.Add(SafeCreateBsonValue(param));
                    }
                    doc[name] = array;
					break;

				default:
                    doc[name] = SafeCreateBsonValue(value);
					break;
			}
		}
开发者ID:ExactBid,项目名称:NLog.MongoDB,代码行数:31,代码来源:BsonDocumentExtensions.cs

示例10: ConvertTreeNodeTozTreeBsonDoc

 /// <summary>
 /// </summary>
 /// <param name="SubNode"></param>
 /// <returns></returns>
 public static BsonDocument ConvertTreeNodeTozTreeBsonDoc(TreeNode SubNode)
 {
     var SingleNode = new BsonDocument();
     SingleNode.Add("name", SubNode.Text + GetTagText(SubNode));
     if (SubNode.Nodes.Count == 0)
     {
         SingleNode.Add("icon", "MainTreeImage" + String.Format("{0:00}", SubNode.ImageIndex) + ".png");
     }
     else
     {
         var ChildrenList = new BsonArray();
         foreach (TreeNode item in SubNode.Nodes)
         {
             ChildrenList.Add(ConvertTreeNodeTozTreeBsonDoc(item));
         }
         SingleNode.Add("children", ChildrenList);
         SingleNode.Add("icon", "MainTreeImage" + String.Format("{0:00}", SubNode.ImageIndex) + ".png");
     }
     if (SubNode.IsExpanded)
     {
         SingleNode.Add("open", "true");
     }
     if (SubNode.Tag != null)
     {
         SingleNode.Add("click",
             "ShowData('" + SystemManager.GetTagType(SubNode.Tag.ToString()) + "','" +
             SystemManager.GetTagData(SubNode.Tag.ToString()) + "')");
     }
     return SingleNode;
 }
开发者ID:EricBlack,项目名称:MagicMongoDBTool,代码行数:34,代码来源:UIHelper_Connection_Present_WebForm.cs

示例11: Serialize

 public BsonDocument Serialize(Scope scope)
 {
     var doc = new BsonDocument();
     doc["_id"] = scope.Name;
     doc["_version"] = 1;
     doc.SetIfNotNull("displayName", scope.DisplayName);
     var claims = new BsonArray();
     foreach (ScopeClaim scopeClaim in scope.Claims)
     {
         var claim = new BsonDocument();
         claim["name"] = scopeClaim.Name;
         claim["alwaysIncludeInIdToken"] = scopeClaim.AlwaysIncludeInIdToken;
         claim.SetIfNotNull("description", scopeClaim.Description);
         claims.Add(claim);
     }
     doc["claims"] = claims;
     doc.SetIfNotNull("claimsRule", scope.ClaimsRule);
     doc.SetIfNotNull("description", scope.Description);
     doc["emphasize"] = scope.Emphasize;
     doc["enabled"] = scope.Enabled;
     doc["includeAllClaimsForUser"] = scope.IncludeAllClaimsForUser;
     doc["required"] = scope.Required;
     doc["showInDiscoveryDocument"] = scope.ShowInDiscoveryDocument;
     doc["type"] = scope.Type.ToString();
     return doc;
 }
开发者ID:nielsmeijssen,项目名称:IdentityServer.v3.MongoDb,代码行数:26,代码来源:ScopeSerializer.cs

示例12: TestAdd

 public void TestAdd()
 {
     var array = new BsonArray();
     var value = BsonValue.Create(1);
     array.Add(value);
     Assert.AreEqual(1, array.Count);
     Assert.AreEqual(value, array[0]);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BsonArrayTests.cs

示例13: ConvertTreeViewTozTreeJson

 /// <summary>
 /// 
 /// </summary>
 /// <param name="tree"></param>
 /// <returns></returns>
 public static String ConvertTreeViewTozTreeJson(TreeView tree)
 {
     BsonArray array = new BsonArray();
     foreach (TreeNode item in tree.Nodes)
     {
         array.Add(ConvertTreeNodeTozTreeBsonDoc(item));
     }
     return array.ToJson(SystemManager.JsonWriterSettings);
 }
开发者ID:Eddie0330,项目名称:MagicMongoDBTool,代码行数:14,代码来源:MongoDBHelper_Connection_Present.cs

示例14: ConvertTreeViewTozTreeJson

 /// <summary>
 /// </summary>
 /// <param name="tree"></param>
 /// <returns></returns>
 public static String ConvertTreeViewTozTreeJson(TreeView tree)
 {
     var array = new BsonArray();
     foreach (TreeNode item in tree.Nodes)
     {
         array.Add(ConvertTreeNodeTozTreeBsonDoc(item));
     }
     return array.ToJson(MongoUtility.Basic.Utility.JsonWriterSettings);
 }
开发者ID:jango2015,项目名称:MongoCola,代码行数:13,代码来源:WEBUIHelper.cs

示例15: GetAllUserByRole

 /// <summary>
 /// 获取角色下所有用户(当前用户角色可见)
 /// </summary>
 /// <param name="Options">查询参数</param>
 /// <param name="ReceiveMessage">回调消息</param>
 public void GetAllUserByRole(BsonDocument Options, BsonDocument ReceiveMessage)
 {
     ObjectId RoleId = new ObjectId(Options.GetValue("UserRoleId").ToString());
     BsonArray RoleList = urs.GetAllChildren(RoleId);
     //RoleList.Add(urs.FindOne(RoleId).ToBsonDocument());//无法编辑自己的角色权限
     BsonArray RoleIds = new BsonArray();
     RoleIds.Add(RoleId);
     foreach (BsonValue ur in RoleList)
     {
         RoleIds.Add(ur["_id"]);
     }
     BsonArray UserList = us.GetAllUsersByRole(RoleIds);
     BsonDocument json = new BsonDocument();
     json.Add("RoleList", RoleList);
     json.Add("UserList", UserList);
     ReceiveMessage.Add("StateCode", 0);//登录成功
     ReceiveMessage.Add("ReData", json.ToJson(jsonSettings));
     CallBack();
 }
开发者ID:Zane0816,项目名称:Mail-.Net,代码行数:24,代码来源:UserManager.cs


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