示例#1
0
        public void Log141Adapter_DeleteFromStore_Can_Delete_Log_With_Data()
        {
            const int numOfRows = 10;

            // Add log
            AddParents();

            _devKit.InitHeader(_log, LogIndexType.measureddepth);
            _devKit.InitDataMany(_log, _devKit.Mnemonics(_log), _devKit.Units(_log), numOfRows);

            AddLog(_log);

            // Query log
            var result   = GetLog(_log);
            var logDatas = result.LogData;

            Assert.IsNotNull(logDatas);
            var logData = logDatas.FirstOrDefault();

            Assert.IsNotNull(logData);
            Assert.AreEqual(numOfRows, logData.Data.Count);

            // Delete log
            DeleteLog(_log, string.Empty);

            // Assert log is deleted
            var query   = _devKit.CreateLog(_log.Uid, null, _log.UidWell, null, _log.UidWellbore, null);
            var results = _devKit.Query <LogList, Log>(query, optionsIn: OptionsIn.ReturnElements.All);

            Assert.AreEqual(0, results.Count);

            var uri = _log.GetUri();

            // Assert Channel Data Chunk is deleted
            var chunks = GetDataChunks(uri);

            Assert.IsTrue(chunks.Count == 0);
        }
示例#2
0
        public void WITSMLWebServiceConnection_Can_Write_And_Query_All_Wells()
        {
            // Add Well
            _devKit.Proxy.Write(_devKit.New <WellList>(x => x.Well = _devKit.List(_well1)));
            _devKit.Proxy.Write(_devKit.New <WellList>(x => x.Well = _devKit.List(_well2)));

            // Get all Wells
            var query  = _devKit.Query <WellList>();
            var result = _devKit.Proxy.Read(query);

            Assert.IsNotNull(result.Well);
            Assert.IsNotNull(result.Well.SingleOrDefault(x => x.Name == _well1.Name));
            Assert.IsNotNull(result.Well.SingleOrDefault(x => x.Name == _well2.Name));
        }
        public void Log141Adapter_AddToStore_Can_Add_Data_Chunk_Exceeds_MongoDb_Document_Size()
        {
            var response = _devKit.Add <WellList, Well>(_well);

            // Adjust Points and Nodes for large file
            WitsmlSettings.LogMaxDataPointsAdd = 5000000;
            WitsmlSettings.LogMaxDataNodesAdd  = 15000;
            WitsmlSettings.LogMaxDataPointsGet = 5000000;
            WitsmlSettings.LogMaxDataNodesGet  = 15000;

            _wellbore.UidWell = response.SuppMsgOut;
            response          = _devKit.Add <WellboreList, Wellbore>(_wellbore);

            var xmlfile = Path.Combine(_testDataDir, string.Format(_exceedFileFormat, "log"));
            var xmlin   = File.ReadAllText(xmlfile);

            var logList = EnergisticsConverter.XmlToObject <LogList>(xmlin);

            Assert.IsNotNull(logList);

            var log = logList.Log.FirstOrDefault();

            Assert.IsNotNull(log);

            log.Uid          = null;
            log.UidWell      = _wellbore.UidWell;
            log.UidWellbore  = response.SuppMsgOut;
            log.NameWell     = _well.Name;
            log.NameWellbore = _wellbore.Name;

            var logDataAdded = log.LogData.FirstOrDefault();

            Assert.IsNotNull(logDataAdded);

            response = _devKit.Add <LogList, Log>(log);
            Assert.AreEqual((short)ErrorCodes.Success, response.Result);

            var uidLog = response.SuppMsgOut;

            log.Uid = uidLog;
            var uri = log.GetUri();

            // Query Channel Data Chunk
            var filter     = MongoDbUtility.BuildFilter <ChannelDataChunk>("Uri", uri.ToString());
            var database   = _provider.GetDatabase();
            var collection = database.GetCollection <ChannelDataChunk>("channelDataChunk");
            var chunks     = collection.Find(filter).ToList();

            Assert.IsTrue(chunks.Count > 0);

            // Query Mongo File
            var fileChunks = chunks.Where(c => string.IsNullOrEmpty(c.Data)).ToList();

            Assert.IsTrue(fileChunks.Count > 0);

            var bucket = new GridFSBucket(database, new GridFSBucketOptions
            {
                BucketName     = ChannelDataChunkAdapter.BucketName,
                ChunkSizeBytes = WitsmlSettings.ChunkSizeBytes
            });

            foreach (var fc in fileChunks)
            {
                Assert.IsNull(fc.Data);
                var mongoFileFilter = Builders <GridFSFileInfo> .Filter.Eq(fi => fi.Metadata[ChannelDataChunkAdapter.FileName], fc.Uid);

                var mongoFile = bucket.Find(mongoFileFilter).FirstOrDefault();
                Assert.IsNotNull(mongoFile);
            }

            // Query Log
            var query = new Log
            {
                Uid         = uidLog,
                UidWell     = log.UidWell,
                UidWellbore = log.UidWellbore
            };

            var results = _devKit.Query <LogList, Log>(query, optionsIn: OptionsIn.ReturnElements.All);

            Assert.AreEqual(1, results.Count);

            var result = results.First();

            Assert.IsNotNull(result);

            var logDataReturned = result.LogData.FirstOrDefault();

            Assert.IsNotNull(logDataReturned);

            Assert.AreEqual(logDataAdded.Data.Count, logDataReturned.Data.Count);
        }