From 3f243611fbab592dbfa6ee35962925377716abeb Mon Sep 17 00:00:00 2001 From: Petr Licman Date: Thu, 2 Nov 2023 09:48:03 +0100 Subject: [PATCH 1/6] Reenumeration fixes --- Src/Witsml/Extensions/ListExtensions.cs | 5 +++ Src/WitsmlExplorer.Api/Jobs/AnalyzeGapJob.cs | 2 +- .../Jobs/BatchModifyWellJob.cs | 2 +- .../Jobs/DeleteCurveValuesJob.cs | 4 +- .../Jobs/DeleteEmptyMnemonicsJob.cs | 4 +- .../Jobs/ImportLogDataJob.cs | 6 +-- Src/WitsmlExplorer.Api/Jobs/MissingDataJob.cs | 6 +-- Src/WitsmlExplorer.Api/Models/LogData.cs | 4 +- .../Models/MissingDataCheck.cs | 2 +- .../Models/Reports/BaseReport.cs | 5 +++ Src/WitsmlExplorer.Api/Query/ObjectQueries.cs | 27 ++++++------ .../Repositories/CosmosRepository.cs | 2 +- .../Repositories/IDocumentRepository.cs | 2 +- .../Repositories/MongoRepository.cs | 2 +- .../Services/BhaRunService.cs | 6 +-- .../Services/ChangeLogService.cs | 6 +-- .../Services/CredentialsService.cs | 7 ++-- .../Services/FluidsReportService.cs | 6 +-- .../Services/FormationMarkerService.cs | 6 +-- Src/WitsmlExplorer.Api/Services/JobCache.cs | 10 ++--- Src/WitsmlExplorer.Api/Services/JobService.cs | 4 +- .../Services/LogDataReader.cs | 2 +- .../Services/LogObjectService.cs | 41 ++++++++----------- .../Services/MessageObjectService.cs | 4 +- .../Services/MudLogService.cs | 6 +-- .../Services/ObjectService.cs | 26 ++++++------ Src/WitsmlExplorer.Api/Services/RigService.cs | 6 +-- .../Services/RiskService.cs | 6 +-- .../Services/TrajectoryService.cs | 6 +-- .../Services/TubularService.cs | 36 ++++++++-------- .../Services/WbGeometryService.cs | 10 ++--- .../Workers/CheckLogHeaderWorker.cs | 20 ++++++++- .../Workers/Copy/CopyLogDataWorker.cs | 4 +- .../Workers/Copy/CopyLogWorker.cs | 4 +- .../Workers/Copy/CopyObjectsWorker.cs | 2 +- .../Workers/Delete/DeleteCurveValuesWorker.cs | 7 ++-- .../Delete/DeleteEmptyMnemonicsWorker.cs | 10 +---- .../Workers/Delete/DeleteObjectsWorker.cs | 12 +++--- .../appsettings.Development.json | 4 ++ .../Workers/BatchModifyWellWorkerTests.cs | 4 +- .../CopyLogDataWorkerDuplicateTests.cs | 3 +- .../Workers/DeleteEmptyMnemonicsWorkerTest.cs | 8 ++-- .../Workers/ImportLogDataWorkerTests.cs | 5 ++- 43 files changed, 181 insertions(+), 163 deletions(-) diff --git a/Src/Witsml/Extensions/ListExtensions.cs b/Src/Witsml/Extensions/ListExtensions.cs index 8f05af771..3ab733688 100644 --- a/Src/Witsml/Extensions/ListExtensions.cs +++ b/Src/Witsml/Extensions/ListExtensions.cs @@ -8,5 +8,10 @@ public static List AsSingletonList(this T item) { return new List { item }; } + + public static ICollection AsCollection(this IList list) + { + return list; + } } } diff --git a/Src/WitsmlExplorer.Api/Jobs/AnalyzeGapJob.cs b/Src/WitsmlExplorer.Api/Jobs/AnalyzeGapJob.cs index 85f434a12..29835858f 100644 --- a/Src/WitsmlExplorer.Api/Jobs/AnalyzeGapJob.cs +++ b/Src/WitsmlExplorer.Api/Jobs/AnalyzeGapJob.cs @@ -17,7 +17,7 @@ public record AnalyzeGapJob : Job /// /// Array of mnemonics names /// - public IEnumerable Mnemonics { get; init; } + public ICollection Mnemonics { get; init; } /// /// Size of the GAP for depth diff --git a/Src/WitsmlExplorer.Api/Jobs/BatchModifyWellJob.cs b/Src/WitsmlExplorer.Api/Jobs/BatchModifyWellJob.cs index 0a7fde4e6..449e17cb2 100644 --- a/Src/WitsmlExplorer.Api/Jobs/BatchModifyWellJob.cs +++ b/Src/WitsmlExplorer.Api/Jobs/BatchModifyWellJob.cs @@ -7,7 +7,7 @@ namespace WitsmlExplorer.Api.Jobs { public record BatchModifyWellJob : Job { - public IEnumerable Wells { get; init; } + public ICollection Wells { get; init; } public override string Description() { diff --git a/Src/WitsmlExplorer.Api/Jobs/DeleteCurveValuesJob.cs b/Src/WitsmlExplorer.Api/Jobs/DeleteCurveValuesJob.cs index 552439778..afc133e08 100644 --- a/Src/WitsmlExplorer.Api/Jobs/DeleteCurveValuesJob.cs +++ b/Src/WitsmlExplorer.Api/Jobs/DeleteCurveValuesJob.cs @@ -7,8 +7,8 @@ namespace WitsmlExplorer.Api.Jobs public record DeleteCurveValuesJob : Job { public ObjectReference LogReference { get; init; } - public IEnumerable Mnemonics { get; init; } - public IEnumerable IndexRanges { get; init; } + public ICollection Mnemonics { get; init; } + public ICollection IndexRanges { get; init; } public override string Description() { diff --git a/Src/WitsmlExplorer.Api/Jobs/DeleteEmptyMnemonicsJob.cs b/Src/WitsmlExplorer.Api/Jobs/DeleteEmptyMnemonicsJob.cs index d900f3b23..e7d04f8db 100644 --- a/Src/WitsmlExplorer.Api/Jobs/DeleteEmptyMnemonicsJob.cs +++ b/Src/WitsmlExplorer.Api/Jobs/DeleteEmptyMnemonicsJob.cs @@ -14,8 +14,8 @@ namespace WitsmlExplorer.Api.Jobs public record DeleteEmptyMnemonicsJob : Job { - public IEnumerable Wells { get; init; } - public IEnumerable Wellbores { get; init; } + public ICollection Wells { get; init; } + public ICollection Wellbores { get; init; } public double NullDepthValue { get; init; } public DateTime NullTimeValue { get; init; } diff --git a/Src/WitsmlExplorer.Api/Jobs/ImportLogDataJob.cs b/Src/WitsmlExplorer.Api/Jobs/ImportLogDataJob.cs index 50ef392ad..5899caf84 100644 --- a/Src/WitsmlExplorer.Api/Jobs/ImportLogDataJob.cs +++ b/Src/WitsmlExplorer.Api/Jobs/ImportLogDataJob.cs @@ -7,9 +7,9 @@ namespace WitsmlExplorer.Api.Jobs public record ImportLogDataJob : Job { public ObjectReference TargetLog { get; init; } - public IEnumerable Mnemonics { get; init; } - public IEnumerable Units { get; init; } - public IEnumerable> DataRows { get; init; } + public ICollection Mnemonics { get; init; } + public ICollection Units { get; init; } + public ICollection> DataRows { get; init; } public override string Description() { diff --git a/Src/WitsmlExplorer.Api/Jobs/MissingDataJob.cs b/Src/WitsmlExplorer.Api/Jobs/MissingDataJob.cs index 06933aafd..d4ad3d1a6 100644 --- a/Src/WitsmlExplorer.Api/Jobs/MissingDataJob.cs +++ b/Src/WitsmlExplorer.Api/Jobs/MissingDataJob.cs @@ -10,9 +10,9 @@ namespace WitsmlExplorer.Api.Jobs { public record MissingDataJob : Job { - public IEnumerable WellReferences { get; init; } - public IEnumerable WellboreReferences { get; init; } - public IEnumerable MissingDataChecks { get; init; } + public ICollection WellReferences { get; init; } + public ICollection WellboreReferences { get; init; } + public ICollection MissingDataChecks { get; init; } public override string Description() { diff --git a/Src/WitsmlExplorer.Api/Models/LogData.cs b/Src/WitsmlExplorer.Api/Models/LogData.cs index 5173f3d23..2c1e9641a 100644 --- a/Src/WitsmlExplorer.Api/Models/LogData.cs +++ b/Src/WitsmlExplorer.Api/Models/LogData.cs @@ -10,8 +10,8 @@ public class LogData public string StartIndex { get; init; } public string EndIndex { get; init; } public string Direction { get; set; } - public IEnumerable CurveSpecifications { get; init; } - public IEnumerable> Data { get; init; } + public ICollection CurveSpecifications { get; init; } + public ICollection> Data { get; init; } } public class CurveSpecification diff --git a/Src/WitsmlExplorer.Api/Models/MissingDataCheck.cs b/Src/WitsmlExplorer.Api/Models/MissingDataCheck.cs index 2de2e0ee6..6900301ff 100644 --- a/Src/WitsmlExplorer.Api/Models/MissingDataCheck.cs +++ b/Src/WitsmlExplorer.Api/Models/MissingDataCheck.cs @@ -5,6 +5,6 @@ namespace WitsmlExplorer.Api.Models public class MissingDataCheck { public EntityType ObjectType { get; set; } - public IEnumerable Properties { get; set; } + public ICollection Properties { get; set; } } } diff --git a/Src/WitsmlExplorer.Api/Models/Reports/BaseReport.cs b/Src/WitsmlExplorer.Api/Models/Reports/BaseReport.cs index 7e41d984c..700ea6cc2 100644 --- a/Src/WitsmlExplorer.Api/Models/Reports/BaseReport.cs +++ b/Src/WitsmlExplorer.Api/Models/Reports/BaseReport.cs @@ -2,6 +2,11 @@ namespace WitsmlExplorer.Api.Models.Reports { + public class BaseReport : BaseReport + { + public ICollection ReportItems { get; init; } + } + public class BaseReport { public string Title { get; set; } diff --git a/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs b/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs index fd8c44541..4fbd1b04f 100644 --- a/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs @@ -15,12 +15,12 @@ namespace WitsmlExplorer.Api.Query { public static class ObjectQueries { - public static IEnumerable DeleteObjectsQuery(ObjectReferences toDelete) + public static IList DeleteObjectsQuery(ObjectReferences toDelete) { return IdsToObjects(toDelete.WellUid, toDelete.WellboreUid, toDelete.ObjectUids, toDelete.ObjectType); } - public static IEnumerable IdsToObjects(string wellUid, string wellboreUid, string[] objectUids, EntityType type) + public static IList IdsToObjects(string wellUid, string wellboreUid, string[] objectUids, EntityType type) { return objectUids.Select((uid) => { @@ -29,20 +29,19 @@ public static IEnumerable IdsToObjects(string wellUid, s o.UidWellbore = wellboreUid; o.UidWell = wellUid; return o; - } - ); + }).ToList(); } - public static IEnumerable CopyObjectsQuery(IEnumerable objects, WitsmlWellbore targetWellbore) where T : WitsmlObjectOnWellbore + public static IList CopyObjectsQuery(IEnumerable objects, WitsmlWellbore targetWellbore) where T : WitsmlObjectOnWellbore { - return objects.Select((o) => + return objects.Select(o => { o.UidWell = targetWellbore.UidWell; o.NameWell = targetWellbore.NameWell; o.UidWellbore = targetWellbore.Uid; o.NameWellbore = targetWellbore.Name; return o; - }); + }).ToList(); } public static IWitsmlObjectList GetWitsmlObjectsByType(EntityType type) @@ -53,16 +52,18 @@ public static IWitsmlObjectList GetWitsmlObjectsByType(EntityType type) public static IWitsmlObjectList GetWitsmlObjectsWithParamByType(EntityType type, string objectProperty, string objectPropertyValue) { WitsmlObjectOnWellbore o = EntityTypeHelper.ToObjectOnWellbore(type); - o.UidWell = ""; - o.UidWellbore = ""; - o.Uid = ""; - o.NameWell = ""; - o.NameWellbore = ""; - o.Name = ""; + o.UidWell = string.Empty; + o.UidWellbore = string.Empty; + o.Uid = string.Empty; + o.NameWell = string.Empty; + o.NameWellbore = string.Empty; + o.Name = string.Empty; if (objectProperty != null) { o = QueryHelper.AddPropertyToObject(o, objectProperty, objectPropertyValue); }; + + // TODO: REMOVE CASTING! return (IWitsmlObjectList)o.AsSingletonWitsmlList(); } diff --git a/Src/WitsmlExplorer.Api/Repositories/CosmosRepository.cs b/Src/WitsmlExplorer.Api/Repositories/CosmosRepository.cs index 33a6c259a..da494c0d8 100644 --- a/Src/WitsmlExplorer.Api/Repositories/CosmosRepository.cs +++ b/Src/WitsmlExplorer.Api/Repositories/CosmosRepository.cs @@ -37,7 +37,7 @@ public async Task GetDocumentAsync(TDocumentId id) return await container.ReadItemAsync(id.ToString(), new PartitionKey(id.ToString())); } - public async Task> GetDocumentsAsync() + public async Task> GetDocumentsAsync() { var container = _cosmosClient.GetContainer(_dbName, _containerId); var queryDefinition = new QueryDefinition("select * from T"); diff --git a/Src/WitsmlExplorer.Api/Repositories/IDocumentRepository.cs b/Src/WitsmlExplorer.Api/Repositories/IDocumentRepository.cs index 95d45ac96..53fc8bf9f 100644 --- a/Src/WitsmlExplorer.Api/Repositories/IDocumentRepository.cs +++ b/Src/WitsmlExplorer.Api/Repositories/IDocumentRepository.cs @@ -7,7 +7,7 @@ namespace WitsmlExplorer.Api.Repositories public interface IDocumentRepository { Task GetDocumentAsync(TDocumentId id); - Task> GetDocumentsAsync(); + Task> GetDocumentsAsync(); Task CreateDocumentAsync(TDocument document); Task UpdateDocumentAsync(TDocumentId id, TDocument document); Task DeleteDocumentAsync(TDocumentId id); diff --git a/Src/WitsmlExplorer.Api/Repositories/MongoRepository.cs b/Src/WitsmlExplorer.Api/Repositories/MongoRepository.cs index 5026ab70f..16c67cea3 100644 --- a/Src/WitsmlExplorer.Api/Repositories/MongoRepository.cs +++ b/Src/WitsmlExplorer.Api/Repositories/MongoRepository.cs @@ -34,7 +34,7 @@ public async Task GetDocumentAsync(TDocumentId id) return documents.First(); } - public async Task> GetDocumentsAsync() + public async Task> GetDocumentsAsync() { var documents = await _collection.FindAsync(new BsonDocument()); return documents.ToList(); diff --git a/Src/WitsmlExplorer.Api/Services/BhaRunService.cs b/Src/WitsmlExplorer.Api/Services/BhaRunService.cs index 903e11959..85660ac8a 100644 --- a/Src/WitsmlExplorer.Api/Services/BhaRunService.cs +++ b/Src/WitsmlExplorer.Api/Services/BhaRunService.cs @@ -14,7 +14,7 @@ namespace WitsmlExplorer.Api.Services public interface IBhaRunService { Task GetBhaRun(string wellUid, string wellboreUid, string bhaRunUid); - Task> GetBhaRuns(string wellUid, string wellboreUid); + Task> GetBhaRuns(string wellUid, string wellboreUid); } public class BhaRunService : WitsmlService, IBhaRunService @@ -27,12 +27,12 @@ public async Task GetBhaRun(string wellUid, string wellboreUid, string b WitsmlBhaRuns result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.All)); return result.BhaRuns.Any() ? WitsmlToBhaRun(result.BhaRuns.First()) : null; } - public async Task> GetBhaRuns(string wellUid, string wellboreUid) + public async Task> GetBhaRuns(string wellUid, string wellboreUid) { WitsmlBhaRuns witsmlBhaRun = BhaRunQueries.GetWitsmlBhaRun(wellUid, wellboreUid); WitsmlBhaRuns result = await _witsmlClient.GetFromStoreAsync(witsmlBhaRun, new OptionsIn(ReturnElements.Requested)); return result.BhaRuns.Select(WitsmlToBhaRun - ).OrderBy(bhaRun => bhaRun.Name); + ).OrderBy(bhaRun => bhaRun.Name).ToList(); } private static BhaRun WitsmlToBhaRun(WitsmlBhaRun bhaRun) diff --git a/Src/WitsmlExplorer.Api/Services/ChangeLogService.cs b/Src/WitsmlExplorer.Api/Services/ChangeLogService.cs index a8c4aefc9..bcc462a24 100644 --- a/Src/WitsmlExplorer.Api/Services/ChangeLogService.cs +++ b/Src/WitsmlExplorer.Api/Services/ChangeLogService.cs @@ -11,14 +11,14 @@ namespace WitsmlExplorer.Api.Services { public interface IChangeLogService { - Task> GetChangeLogs(string wellUid, string wellboreUid); + Task> GetChangeLogs(string wellUid, string wellboreUid); } public class ChangeLogService : WitsmlService, IChangeLogService { public ChangeLogService(IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider) { } - public async Task> GetChangeLogs(string wellUid, string wellboreUid) + public async Task> GetChangeLogs(string wellUid, string wellboreUid) { WitsmlChangeLogs witsmlChangeLog = new WitsmlChangeLog() { @@ -35,7 +35,7 @@ public async Task> GetChangeLogs(string wellUid, string w } }.AsSingletonWitsmlList(); WitsmlChangeLogs result = await _witsmlClient.GetFromStoreAsync(witsmlChangeLog, new OptionsIn(ReturnElements.Requested)); - return result.ChangeLogs.Select(WitsmlToChangeLog); + return result.ChangeLogs.Select(WitsmlToChangeLog).ToList(); } private static ChangeLog WitsmlToChangeLog(WitsmlChangeLog changeLog) diff --git a/Src/WitsmlExplorer.Api/Services/CredentialsService.cs b/Src/WitsmlExplorer.Api/Services/CredentialsService.cs index fa0ea0c16..ebdbebe5b 100644 --- a/Src/WitsmlExplorer.Api/Services/CredentialsService.cs +++ b/Src/WitsmlExplorer.Api/Services/CredentialsService.cs @@ -34,7 +34,7 @@ public class CredentialsService : ICredentialsService private readonly IWitsmlSystemCredentials _witsmlServerCredentials; private readonly IDocumentRepository _witsmlServerRepository; private readonly ICredentialsCache _credentialsCache; - private readonly Task> _allServers; + private readonly Task> _allServers; private static readonly string SUBJECT = "sub"; private readonly bool _useOAuth2; @@ -86,11 +86,10 @@ public async Task VerifyAndCacheCredentials(IEssentialHeaders eh, bool kee private async Task UserHasRoleForHost(string[] roles, Uri host) { bool result = true; - IEnumerable allServers = await _allServers; + ICollection allServers = await _allServers; bool systemCredsExists = _witsmlServerCredentials.WitsmlCreds.Any(n => n.Host.EqualsIgnoreCase(host)); - IEnumerable hostServer = allServers.Where(n => n.Url.EqualsIgnoreCase(host)); - bool validRole = hostServer.Any(n => + bool validRole = allServers.Where(n => n.Url.EqualsIgnoreCase(host)).Any(n => n.Roles != null && n.Roles.Intersect(roles).Any() ); result &= systemCredsExists & validRole; diff --git a/Src/WitsmlExplorer.Api/Services/FluidsReportService.cs b/Src/WitsmlExplorer.Api/Services/FluidsReportService.cs index 818b940d8..ce602b79f 100644 --- a/Src/WitsmlExplorer.Api/Services/FluidsReportService.cs +++ b/Src/WitsmlExplorer.Api/Services/FluidsReportService.cs @@ -13,7 +13,7 @@ namespace WitsmlExplorer.Api.Services { public interface IFluidsReportService { - Task> GetFluidsReports(string wellUid, string wellboreUid); + Task> GetFluidsReports(string wellUid, string wellboreUid); Task GetFluidsReport(string wellUid, string wellboreUid, string fluidsReportUid); } @@ -21,11 +21,11 @@ public class FluidsReportService : WitsmlService, IFluidsReportService { public FluidsReportService(IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider) { } - public async Task> GetFluidsReports(string wellUid, string wellboreUid) + public async Task> GetFluidsReports(string wellUid, string wellboreUid) { WitsmlFluidsReports query = FluidsReportQueries.QueryByWellbore(wellUid, wellboreUid); WitsmlFluidsReports result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.Requested)); - return result.FluidsReports.Select(WitsmlToFluidsReport); + return result.FluidsReports.Select(WitsmlToFluidsReport).ToList(); } public async Task GetFluidsReport(string wellUid, string wellboreUid, string fluidsReportUid) diff --git a/Src/WitsmlExplorer.Api/Services/FormationMarkerService.cs b/Src/WitsmlExplorer.Api/Services/FormationMarkerService.cs index d1891a98a..05e8d0ce9 100644 --- a/Src/WitsmlExplorer.Api/Services/FormationMarkerService.cs +++ b/Src/WitsmlExplorer.Api/Services/FormationMarkerService.cs @@ -14,7 +14,7 @@ namespace WitsmlExplorer.Api.Services public interface IFormationMarkerService { Task GetFormationMarker(string wellUid, string wellboreUid, string formationMarkerUid); - Task> GetFormationMarkers(string wellUid, string wellboreUid); + Task> GetFormationMarkers(string wellUid, string wellboreUid); } public class FormationMarkerService : WitsmlService, IFormationMarkerService @@ -27,11 +27,11 @@ public async Task GetFormationMarker(string wellUid, string wel WitsmlFormationMarkers result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.All)); return result.FormationMarkers.Any() ? WitsmlToFormationMarker(result.FormationMarkers.First()) : null; } - public async Task> GetFormationMarkers(string wellUid, string wellboreUid) + public async Task> GetFormationMarkers(string wellUid, string wellboreUid) { WitsmlFormationMarkers query = (WitsmlFormationMarkers)ObjectQueries.GetWitsmlObjectById(wellUid, wellboreUid, "", EntityType.FormationMarker); WitsmlFormationMarkers result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.All)); - return result.FormationMarkers.Select(WitsmlToFormationMarker); + return result.FormationMarkers.Select(WitsmlToFormationMarker).ToList(); } private static FormationMarker WitsmlToFormationMarker(WitsmlFormationMarker formationMarker) diff --git a/Src/WitsmlExplorer.Api/Services/JobCache.cs b/Src/WitsmlExplorer.Api/Services/JobCache.cs index 69862b538..1586c412e 100644 --- a/Src/WitsmlExplorer.Api/Services/JobCache.cs +++ b/Src/WitsmlExplorer.Api/Services/JobCache.cs @@ -13,9 +13,9 @@ namespace WitsmlExplorer.Api.Services public interface IJobCache { void CacheJob(JobInfo jobInfo); - IEnumerable GetJobInfosByUser(string username); + ICollection GetJobInfosByUser(string username); JobInfo GetJobInfoById(string jobId); - IEnumerable GetAllJobInfos(); + ICollection GetAllJobInfos(); } public class JobCache : IJobCache @@ -47,9 +47,9 @@ public void CacheJob(JobInfo jobInfo) } } - public IEnumerable GetJobInfosByUser(string username) + public ICollection GetJobInfosByUser(string username) { - return _jobs.Values.Where(job => job.Username == username); + return _jobs.Values.Where(job => job.Username == username).ToList(); } public JobInfo GetJobInfoById(string jobId) @@ -57,7 +57,7 @@ public JobInfo GetJobInfoById(string jobId) return _jobs[jobId]; } - public IEnumerable GetAllJobInfos() + public ICollection GetAllJobInfos() { return _jobs.Values; } diff --git a/Src/WitsmlExplorer.Api/Services/JobService.cs b/Src/WitsmlExplorer.Api/Services/JobService.cs index bc851badf..39addabc1 100644 --- a/Src/WitsmlExplorer.Api/Services/JobService.cs +++ b/Src/WitsmlExplorer.Api/Services/JobService.cs @@ -20,9 +20,9 @@ public class JobService : IJobService { private readonly IJobCache _jobCache; private readonly IJobQueue _jobQueue; - private readonly IEnumerable _workers; + private readonly ICollection _workers; - public JobService(IJobQueue jobQueue, IEnumerable workers, IJobCache jobCache) + public JobService(IJobQueue jobQueue, ICollection workers, IJobCache jobCache) { _jobQueue = jobQueue; _workers = workers; diff --git a/Src/WitsmlExplorer.Api/Services/LogDataReader.cs b/Src/WitsmlExplorer.Api/Services/LogDataReader.cs index c11f610e0..6c7447d08 100644 --- a/Src/WitsmlExplorer.Api/Services/LogDataReader.cs +++ b/Src/WitsmlExplorer.Api/Services/LogDataReader.cs @@ -27,7 +27,7 @@ public class LogDataReader : IAsyncDisposable private readonly string _uidWellbore; private readonly string _uidLog; private readonly string _indexType; - private readonly IEnumerable _mnemonics; + private readonly ICollection _mnemonics; private readonly ILogger _logger; private Index _startIndex; private readonly Index _endIndex; diff --git a/Src/WitsmlExplorer.Api/Services/LogObjectService.cs b/Src/WitsmlExplorer.Api/Services/LogObjectService.cs index 35ea9aa8e..da030585a 100644 --- a/Src/WitsmlExplorer.Api/Services/LogObjectService.cs +++ b/Src/WitsmlExplorer.Api/Services/LogObjectService.cs @@ -3,6 +3,8 @@ using System.Net; using System.Threading.Tasks; +using Microsoft.IdentityModel.Tokens; + using Witsml.Data; using Witsml.Extensions; using Witsml.ServiceReference; @@ -18,10 +20,10 @@ namespace WitsmlExplorer.Api.Services { public interface ILogObjectService { - Task> GetLogs(string wellUid, string wellboreUid); + Task> GetLogs(string wellUid, string wellboreUid); Task GetLog(string wellUid, string wellboreUid, string logUid); Task GetLog(string wellUid, string wellboreUid, string logUid, OptionsIn queryOptions); - Task> GetLogCurveInfo(string wellUid, string wellboreUid, string logUid); + Task> GetLogCurveInfo(string wellUid, string wellboreUid, string logUid); Task ReadLogData(string wellUid, string wellboreUid, string logUid, List mnemonics, bool startIndexIsInclusive, string start, string end); } @@ -30,7 +32,7 @@ public class LogObjectService : WitsmlService, ILogObjectService { public LogObjectService(IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider) { } - public async Task> GetLogs(string wellUid, string wellboreUid) + public async Task> GetLogs(string wellUid, string wellboreUid) { WitsmlLogs witsmlLog = LogQueries.GetWitsmlLogsByWellbore(wellUid, wellboreUid); WitsmlLogs result = await _witsmlClient.GetFromStoreAsync(witsmlLog, new OptionsIn(ReturnElements.HeaderOnly)); @@ -58,7 +60,7 @@ public async Task> GetLogs(string wellUid, string wellbor DTimCreation = log.CommonData.DTimCreation, DTimLastChange = log.CommonData.DTimLastChange, } - }).OrderBy(log => log.Name); + }).OrderBy(log => log.Name).ToList(); } public async Task GetLog(string wellUid, string wellboreUid, string logUid) @@ -113,7 +115,7 @@ private async Task GetLogHeader(string wellUid, string wellboreUid, s return result.Logs.FirstOrDefault(); } - public async Task> GetLogCurveInfo(string wellUid, string wellboreUid, string logUid) + public async Task> GetLogCurveInfo(string wellUid, string wellboreUid, string logUid) { WitsmlLog witsmlLog = await GetLogHeader(wellUid, wellboreUid, logUid); @@ -137,7 +139,7 @@ public async Task> GetLogCurveInfo(string wellUid, str Count = a.Count, DoubleValues = a.DoubleValues }).ToList(), - }); + }).ToList(); } public async Task ReadLogData(string wellUid, string wellboreUid, string logUid, List mnemonics, bool startIndexIsInclusive, string start, string end) @@ -160,13 +162,14 @@ public async Task ReadLogData(string wellUid, string wellboreUid, strin WitsmlLogs query = LogQueries.GetLogContent(wellUid, wellboreUid, logUid, log.IndexType, mnemonics, startIndex, endIndex); WitsmlLogs witsmlLogs = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.All)); - if (!witsmlLogs.Logs.Any() || witsmlLogs.Logs.First().LogData == null || !witsmlLogs.Logs.First().LogData.Data.Any()) + + WitsmlLog witsmlLog = witsmlLogs.Logs?.FirstOrDefault(); + + if (witsmlLog?.LogData == null || witsmlLog.LogData.Data.IsNullOrEmpty()) { return new LogData(); } - WitsmlLog witsmlLog = witsmlLogs.Logs.First(); - if (!startIndexIsInclusive) { witsmlLog.LogData.Data.RemoveAt(0); @@ -184,32 +187,24 @@ public async Task ReadLogData(string wellUid, string wellboreUid, strin StartIndex = Index.Start(witsmlLog).GetValueAsString(), EndIndex = Index.End(witsmlLog).GetValueAsString(), CurveSpecifications = witsmlLogMnemonics.Zip(witsmlLogUnits, (mnemonic, unit) => - new CurveSpecification { Mnemonic = mnemonic, Unit = unit }), + new CurveSpecification { Mnemonic = mnemonic, Unit = unit }).ToList(), Data = GetDataDictionary(witsmlLog.LogData) }; } - private static IEnumerable> GetDataDictionary(WitsmlLogData logData) + private static ICollection> GetDataDictionary(WitsmlLogData logData) { List> result = new(); string[] mnemonics = logData.MnemonicList.Split(","); foreach (string valueRow in logData.Data.Select(d => d.Data)) { - Dictionary data = new(); - var keyValuePairs = valueRow.Split(",").Select((value, index) => new { index, value }); - if (keyValuePairs.Count() > mnemonics.Length) + var keyValuePairs = valueRow.Split(",").Select((value, index) => new { index, value }).ToList(); + if (keyValuePairs.Count > mnemonics.Length) { - throw new WitsmlResultParsingException($"Unable to parse log data due to unexpected amount of commas in row {result.Count + 1}. Expected {mnemonics.Length} got {keyValuePairs.Count()}.", (int)HttpStatusCode.InternalServerError); + throw new WitsmlResultParsingException($"Unable to parse log data due to unexpected amount of commas in row {result.Count + 1}. Expected {mnemonics.Length} got {keyValuePairs.Count}.", (int)HttpStatusCode.InternalServerError); } - foreach (var keyValuePair in keyValuePairs) - { - if (string.IsNullOrEmpty(keyValuePair.value)) - { - continue; - } - data.Add(mnemonics[keyValuePair.index], new LogDataValue(keyValuePair.value)); - } + var data = keyValuePairs.Where(keyValuePair => !string.IsNullOrEmpty(keyValuePair.value)).ToDictionary(keyValuePair => mnemonics[keyValuePair.index], keyValuePair => new LogDataValue(keyValuePair.value)); result.Add(data); } diff --git a/Src/WitsmlExplorer.Api/Services/MessageObjectService.cs b/Src/WitsmlExplorer.Api/Services/MessageObjectService.cs index 7ec16d28c..5d31203ed 100644 --- a/Src/WitsmlExplorer.Api/Services/MessageObjectService.cs +++ b/Src/WitsmlExplorer.Api/Services/MessageObjectService.cs @@ -14,7 +14,7 @@ namespace WitsmlExplorer.Api.Services public interface IMessageObjectService { Task GetMessageObject(string wellUid, string wellboreUid, string msgUid); - Task> GetMessageObjects(string wellUid, string wellboreUid); + Task> GetMessageObjects(string wellUid, string wellboreUid); } public class MessageObjectService : WitsmlService, IMessageObjectService @@ -31,7 +31,7 @@ public async Task GetMessageObject(string wellUid, string wellbor return messageObject == null ? null : FromWitsml(messageObject); } - public async Task> GetMessageObjects(string wellUid, string wellboreUid) + public async Task> GetMessageObjects(string wellUid, string wellboreUid) { return await MeasurementHelper.MeasureExecutionTimeAsync(async (timeMeasurer) => { diff --git a/Src/WitsmlExplorer.Api/Services/MudLogService.cs b/Src/WitsmlExplorer.Api/Services/MudLogService.cs index 682d3907e..9d8d22076 100644 --- a/Src/WitsmlExplorer.Api/Services/MudLogService.cs +++ b/Src/WitsmlExplorer.Api/Services/MudLogService.cs @@ -13,7 +13,7 @@ namespace WitsmlExplorer.Api.Services { public interface IMudLogService { - Task> GetMudLogs(string wellUid, string wellboreUid); + Task> GetMudLogs(string wellUid, string wellboreUid); Task GetMudLog(string wellUid, string wellboreUid, string mudlogUid); } // ReSharper disable once UnusedMember.Global @@ -21,12 +21,12 @@ public class MudLogService : WitsmlService, IMudLogService { public MudLogService(IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider) { } - public async Task> GetMudLogs(string wellUid, string wellboreUid) + public async Task> GetMudLogs(string wellUid, string wellboreUid) { WitsmlMudLogs query = MudLogQueries.QueryByWellbore(wellUid, wellboreUid); WitsmlMudLogs result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.HeaderOnly)); - return result.MudLogs.Select(FromWitsml).OrderBy(mudLog => mudLog.Name); + return result.MudLogs.Select(FromWitsml).OrderBy(mudLog => mudLog.Name).ToList(); } public async Task GetMudLog(string wellUid, string wellboreUid, string mudlogUid) diff --git a/Src/WitsmlExplorer.Api/Services/ObjectService.cs b/Src/WitsmlExplorer.Api/Services/ObjectService.cs index 19e258a51..87338e47b 100644 --- a/Src/WitsmlExplorer.Api/Services/ObjectService.cs +++ b/Src/WitsmlExplorer.Api/Services/ObjectService.cs @@ -18,10 +18,10 @@ namespace WitsmlExplorer.Api.Services { public interface IObjectService { - Task> GetObjectsWithParamByType(EntityType objectType, string objectProperty, string objectPropertyValue); - Task> GetObjectsByType(EntityType objectType); - Task> GetObjectsIdOnly(string wellUid, string wellboreUid, EntityType objectType); - Task> GetObjectIdOnly(string wellUid, string wellboreUid, string objectUid, EntityType objectType); + Task> GetObjectsWithParamByType(EntityType objectType, string objectProperty, string objectPropertyValue); + Task> GetObjectsByType(EntityType objectType); + Task> GetObjectsIdOnly(string wellUid, string wellboreUid, EntityType objectType); + Task> GetObjectIdOnly(string wellUid, string wellboreUid, string objectUid, EntityType objectType); Task> GetExpandableObjectsCount(string wellUid, string wellboreUid); } @@ -35,15 +35,15 @@ public ObjectService(IWitsmlClientProvider witsmlClientProvider, ILogger> GetObjectsByType(EntityType objectType) + public async Task> GetObjectsByType(EntityType objectType) { if (EntityTypeHelper.ToObjectOnWellbore(objectType) == null) { throw new ArgumentException($"{nameof(objectType)} must be a valid type of an object on wellbore"); } - IWitsmlObjectList query = ObjectQueries.GetWitsmlObjectsByType(objectType); - IWitsmlObjectList result = await _witsmlClient.GetFromStoreNullableAsync(query, new OptionsIn(ReturnElements.Requested)); + var query = ObjectQueries.GetWitsmlObjectsByType(objectType); + var result = await _witsmlClient.GetFromStoreNullableAsync(query, new OptionsIn(ReturnElements.Requested)); if (result?.Objects == null) { return new List(); @@ -59,10 +59,10 @@ public async Task> GetObjectsByType(EntityType o WellboreName = obj.NameWellbore, WellName = obj.NameWell } - ); + ).ToList(); } - public async Task> GetObjectsWithParamByType(EntityType objectType, string objectProperty, string objectPropertyValue) + public async Task> GetObjectsWithParamByType(EntityType objectType, string objectProperty, string objectPropertyValue) { if (EntityTypeHelper.ToObjectOnWellbore(objectType) == null) { @@ -115,15 +115,15 @@ public async Task> GetObjectsWithParamByType(Ent } return searchResult; - }); + }).ToList(); } - public async Task> GetObjectsIdOnly(string wellUid, string wellboreUid, EntityType objectType) + public async Task> GetObjectsIdOnly(string wellUid, string wellboreUid, EntityType objectType) { return await GetObjectIdOnly(wellUid, wellboreUid, "", objectType); } - public async Task> GetObjectIdOnly(string wellUid, string wellboreUid, string objectUid, EntityType objectType) + public async Task> GetObjectIdOnly(string wellUid, string wellboreUid, string objectUid, EntityType objectType) { if (EntityTypeHelper.ToObjectOnWellbore(objectType) == null) { @@ -146,7 +146,7 @@ public async Task> GetObjectIdOnly(string wellUid, WellboreName = obj.NameWellbore, WellName = obj.NameWell } - ); + ).ToList(); } public async Task> GetExpandableObjectsCount(string wellUid, string wellboreUid) diff --git a/Src/WitsmlExplorer.Api/Services/RigService.cs b/Src/WitsmlExplorer.Api/Services/RigService.cs index fed112c88..09b792e71 100644 --- a/Src/WitsmlExplorer.Api/Services/RigService.cs +++ b/Src/WitsmlExplorer.Api/Services/RigService.cs @@ -13,7 +13,7 @@ namespace WitsmlExplorer.Api.Services { public interface IRigService { - Task> GetRigs(string wellUid, string wellboreUid); + Task> GetRigs(string wellUid, string wellboreUid); Task GetRig(string wellUid, string wellboreUid, string rigUid); } @@ -21,11 +21,11 @@ public class RigService : WitsmlService, IRigService { public RigService(IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider) { } - public async Task> GetRigs(string wellUid, string wellboreUid) + public async Task> GetRigs(string wellUid, string wellboreUid) { WitsmlRigs witsmlRigs = RigQueries.GetWitsmlRig(wellUid, wellboreUid); WitsmlRigs result = await _witsmlClient.GetFromStoreAsync(witsmlRigs, new OptionsIn(ReturnElements.Requested)); - return result.Rigs.Select(WitsmlRigToRig).OrderBy(rig => rig.Name); + return result.Rigs.Select(WitsmlRigToRig).OrderBy(rig => rig.Name).ToList(); } public async Task GetRig(string wellUid, string wellboreUid, string rigUid) diff --git a/Src/WitsmlExplorer.Api/Services/RiskService.cs b/Src/WitsmlExplorer.Api/Services/RiskService.cs index 4d7d428ef..47cedaa26 100644 --- a/Src/WitsmlExplorer.Api/Services/RiskService.cs +++ b/Src/WitsmlExplorer.Api/Services/RiskService.cs @@ -13,14 +13,14 @@ namespace WitsmlExplorer.Api.Services { public interface IRiskService { - Task> GetRisks(string wellUid, string wellboreUid); + Task> GetRisks(string wellUid, string wellboreUid); } public class RiskService : WitsmlService, IRiskService { public RiskService(IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider) { } - public async Task> GetRisks(string wellUid, string wellboreUid) + public async Task> GetRisks(string wellUid, string wellboreUid) { WitsmlRisks query = RiskQueries.GetWitsmlRiskByWellbore(wellUid, wellboreUid); WitsmlRisks result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.Requested)); @@ -55,7 +55,7 @@ public async Task> GetRisks(string wellUid, string wellboreUid DTimLastChange = risk.CommonData.DTimLastChange, DTimCreation = risk.CommonData.DTimCreation, } - }).OrderBy(risk => risk.Name); + }).OrderBy(risk => risk.Name).ToList(); } } } diff --git a/Src/WitsmlExplorer.Api/Services/TrajectoryService.cs b/Src/WitsmlExplorer.Api/Services/TrajectoryService.cs index a487d8520..e87d826b5 100644 --- a/Src/WitsmlExplorer.Api/Services/TrajectoryService.cs +++ b/Src/WitsmlExplorer.Api/Services/TrajectoryService.cs @@ -13,7 +13,7 @@ namespace WitsmlExplorer.Api.Services { public interface ITrajectoryService { - Task> GetTrajectories(string wellUid, string wellboreUid); + Task> GetTrajectories(string wellUid, string wellboreUid); Task GetTrajectory(string wellUid, string wellboreUid, string trajectoryUid); Task> GetTrajectoryStations(string wellUid, string wellboreUid, string trajectoryUid); } @@ -25,12 +25,12 @@ public TrajectoryService(IWitsmlClientProvider witsmlClientProvider) : base(wits { } - public async Task> GetTrajectories(string wellUid, string wellboreUid) + public async Task> GetTrajectories(string wellUid, string wellboreUid) { WitsmlTrajectories witsmlTrajectory = TrajectoryQueries.GetWitsmlTrajectoryByWellbore(wellUid, wellboreUid); WitsmlTrajectories result = await _witsmlClient.GetFromStoreAsync(witsmlTrajectory, new OptionsIn(ReturnElements.Requested)); return result.Trajectories.Select(WitsmlToTrajectory - ).OrderBy(trajectory => trajectory.Name); + ).OrderBy(trajectory => trajectory.Name).ToList(); } public async Task GetTrajectory(string wellUid, string wellboreUid, string trajectoryUid) diff --git a/Src/WitsmlExplorer.Api/Services/TubularService.cs b/Src/WitsmlExplorer.Api/Services/TubularService.cs index 3a282a88e..4c6acc036 100644 --- a/Src/WitsmlExplorer.Api/Services/TubularService.cs +++ b/Src/WitsmlExplorer.Api/Services/TubularService.cs @@ -14,9 +14,9 @@ namespace WitsmlExplorer.Api.Services { public interface ITubularService { - Task> GetTubulars(string wellUid, string wellboreUid); + Task> GetTubulars(string wellUid, string wellboreUid); Task GetTubular(string wellUid, string wellboreUid, string tubularUid); - Task> GetTubularComponents(string wellUid, string wellboreUid, string tubularUid); + Task> GetTubularComponents(string wellUid, string wellboreUid, string tubularUid); } public class TubularService : WitsmlService, ITubularService @@ -25,12 +25,12 @@ public TubularService(IWitsmlClientProvider witsmlClientProvider) : base(witsmlC { } - public async Task> GetTubulars(string wellUid, string wellboreUid) + public async Task> GetTubulars(string wellUid, string wellboreUid) { WitsmlTubulars witsmlTubular = TubularQueries.GetWitsmlTubular(wellUid, wellboreUid); WitsmlTubulars result = await _witsmlClient.GetFromStoreAsync(witsmlTubular, new OptionsIn(ReturnElements.Requested)); - return result.Tubulars.Select(WitsmlToTubular).OrderBy(tubular => tubular.Name); + return result.Tubulars.Select(WitsmlToTubular).OrderBy(tubular => tubular.Name).ToList(); } public async Task GetTubular(string wellUid, string wellboreUid, string tubularUid) @@ -38,31 +38,29 @@ public async Task GetTubular(string wellUid, string wellboreUid, string WitsmlTubulars witsmlTubular = TubularQueries.GetWitsmlTubular(wellUid, wellboreUid, tubularUid); WitsmlTubulars result = await _witsmlClient.GetFromStoreAsync(witsmlTubular, new OptionsIn(ReturnElements.Requested)); - return result.Tubulars.Any() ? WitsmlToTubular(result.Tubulars.First()) : null; + return WitsmlToTubular(result.Tubulars.FirstOrDefault()); } - public async Task> GetTubularComponents(string wellUid, string wellboreUid, string tubularUid) + public async Task> GetTubularComponents(string wellUid, string wellboreUid, string tubularUid) { WitsmlTubulars tubularToQuery = TubularQueries.GetWitsmlTubular(wellUid, wellboreUid, tubularUid); WitsmlTubulars result = await _witsmlClient.GetFromStoreAsync(tubularToQuery, new OptionsIn(ReturnElements.All)); WitsmlTubular witsmlTubular = result.Tubulars.FirstOrDefault(); - return witsmlTubular == null - ? null - : (IEnumerable)witsmlTubular.TubularComponents?.Select(tComponent => new TubularComponent - { - Uid = tComponent.Uid, - Sequence = tComponent.Sequence, - Id = tComponent.Id == null ? null : new LengthMeasure { Uom = tComponent.Id.Uom, Value = decimal.Parse(tComponent.Id.Value, CultureInfo.InvariantCulture) }, - Od = tComponent.Od == null ? null : new LengthMeasure { Uom = tComponent.Od.Uom, Value = decimal.Parse(tComponent.Od.Value, CultureInfo.InvariantCulture) }, - Len = tComponent.Len == null ? null : new LengthMeasure { Uom = tComponent.Len.Uom, Value = decimal.Parse(tComponent.Len.Value, CultureInfo.InvariantCulture) }, - TypeTubularComponent = tComponent.TypeTubularComp, - }) - .OrderBy(tComponent => tComponent.Sequence); + return witsmlTubular?.TubularComponents?.Select(tComponent => new TubularComponent + { + Uid = tComponent.Uid, + Sequence = tComponent.Sequence, + Id = tComponent.Id == null ? null : new LengthMeasure { Uom = tComponent.Id.Uom, Value = decimal.Parse(tComponent.Id.Value, CultureInfo.InvariantCulture) }, + Od = tComponent.Od == null ? null : new LengthMeasure { Uom = tComponent.Od.Uom, Value = decimal.Parse(tComponent.Od.Value, CultureInfo.InvariantCulture) }, + Len = tComponent.Len == null ? null : new LengthMeasure { Uom = tComponent.Len.Uom, Value = decimal.Parse(tComponent.Len.Value, CultureInfo.InvariantCulture) }, + TypeTubularComponent = tComponent.TypeTubularComp, + }) + .OrderBy(tComponent => tComponent.Sequence).ToList(); } private static Tubular WitsmlToTubular(WitsmlTubular tubular) { - return new Tubular + return tubular == null ? null : new Tubular { Uid = tubular.Uid, WellUid = tubular.UidWell, diff --git a/Src/WitsmlExplorer.Api/Services/WbGeometryService.cs b/Src/WitsmlExplorer.Api/Services/WbGeometryService.cs index d55f49010..455c12374 100644 --- a/Src/WitsmlExplorer.Api/Services/WbGeometryService.cs +++ b/Src/WitsmlExplorer.Api/Services/WbGeometryService.cs @@ -13,7 +13,7 @@ namespace WitsmlExplorer.Api.Services { public interface IWbGeometryService { - Task> GetWbGeometrys(string wellUid, string wellboreUid); + Task> GetWbGeometrys(string wellUid, string wellboreUid); Task GetWbGeometry(string wellUid, string wellboreUid, string wbGeometryUid); Task> GetWbGeometrySections(string wellUid, string wellboreUid, string wbGeometryUid); } @@ -28,20 +28,20 @@ public async Task GetWbGeometry(string wellUid, string wellboreUid, WitsmlWbGeometrys query = WbGeometryQueries.GetWitsmlWbGeometryById(wellUid, wellboreUid, wbGeometryUid); WitsmlWbGeometrys result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.Requested)); - return result.WbGeometrys.Any() ? FromWitsml(result.WbGeometrys.First()) : null; + return FromWitsml(result.WbGeometrys.FirstOrDefault()); } - public async Task> GetWbGeometrys(string wellUid, string wellboreUid) + public async Task> GetWbGeometrys(string wellUid, string wellboreUid) { WitsmlWbGeometrys query = WbGeometryQueries.GetWitsmlWbGeometryByWellbore(wellUid, wellboreUid); WitsmlWbGeometrys result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.Requested)); - return result.WbGeometrys.Select(FromWitsml).OrderBy(wbGeometry => wbGeometry.DTimReport); + return result.WbGeometrys.Select(FromWitsml).OrderBy(wbGeometry => wbGeometry.DTimReport).ToList(); } private static WbGeometry FromWitsml(WitsmlWbGeometry wbGeometry) { - return new WbGeometry + return wbGeometry == null ? null : new WbGeometry { WellUid = wbGeometry.UidWell, Uid = wbGeometry.Uid, diff --git a/Src/WitsmlExplorer.Api/Workers/CheckLogHeaderWorker.cs b/Src/WitsmlExplorer.Api/Workers/CheckLogHeaderWorker.cs index 55d1f97b0..9b2f42a53 100644 --- a/Src/WitsmlExplorer.Api/Workers/CheckLogHeaderWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/CheckLogHeaderWorker.cs @@ -102,7 +102,7 @@ public CheckLogHeaderWorker(ILogger logger, IWitsmlClientProv { return null; } - IEnumerable> endResultLogData = dataEndResultLog.LogData.Data?.Select(data => data.Data.Split(",")); + var endResultLogData = dataEndResultLog.LogData.Data?.Select(data => data.Data.Split(",")).ToList(); string[] startResultLogData = dataStartResultLog.LogData.Data?.FirstOrDefault()?.Data.Split(","); if (startResultLogData.IsNullOrEmpty() || endResultLogData.IsNullOrEmpty()) { @@ -206,7 +206,23 @@ private static CheckLogHeaderReport GetReport(List mis }; } - private static IEnumerable ExtractColumnIndexes(IEnumerable> data, int indexColumn = 0) + private static List ExtractColumnIndexes(List data, int indexColumn = 0) + { + List result = Enumerable.Repeat(string.Empty, data.First().Length).ToList(); + foreach (var row in data) + { + for (int col = 0; col < row.Length; col++) + { + if (!string.IsNullOrEmpty(row[col])) + { + result[col] = row[indexColumn]; + } + } + } + return result; + } + + private static IEnumerable ExtractColumnIndexes2(IEnumerable> data, int indexColumn = 0) { List result = Enumerable.Repeat(string.Empty, data.First().Count()).ToList(); List> list = data.ToList(); diff --git a/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs b/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs index c89b0f5d2..7024f0c0a 100644 --- a/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs @@ -40,7 +40,7 @@ public CopyLogDataWorker(IWitsmlClientProvider witsmlClientProvider, ILogger servers = _witsmlServerRepository == null ? new List() : await _witsmlServerRepository.GetDocumentsAsync(); + ICollection servers = _witsmlServerRepository == null ? new List() : await _witsmlServerRepository.GetDocumentsAsync(); int targetDepthLogDecimals = servers.FirstOrDefault((server) => server.Url.EqualsIgnoreCase(targetHostname))?.DepthLogDecimals ?? 0; int sourceDepthLogDecimals = servers.FirstOrDefault((server) => server.Url.EqualsIgnoreCase(sourceHostname))?.DepthLogDecimals ?? 0; @@ -49,7 +49,7 @@ public CopyLogDataWorker(IWitsmlClientProvider witsmlClientProvider, ILogger lci.Mnemonic).ToList(); - IEnumerable targetLogMnemonics = targetLog.LogCurveInfo.Select(lci => lci.Mnemonic); + ICollection targetLogMnemonics = targetLog.LogCurveInfo.Select(lci => lci.Mnemonic).ToList(); List existingMnemonicsInTarget = mnemonicsToCopy.Where(mnemonic => targetLogMnemonics.Contains(mnemonic, StringComparer.OrdinalIgnoreCase)).ToList(); List newMnemonicsInTarget = mnemonicsToCopy.Where(mnemonic => !targetLogMnemonics.Contains(mnemonic, StringComparer.OrdinalIgnoreCase)).ToList(); diff --git a/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogWorker.cs b/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogWorker.cs index ff163a7e0..f449841c3 100644 --- a/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogWorker.cs @@ -37,11 +37,11 @@ public CopyLogWorker(ILogger logger, IWitsmlClientProvider witsm public override async Task<(WorkerResult, RefreshAction)> Execute(CopyObjectsJob job) { (WitsmlLog[] sourceLogs, WitsmlWellbore targetWellbore) = await FetchSourceLogsAndTargetWellbore(job); - IEnumerable copyLogsQuery = ObjectQueries.CopyObjectsQuery(sourceLogs, targetWellbore); + ICollection copyLogsQuery = ObjectQueries.CopyObjectsQuery(sourceLogs, targetWellbore); List> copyLogTasks = copyLogsQuery.Select(logToCopy => GetTargetWitsmlClientOrThrow().AddToStoreAsync(logToCopy.AsSingletonWitsmlList())).ToList(); Task copyLogTasksResult = Task.WhenAll(copyLogTasks); - IEnumerable results = await copyLogTasksResult; + ICollection results = await copyLogTasksResult; string errorMessage = "Failed to copy log."; if (copyLogTasksResult.Status == TaskStatus.Faulted) diff --git a/Src/WitsmlExplorer.Api/Workers/Copy/CopyObjectsWorker.cs b/Src/WitsmlExplorer.Api/Workers/Copy/CopyObjectsWorker.cs index 3e43c5d13..43c7b843f 100644 --- a/Src/WitsmlExplorer.Api/Workers/Copy/CopyObjectsWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Copy/CopyObjectsWorker.cs @@ -59,7 +59,7 @@ public CopyObjectsWorker(ILogger logger, IWitsmlClientProvider w return (new WorkerResult(targetClient.GetServerHostname(), false, "Could not find any objects to copy"), null); } - IEnumerable queries = ObjectQueries.CopyObjectsQuery(objectsToCopy.Objects, targetWellbore); + ICollection queries = ObjectQueries.CopyObjectsQuery(objectsToCopy.Objects, targetWellbore); RefreshObjects refreshAction = new(targetClient.GetServerHostname(), job.Target.WellUid, job.Target.WellboreUid, job.Source.ObjectType); return await _copyUtils.CopyObjectsOnWellbore(targetClient, queries, refreshAction, job.Source.WellUid, job.Source.WellboreUid); } diff --git a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteCurveValuesWorker.cs b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteCurveValuesWorker.cs index dcdf06db9..d81b06e5a 100644 --- a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteCurveValuesWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteCurveValuesWorker.cs @@ -73,13 +73,12 @@ private async Task GetLogHeader(string wellUid, string wellboreUid, s return result.Logs.FirstOrDefault(); } - private static IEnumerable CreateDeleteQueries(DeleteCurveValuesJob job, WitsmlLog witsmlLog, List logCurveInfos) + private static ICollection CreateDeleteQueries(DeleteCurveValuesJob job, WitsmlLog witsmlLog, List logCurveInfos) { - IEnumerable<(Index, Index)> indexRanges = job.IndexRanges.ToList().Select(range => (Index.Start(witsmlLog, range.StartIndex), Index.End(witsmlLog, range.EndIndex))); - return indexRanges + return job.IndexRanges.ToList().Select(range => (Index.Start(witsmlLog, range.StartIndex), Index.End(witsmlLog, range.EndIndex))) .Where(range => range.Item1 >= Index.Start(witsmlLog) && range.Item2 <= Index.End(witsmlLog)) .Select(range => LogQueries.DeleteLogCurveContent(job.LogReference.WellUid, job.LogReference.WellboreUid, job.LogReference.Uid, witsmlLog.IndexType, - logCurveInfos, range.Item1, range.Item2)); + logCurveInfos, range.Item1, range.Item2)).ToList(); } } } diff --git a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteEmptyMnemonicsWorker.cs b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteEmptyMnemonicsWorker.cs index 96465ce1f..0fc4e08c7 100644 --- a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteEmptyMnemonicsWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteEmptyMnemonicsWorker.cs @@ -223,15 +223,7 @@ private async Task> ExtractWellboreRefs(IEnumerab if (!wellbores.IsNullOrEmpty()) { - wellboreRefs = wellboreRefs.Concat(wellbores.Select(wb => - new WellboreReference - { - WellboreUid = wb.Uid, - WellboreName = wb.Name, - WellUid = wb.WellUid, - WellName = wb.WellName - })) - .ToList(); + wellboreRefs.AddRange(wellbores.Select(wb => new WellboreReference { WellboreUid = wb.Uid, WellboreName = wb.Name, WellUid = wb.WellUid, WellName = wb.WellName })); } } } diff --git a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs index 228512759..fd33ed874 100644 --- a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs @@ -30,7 +30,7 @@ public DeleteObjectsWorker(ILogger logger, IWitsmlClientProvid public override async Task<(WorkerResult, RefreshAction)> Execute(DeleteObjectsJob job) { job.ToDelete.Verify(); - IEnumerable queries = ObjectQueries.DeleteObjectsQuery(job.ToDelete); + ICollection queries = ObjectQueries.DeleteObjectsQuery(job.ToDelete); RefreshObjects refreshAction = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), job.ToDelete.WellUid, job.ToDelete.WellboreUid, job.ToDelete.ObjectType); return await DeleteObjectsOnWellbore(queries, refreshAction); } @@ -38,8 +38,10 @@ public DeleteObjectsWorker(ILogger logger, IWitsmlClientProvid private async Task<(WorkerResult, RefreshAction)> DeleteObjectsOnWellbore(IEnumerable queries, RefreshAction refreshAction) { IWitsmlClient witsmlClient = GetTargetWitsmlClientOrThrow(); - string uidWell = queries.FirstOrDefault()?.UidWell; - string uidWellbore = queries.FirstOrDefault()?.UidWellbore; + var witsmlObjectOnWellbore = queries.FirstOrDefault(); + + string uidWell = witsmlObjectOnWellbore?.UidWell; + string uidWellbore = witsmlObjectOnWellbore?.UidWellbore; bool error = false; List successUids = new(); @@ -79,10 +81,10 @@ await Task.WhenAll(queries.Select(async (query) => } }).ToList()); - string successString = successUids.Count > 0 ? $"Deleted {queries.FirstOrDefault()?.GetType().Name}s: {string.Join(", ", successUids)}." : ""; + string successString = successUids.Count > 0 ? $"Deleted {witsmlObjectOnWellbore?.GetType().Name}s: {string.Join(", ", successUids)}." : ""; return !error ? (new WorkerResult(witsmlClient.GetServerHostname(), true, successString), refreshAction) - : (new WorkerResult(witsmlClient.GetServerHostname(), false, $"{successString} Failed to delete some {queries.FirstOrDefault()?.GetType().Name}s", errorReason, null), successUids.Count > 0 ? refreshAction : null); + : (new WorkerResult(witsmlClient.GetServerHostname(), false, $"{successString} Failed to delete some {witsmlObjectOnWellbore?.GetType().Name}s", errorReason, null), successUids.Count > 0 ? refreshAction : null); } } } diff --git a/Src/WitsmlExplorer.Api/appsettings.Development.json b/Src/WitsmlExplorer.Api/appsettings.Development.json index 584a0e456..b5da516cb 100644 --- a/Src/WitsmlExplorer.Api/appsettings.Development.json +++ b/Src/WitsmlExplorer.Api/appsettings.Development.json @@ -1,4 +1,8 @@ { +"MongoDb": { + "Name": "witsml-explorer-db", + "ConnectionString": "mongodb://localhost" + }, "Serilog": { "Using": ["Serilog.Expressions"], "MinimumLevel": { diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/BatchModifyWellWorkerTests.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/BatchModifyWellWorkerTests.cs index ce546258e..7036b8e44 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/BatchModifyWellWorkerTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/BatchModifyWellWorkerTests.cs @@ -71,14 +71,14 @@ public async Task RenameWells() private static BatchModifyWellJob CreateJobTemplate(IEnumerable wellUids) { - IEnumerable wells = CreateWells(wellUids); + var wells = CreateWells(wellUids); return new BatchModifyWellJob { Wells = wells }; } - private static IEnumerable CreateWells(IEnumerable wellUids) + private static ICollection CreateWells(IEnumerable wellUids) { return wellUids.Select(wellId => new Well { Uid = wellId, Name = wellId + "Name" }).ToArray(); } diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/CopyLogDataWorkerDuplicateTests.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/CopyLogDataWorkerDuplicateTests.cs index dcd877d9f..afe1ece23 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/CopyLogDataWorkerDuplicateTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/CopyLogDataWorkerDuplicateTests.cs @@ -9,6 +9,7 @@ using Witsml; using Witsml.Data; +using Witsml.Extensions; using WitsmlExplorer.Api.Jobs; using WitsmlExplorer.Api.Models; @@ -49,7 +50,7 @@ public CopyLogDataWorkerDuplicateTests() Url = _sourceUri, DepthLogDecimals = 2 } - }); + }.AsCollection()); Mock> logger = new(); _worker = new CopyLogDataWorker(witsmlClientProvider.Object, logger.Object, _documentRepository.Object); } diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/DeleteEmptyMnemonicsWorkerTest.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/DeleteEmptyMnemonicsWorkerTest.cs index 6f98f4617..69f30d88b 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/DeleteEmptyMnemonicsWorkerTest.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/DeleteEmptyMnemonicsWorkerTest.cs @@ -146,7 +146,7 @@ private void SetupDateTimeLogObject() { _logObjectService .Setup(los => los.GetLogs(It.IsAny(), It.IsAny())) - .Returns(Task.Run(() => new List { new LogObject() { Uid = "123", IndexType = WitsmlLog.WITSML_INDEX_TYPE_DATE_TIME } }.AsEnumerable())); + .Returns(Task.Run(() => new List { new LogObject() { Uid = "123", IndexType = WitsmlLog.WITSML_INDEX_TYPE_DATE_TIME } }.AsCollection())); var lcis = new List(); @@ -173,14 +173,14 @@ private void SetupDateTimeLogObject() _logObjectService .Setup(los => los.GetLogCurveInfo(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(Task.Run(() => lcis.AsEnumerable())); + .Returns(Task.Run(() => lcis.AsCollection())); } private void SetupDepthLogObject() { _logObjectService .Setup(los => los.GetLogs(It.IsAny(), It.IsAny())) - .Returns(Task.Run(() => new List { new LogObject() { Uid = "123", IndexType = WitsmlLog.WITSML_INDEX_TYPE_MD } }.AsEnumerable())); + .Returns(Task.Run(() => new List { new LogObject() { Uid = "123", IndexType = WitsmlLog.WITSML_INDEX_TYPE_MD } }.AsCollection())); var lcis = new List(); @@ -207,7 +207,7 @@ private void SetupDepthLogObject() _logObjectService .Setup(los => los.GetLogCurveInfo(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(Task.Run(() => lcis.AsEnumerable())); + .Returns(Task.Run(() => lcis.AsCollection())); } private DeleteEmptyMnemonicsJob CreateJob(double nullDepthValue, DateTime nullTimeValue) diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/ImportLogDataWorkerTests.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/ImportLogDataWorkerTests.cs index 1cb878f2c..8779394c2 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/ImportLogDataWorkerTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/ImportLogDataWorkerTests.cs @@ -10,6 +10,7 @@ using Witsml; using Witsml.Data; +using Witsml.Extensions; using Witsml.ServiceReference; using WitsmlExplorer.Api.Jobs; @@ -144,7 +145,7 @@ private static ImportLogDataJob CreateDepthJobTemplate() { List mnemonics = new() { "Depth", "mnemo1", "mnemo2" }; List units = new() { "m", "unitless", "unitless" }; - List> dataRows = new() + ICollection> dataRows = new List> { new List { "1", "something", "something2" }, new List { "2", "something", "something2" }, @@ -168,7 +169,7 @@ private static ImportLogDataJob CreateTimeJobTemplate() { List mnemonics = new() { "Time", "mnemo1", "mnemo2" }; List units = new() { "date time", "unitless", "unitless" }; - List> dataRows = new() + ICollection> dataRows = new List> { new List { "2018-01-21T12:24:30.000Z", "something", "something2" }, new List { "2019-01-21T12:24:30.000Z", "something", "something2" }, From bea95afdf92db867c7a9bef6ddedf3fd3bebfbfe Mon Sep 17 00:00:00 2001 From: Petr Licman Date: Tue, 7 Nov 2023 09:53:02 +0100 Subject: [PATCH 2/6] LinQreenumeration fixes --- .../Configuration/ICredentials.cs | 2 +- .../Configuration/ServerCredentials.cs | 13 +++---------- .../Configuration/WitsmlSystemCredentials.cs | 8 ++++---- Src/WitsmlExplorer.Api/HttpHandlers/JobHandler.cs | 2 +- Src/WitsmlExplorer.Api/Query/ObjectQueries.cs | 1 + .../Services/CredentialsService.cs | 10 +++++----- .../Services/WitsmlClientProvider.cs | 4 ++-- .../Extensions/HttpRequestExtensionsTests.cs | 6 +++--- .../Workers/CopyLogDataWorkerTests.cs | 14 ++++++++++++++ 9 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Src/WitsmlExplorer.Api/Configuration/ICredentials.cs b/Src/WitsmlExplorer.Api/Configuration/ICredentials.cs index c06621998..58cb20692 100644 --- a/Src/WitsmlExplorer.Api/Configuration/ICredentials.cs +++ b/Src/WitsmlExplorer.Api/Configuration/ICredentials.cs @@ -4,6 +4,6 @@ public interface ICredentials { internal string UserId { get; } internal string Password { get; } - + public bool IsNullOrEmpty(); } } diff --git a/Src/WitsmlExplorer.Api/Configuration/ServerCredentials.cs b/Src/WitsmlExplorer.Api/Configuration/ServerCredentials.cs index d0c1bc0c2..81633fae9 100644 --- a/Src/WitsmlExplorer.Api/Configuration/ServerCredentials.cs +++ b/Src/WitsmlExplorer.Api/Configuration/ServerCredentials.cs @@ -4,15 +4,13 @@ namespace WitsmlExplorer.Api.Configuration { - public class ServerCredentials : ICredentials, IEquatable + public class ServerCredentials : BasicCredentials, ICredentials, IEquatable { public ServerCredentials() { } - public ServerCredentials(string host, string userid, string password) + public ServerCredentials(string host, string userid, string password) : base(userid, password) { Host = new Uri(host); - UserId = userid; - Password = password; } public ServerCredentials(string host, ICredentials creds) { @@ -21,12 +19,7 @@ public ServerCredentials(string host, ICredentials creds) Password = creds.Password; } public Uri Host { get; init; } - public string UserId { get; init; } - public string Password { get; init; } - public bool IsCredsNullOrEmpty() - { - return string.IsNullOrEmpty(UserId) || string.IsNullOrEmpty(Password); - } + public bool Equals(ServerCredentials other) { return (Host.EqualsIgnoreCase(other.Host)) && diff --git a/Src/WitsmlExplorer.Api/Configuration/WitsmlSystemCredentials.cs b/Src/WitsmlExplorer.Api/Configuration/WitsmlSystemCredentials.cs index 457e44030..3441496c9 100644 --- a/Src/WitsmlExplorer.Api/Configuration/WitsmlSystemCredentials.cs +++ b/Src/WitsmlExplorer.Api/Configuration/WitsmlSystemCredentials.cs @@ -8,7 +8,7 @@ namespace WitsmlExplorer.Api.Configuration { public interface IWitsmlSystemCredentials { - public ServerCredentials[] WitsmlCreds { get; set; } + public IReadOnlyCollection WitsmlCreds { get; set; } } /// @@ -30,7 +30,7 @@ public interface IWitsmlSystemCredentials /// public class WitsmlSystemCredentials : IWitsmlSystemCredentials, IDisposable { - public ServerCredentials[] WitsmlCreds { get; set; } + public IReadOnlyCollection WitsmlCreds { get; set; } private IDisposable _unregister; public WitsmlSystemCredentials(IConfiguration configuration) @@ -48,13 +48,13 @@ private void Bind(IConfiguration configuration) { ServerCredentials cred = new(); rule.Bind(cred); - if (!cred.IsCredsNullOrEmpty() && cred.Host != null) + if (!cred.IsNullOrEmpty() && cred.Host != null) { credsList.Add(cred); } } - WitsmlCreds = credsList.ToArray(); + WitsmlCreds = credsList; _unregister?.Dispose(); _unregister = configuration.GetReloadToken().RegisterChangeCallback((_) => Bind(configuration), null); } diff --git a/Src/WitsmlExplorer.Api/HttpHandlers/JobHandler.cs b/Src/WitsmlExplorer.Api/HttpHandlers/JobHandler.cs index 0ca518a7e..c60b02e8d 100644 --- a/Src/WitsmlExplorer.Api/HttpHandlers/JobHandler.cs +++ b/Src/WitsmlExplorer.Api/HttpHandlers/JobHandler.cs @@ -75,7 +75,7 @@ private static bool IsAdminOrDeveloper(string token) { JwtSecurityTokenHandler handler = new(); JwtSecurityToken jwt = handler.ReadJwtToken(token); - IEnumerable userRoles = jwt.Claims.Where(n => n.Type == "roles").Select(n => n.Value); + IEnumerable userRoles = jwt.Claims.Where(n => n.Type == "roles").Select(n => n.Value).ToList(); return userRoles.Contains(AuthorizationPolicyRoles.ADMIN) || userRoles.Contains(AuthorizationPolicyRoles.DEVELOPER); } diff --git a/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs b/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs index 4fbd1b04f..0929af3c8 100644 --- a/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs @@ -145,6 +145,7 @@ public static IEnumerable GetComponentUids(WitsmlObjectOnWellbore object /// The type of components copy. /// Reference of the target object that will be used to initialize the query. /// A list of uids that will be used to filter the components. + /// public static WitsmlObjectOnWellbore CopyComponents(WitsmlObjectOnWellbore source, ComponentType componentType, ObjectReference reference, string[] uidsToCopy) { WitsmlObjectOnWellbore target = EntityTypeHelper.FromObjectReference(componentType.ToParentType(), reference); diff --git a/Src/WitsmlExplorer.Api/Services/CredentialsService.cs b/Src/WitsmlExplorer.Api/Services/CredentialsService.cs index ebdbebe5b..51f7ef196 100644 --- a/Src/WitsmlExplorer.Api/Services/CredentialsService.cs +++ b/Src/WitsmlExplorer.Api/Services/CredentialsService.cs @@ -60,7 +60,7 @@ public CredentialsService( public async Task VerifyAndCacheCredentials(IEssentialHeaders eh, bool keep, HttpContext httpContext) { ServerCredentials creds = HttpRequestExtensions.ParseServerHttpHeader(eh.WitsmlAuth, Decrypt); - if (creds.IsCredsNullOrEmpty()) + if (creds.IsNullOrEmpty()) { return false; } @@ -140,7 +140,7 @@ private async Task GetSystemCredentialsByToken(string token, if (await UserHasRoleForHost(userRoles, server)) { result = _witsmlServerCredentials.WitsmlCreds.Single(n => n.Host.EqualsIgnoreCase(server)); - if (!result.IsCredsNullOrEmpty()) + if (!result.IsNullOrEmpty()) { CacheCredentials(GetClaimFromToken(token, SUBJECT), result, 1.0); } @@ -160,7 +160,7 @@ public void VerifyUserIsLoggedIn(IEssentialHeaders eh, ServerType serverType) string server = serverType == ServerType.Target ? eh.TargetServer : eh.SourceServer; string username = serverType == ServerType.Target ? eh.TargetUsername : eh.SourceUsername; ServerCredentials creds = GetCredentials(eh, server, username); - if (creds == null || creds.IsCredsNullOrEmpty()) + if (creds == null || creds.IsNullOrEmpty()) { string serverTypeName = serverType == ServerType.Target ? "target" : "source"; throw new WitsmlClientProviderException($"Missing {serverTypeName} server credentials", (int)HttpStatusCode.Unauthorized, serverType); @@ -174,7 +174,7 @@ public async Task GetLoggedInUsernames(IEssentialHeaders eh, Uri serve if (_useOAuth2) { ServerCredentials systemCredentials = await GetSystemCredentialsByToken(eh.GetBearerToken(), serverUrl); - if (!systemCredentials.IsCredsNullOrEmpty() && !usernames.Contains(systemCredentials.UserId)) + if (!systemCredentials.IsNullOrEmpty() && !usernames.Contains(systemCredentials.UserId)) { usernames.Add(systemCredentials.UserId); } @@ -206,7 +206,7 @@ public ServerCredentials GetCredentials(IEssentialHeaders eh, string server, str if (creds == null && _useOAuth2) { creds = GetSystemCredentialsByToken(eh.GetBearerToken(), new Uri(server)).Result; - if (creds.IsCredsNullOrEmpty() || !string.Equals(creds.UserId, username, StringComparison.Ordinal)) + if (creds.IsNullOrEmpty() || !string.Equals(creds.UserId, username, StringComparison.Ordinal)) { return null; } diff --git a/Src/WitsmlExplorer.Api/Services/WitsmlClientProvider.cs b/Src/WitsmlExplorer.Api/Services/WitsmlClientProvider.cs index 07d4c2a55..c4d35671b 100644 --- a/Src/WitsmlExplorer.Api/Services/WitsmlClientProvider.cs +++ b/Src/WitsmlExplorer.Api/Services/WitsmlClientProvider.cs @@ -72,7 +72,7 @@ public IWitsmlClient GetClient() if (_witsmlClient == null) { _targetCreds = _credentialsService.GetCredentials(_httpHeaders, _httpHeaders.TargetServer, _httpHeaders.TargetUsername); - _witsmlClient = (_targetCreds != null && !_targetCreds.IsCredsNullOrEmpty()) + _witsmlClient = (_targetCreds != null && !_targetCreds.IsNullOrEmpty()) ? new WitsmlClient(options => { options.Hostname = _targetCreds.Host.ToString(); @@ -91,7 +91,7 @@ public IWitsmlClient GetSourceClient() if (_witsmlSourceClient == null) { _sourceCreds = _credentialsService.GetCredentials(_httpHeaders, _httpHeaders.SourceServer, _httpHeaders.SourceUsername); - _witsmlSourceClient = (_sourceCreds != null && !_sourceCreds.IsCredsNullOrEmpty()) + _witsmlSourceClient = (_sourceCreds != null && !_sourceCreds.IsNullOrEmpty()) ? new WitsmlClient(options => { options.Hostname = _sourceCreds.Host.ToString(); diff --git a/Tests/WitsmlExplorer.Api.Tests/Extensions/HttpRequestExtensionsTests.cs b/Tests/WitsmlExplorer.Api.Tests/Extensions/HttpRequestExtensionsTests.cs index 6a1a6c278..0ad46839d 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Extensions/HttpRequestExtensionsTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Extensions/HttpRequestExtensionsTests.cs @@ -73,7 +73,7 @@ public void GetWitsmlServerHttpHeader_EmptyInput_NoExceptionReturnNull() // "Decrypt" function is not under test ServerCredentials testResult = mockRequest.Object.GetWitsmlServerHttpHeader(headerName, n => ""); - Assert.True(testResult.IsCredsNullOrEmpty() && testResult.Host == null); + Assert.True(testResult.IsNullOrEmpty() && testResult.Host == null); } [Fact] @@ -91,7 +91,7 @@ public void ParseServerHttpHeader_BasicNoCreds_ReturnEmpty() string basicHeader = "http://some.url.com"; ServerCredentials creds = HttpRequestExtensions.ParseServerHttpHeader(basicHeader, n => n); - Assert.True(creds.IsCredsNullOrEmpty()); + Assert.True(creds.IsNullOrEmpty()); } [Fact] @@ -100,7 +100,7 @@ public void ParseServerHttpHeader_BasicNoHeader_ReturnEmpty() string basicHeader = null; ServerCredentials creds = HttpRequestExtensions.ParseServerHttpHeader(basicHeader, n => n); - Assert.True(creds.IsCredsNullOrEmpty()); + Assert.True(creds.IsNullOrEmpty()); } private static string CreateBasicHeaderValue(string username, string dummypassword, string host) diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/CopyLogDataWorkerTests.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/CopyLogDataWorkerTests.cs index 5130c54ce..bfeb8aa13 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/CopyLogDataWorkerTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/CopyLogDataWorkerTests.cs @@ -10,6 +10,7 @@ using Witsml; using Witsml.Data; +using Witsml.Extensions; using Witsml.ServiceReference; using WitsmlExplorer.Api.Jobs; @@ -35,6 +36,8 @@ public class CopyLogDataWorkerTests }; private const double DepthStart = 1; private const double DepthEnd = 5; + private readonly Uri _targetUri = new("https://target"); + private readonly Uri _sourceUri = new("https://source"); public CopyLogDataWorkerTests() { @@ -44,6 +47,17 @@ public CopyLogDataWorkerTests() witsmlClientProvider.Setup(provider => provider.GetSourceClient()).Returns(_witsmlClient.Object); Mock> logger = new(); Mock> documentRepository = new(); + documentRepository.Setup(client => client.GetDocumentsAsync()) + .ReturnsAsync(new List(){ + new(){ + Url = _targetUri, + DepthLogDecimals = 1 + }, + new(){ + Url = _sourceUri, + DepthLogDecimals = 2 + } + }.AsCollection()); _worker = new CopyLogDataWorker(witsmlClientProvider.Object, logger.Object, documentRepository.Object); } From 1ebb650be233d99edc979bbd1674d237173f4276 Mon Sep 17 00:00:00 2001 From: Petr Licman Date: Tue, 7 Nov 2023 12:22:31 +0100 Subject: [PATCH 3/6] LinqReenumerations fixes --- .../Services/CredentialsService.cs | 15 ++++----------- .../Services/FormationMarkerService.cs | 4 ++-- Src/WitsmlExplorer.Api/Services/JobService.cs | 4 ++-- .../Services/MessageObjectService.cs | 4 ++-- Src/WitsmlExplorer.Api/Services/MudLogService.cs | 2 +- Src/WitsmlExplorer.Api/Services/RigService.cs | 1 - Src/WitsmlExplorer.Api/Services/TubularService.cs | 4 +--- Src/WitsmlExplorer.Api/Services/WellService.cs | 5 +++-- .../Workers/Copy/CopyLogDataWorker.cs | 10 +++++----- .../Workers/Copy/CopyLogWorker.cs | 2 +- Src/WitsmlExplorer.Api/Workers/Copy/CopyUtils.cs | 5 +++-- .../Workers/Create/CreateLogWorker.cs | 2 +- 12 files changed, 25 insertions(+), 33 deletions(-) diff --git a/Src/WitsmlExplorer.Api/Services/CredentialsService.cs b/Src/WitsmlExplorer.Api/Services/CredentialsService.cs index 51f7ef196..b9c36eeee 100644 --- a/Src/WitsmlExplorer.Api/Services/CredentialsService.cs +++ b/Src/WitsmlExplorer.Api/Services/CredentialsService.cs @@ -34,7 +34,6 @@ public class CredentialsService : ICredentialsService private readonly IWitsmlSystemCredentials _witsmlServerCredentials; private readonly IDocumentRepository _witsmlServerRepository; private readonly ICredentialsCache _credentialsCache; - private readonly Task> _allServers; private static readonly string SUBJECT = "sub"; private readonly bool _useOAuth2; @@ -49,11 +48,10 @@ public CredentialsService( { _dataProtector = dataProtectionProvider.CreateProtector("WitsmlServerPassword").ToTimeLimitedDataProtector(); _logger = logger ?? throw new ArgumentException("Missing ILogger"); - _clientCapabilities = clientCapabilities.Value ?? throw new ArgumentException("Missing WitsmlClientCapabilities"); + _clientCapabilities = clientCapabilities?.Value ?? throw new ArgumentException("Missing WitsmlClientCapabilities"); _witsmlServerCredentials = witsmlServerCredentials ?? throw new ArgumentException("Missing WitsmlServerCredentials"); _witsmlServerRepository = witsmlServerRepository ?? throw new ArgumentException("Missing WitsmlServerRepository"); _credentialsCache = credentialsCache ?? throw new ArgumentException("CredentialsService missing"); - _allServers = _witsmlServerRepository.GetDocumentsAsync(); _useOAuth2 = StringHelpers.ToBoolean(configuration[ConfigConstants.OAuth2Enabled]); } @@ -85,15 +83,10 @@ public async Task VerifyAndCacheCredentials(IEssentialHeaders eh, bool kee private async Task UserHasRoleForHost(string[] roles, Uri host) { - bool result = true; - ICollection allServers = await _allServers; - + ICollection allServers = await _witsmlServerRepository.GetDocumentsAsync(); bool systemCredsExists = _witsmlServerCredentials.WitsmlCreds.Any(n => n.Host.EqualsIgnoreCase(host)); - bool validRole = allServers.Where(n => n.Url.EqualsIgnoreCase(host)).Any(n => - n.Roles != null && n.Roles.Intersect(roles).Any() - ); - result &= systemCredsExists & validRole; - return result; + bool validRole = allServers.Where(n => n.Url.EqualsIgnoreCase(host)).Any(n => n.Roles != null && n.Roles.Intersect(roles).Any()); + return systemCredsExists & validRole; } private string Encrypt(string inputString) diff --git a/Src/WitsmlExplorer.Api/Services/FormationMarkerService.cs b/Src/WitsmlExplorer.Api/Services/FormationMarkerService.cs index 05e8d0ce9..af25358d3 100644 --- a/Src/WitsmlExplorer.Api/Services/FormationMarkerService.cs +++ b/Src/WitsmlExplorer.Api/Services/FormationMarkerService.cs @@ -25,7 +25,7 @@ public async Task GetFormationMarker(string wellUid, string wel { WitsmlFormationMarkers query = (WitsmlFormationMarkers)ObjectQueries.GetWitsmlObjectById(wellUid, wellboreUid, formationMarkerUid, EntityType.FormationMarker); WitsmlFormationMarkers result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.All)); - return result.FormationMarkers.Any() ? WitsmlToFormationMarker(result.FormationMarkers.First()) : null; + return WitsmlToFormationMarker(result.FormationMarkers.FirstOrDefault()); } public async Task> GetFormationMarkers(string wellUid, string wellboreUid) { @@ -36,7 +36,7 @@ public async Task> GetFormationMarkers(string wellU private static FormationMarker WitsmlToFormationMarker(WitsmlFormationMarker formationMarker) { - return new FormationMarker + return formationMarker == null ? null : new FormationMarker { Uid = formationMarker.Uid, Name = formationMarker.Name, diff --git a/Src/WitsmlExplorer.Api/Services/JobService.cs b/Src/WitsmlExplorer.Api/Services/JobService.cs index 39addabc1..bc851badf 100644 --- a/Src/WitsmlExplorer.Api/Services/JobService.cs +++ b/Src/WitsmlExplorer.Api/Services/JobService.cs @@ -20,9 +20,9 @@ public class JobService : IJobService { private readonly IJobCache _jobCache; private readonly IJobQueue _jobQueue; - private readonly ICollection _workers; + private readonly IEnumerable _workers; - public JobService(IJobQueue jobQueue, ICollection workers, IJobCache jobCache) + public JobService(IJobQueue jobQueue, IEnumerable workers, IJobCache jobCache) { _jobQueue = jobQueue; _workers = workers; diff --git a/Src/WitsmlExplorer.Api/Services/MessageObjectService.cs b/Src/WitsmlExplorer.Api/Services/MessageObjectService.cs index 5d31203ed..9a69b868c 100644 --- a/Src/WitsmlExplorer.Api/Services/MessageObjectService.cs +++ b/Src/WitsmlExplorer.Api/Services/MessageObjectService.cs @@ -28,7 +28,7 @@ public async Task GetMessageObject(string wellUid, string wellbor WitsmlMessages witsmlMessage = MessageQueries.GetMessageById(wellUid, wellboreUid, msgUid); WitsmlMessages result = await _witsmlClient.GetFromStoreAsync(witsmlMessage, new OptionsIn(ReturnElements.All)); WitsmlMessage messageObject = result.Messages.FirstOrDefault(); - return messageObject == null ? null : FromWitsml(messageObject); + return FromWitsml(messageObject); } public async Task> GetMessageObjects(string wellUid, string wellboreUid) @@ -47,7 +47,7 @@ public async Task> GetMessageObjects(string wellUid, private static MessageObject FromWitsml(WitsmlMessage message) { - return new MessageObject + return message == null ? null : new MessageObject { WellboreUid = message.UidWellbore, WellboreName = message.NameWellbore, diff --git a/Src/WitsmlExplorer.Api/Services/MudLogService.cs b/Src/WitsmlExplorer.Api/Services/MudLogService.cs index 9d8d22076..5987352f4 100644 --- a/Src/WitsmlExplorer.Api/Services/MudLogService.cs +++ b/Src/WitsmlExplorer.Api/Services/MudLogService.cs @@ -82,7 +82,7 @@ private static List GetGeologyIntervals(List GetRig(string wellUid, string wellboreUid, string rigUid) WitsmlRigs query = RigQueries.GetWitsmlRig(wellUid, wellboreUid, rigUid); WitsmlRigs result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.Requested)); WitsmlRig witsmlRig = result.Rigs.FirstOrDefault(); - return WitsmlRigToRig(witsmlRig); } diff --git a/Src/WitsmlExplorer.Api/Services/TubularService.cs b/Src/WitsmlExplorer.Api/Services/TubularService.cs index 4c6acc036..0715362c8 100644 --- a/Src/WitsmlExplorer.Api/Services/TubularService.cs +++ b/Src/WitsmlExplorer.Api/Services/TubularService.cs @@ -54,8 +54,7 @@ public async Task> GetTubularComponents(string wel Od = tComponent.Od == null ? null : new LengthMeasure { Uom = tComponent.Od.Uom, Value = decimal.Parse(tComponent.Od.Value, CultureInfo.InvariantCulture) }, Len = tComponent.Len == null ? null : new LengthMeasure { Uom = tComponent.Len.Uom, Value = decimal.Parse(tComponent.Len.Value, CultureInfo.InvariantCulture) }, TypeTubularComponent = tComponent.TypeTubularComp, - }) - .OrderBy(tComponent => tComponent.Sequence).ToList(); + }).OrderBy(tComponent => tComponent.Sequence).ToList(); } private static Tubular WitsmlToTubular(WitsmlTubular tubular) @@ -76,6 +75,5 @@ private static Tubular WitsmlToTubular(WitsmlTubular tubular) } }; } - } } diff --git a/Src/WitsmlExplorer.Api/Services/WellService.cs b/Src/WitsmlExplorer.Api/Services/WellService.cs index f71a2288e..524ff1cb2 100644 --- a/Src/WitsmlExplorer.Api/Services/WellService.cs +++ b/Src/WitsmlExplorer.Api/Services/WellService.cs @@ -76,12 +76,13 @@ public async Task GetWell(string wellUid) Task> getWell = GetWellsInformation(wellUid); await Task.WhenAll(getWellbores, getWell); - if (!getWell.Result.Any()) + Well well = getWell.Result.FirstOrDefault(); + + if (well == null) { return null; } - Well well = getWell.Result.First(); well.Wellbores = getWellbores.Result; return well; } diff --git a/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs b/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs index 7024f0c0a..4b0f4809a 100644 --- a/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs @@ -202,13 +202,13 @@ private async Task CopyLogDataWithoutDuplicates(WitsmlLog sourceLog, Index.Start(sourceLog, startIndex.ToString(CultureInfo.InvariantCulture)), Index.End(sourceLog, endIndex.ToString(CultureInfo.InvariantCulture))); WitsmlLogs sourceData = await RequestUtils.WithRetry(async () => await GetSourceWitsmlClientOrThrow().GetFromStoreAsync(query, new OptionsIn(ReturnElements.DataOnly)), Logger); - if (!sourceData.Logs.Any()) + WitsmlLog sourceLogWithData = sourceData?.Logs?.FirstOrDefault(); + + if (sourceLogWithData == null) { break; } - WitsmlLog sourceLogWithData = sourceData.Logs.First(); - List data = sourceLogWithData.LogData.Data; List newData = new(); List rowsToCollate = new(); @@ -226,10 +226,10 @@ private async Task CopyLogDataWithoutDuplicates(WitsmlLog sourceLog, if (rowsToCollate.Any()) { newData.Add(CollateData(rowsToCollate, targetIndex)); + rowsToCollate.Clear(); } firstSourceRowIndex = lastSourceRowIndex; targetIndex = nextTargetIndex; - rowsToCollate = new(); } rowsToCollate.Add(split[1..]); } @@ -377,7 +377,7 @@ private static void VerifyIndexCurveIsIncludedInMnemonics(WitsmlLog log, IList GetLogHeaderOnly(IWitsmlClient client, stri { WitsmlLogs logQuery = LogQueries.GetWitsmlLogById(wellUid, wellboreUid, logUid); WitsmlLogs result = await client.GetFromStoreAsync(logQuery, new OptionsIn(ReturnElements.HeaderOnly)); - return !result.Logs.Any() ? null : result.Logs.First(); + return result.Logs?.FirstOrDefault(); } private static CopyLogDataJob CreateCopyLogDataJob(CopyObjectsJob job, WitsmlLog targetLog) diff --git a/Src/WitsmlExplorer.Api/Workers/Copy/CopyUtils.cs b/Src/WitsmlExplorer.Api/Workers/Copy/CopyUtils.cs index efcc45f8b..8f1848082 100644 --- a/Src/WitsmlExplorer.Api/Workers/Copy/CopyUtils.cs +++ b/Src/WitsmlExplorer.Api/Workers/Copy/CopyUtils.cs @@ -75,10 +75,11 @@ public CopyUtils(ILogger logger) } }).ToList()); - string successString = successUids.Count > 0 ? $"Copied {queries.FirstOrDefault()?.GetType().Name}s: {string.Join(", ", successUids)}." : ""; + var typeName = queries.FirstOrDefault()?.GetType().Name; + string successString = successUids.Count > 0 ? $"Copied {typeName}s: {string.Join(", ", successUids)}." : ""; return !error ? (new WorkerResult(witsmlClient.GetServerHostname(), true, successString), refreshAction) - : (new WorkerResult(witsmlClient.GetServerHostname(), false, $"{successString} Failed to copy some {queries.First()?.GetType().Name}s", errorReason, errorEntity), successUids.Count > 0 ? refreshAction : null); + : (new WorkerResult(witsmlClient.GetServerHostname(), false, $"{successString} Failed to copy some {typeName}s", errorReason, errorEntity), successUids.Count > 0 ? refreshAction : null); } } } diff --git a/Src/WitsmlExplorer.Api/Workers/Create/CreateLogWorker.cs b/Src/WitsmlExplorer.Api/Workers/Create/CreateLogWorker.cs index a97aad85e..24932095c 100644 --- a/Src/WitsmlExplorer.Api/Workers/Create/CreateLogWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Create/CreateLogWorker.cs @@ -84,7 +84,7 @@ private static async Task GetWellbore(IWitsmlClient client, LogO { WitsmlWellbores query = WellboreQueries.GetWitsmlWellboreByUid(logObject.WellUid, logObject.WellboreUid); WitsmlWellbores wellbores = await client.GetFromStoreAsync(query, new OptionsIn(ReturnElements.Requested)); - return !wellbores.Wellbores.Any() ? null : wellbores.Wellbores.First(); + return wellbores.Wellbores.FirstOrDefault(); } } } From fb67338b39eb05d8be7c46e503fd2a01059d91ac Mon Sep 17 00:00:00 2001 From: Petr Licman Date: Tue, 7 Nov 2023 12:52:22 +0100 Subject: [PATCH 4/6] BaseReport generic needed --- Src/WitsmlExplorer.Api/Models/Reports/BaseReport.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Src/WitsmlExplorer.Api/Models/Reports/BaseReport.cs b/Src/WitsmlExplorer.Api/Models/Reports/BaseReport.cs index 700ea6cc2..7e41d984c 100644 --- a/Src/WitsmlExplorer.Api/Models/Reports/BaseReport.cs +++ b/Src/WitsmlExplorer.Api/Models/Reports/BaseReport.cs @@ -2,11 +2,6 @@ namespace WitsmlExplorer.Api.Models.Reports { - public class BaseReport : BaseReport - { - public ICollection ReportItems { get; init; } - } - public class BaseReport { public string Title { get; set; } From ac26dedf5caa35bb2e31669be4b953bfdf53417b Mon Sep 17 00:00:00 2001 From: Petr Licman Date: Mon, 13 Nov 2023 10:00:20 +0100 Subject: [PATCH 5/6] Fix of one IEnumerable to List type --- Src/WitsmlExplorer.Api/HttpHandlers/JobHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/WitsmlExplorer.Api/HttpHandlers/JobHandler.cs b/Src/WitsmlExplorer.Api/HttpHandlers/JobHandler.cs index c60b02e8d..b4fba3cfa 100644 --- a/Src/WitsmlExplorer.Api/HttpHandlers/JobHandler.cs +++ b/Src/WitsmlExplorer.Api/HttpHandlers/JobHandler.cs @@ -75,7 +75,7 @@ private static bool IsAdminOrDeveloper(string token) { JwtSecurityTokenHandler handler = new(); JwtSecurityToken jwt = handler.ReadJwtToken(token); - IEnumerable userRoles = jwt.Claims.Where(n => n.Type == "roles").Select(n => n.Value).ToList(); + List userRoles = jwt.Claims.Where(n => n.Type == "roles").Select(n => n.Value).ToList(); return userRoles.Contains(AuthorizationPolicyRoles.ADMIN) || userRoles.Contains(AuthorizationPolicyRoles.DEVELOPER); } From 233c0c321ec2546921ff45785e0aebad9ce1b9a6 Mon Sep 17 00:00:00 2001 From: Petr Licman Date: Wed, 15 Nov 2023 08:50:32 +0100 Subject: [PATCH 6/6] reverse of appsettings.Dev --- Src/WitsmlExplorer.Api/appsettings.Development.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Src/WitsmlExplorer.Api/appsettings.Development.json b/Src/WitsmlExplorer.Api/appsettings.Development.json index b5da516cb..584a0e456 100644 --- a/Src/WitsmlExplorer.Api/appsettings.Development.json +++ b/Src/WitsmlExplorer.Api/appsettings.Development.json @@ -1,8 +1,4 @@ { -"MongoDb": { - "Name": "witsml-explorer-db", - "ConnectionString": "mongodb://localhost" - }, "Serilog": { "Using": ["Serilog.Expressions"], "MinimumLevel": {