diff --git a/ClientHub/.vscode/settings.json b/ClientHub/.vscode/settings.json index cb4d148..c6f89f4 100644 --- a/ClientHub/.vscode/settings.json +++ b/ClientHub/.vscode/settings.json @@ -1,5 +1,9 @@ { "cSpell.words": [ + "Blazor", + "Dispo", + "Hsts", + "Serilog", "tooltype" ] } \ No newline at end of file diff --git a/ClientHub/.vscode/tasks.json b/ClientHub/.vscode/tasks.json index a2c6218..a82559c 100644 --- a/ClientHub/.vscode/tasks.json +++ b/ClientHub/.vscode/tasks.json @@ -44,7 +44,7 @@ "args": [ "watch", "--launch-profile", - "https", + "http", "run", "--project", "${workspaceFolder}/OI.Metrology.ClientHub.csproj", diff --git a/ClientHub/Pages/AwaitingDisposition.razor.cs b/ClientHub/Pages/AwaitingDisposition.razor.cs index 4794004..42b7690 100644 --- a/ClientHub/Pages/AwaitingDisposition.razor.cs +++ b/ClientHub/Pages/AwaitingDisposition.razor.cs @@ -7,6 +7,7 @@ public partial class AwaitingDisposition { [Inject] protected IJSRuntime? JSRuntime { get; set; } + [Inject] protected Models.AppSettings? AppSettings { get; set; } protected override Task OnAfterRenderAsync(bool firstRender) { @@ -14,7 +15,9 @@ public partial class AwaitingDisposition { if (JSRuntime is null) throw new NullReferenceException(nameof(JSRuntime)); - return JSRuntime.InvokeVoidAsync("initAwaitingDisposition").AsTask(); + if (AppSettings is null) + throw new NullReferenceException(nameof(AppSettings)); + return JSRuntime.InvokeVoidAsync("initAwaitingDisposition", AppSettings.ApiUrl).AsTask(); } return Task.CompletedTask; } diff --git a/ClientHub/Pages/Export.razor.cs b/ClientHub/Pages/Export.razor.cs index 89ddd1e..2e30a21 100644 --- a/ClientHub/Pages/Export.razor.cs +++ b/ClientHub/Pages/Export.razor.cs @@ -7,6 +7,7 @@ public partial class Export { [Inject] protected IJSRuntime? JSRuntime { get; set; } + [Inject] protected Models.AppSettings? AppSettings { get; set; } [Parameter] public Metrology.Shared.ViewModels.Export? Model { get; set; } public Export() @@ -25,7 +26,9 @@ public partial class Export { if (JSRuntime is null) throw new NullReferenceException(nameof(JSRuntime)); - return JSRuntime.InvokeVoidAsync("initExport", DateTime.Now.AddMonths(-1), DateTime.Now).AsTask(); + if (AppSettings is null) + throw new NullReferenceException(nameof(AppSettings)); + return JSRuntime.InvokeVoidAsync("initExport", AppSettings.ApiUrl, DateTime.Now.AddMonths(-1), DateTime.Now).AsTask(); } return Task.CompletedTask; } diff --git a/ClientHub/Pages/RunHeaders.razor.cs b/ClientHub/Pages/RunHeaders.razor.cs index 2768c81..e068a0f 100644 --- a/ClientHub/Pages/RunHeaders.razor.cs +++ b/ClientHub/Pages/RunHeaders.razor.cs @@ -7,6 +7,7 @@ public partial class RunHeaders { [Inject] protected IJSRuntime? JSRuntime { get; set; } + [Inject] protected Models.AppSettings? AppSettings { get; set; } protected override Task OnAfterRenderAsync(bool firstRender) { @@ -14,7 +15,9 @@ public partial class RunHeaders { if (JSRuntime is null) throw new NullReferenceException(nameof(JSRuntime)); - return JSRuntime.InvokeVoidAsync("initRunHeaders").AsTask(); + if (AppSettings is null) + throw new NullReferenceException(nameof(AppSettings)); + return JSRuntime.InvokeVoidAsync("initRunHeaders", AppSettings.ApiUrl).AsTask(); } return Task.CompletedTask; } diff --git a/ClientHub/Pages/RunInfo.razor.cs b/ClientHub/Pages/RunInfo.razor.cs index 4a3011f..ee35280 100644 --- a/ClientHub/Pages/RunInfo.razor.cs +++ b/ClientHub/Pages/RunInfo.razor.cs @@ -9,6 +9,7 @@ public partial class RunInfo [Parameter] public Metrology.Shared.ViewModels.RunInfo? Model { get; set; } [Inject] protected IJSRuntime? JSRuntime { get; set; } + [Inject] protected Models.AppSettings? AppSettings { get; set; } protected override Task OnAfterRenderAsync(bool firstRender) { @@ -16,10 +17,12 @@ public partial class RunInfo { if (JSRuntime is null) throw new NullReferenceException(nameof(JSRuntime)); + if (AppSettings is null) + throw new NullReferenceException(nameof(AppSettings)); int initialToolTypeID = Model is not null ? Model.ToolTypeID : 0; int initialHeaderId = Model is not null ? Model.HeaderID : 0; string initialHeaderAttachmentId = Model is not null ? Model.HeaderAttachmentID.ToString() : string.Empty; - return JSRuntime.InvokeVoidAsync("initRunInfo", initialToolTypeID, initialHeaderId, initialHeaderAttachmentId).AsTask(); + return JSRuntime.InvokeVoidAsync("initRunInfo", AppSettings.ApiUrl, initialToolTypeID, initialHeaderId, initialHeaderAttachmentId).AsTask(); } return Task.CompletedTask; } diff --git a/ClientHub/appsettings.Development.json b/ClientHub/appsettings.Development.json index 6f0d44a..435546a 100644 --- a/ClientHub/appsettings.Development.json +++ b/ClientHub/appsettings.Development.json @@ -1,5 +1,6 @@ { - "ApiUrl": "https://localhost:7130", + "xApiUrl": "https://localhost:7130", + "ApiUrl": "http://messa010ec.ec.local:50301", "DetailedErrors": true, "IsDevelopment": true, "IsStaging": false, diff --git a/ClientHub/wwwroot/site.js b/ClientHub/wwwroot/site.js index a9f78ee..21c2fdb 100644 --- a/ClientHub/wwwroot/site.js +++ b/ClientHub/wwwroot/site.js @@ -1,3 +1,4 @@ +var _apiUrl = null; var _initialHeaderAttachmentId = null; var _initialHeaderId = null; var _toolType = null; @@ -25,7 +26,8 @@ function loadRunInfoAwaitingDisposition() { window.location.href = targetURL; } -function initAwaitingDisposition() { +function initAwaitingDisposition(apiUrl) { + _apiUrl = apiUrl; $("#grid").igGrid({ autoGenerateColumns: false, width: "70%", @@ -45,7 +47,7 @@ function initAwaitingDisposition() { { key: "InsertDate", dataType: "date", width: "10%", format: "dateTime" }, { key: "Expiration", dataType: "date", width: "10%", format: "dateTime" } ], - dataSource: "https://localhost:7130/api/awaitingdispo/", + dataSource: _apiUrl + "/api/awaitingdispo/", responseDataKey: "Results", tabIndex: 1, features: [ @@ -61,11 +63,12 @@ function initAwaitingDisposition() { $("#grid").on("dblclick", "tr", loadRunInfoAwaitingDisposition); }; -function initExport(startTimeValue, endTimeValue) { +function initExport(apiUrl, startTimeValue, endTimeValue) { + _apiUrl = apiUrl; var endTime = new Date(endTimeValue); var startTime = new Date(startTimeValue); $("#ToolType").igCombo({ - dataSource: 'https://localhost:7130/api/tooltypes', + dataSource: _apiUrl + '/api/tooltypes', responseDataKey: "Results", textKey: "ToolTypeName", valueKey: "ID", @@ -104,7 +107,7 @@ function loadHeaderGridRunHeaders() { if (gridCreated) $("#HeaderGrid").igGrid("destroy"); clearFieldsGridRunHeaders(); - var headerURL = "https://localhost:7130/api/tooltypes/" + toolTypeID + "/headertitles"; + var headerURL = _apiUrl + "/api/tooltypes/" + toolTypeID + "/headertitles"; $("#HeaderGrid").igGrid({ autoGenerateColumns: false, primaryKey: "ID", @@ -134,7 +137,7 @@ function clearFieldsGridRunHeaders() { function headerSelectionChangedRunHeaders(evt, ui) { var toolTypeID = $("#ToolType").igCombo("value"); clearFieldsGridRunHeaders(); - var url = "https://localhost:7130/api/tooltypes/" + toolTypeID + "/headers/" + ui.row.id + "/fields"; + var url = _apiUrl + "/api/tooltypes/" + toolTypeID + "/headers/" + ui.row.id + "/fields"; $("#FieldsGrid").igGrid({ autoGenerateColumns: false, primaryKey: "Column", @@ -153,9 +156,10 @@ function headerSelectionChangedRunHeaders(evt, ui) { }); } -function initRunHeaders() { +function initRunHeaders(apiUrl) { + _apiUrl = apiUrl; $("#ToolType").igCombo({ - dataSource: 'https://localhost:7130/api/tooltypes', + dataSource: _apiUrl + '/api/tooltypes', responseDataKey: "Results", textKey: "ToolTypeName", valueKey: "ID", @@ -181,7 +185,7 @@ function loadHeaderGridRunInfo() { $("#HeaderGrid").igGrid("destroy"); $.ajax({ type: "GET", - url: "https://localhost:7130/api/tooltypes/" + toolTypeID + "?sortby=grid", + url: _apiUrl + "/api/tooltypes/" + toolTypeID + "?sortby=grid", success: function (r) { if ((r.Results == null) || (r.Results.ToolType == null) || (r.Results.Metadata == null)) ShowErrorMessage("Invalid tool type: " + toolTypeID); @@ -263,7 +267,7 @@ function detailSelectionChangedRunInfo(evt, ui) { if (ui.row.index >= 0) { var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index]; var toolTypeID = $("#ToolTypeID").text(); - var attachmentUrlBase = 'https://localhost:7130/api/tooltypes/' + toolTypeID; + var attachmentUrlBase = _apiUrl + '/api/tooltypes/' + toolTypeID; var attachmentId = rowData.AttachmentID; if ((attachmentId == null) || (attachmentId === '')) return; @@ -276,7 +280,7 @@ function detailSelectionChangedRunInfo(evt, ui) { function loadHeaderAttachmentRunInfo() { var toolTypeID = $("#ToolTypeID").text(); var attachmentId = $("#HeaderAttachmentId").text(); - var attachmentUrlBase = 'https://localhost:7130/api/tooltypes/' + toolTypeID; + var attachmentUrlBase = _apiUrl + '/api/tooltypes/' + toolTypeID; if ((attachmentId == null) || (attachmentId === '') || (_toolType.DisplayHeaderAttachment == null) || (_toolType.DisplayHeaderAttachment === '')) { $("#HeaderAttachmentFrame").prop("src", ""); } else { @@ -290,7 +294,7 @@ function markAsReviewedRunInfo() { var headerId = $("#HeaderId").text(); $.ajax({ type: "POST", - url: "https://localhost:7130/api/awaitingdispo/markasreviewed?tooltypeid=" + toolTypeId + "&headerid=" + headerId, + url: _apiUrl + "/api/awaitingdispo/markasreviewed?tooltypeid=" + toolTypeId + "&headerid=" + headerId, success: function () { }, error: function (e, ajaxOptions, ex) { @@ -308,7 +312,7 @@ function loadDetailsRunInfo() { $("#DetailsGrid").igGrid("destroy"); var headerId = $("#HeaderId").text(); var toolTypeID = $("#ToolTypeID").text(); - var detailsURL = "https://localhost:7130/api/tooltypes/" + toolTypeID + "/headers/" + headerId + "/data"; + var detailsURL = _apiUrl + "/api/tooltypes/" + toolTypeID + "/headers/" + headerId + "/data"; var gridColumns = [ { key: "AttachmentID", dataType: "string", hidden: true }, { key: "Title", dataType: "string", hidden: true }, @@ -372,7 +376,7 @@ function requestHeaderDataRunInfo() { $("#HeaderAttachmentId").text(_initialHeaderAttachmentId); _initialHeaderId = -1; } - var headerURL = "https://localhost:7130/api/tooltypes/" + _toolType.ID + "/headers?" + $.param(parms); + var headerURL = _apiUrl + "/api/tooltypes/" + _toolType.ID + "/headers?" + $.param(parms); var gridColumns = [ { key: "ID", dataType: "number", hidden: true }, { key: "AttachmentID", dataType: "string", hidden: true }, @@ -428,7 +432,7 @@ function reviewButtonRunInfo() { $("#ReviewButton").prop("disabled", true); $.ajax({ type: "POST", - url: "https://localhost:7130/api/awaitingdispo/markasawaiting?tooltypeid=" + toolTypeId + "&headerid=" + headerId, + url: _apiUrl + "/api/awaitingdispo/markasawaiting?tooltypeid=" + toolTypeId + "&headerid=" + headerId, success: function (e) { DisplayWSMessage("info", "Marked as awaiting disposition", e); $("#ReviewButton").prop("disabled", false); @@ -446,7 +450,7 @@ function oiExportButtonRunInfo() { $("#OIExportButton").prop("disabled", true); $.ajax({ type: "POST", - url: "https://localhost:7130/api/tooltypes/" + toolTypeID + "/headers/" + headerId + "/oiexport", + url: _apiUrl + "/api/tooltypes/" + toolTypeID + "/headers/" + headerId + "/oiexport", success: function (r) { $("#OIExportResult").text("Exported!"); }, @@ -482,11 +486,12 @@ function setInitialDateTimesRunInfo() { }); } -function initRunInfo(initialToolTypeID, initialHeaderId, initialHeaderAttachmentId) { +function initRunInfo(apiUrl, initialToolTypeID, initialHeaderId, initialHeaderAttachmentId) { + _apiUrl = apiUrl; _initialHeaderId = initialHeaderId; _initialHeaderAttachmentId = initialHeaderAttachmentId; $("#ToolType").igCombo({ - dataSource: 'https://localhost:7130/api/tooltypes', + dataSource: _apiUrl + '/api/tooltypes', responseDataKey: "Results", textKey: "ToolTypeName", valueKey: "ID", diff --git a/azure-pipelines-server-development.yml b/azure-pipelines-server-development.yml index 43f54cb..45eb7dd 100644 --- a/azure-pipelines-server-development.yml +++ b/azure-pipelines-server-development.yml @@ -20,19 +20,45 @@ pool: steps: - script: | - echo $(Build.BuildId) - echo $(Build.Reason) - echo $(Build.Repository.Id) - echo $(Build.Repository.Name) - echo $(Build.SourceVersion) + set coreVersion=net7.0 + echo %coreVersion% + echo ##vso[task.setvariable variable=CoreVersion;]%coreVersion% + echo $(CoreVersion) + displayName: CoreVersion + + - script: | + set configuration=Debug + echo %configuration% + echo ##vso[task.setvariable variable=Configuration;]%configuration% + echo ($Configuration) + displayName: Configuration + + - script: | + set nugetSource=https://messa017.infineon.com/v3/index.json + echo %nugetSource% + echo ##vso[task.setvariable variable=NugetSource;]%nugetSource% + echo $(NugetSource) + displayName: NugetSource + + - script: | set gitCommit=$(Build.SourceVersion) set gitCommitSeven=%gitCommit:~0,7% echo %gitCommitSeven% echo ##vso[task.setvariable variable=GitCommitSeven;]%gitCommitSeven% echo $(GitCommitSeven) - displayName: Echo + displayName: GitCommitSeven - - script: "echo $(GitCommitSeven)" + - script: | + echo $(Build.BuildId) + echo $(Build.Reason) + echo $(Build.Repository.Id) + echo $(Build.Repository.Name) + echo $(Build.SourceVersion) + echo $(CoreVersion) + echo $(Configuration) + echo $(NugetSource) + echo $(GitCommitSeven) + REM echo $(pipelinePassword) displayName: "Echo Check" - script: '"C:\program files\dotnet\dotnet.exe" nuget locals all --clear' @@ -47,11 +73,11 @@ steps: workingDirectory: Server displayName: "Safe storage of app secrets - Server" - - script: '"C:\program files\dotnet\dotnet.exe" build --configuration Release --source "https://messa017.infineon.com/v3/index.json"' + - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' workingDirectory: Server displayName: "Core Build - Server" - - script: "dotnet test --configuration Release" + - script: "dotnet test --configuration $(Configuration)" workingDirectory: Tests displayName: "Core Test" enabled: false @@ -66,7 +92,7 @@ steps: displayName: "Report Generator" enabled: false - - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration Release --runtime win-x64 --self-contained -o $(Build.ArtifactStagingDirectory)\Server --source "https://messa017.infineon.com/v3/index.json"' + - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o $(Build.ArtifactStagingDirectory)\Server --source $(NugetSource)' workingDirectory: Server displayName: "Core Publish" @@ -74,20 +100,18 @@ steps: displayName: "Copy Files" inputs: SourceFolder: '$(Build.ArtifactStagingDirectory)\Server' - TargetFolder: 'D:\net7.0\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-Release\Server' + TargetFolder: 'D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server' - task: PublishBuildArtifacts@1 displayName: "Publish Artifact: drop" enabled: false - script: | - "C:\program files\dotnet\dotnet.exe" clean --configuration Debug - "C:\program files\dotnet\dotnet.exe" clean --configuration Release + "C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration) workingDirectory: Tests displayName: "Core Clean - Tests" - script: | - "C:\program files\dotnet\dotnet.exe" clean --configuration Debug - "C:\program files\dotnet\dotnet.exe" clean --configuration Release + "C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration) workingDirectory: Server displayName: "Core Clean - Server" diff --git a/azure-pipelines-server.yml b/azure-pipelines-server.yml new file mode 100644 index 0000000..8adc99a --- /dev/null +++ b/azure-pipelines-server.yml @@ -0,0 +1,117 @@ +trigger: + branches: + include: + - master + paths: + include: + - "Server/*" + - "Shared/*" + - "Tests/*" + exclude: + - "**/*.yaml" + - "**/*.yml" + - "Archive/*" + - "Client/*" + - "ClientHub/*" + +pool: + name: Mesa-IIS + demands: OI-Metrology-Server + +steps: + - script: | + set coreVersion=net7.0 + echo %coreVersion% + echo ##vso[task.setvariable variable=CoreVersion;]%coreVersion% + echo $(CoreVersion) + displayName: CoreVersion + + - script: | + set configuration=Release + echo %configuration% + echo ##vso[task.setvariable variable=Configuration;]%configuration% + echo ($Configuration) + displayName: Configuration + + - script: | + set nugetSource=https://messa08ec.ec.local/v3/index.json + echo %nugetSource% + echo ##vso[task.setvariable variable=NugetSource;]%nugetSource% + echo $(NugetSource) + displayName: NugetSource + + - script: | + set gitCommit=$(Build.SourceVersion) + set gitCommitSeven=%gitCommit:~0,7% + echo %gitCommitSeven% + echo ##vso[task.setvariable variable=GitCommitSeven;]%gitCommitSeven% + echo $(GitCommitSeven) + displayName: GitCommitSeven + + - script: | + echo $(Build.BuildId) + echo $(Build.Reason) + echo $(Build.Repository.Id) + echo $(Build.Repository.Name) + echo $(Build.SourceVersion) + echo $(CoreVersion) + echo $(Configuration) + echo $(NugetSource) + echo $(GitCommitSeven) + REM echo $(pipelinePassword) + displayName: "Echo Check" + + - script: '"C:\program files\dotnet\dotnet.exe" nuget locals all --clear' + displayName: "Nuget Clear" + enabled: false + + - script: | + "C:\program files\dotnet\dotnet.exe" user-secrets init + "C:\program files\dotnet\dotnet.exe" user-secrets set "BuildNumber" "$(Build.BuildId)" + "C:\program files\dotnet\dotnet.exe" user-secrets set "GitCommitSeven" "$(GitCommitSeven)" + "C:\program files\dotnet\dotnet.exe" user-secrets list + workingDirectory: Server + displayName: "Safe storage of app secrets - Server" + + - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' + workingDirectory: Server + displayName: "Core Build - Server" + + - script: "dotnet test --configuration $(Configuration)" + workingDirectory: Tests + displayName: "Core Test" + enabled: false + + - script: '"C:\program files\dotnet\dotnet.exe" tool restore' + workingDirectory: Server + displayName: "Tool Restore" + enabled: false + + - script: '"C:\program files\dotnet\dotnet.exe" ReportGenerator -reports:.vscode/TestResults/*/coverage.cobertura.xml -targetDir:$(Build.ArtifactStagingDirectory)\Coverage -reportTypes:Html_Dark' + workingDirectory: Server + displayName: "Report Generator" + enabled: false + + - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o $(Build.ArtifactStagingDirectory)\Server --source $(NugetSource)' + workingDirectory: Server + displayName: "Core Publish" + + - task: CopyFiles@2 + displayName: "Copy Files" + inputs: + SourceFolder: '$(Build.ArtifactStagingDirectory)\Server' + TargetFolder: 'D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server' + + - task: PublishBuildArtifacts@1 + displayName: "Publish Artifact: drop" + enabled: false + + - script: | + "C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration) + workingDirectory: Tests + displayName: "Core Clean - Tests" + + - script: | + "C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration) + workingDirectory: Server + displayName: "Core Clean - Server"