-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - Add remote service interactions #6
Open
artl93
wants to merge
34
commits into
main
Choose a base branch
from
remote-approvals
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
248f8a5
WIP - hack authentication for my tenant into the client to verifythat…
artl93 227a7df
WIP started playingwith request APIs
artl93 9f7f0eb
Fix await
artl93 5a39818
Merge branch 'main' into remote-approvals
artl93 cb4e2c2
Update .gitignore
artl93 b3c14a9
Merge branch 'main' into remote-approvals
artl93 8457c99
General cleanup
artl93 3e6ca52
Rename UserConfigurationProvider to LocalConfigurationProvider
artl93 6318016
- Fixup namespaces.
artl93 ba86cf4
WIP - refactor remote services from HiddenForm into their own classes
artl93 1d83e57
WIP - Add remote / local switcher
artl93 5ab47d7
Refactor user configuration and service registrations
artl93 bf59620
Add heartbeat functionality and simplify service setup
artl93 d8d9b6f
Refactor common record types into a common assembly
artl93 b43ea29
Add ScreenTIme.Common project reference
artl93 d05746d
Rename fields
artl93 0fb20e1
Move Heartbeat to ScreenTime.Common
artl93 f5f97ae
Heartbeat is now working end-to-end
artl93 93eb5bc
Rename RemoteUserConfigurationProvicer to ScreenTimeServiceClient
artl93 96516cd
Update src/ScreenTimeClient/Configuration/RemoteUserConfigurationProv…
artl93 d4a1b1d
Update src/ScreenTimeClient/Configuration/RemoteUserConfigurationProv…
artl93 50d72c8
Github copilot led me wrong - I didn't check - these weren't async me…
artl93 ef90cad
Add verification builds
artl93 cee21e8
WIP - screentimeservice is all up to date with the EF models from the…
artl93 f99a058
Remove unused "name" field from user configuration
artl93 1d04eba
Separate client configuration from user's daily limits / configuation
artl93 43c868a
Back to working
artl93 ffc25f2
Remove old database concepts.
artl93 9b4caa2
Remove old types
artl93 ed86562
Updated models to represent new reality. And it works.
artl93 7baa8e5
Updated models and ensured heartbeat works.
artl93 b520146
- Add Request Extensions
artl93 a557a36
Service can now to approvals and denials.
artl93 2baa97d
Sending a message using SignalR actually kind of works now (using Sca…
artl93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
# This workflow will build, test, sign and package a WPF or Windows Forms desktop application | ||
# built on .NET Core. | ||
# To learn how to migrate your existing application to .NET Core, | ||
# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework | ||
# | ||
# To configure this workflow: | ||
# | ||
# 1. Configure environment variables | ||
# GitHub sets default environment variables for every workflow run. | ||
# Replace the variables relative to your project in the "env" section below. | ||
# | ||
# 2. Signing | ||
# Generate a signing certificate in the Windows Application | ||
# Packaging Project or add an existing signing certificate to the project. | ||
# Next, use PowerShell to encode the .pfx file using Base64 encoding | ||
# by running the following Powershell script to generate the output string: | ||
# | ||
# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte | ||
# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt' | ||
# | ||
# Open the output file, SigningCertificate_Encoded.txt, and copy the | ||
# string inside. Then, add the string to the repo as a GitHub secret | ||
# and name it "Base64_Encoded_Pfx." | ||
# For more information on how to configure your signing certificate for | ||
# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing | ||
# | ||
# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key". | ||
# See "Build the Windows Application Packaging project" below to see how the secret is used. | ||
# | ||
# For more information on GitHub Actions, refer to https://github.com/features/actions | ||
# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications, | ||
# refer to https://github.com/microsoft/github-actions-for-desktop-apps | ||
|
||
name: Service Build and Verify | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
|
||
build: | ||
|
||
strategy: | ||
matrix: | ||
configuration: [Release] | ||
|
||
runs-on: windows-latest # For a list of available runner types, refer to | ||
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on | ||
|
||
env: | ||
Solution_Name: services.sln # Replace with your solution name, i.e. MyWpfApp.sln. | ||
Test_Project_Path: src\ScreenTimeTest\ScreenTimeTest.csproj # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj. | ||
# Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package. | ||
# Wap_Project_Path: your-wap-project-path # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj. | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# Install the .NET Core workload | ||
- name: Install .NET Core | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: 9.0.x | ||
|
||
# Build the application to populate the obj folder with RuntimeIdentifiers | ||
- name: Build the application | ||
run: dotnet build $env:Solution_Name | ||
env: | ||
Configuration: ${{ matrix.configuration }} | ||
|
||
# Execute all unit tests in the solution | ||
- name: Execute unit tests | ||
run: dotnet test $env:Test_Project_Path | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,3 +396,4 @@ FodyWeavers.xsd | |
|
||
# JetBrains Rider | ||
*.sln.iml | ||
.VSCodeCounter/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ScreenTime.Common | ||
{ | ||
public record AdminExtensionGrant(Guid UserId, TimeSpan Duration, Guid[] RequestIds); | ||
public record ExtensionGrant(DateTimeOffset GrantDate, TimeSpan Duration); | ||
public record ExtensionRequest(TimeSpan Duration); | ||
public record AdminExtensionRequest(Guid requestId, User User, DateTimeOffset SubmissionDate, TimeSpan Duration); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace ScreenTime.Common | ||
{ | ||
public record Heartbeat(DateTimeOffset Timestamp, TimeSpan Duration, UserState UserState); | ||
|
||
public record User (Guid Id, string Name, string Email); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
2 changes: 1 addition & 1 deletion
2
src/ScreenTimeClient/UserActivityState.cs → src/ScreenTIme.Common/UserActivityState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
| ||
namespace ScreenTimeClient | ||
namespace ScreenTime.Common | ||
{ | ||
|
||
public enum UserActivityState | ||
|
2 changes: 1 addition & 1 deletion
2
src/ScreenTimeClient/UserMessage.cs → src/ScreenTIme.Common/UserMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ScreenTime.Common | ||
{ | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public enum UserState { Invalid, Okay, Warn, Error, Lock, Paused } | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
src/ScreenTimeClient/UserStatus.cs → src/ScreenTIme.Common/UserStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using ScreenTime.Common; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
|
||
namespace ScreenTimeClient.Configuration | ||
{ | ||
|
||
public record ClientConfiguration(int WarningInterval, bool EnableOnline); | ||
} |
40 changes: 40 additions & 0 deletions
40
src/ScreenTimeClient/Configuration/ClientConfigurationRegistryReader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Microsoft.Win32; | ||
|
||
namespace ScreenTimeClient.Configuration | ||
{ | ||
public class ClientConfigurationRegistryReader : IClientConfigurationReader | ||
{ | ||
const string _baseKey = @"HKEY_CURRENT_USER\Software\ScreenTime"; | ||
|
||
public ClientConfiguration GetConfiguration() | ||
{ | ||
var warningInterval = GetRegistryIntValue(_baseKey, "WarningInterval", 60); | ||
var enableOnline = GetRegistryIntValue(_baseKey, "EnableOnline", 0) == 1; // convert to boolean | ||
|
||
return new ClientConfiguration(warningInterval, enableOnline); | ||
|
||
} | ||
|
||
private static int GetRegistryIntValue(string key, string valueName, int defaultValue) | ||
{ | ||
var objectValue = Registry.GetValue(key, valueName, defaultValue); | ||
if (objectValue == null) | ||
{ | ||
return defaultValue; | ||
} | ||
else if (objectValue is int intValue) | ||
{ | ||
return intValue; | ||
} | ||
else if (objectValue is string stringValue) | ||
{ | ||
if (int.TryParse(stringValue, out int result)) | ||
{ | ||
return result; | ||
} | ||
} | ||
return defaultValue; | ||
} | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/ScreenTimeClient/Configuration/DailyConfigurationEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using ScreenTime.Common; | ||
|
||
|
||
namespace ScreenTimeClient.Configuration | ||
{ | ||
public class DailyConfigurationEventArgs(object Sender, DailyConfiguration Configuration) : EventArgs | ||
{ | ||
public DailyConfiguration Configuration { get; } = Configuration; | ||
public object Sender { get; } = Sender; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build command does not correctly use the Configuration environment variable. It should be passed as an argument to the dotnet build command.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.