コード例 #1
0
        public static async Task Main(string[] args)
        {
            var          count   = 0;
            WriteConcern WCValue = new WriteConcern(1);

            client.WithWriteConcern(WCValue);
            string modeName          = "Mode 3 Cams";
            string jobName           = "CA20190305";
            string jobId             = "SANTANDER1000";
            List <BsonDocument> data = new List <BsonDocument>
            {
                new BsonDocument("OCR1", GetUniqueKey(15)),
                new BsonDocument("OCR2", GetUniqueKey(15)),
                new BsonDocument("OCR3", GetUniqueKey(15)),
                new BsonDocument("OCR4", GetUniqueKey(15))
            };

            //List<BsonDocument> data = new List<BsonDocument>(new List<BsonDocument>( ReadData));

            Console.WriteLine("Program Start");
            var docCount = MS3Collection.CountDocuments(new BsonDocument());


            MS3Collection.InsertOne(new MS3LiveData(modeName, jobName, jobId, data, docCount++, DateTime.Now));
            MS3Collection.Indexes.CreateOne(new BsonDocument("modeName", 1));
            MS3Collection.Indexes.CreateOne(new BsonDocument("jobName", 1));
            MS3Collection.Indexes.CreateOne(new BsonDocument("data", 1));


            for (int i = 0; i < 1000000; i++)
            {
                Stopwatch st1 = new Stopwatch();
                st1.Start();
                data = new List <BsonDocument>
                {
                    new BsonDocument("OCR1", GetUniqueKey(15)),
                    new BsonDocument("OCR2", GetUniqueKey(15)),
                    new BsonDocument("OCR3", GetUniqueKey(15)),
                    new BsonDocument("OCR4", GetUniqueKey(15))
                };
                MS3LiveData MS3Data = new MS3LiveData(modeName, jobName, jobId, data, docCount++, DateTime.Now);
                count++;
                await CreateOne(MS3Data);

                Console.WriteLine($"i:{i} elapsed: {st1.Elapsed.TotalMilliseconds}");
                st1.Stop();
            }



            // ReadAll();
        }
コード例 #2
0
        public static async Task <string> CreateOne(MS3LiveData mS3LiveDataCollection)
        {
            await MS3Collection.InsertOneAsync(mS3LiveDataCollection);

            return("inserted");
        }