示例#1
0
        private static async void PumpData()
        {
            Random rnd    = new Random();
            int    min    = 0;
            int    max    = 100;
            long   docCtr = 0;

            do
            {
                docCtr++;
                if (docCtr % 1000 == 1)
                {
                    Console.WriteLine(docCtr);
                }

                _iotid     = GetRandomlyRepeatedString(3);
                _temp      = rnd.Next(min, max);
                _timestamp = DateTime.UtcNow.Ticks;
                Random  r    = new Random(DateTime.Now.Millisecond);
                IoTData data = new IoTData
                {
                    iotid     = _iotid,
                    temp      = _temp,
                    lat       = r.Next(100),
                    longitude = r.Next(100),
                    carid     = GetRandomlyRepeatedString(3),
                    timestamp = _timestamp
                };

                await client.CreateDocumentAsync(collectionUri, data);

                Console.Write("*");
            } while (docCtr < MAX_DOCUMENTS);
        }
        private static async void PumpData()
        {
            Random rnd    = new Random();
            int    min    = 0;
            int    max    = 100;
            long   docCtr = 0;

            do
            {
                docCtr++;
                if (docCtr % 1000 == 1)
                {
                    Console.WriteLine(docCtr);
                }

                _iotid = GetRandomlyRepeatedString(3);

                _timestamp = DateTime.UtcNow.Ticks;
                Random  r      = new Random(DateTime.Now.Millisecond);
                string  _state = GetstateName(r);
                IoTData data   = new IoTData
                {
                    iotid     = _iotid,
                    state     = _state,
                    model     = GetModel(r),
                    engineoil = GetEngineOil(r),
                    color     = GetColor(r),
                    temp      = GetTemprature(_state, r),
                    lat       = r.Next(100),
                    longitude = r.Next(100),
                    carid     = GetRandomlyRepeatedString(3),
                    timestamp = _timestamp
                };

                await client.CreateDocumentAsync(collectionUri, data);

                Console.Write(".");
            } while (docCtr < MAX_DOCUMENTS);
        }