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


C# BsonDocument.ToString方法代码示例

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


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

示例1: btnPickDoc_Click

 private void btnPickDoc_Click(object sender, EventArgs e)
 {
     var frmInsertDoc = new frmCreateDocument();
     UIAssistant.OpenModalForm(frmInsertDoc, false, true);
     if (frmInsertDoc.mBsonDocument == null) return;
     customData = frmInsertDoc.mBsonDocument;
     lblcustomDocument.Text = "Custom Document:" + customData.ToString();
 }
开发者ID:magicdict,项目名称:MongoCola,代码行数:8,代码来源:frmUser.cs

示例2: TestUpdate

        /// <summary>
        /// Update测试。
        /// </summary>
        /// <param name="sdb"></param>
        static void TestUpdate(Sequoiadb sdb)
        {
            // The collection space name
            string csName = "sample";
            // The collection name
            string cName = "sample";

            // connect
            CollectionSpace cs;
            if (sdb.IsCollectionSpaceExist(csName))
                cs = sdb.GetCollecitonSpace(csName);
            else
                cs = sdb.CreateCollectionSpace(csName);

            DBCollection coll = null;
            if (cs.IsCollectionExist(cName))
                coll = cs.GetCollection(cName);
            else
                coll = cs.CreateCollection(cName);

            // delete all records from the collection
            BsonDocument bson = new BsonDocument();
            coll.Delete(bson);
            
            String[] record = new String[4];
            record[0] = "{cust_id:\"A123\",amount:500,status:\"A\"}";
            record[1] = "{cust_id:\"A123\",amount:250,status:\"A\"}";
            record[2] = "{cust_id:\"B212\",amount:200,status:\"A\"}";
            record[3] = "{cust_id:\"A123\",amount:300,status:\"D\"}";
            // insert record into database
            for (int i = 0; i < record.Length; i++)
            {
                BsonDocument obj = new BsonDocument();
                obj = BsonDocument.Parse(record[i]);
                Console.WriteLine("Record is: " + obj.ToString());
                coll.Insert(obj);
            }
            
            //准备update
            BsonDocument updater = new BsonDocument();
            BsonDocument matcher = new BsonDocument();
            BsonDocument modifier = new BsonDocument();
            BsonDocument hint = new BsonDocument();           

            //条件
            matcher.Add("cust_id", new BsonDocument("$et", "A123"));
            //更新。
            updater.Add("amount", "1000");
            updater.Add("status", "C");
            modifier.Add("$set", updater);
            //update
            coll.Update(matcher, modifier, hint);

            System.Console.ReadLine();
        }
开发者ID:huoxudong125,项目名称:SequoiaDB.Charp,代码行数:59,代码来源:Program.cs

示例3: TestMethod1

        public void TestMethod1()
        {
            BsonArray membersDoc = new BsonArray();

            List<IPEndPoint> nodes = new List<IPEndPoint>();
            nodes.Add(new IPEndPoint(IPAddress.Parse("10.0.0.1"), 10000));
            nodes.Add(new IPEndPoint(IPAddress.Parse("10.0.0.2"), 10000));
            nodes.Add(new IPEndPoint(IPAddress.Parse("10.0.0.3"), 10000));

            // Get all the instances of the replica
            int serverId = 0;
            foreach (IPEndPoint node in nodes)
            {

                string host = string.Format("{0}:{1}", node.Address, node.Port);
                BsonDocument nodeDoc;

                if (serverId != 2)
                {
                    //Normal member
                    nodeDoc = new BsonDocument { { "_id", serverId }, { "host", host } };
                }
                else
                {
                    //Hidden member
                    nodeDoc = new BsonDocument { { "_id", serverId }, { "host", host }, { "buildIndexes", "false" }, { "hidden", "true" }, { "priority", "0" } };
                }

                membersDoc.Add(nodeDoc);

                serverId++;
            }

            var configDoc = new BsonDocument { { "_id", "replica1" }, { "members", membersDoc } };

            //rs.initiate ({_id : "replica1",members : [{ _id : 0, host : "10.61.92.137:20003" },{ _id : 1, host : "10.61.82.87:20003" },{ _id : 2, host : "10.61.80.121:20003", buildIndexes : false, hidden : true, priority: 0  } ] })
            string s = configDoc.ToString();
        }
开发者ID:smonteil,项目名称:azuremongospare,代码行数:38,代码来源:UnitTest1.cs

示例4: query

    public static string query(string url, string method,BsonArray param)
    {
        TimeSpan span = DateTime.UtcNow - new DateTime(1970, 1, 1);
        long ms = Convert.ToInt64(span.TotalMilliseconds * 1000);
        string tonce = Convert.ToString(ms);

        Dictionary<string, string> list_sign = new Dictionary<string, string>();
        list_sign.Add("tonce", tonce);
        list_sign.Add("accesskey", api_key);
        list_sign.Add("requestmethod", "post");
        list_sign.Add("id", "1");
        list_sign.Add("method", method);
        list_sign.Add("params", "");
        string str_sign_input = get_post_string(list_sign);

        string hash = get_hm_hash(secret_key, str_sign_input);
        string base64 = Convert.ToBase64String(Encoding.ASCII.GetBytes(api_key + ':' + hash));

        BsonDocument doc = new BsonDocument();
        doc.Add("method", method);
        doc.Add("params", param);
        doc.Add("id", 1);
        byte[] data = Encoding.ASCII.GetBytes(doc.ToString());

        var request = WebRequest.Create(new Uri(url)) as HttpWebRequest;
        if (request == null) throw new Exception("Non HTTP WebRequest");

        request.Method = "POST";
        request.ContentType = "application/json-rpc";
        request.ContentLength = data.Length;
        request.Headers["Authorization"] = "Basic " + base64;
        request.Headers["Json-Rpc-Tonce"] = tonce;

        var request_stream = request.GetRequestStream();
        request_stream.Write(data, 0, data.Length);
        request_stream.Close();
        return new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd();
    }
开发者ID:topomondher,项目名称:web_helper,代码行数:38,代码来源:OandaHelper.cs

示例5: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string objectidvalue = Session["objid"].ToString();
            string ordervalue = Session["order"].ToString();
            MyDB md = new MyDB();
            var col = md.GetBColl("registration");
            var queryid = new QueryDocument("_id", ObjectId.Parse(objectidvalue));
            BsonDocument baddress = new BsonDocument();
            foreach (BsonDocument bits in col.Find(queryid))
            {
                baddress.Add("mobileNo", bits.GetElement("mobile").Value.ToDouble());
                baddress.Add("address", bits.GetElement("address").Value.ToString());
                baddress.Add("city", bits.GetElement("city").Value.ToString());
                baddress.Add("pincode", bits.GetElement("pincode").Value.ToDouble());
                baddress.Add("order", ordervalue);
            }
            Response.Clear();
            Response.CacheControl = "no-cache";
            Response.ContentType = "application/json";
            Response.Write(baddress.ToString());  //Valid User
            Response.End();
        }

        catch (ThreadAbortException ee) { }

        catch (Exception e3)
        {
            Response.Clear();
            Response.CacheControl = "no-cache";
            Response.ContentType = "application/json";
            Response.Write("exception");
            Response.End();
        }
    }
开发者ID:bakkupavan407,项目名称:street,代码行数:36,代码来源:AddressAction.aspx.cs

示例6: setValue

 /// <summary>
 /// 使用属性会发生一些MONO上的移植问题
 /// </summary>
 /// <returns></returns>
 public void setValue(BsonValue value)
 {
     txtBsonValue.Visible = false;
     txtBsonValue.Text = String.Empty;
     txtBsonValue.ReadOnly = false;
     radTrue.Visible = false;
     radFalse.Visible = false;
     radFalse.Checked = true;
     dateTimePicker.Visible = false;
     NumberPick.Visible = false;
     if (value.IsString)
     {
         cmbDataType.SelectedIndex = 0;
         txtBsonValue.Visible = true;
         txtBsonValue.Text = value.ToString();
     }
     if (value.IsInt32)
     {
         cmbDataType.SelectedIndex = 1;
         NumberPick.Visible = true;
         NumberPick.Value = value.AsInt32;
     }
     if (value.IsValidDateTime)
     {
         dateTimePicker.Visible = true;
         dateTimePicker.Value = value.ToUniversalTime();
         cmbDataType.SelectedIndex = 2;
     }
     if (value.IsBoolean)
     {
         radTrue.Visible = true;
         radFalse.Visible = true;
         if (value.AsBoolean)
         {
             radTrue.Checked = true;
         }
         else
         {
             radFalse.Checked = true;
         }
         cmbDataType.SelectedIndex = 3;
     }
     if (value.IsBsonArray)
     {
         frmArrayCreator frmInsertArray = new frmArrayCreator();
         SystemManager.OpenForm(frmInsertArray, false, true);
         if (frmInsertArray.mBsonArray != null)
         {
             mBsonArray = frmInsertArray.mBsonArray;
             txtBsonValue.Visible = true;
             txtBsonValue.Text = mBsonArray.ToString();
             txtBsonValue.ReadOnly = true;
             cmbDataType.SelectedIndex = 4;
         }
     }
     if (value.IsBsonDocument)
     {
         frmNewDocument frmInsertDoc = new frmNewDocument();
         SystemManager.OpenForm(frmInsertDoc, false, true);
         if (frmInsertDoc.mBsonDocument != null)
         {
             mBsonDocument = frmInsertDoc.mBsonDocument;
             txtBsonValue.Visible = true;
             txtBsonValue.Text = mBsonDocument.ToString();
             txtBsonValue.ReadOnly = true;
             cmbDataType.SelectedIndex = 5;
         }
     }
 }
开发者ID:huchao007,项目名称:MagicMongoDBTool,代码行数:73,代码来源:ctlBsonValue.cs

示例7: SetValue

 /// <summary>
 ///     使用属性会发生一些MONO上的移植问题
 /// </summary>
 /// <returns></returns>
 public void SetValue(BsonValue value)
 {
     txtBsonValue.Visible = false;
     txtBsonValue.Text = string.Empty;
     txtBsonValue.ReadOnly = false;
     radTrue.Visible = false;
     radFalse.Visible = false;
     radFalse.Checked = true;
     dateTimePicker.Visible = false;
     NumberPick.Visible = false;
     if (value.IsString)
     {
         cmbDataType.SelectedIndex = 0;
         txtBsonValue.Visible = true;
         txtBsonValue.Text = value.ToString();
     }
     if (value.IsInt32)
     {
         cmbDataType.SelectedIndex = 1;
         NumberPick.Visible = true;
         NumberPick.Value = value.AsInt32;
     }
     if (value.IsValidDateTime)
     {
         dateTimePicker.Visible = true;
         dateTimePicker.Value = value.ToUniversalTime();
         cmbDataType.SelectedIndex = 2;
     }
     if (value.IsBoolean)
     {
         radTrue.Visible = true;
         radFalse.Visible = true;
         if (value.AsBoolean)
         {
             radTrue.Checked = true;
         }
         else
         {
             radFalse.Checked = true;
         }
         cmbDataType.SelectedIndex = 3;
     }
     if (value.IsBsonArray)
     {
         var t = GetArray();
         if (t != null)
         {
             _mBsonArray = t;
             txtBsonValue.Visible = true;
             txtBsonValue.Text = _mBsonArray.ToString();
             txtBsonValue.ReadOnly = true;
             cmbDataType.SelectedIndex = 4;
         }
     }
     if (value.IsBsonDocument)
     {
         var t = GetDocument();
         if (t != null)
         {
             _mBsonDocument = t;
             txtBsonValue.Visible = true;
             txtBsonValue.Text = _mBsonDocument.ToString();
             txtBsonValue.ReadOnly = true;
             cmbDataType.SelectedIndex = 5;
         }
     }
 }
开发者ID:lizhi5753186,项目名称:MongoCola,代码行数:71,代码来源:ctlBsonValue.cs

示例8: TestAggregate5

        static void TestAggregate5(Sequoiadb sdb)
        {
            // The collection space name
            string csName = "sample";
            // The collection name
            string cName = "sample";

            // connect
            CollectionSpace cs;
            if (sdb.IsCollectionSpaceExist(csName))
                cs = sdb.GetCollecitonSpace(csName);
            else
                cs = sdb.CreateCollectionSpace(csName);

            DBCollection coll = null;
            if (cs.IsCollectionExist(cName))
                coll = cs.GetCollection(cName);
            else
                coll = cs.CreateCollection(cName);

            // delete all records from the collection
            BsonDocument bson = new BsonDocument();
            coll.Delete(bson);

            String[] command = new String[2];
            command[0] = "{$match:{status:\"A\"}}";
            command[1] = "{$group:{_id:\"$cust_id\",amount:{\"$sum\":\"$amount\"},cust_id:{\"$first\":\"$cust_id\"}}}";
            String[] record = new String[4];
            record[0] = "{cust_id:\"A123\",amount:500,status:\"A\"}";
            record[1] = "{cust_id:\"A123\",amount:250,status:\"A\"}";
            record[2] = "{cust_id:\"B212\",amount:200,status:\"A\"}";
            record[3] = "{cust_id:\"A123\",amount:300,status:\"D\"}";
            // insert record into database
            for (int i = 0; i < record.Length; i++)
            {
                BsonDocument obj = new BsonDocument();
                obj = BsonDocument.Parse(record[i]);
                Console.WriteLine("Record is: " + obj.ToString());
                coll.Insert(obj);
            }
            List<BsonDocument> list = new List<BsonDocument>();
            for (int i = 0; i < command.Length; i++)
            {
                BsonDocument obj = new BsonDocument();
                obj = BsonDocument.Parse(command[i]);
                list.Add(obj);
            }

            DBCursor cursor = coll.Aggregate(list);
            int count = 0;
            while (null != cursor.Next())
            {
                Console.WriteLine("Result is: " + cursor.Current().ToString());
                String str = cursor.Current().ToString();
                count++;
            }

            System.Console.ReadLine();
        }
开发者ID:huoxudong125,项目名称:SequoiaDB.Charp,代码行数:59,代码来源:Program.cs

示例9: BuildMatchQuery

        public static Report BuildMatchQuery(Report report)
        {

         

            var bsonArray = new BsonArray();
            DateTime outDate = DateTime.MinValue;
            int filterCount = 0;

            foreach (var query in report.LambdaQuery)
            {

                if (report.FilterDataValue[query.Values] == null ||
                        string.IsNullOrEmpty(report.FilterDataValue[query.Values].ToString()))
                {
                    if ( query.AllowNull)
                    {
                        continue;
                    }
                    else
                    {

                        throw new Exception("champs obligatoire non renségné ");
                    }
                }

                BsonDocument element = null;
                if (query.Operator == LambdaOperator.Eq)
                {
                    if (DateTime.TryParse(report.FilterDataValue[query.Values].ToString(), out outDate))
                    {
                        element = new BsonDocument(query.Field, BsonDateTime.Create(outDate));
                        
                    }

                    else
                    {
                        element = new BsonDocument(query.Field, BsonString.Create(report.FilterDataValue[query.Values]));
                    }
                    filterCount++;
                    bsonArray.Add(element);
                }

                if (query.Operator == LambdaOperator.Gt)
                {
                 

                    if (DateTime.TryParse(report.FilterDataValue[query.Values].ToString(), out outDate))
                    {

                        element = new BsonDocument("$gt", BsonDateTime.Create(outDate));
                    }

                    else
                    {
                        element = new BsonDocument("$gt", BsonString.Create(report.FilterDataValue[query.Values]));
                    }

                    var surElement = new BsonDocument(query.Field, element);
                    bsonArray.Add(surElement);
                    filterCount++;
                }

              
                if (query.Operator == LambdaOperator.Lt)
                {
                    if ( DateTime.TryParse( report.FilterDataValue[query.Values].ToString(),out  outDate))
                    {
                        element = new BsonDocument("$lt", BsonDateTime.Create(outDate));
                    }

                    else
                    {
                        element = new BsonDocument("$lt", BsonString.Create(report.FilterDataValue[query.Values]));
                    }
                    var surElement = new BsonDocument(query.Field, element);
                    bsonArray.Add(surElement);
                    filterCount++;

                }

            }
            
            if(filterCount == 0)
            {
                throw new Exception("Au moins un filtre doit être renségné");
            }

            var bsonAnd = new BsonDocument("$and", bsonArray);
            var bsonMatch = new BsonDocument("$match", bsonAnd);
          

            for(int i=0;i< report.Query.Count; i++)
            {
                if(report.Query[i].Contains("$$lambdaFilter$$"))
                {
                    report.Query[i] = bsonMatch.ToString();
                }
            }

//.........这里部分代码省略.........
开发者ID:ylasmak,项目名称:SQLi.NoSql.API,代码行数:101,代码来源:AggregationQueryProcessing.cs

示例10: TestAggregate2

        static void TestAggregate2(Sequoiadb sdb)
        {
            var cs = sdb.GetCollecitonSpace("dbo");

            DBCollection coll = null;
            if (cs.IsCollectionExist("t2"))
                coll = cs.GetCollection("t2");
            else
                coll = cs.CreateCollection("t2");

            String[] command = new String[2];
            command[0] = "{$match:{status:\"A\"}}";
            command[1] = "{$group:{_id:\"$cust_id\",amount:{\"$sum\":\"$amount\"},cust_id:{\"$first\":\"$cust_id\"}}}";
            String[] record = new String[4];
            record[0] = "{cust_id:\"A123\",amount:500,status:\"A\"}";
            record[1] = "{cust_id:\"A123\",amount:250,status:\"A\"}";
            record[2] = "{cust_id:\"B212\",amount:200,status:\"A\"}";
            record[3] = "{cust_id:\"A123\",amount:300,status:\"D\"}";
            // insert record into database
            for (int i = 0; i < record.Length; i++)
            {
                BsonDocument obj = new BsonDocument();
                obj = BsonDocument.Parse(record[i]);
                Console.WriteLine("Record is: " + obj.ToString());
                coll.Insert(obj);
            }
            List<BsonDocument> list = new List<BsonDocument>();
            for (int i = 0; i < command.Length; i++)
            {
                BsonDocument obj = new BsonDocument();
                obj = BsonDocument.Parse(command[i]);
                list.Add(obj);
            }

            DBCursor cursor = coll.Aggregate(list);
            int count = 0;
            while (null != cursor.Next())
            {
                Console.WriteLine("Result is: " + cursor.Current().ToString());
                String str = cursor.Current().ToString();
                count++;
            }
        }
开发者ID:huoxudong125,项目名称:SequoiaDB.Charp,代码行数:43,代码来源:Program.cs

示例11: GotNewBar

        void GotNewBar(string symbol, int interval)
        {
            // get current barlist for this symbol+interval
            BarList bl = track_barlists[symbol, interval];

            // issue an event (todo: should I put this functionality into MessageResponseTemplate.cs? or should I get rid of GotNewBar at all? hmm...) will stay here for a while..
            BsonDocument bson_doc = new BsonDocument();
            bson_doc = new BsonDocument();
            bson_doc["Symbol"] = bl.RecentBar.Symbol;
            bson_doc["High"] = bl.RecentBar.High.ToString();
            bson_doc["Low"] = bl.RecentBar.Low.ToString();
            bson_doc["Open"] = bl.RecentBar.Open.ToString();
            bson_doc["Close"] = bl.RecentBar.Close.ToString();
            bson_doc["Volume"] = bl.RecentBar.Volume.ToString();
            bson_doc["isNew"] = bl.RecentBar.isNew;
            bson_doc["Bartime"] = bl.RecentBar.Bartime;
            bson_doc["Bardate"] = bl.RecentBar.Bardate;
            bson_doc["isValid"] = bl.RecentBar.isValid;
            bson_doc["Interval"] = bl.RecentBar.Interval;
            bson_doc["time"] = bl.RecentBar.time;

            //send_event(MimeType.got_new_bar, "bar", bson_doc.ToString());
            log_file.WriteLine("got_new_bar"+ bson_doc.ToString());

            // get index for symbol
            int idx = track_symbols.getindex(symbol);

            string dbg_msg = "GotNewBar(" + symbol + ", " + interval + "):";

            // check for first cross on first interval
            if (interval == _response_barsize_s)
            {
                decimal ema = Calc.Avg(Calc.EndSlice(bl.Close(), _ema_bar));

                track_ema[symbol].Add(ema);

                // drawings...
                if (bl.Close().Length > _ema_bar)
                {
                    // draw 2 sma lines:
                    sendchartlabel(ema, time, System.Drawing.Color.FromArgb(0xff, 0x01, 0x01));

                    // do the trade (if required)
                    decimal[] ema_arr = track_ema[symbol].ToArray();

                    decimal prev_ema = ema_arr[ema_arr.Length - 2];
                    decimal curr_ema = ema_arr[ema_arr.Length - 1];
                    decimal delta_ema = curr_ema - prev_ema;

                    // sma just crossed?
                    bool should_buy = track_positions[symbol].isFlat && delta_ema >= 0.002m;
                    bool should_sell = false;

                    dbg_msg += " delta_ema=" + delta_ema.ToString("000.000");
                    /*
                    dbg_msg += " fast=" + curr_sma_fast.ToString("000.000");
                    dbg_msg += " pr_slow=" + prev_sma_slow.ToString("000.000");
                    dbg_msg += " pr_fast=" + prev_sma_fast.ToString("000.000");
                    dbg_msg += " [" + symbol + "].isFlat=" + track_positions[symbol].isFlat.ToString();
                    dbg_msg += " track_positions[symbol].ToString=" + track_positions[symbol].ToString();
                    dbg_msg += " should_buy=" + should_buy.ToString();
                    dbg_msg += " should_sell=" + should_sell.ToString();
                     */

                    //senddebug("GotNewBar(): " + debug_position_tracker(symbol));

                    if (should_buy)
                    {
                        // come buy some! (c) Duke Nukem
                        string comment = " BuyMarket(" + symbol + ", " + EntrySize.ToString() + ")";
                        sendorder(new BuyMarket(symbol, EntrySize, comment));
                        log_file.WriteLine("close position: " + comment);
                        dbg_msg += comment;
                    }

                    if (false) // we do all the selling on tick()
                    {
                        if (!track_positions[symbol].isFlat && should_sell) // we don't short, so also check if !flat
                        //if ( should_sell) // we don't short, so also check if !flat
                        {
                            sendorder(new SellMarket(symbol, EntrySize));
                            dbg_msg += " SellMarket(" + symbol + ", " + EntrySize.ToString() + ")";
                        }
                    }
                }
            }
            //else
            //{
            //    // 
            //    dbg_msg += "GotNewBar() other interval=" + interval;
            //}

            // spit out one dbg message line per bar
            D(dbg_msg);

            // nice way to notify of current tracker values
            sendindicators(gt.GetIndicatorValues(idx, gens()));
            return;
        }
开发者ID:RedBanies3ofThem,项目名称:tradelink.afterlife,代码行数:99,代码来源:_TS_step_by_step.cs

示例12: BuildProjectTest

        public void BuildProjectTest()
        {
            var groupDefinition = GetGroupDefinition();
            var keyItems = new List<BsonElement>();
            var valueItems = new List<BsonElement>();

            var ignoreId = new BsonElement("_id", new BsonInt32(0));

            for (var i = 0; i < groupDefinition.Dimensions.Count; i++)
            {
                var el = new BsonElement(String.Format("s{0}", i), new BsonString(String.Format("$_id.s{0}", i)));
                keyItems.Add(el);
            }
            for (var i = 0; i < groupDefinition.Measures.Count; i++)
            {
                var el = new BsonElement(String.Format("f{0}", i), new BsonString(String.Format("$f{0}", i)));
                valueItems.Add(el);
            }

            var keyValuesDoc = new BsonDocument();
            keyValuesDoc.AddRange(keyItems);
            var keyValuesElement = new BsonElement("key", keyValuesDoc);

            var valueValuesDoc = new BsonDocument();
            valueValuesDoc.AddRange(valueItems);

            var valueValuesElement = new BsonElement("value", valueValuesDoc);

            var ignoreIdDoc = new BsonDocument();
            ignoreIdDoc.Add();

            var projectDoc = new BsonDocument();
            projectDoc.Add(new BsonElement("_id", new BsonInt32(0)));
            projectDoc.Add(keyValuesElement);
            projectDoc.Add(valueValuesElement);
            var projectElement = new BsonElement("$project", projectDoc);
            var finalDoc = new BsonDocument();
            finalDoc.Add(projectElement);
            //var projectValuesDoc  = new BsonDocument();

            //projectValuesDoc.AddRange(keyItems);

            //var projectItemsElement = new BsonElement("$project", projectValuesDoc);
            //var finalDoc = new BsonDocument();
            //finalDoc.Add(projectItemsElement);
            Console.Out.Write(finalDoc.ToString());
        }
开发者ID:cmcginn,项目名称:Akron,代码行数:47,代码来源:DataServiceTests.cs

示例13: get_depth_with_time

    public string get_depth_with_time(string time)
    {
        double range = 10;
        double sell_qty = 0;
        double buy_qty = 0;
        BsonDocument doc_result = new BsonDocument();

        string sql = "select min(id) from depth_log where website='btcchina' and type='sell' and time>={0} ";
        sql = string.Format(sql, time);
        string max_id = SQLServerHelper.get_table(sql).Rows[0][0].ToString();

        if (string.IsNullOrEmpty(max_id))
        {
            doc_result.Add("data", "");
            doc_result.Add("time", "no");
            return doc_result.ToString();
        }

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

        sql = "select min(id) from depth_log where website='btcchina' and type='buy'  and time >={0}";
        sql = string.Format(sql, time);
        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);

        double middle = Convert.ToDouble(array_buy[0][0].ToString());
        double min = middle - range;
        double max = middle + range;

        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--)
        {
            if (Convert.ToDouble(array_buy[i][0].ToString()) > min && Convert.ToDouble(array_buy[i][0].ToString()) < max)
            {
                BsonDocument doc_item = new BsonDocument();
                doc_item.Add("x", array_buy[i][0]);
                doc_item.Add("y", array_buy[i][1]);
                buy_qty = buy_qty + Convert.ToDouble(array_buy[i][1].ToString());
                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--)
        {
            if (Convert.ToDouble(array_sell[i][0].ToString()) > min && Convert.ToDouble(array_sell[i][0].ToString()) < max)
            {
                BsonDocument doc_item = new BsonDocument();
                doc_item.Add("x", array_sell[i][0]);
                doc_item.Add("y", array_sell[i][1]);
                sell_qty = sell_qty + Convert.ToDouble(array_sell[i][1].ToString());
                list_sell.Add(doc_item);
            }
        }
        doc_sell.Add("data", list_sell);
        list.Add(doc_buy);
        list.Add(doc_sell);

        TimeSpan span = UnixTime.get_local_time_long(Convert.ToUInt64(depth_time)) - UnixTime.get_local_time_long(Convert.ToUInt64(time));

        doc_result.Add("data", list);
        doc_result.Add("time", depth_time);
        doc_result.Add("seconds", span.TotalSeconds);
        doc_result.Add("buy_qty", Math.Round(buy_qty,6));
        doc_result.Add("sell_qty",Math.Round(sell_qty,6));
        return doc_result.ToString();
    }
开发者ID:topomondher,项目名称:web_helper,代码行数:84,代码来源:response.aspx.cs

示例14: ReconfigReplsetServer

        /// <summary>
        /// 重新启动
        /// </summary>
        /// <param name="mongoSvr">副本组主服务器</param>
        /// <param name="HostPort">服务器信息</param>
        /// <remarks>这个命令C#无法正确执行</remarks>
        /// <returns></returns>
        public static CommandResult ReconfigReplsetServer(MongoServer PrimarySvr, BsonDocument config)
        {
            CommandResult cmdRtn = new CommandResult(new BsonDocument());
            try
            {
                return ExecuteJsShell("rs.reconfig(" + config.ToString() + ",{force : true})", PrimarySvr);
            }
            catch (EndOfStreamException)
            {

            }
            return cmdRtn;
        }
开发者ID:qq33357486,项目名称:MagicMongoDBTool,代码行数:20,代码来源:MongoDBHelper_RunCommand.cs

示例15: frmUser_Load

        /// <summary>
        ///     Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmUser_Load(object sender, EventArgs e)
        {
            if (_modifyName != string.Empty)
            {
                Text = "Change User Config";
                txtUserName.Enabled = false;
                txtUserName.Text = _modifyName;
                var userInfo = RuntimeMongoDbContext.GetCurrentDataBase().GetCollection(ConstMgr.CollectionNameUsers)
                    .FindOneAs<BsonDocument>(Query.EQ("user", _modifyName));

                BsonElement role;
                if (userInfo.TryGetElement("roles", out role))
                {
                    var roles = role.Value.AsBsonArray;
                    foreach (var _role in roles)
                    {
                        if (_role.IsBsonDocument)
                        {
                            _roleList.Add(new Role.GrantRole()
                            {
                                Role = _role.AsBsonDocument.GetElement("role").Value.ToString(),
                                Db = _role.AsBsonDocument.GetElement("db").Value.ToString()
                            });
                        }
                        else
                        {
                            _roleList.Add(new Role.GrantRole()
                            {
                                Role = _role.ToString(),
                            });
                        }
                    }
                }
                RefreshRoles();

                BsonElement custom;
                if (userInfo.TryGetElement("customData", out custom))
                {
                    customData = custom.Value.AsBsonDocument;
                    lblcustomDocument.Text = "Custom Document:" + customData.ToString();
                }

            }

            GuiConfig.Translateform(this);

            if (!GuiConfig.IsUseDefaultLanguage)
            {
                if (_modifyName == string.Empty)
                {
                    if (!GuiConfig.IsMono) Icon = GetSystemIcon.ConvertImgToIcon(Resources.AddUserToDB);
                    Text = GuiConfig.GetText(_isAdmin ? "MainMenu.OperationServerAddUserToAdmin" : "MainMenu.OperationDatabaseAddUser");
                }
                else
                {
                    if (!GuiConfig.IsMono) Icon = GetSystemIcon.ConvertImgToIcon(Resources.DBkey);
                    Text = GuiConfig.GetText("CommonChangePassword");
                }
            }
        }
开发者ID:magicdict,项目名称:MongoCola,代码行数:65,代码来源:frmUser.cs


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