From d439df5d80b81673bb26e9bee2f3dcea54a12cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dongmin=20Jang=20=28=EC=9E=A5=EB=8F=99=EB=AF=BC=29?= Date: Mon, 24 Jun 2024 19:30:21 +0900 Subject: [PATCH] Update save and read workflow --- .../Current/cora-organizer-settings.json | 40 +++++ .../Corathing.Organizer.csproj | 7 +- .../Models/ProjectContext.cs | 34 +++- .../Models/WorkflowContext.cs | 46 ++++-- .../Services/AppStateService.cs | 150 ++++++++++------- .../Services/AuthService.cs | 1 + .../Services/StorageService.cs | 152 ++++++++++++++++++ .../ViewModels/DashboardViewModel.cs | 40 ++--- .../ViewModels/ProjectSettingsViewModel.cs | 2 +- .../Views/DashboardView.xaml | 4 +- src/Apps/Corathing.Organizer/appsettings.json | 1 + .../Bases/AppDashboardState.cs | 2 +- .../Corathing.Contracts/Bases/AppSettings.cs | 1 + .../Corathing.Contracts/Bases/ProjectState.cs | 2 +- .../Bases/WorkflowState.cs | 2 +- .../Services/IAppStateService.cs | 7 + .../Services/IStorageService.cs | 10 ++ .../Services/IWidgetService.cs | 2 + .../Widgets/Timers/TimerWidget.xaml | 2 +- 19 files changed, 388 insertions(+), 117 deletions(-) create mode 100644 src/Apps/Corathing.Organizer/AppData/Current/cora-organizer-settings.json diff --git a/src/Apps/Corathing.Organizer/AppData/Current/cora-organizer-settings.json b/src/Apps/Corathing.Organizer/AppData/Current/cora-organizer-settings.json new file mode 100644 index 0000000..35f3b47 --- /dev/null +++ b/src/Apps/Corathing.Organizer/AppData/Current/cora-organizer-settings.json @@ -0,0 +1,40 @@ +{ + "Preferences": { + "UseSystemTheme": false, + "Theme": "Light", + "Language": "en_US" + }, + "Packages": {}, + "Dashboards": { + "Id": "ba5b6e0a-51fa-4dc4-992e-3123cc287cb7", + "SelectedProjectId": null, + "Projects": [ + { + "Id": "926c252b-a158-4e05-8593-7cb55c10bf24", + "SelectedWorkflowId": null, + "Settings": { + "Name": "ABCasdasdasd" + }, + "WorkflowIds": [] + }, + { + "Id": "22778c82-674a-41a7-9fe9-c61d76329690", + "SelectedWorkflowId": null, + "Settings": { + "Name": "\uC548\uB155\uD558\uC138\uC694!" + }, + "WorkflowIds": [] + }, + { + "Id": "0c7f047c-e153-4496-9bc0-1d79d8e2c91b", + "SelectedWorkflowId": null, + "Settings": { + "Name": "My Project" + }, + "WorkflowIds": [] + } + ], + "Workflows": [], + "Widgets": [] + } +} \ No newline at end of file diff --git a/src/Apps/Corathing.Organizer/Corathing.Organizer.csproj b/src/Apps/Corathing.Organizer/Corathing.Organizer.csproj index 47ecc9e..1521651 100644 --- a/src/Apps/Corathing.Organizer/Corathing.Organizer.csproj +++ b/src/Apps/Corathing.Organizer/Corathing.Organizer.csproj @@ -22,8 +22,8 @@ - - + + @@ -68,6 +68,9 @@ + + Always + Always diff --git a/src/Apps/Corathing.Organizer/Models/ProjectContext.cs b/src/Apps/Corathing.Organizer/Models/ProjectContext.cs index 24159ef..6cbaaa4 100644 --- a/src/Apps/Corathing.Organizer/Models/ProjectContext.cs +++ b/src/Apps/Corathing.Organizer/Models/ProjectContext.cs @@ -11,7 +11,9 @@ using CommunityToolkit.Mvvm.Input; using Corathing.Contracts.Bases; +using Corathing.Contracts.Bases.Interfaces; using Corathing.Contracts.Services; +using Corathing.Organizer.Services; using Microsoft.Extensions.DependencyInjection; @@ -24,7 +26,6 @@ public partial class ProjectContext : ObservableObject #endregion #region Public Properties public Guid ProjectId { get; set; } - public ProjectState ProjectState; /// /// Gets or sets the title. @@ -64,11 +65,20 @@ public ObservableCollection Workflows public void AddWorkflow() { var appState = _services.GetService(); - var workflow = appState.CreateAddWorkflow(); - //appState.NewWorkflowState(); + + var workflowState = appState.CreateAddWorkflow(); var workflowContext = _services.GetService(); - workflowContext.WorkflowId = workflow.Id; workflowContext.EditMode = EditMode; + workflowContext.UpdateWorkflow(workflowState); + + if (!appState.TryGetProject(ProjectId, out var projectState)) + { + // TODO: + // Change Exception Type + throw new Exception(); + } + projectState.WorkflowIds.Add(workflowState.Id); + appState.UpdateProject(projectState); Workflows.Add(workflowContext); SelectedWorkflow = workflowContext; @@ -97,11 +107,23 @@ public static ProjectContext Create(ProjectState? state = null) public void UpdateProject(ProjectState projectState) { - var packageService = _services.GetService(); var appStateService = _services.GetService(); - var dashboardState = appStateService.GetAppDashboardState(); + ProjectId = projectState.Id; + Name = projectState.Settings.Name; + foreach (var workflowStateId in projectState.WorkflowIds) + { + if (!appStateService.TryGetWorkflow(workflowStateId, out var workflowState)) + { + // TODO: + // Change Exception Type + throw new Exception(); + } + var workflowContext = _services.GetService(); + workflowContext.EditMode = EditMode; + workflowContext.UpdateWorkflow(workflowState); + } } protected override void OnPropertyChanged(PropertyChangedEventArgs e) diff --git a/src/Apps/Corathing.Organizer/Models/WorkflowContext.cs b/src/Apps/Corathing.Organizer/Models/WorkflowContext.cs index a6f614a..76e9f44 100644 --- a/src/Apps/Corathing.Organizer/Models/WorkflowContext.cs +++ b/src/Apps/Corathing.Organizer/Models/WorkflowContext.cs @@ -16,6 +16,7 @@ using Corathing.Contracts.Bases; using Corathing.Contracts.Entries; +using Corathing.Contracts.Factories; using Corathing.Contracts.Services; using Corathing.Dashboards.WPF.Controls; using Corathing.Organizer.Controls; @@ -54,7 +55,7 @@ public partial class WorkflowContext : ObservableObject #endregion - public Guid? WorkflowId { get; set; } + public Guid WorkflowId { get; set; } public WorkflowState WorkflowState { get; set; } #region Public Properties @@ -63,7 +64,7 @@ public partial class WorkflowContext : ObservableObject /// /// The title. [ObservableProperty] - private string _title = "My Workflow"; + private string _name = "My Workflow"; [DefaultValue(false)] [ObservableProperty] @@ -80,24 +81,33 @@ public partial class WorkflowContext : ObservableObject [ObservableProperty] private ObservableCollection _widgets; + public WorkflowContext(IServiceProvider services) + { + _services = services; + Widgets = new ObservableCollection(); + } + public void UpdateWorkflow(WorkflowState workflowState) { var packageService = _services.GetService(); var appStateService = _services.GetService(); - var dashboardState = appStateService.GetAppDashboardState(); - Title = workflowState.Settings.Name; + Name = workflowState.Settings.Name; WorkflowId = workflowState.Id; - foreach (var widgetId in workflowState.WidgetIds) + foreach (var widgetStateId in workflowState.WidgetIds) { - var widgetState = dashboardState.Widgets.FirstOrDefault(widget => widget.Id == widgetId); - if (widgetState == null) - continue; + if (!appStateService.TryGetWidget(widgetStateId, out var widgetState)) + { + // TODO: + // Change Exception Type + throw new Exception(); + } if (!packageService.TryGetWidgetGenerator(widgetState.CoreSettings.TypeName, out var generator)) continue; var widgetContext = generator.CreateWidget(widgetState); + widgetContext.EditMode = EditMode; AddWidget(widgetContext); } } @@ -111,8 +121,18 @@ public void AddWidget(CoraWidgetGenerator generator) public void AddWidget(WidgetContext context) { - var dialogService = _services.GetService(); var appState = _services.GetService(); + + if (!appState.TryGetWorkflow(WorkflowId, out var workflowState)) + { + // TODO: + // Change Exception Type + throw new Exception(); + } + + appState.UpdateWidget(context.State); + workflowState.WidgetIds.Add(context.WidgetId); + appState.UpdateWorkflow(workflowState); Widgets.Add(context); } @@ -151,7 +171,7 @@ public void ConfigureWidget(WidgetHost widget) public void LayoutChanged(DashboardHost host) { var appState = _services.GetService(); - if (WorkflowId != null && appState.TryGetWorkflow(WorkflowId.Value, out var workflowState)) + if (WorkflowId != null && appState.TryGetWorkflow(WorkflowId, out var workflowState)) { appState.UpdateWorkflow(workflowState); appState.UpdateForce(); @@ -167,12 +187,6 @@ protected override void OnPropertyChanging(PropertyChangingEventArgs e) } - public WorkflowContext(IServiceProvider services) - { - _services = services; - Widgets = new ObservableCollection(); - } - #endregion Public Properties protected override void OnPropertyChanged(PropertyChangedEventArgs e) { diff --git a/src/Apps/Corathing.Organizer/Services/AppStateService.cs b/src/Apps/Corathing.Organizer/Services/AppStateService.cs index 8c254f9..85a0092 100644 --- a/src/Apps/Corathing.Organizer/Services/AppStateService.cs +++ b/src/Apps/Corathing.Organizer/Services/AppStateService.cs @@ -15,6 +15,10 @@ using Corathing.Contracts.Services; using Corathing.Organizer.Models; +using Microsoft.Extensions.DependencyInjection; + +using Windows.ApplicationModel.Calls; + using MessageBox = System.Windows.MessageBox; namespace Corathing.Organizer.Services; @@ -24,8 +28,11 @@ namespace Corathing.Organizer.Services; public class AppStateService : IAppStateService { #region Readonly Properties + private readonly IServiceProvider _services; + private const string AppSettingsFilename = "appsettings.json"; - private const string CorathingSettingsFilename = "corathing-settings.json"; + private const string OrganizerSettingsFilename = "cora-organizer-settings.json"; + private const string AppStateJsonDomBase = """ { @@ -58,17 +65,9 @@ public class AppStateService : IAppStateService private object _lockAppState; #endregion - private void SaveAppSate() - { - lock (_lockAppState) - { - - } - } - - private void ReadAppSate() + public AppStateService(IServiceProvider services) { - + _services = services; } public async Task InitializeAsync() @@ -129,8 +128,7 @@ public bool TryGetProject(Guid id, out ProjectState project) if (_cachedAppDashboardState == null) ReadOrCreateAppStateByAppSettings().Wait(); - project = ProjectState.Create(); - return true; + return _cachedAppDashboardState.HashedProjects.TryGetValue(id, out project); } public bool TryGetWorkflow(Guid id, out WorkflowState workflow) @@ -138,17 +136,15 @@ public bool TryGetWorkflow(Guid id, out WorkflowState workflow) if (_cachedAppDashboardState == null) ReadOrCreateAppStateByAppSettings().Wait(); - workflow = WorkflowState.Create(); - return true; + return _cachedAppDashboardState.HashedWorkflows.TryGetValue(id, out workflow); } - public bool TryGetWidget(Guid id, out WidgetState option) + public bool TryGetWidget(Guid id, out WidgetState widget) { if (_cachedAppDashboardState == null) ReadOrCreateAppStateByAppSettings().Wait(); - option = default; - return true; + return _cachedAppDashboardState.HashedWidgets.TryGetValue(id, out widget); } public ProjectState GetOrAddProject(Guid? id = null) @@ -274,26 +270,74 @@ public void RemoveProject(Guid projectid) public async void RemoveProject(ProjectState project) { + foreach (var workflowId in project.WorkflowIds) + { + RemoveWorkflow(workflowId); + } _cachedAppDashboardState.RemoveProject(project); await PendingWriteAppState(); } - public void RemoveWorkflow(Guid guid) + public void RemoveWorkflow(Guid workflowId) { - + if (!TryGetWorkflow(workflowId, out var workflow)) + { + // TODO: + // Change Exception Type + throw new Exception(); + } + RemoveWorkflow(workflow); } public async void RemoveWorkflow(WorkflowState workflow) { + foreach (var widgetId in workflow.WidgetIds) + { + RemoveWidget(widgetId); + } _cachedAppDashboardState.RemoveWorkflow(workflow); + await PendingWriteAppState(); + } + public void RemoveWidget(Guid widgetId) + { + if (!TryGetWidget(widgetId, out var widget)) + { + // TODO: + // Change Exception Type + throw new Exception(); + } + RemoveWidget(widget); + } + + public async void RemoveWidget(WidgetState widget) + { + _cachedAppDashboardState.RemoveWidget(widget); await PendingWriteAppState(); } #region Private Methods + private string GetOrganizerSettingsFilename() + { + AppSettings appSettings = GetAppSettings(); + + // Read or Create AppState Data + if ((appSettings.UseCustomConfiguration ?? false) && + !string.IsNullOrEmpty(appSettings.CustomConfigurationFilename)) + { + return appSettings.CustomConfigurationFilename; + } + else + { + var storageService = _services.GetService(); + string appDataPath = storageService.GetAppDataPath(); + return Path.Combine(appDataPath, OrganizerSettingsFilename); + } + } + private async Task ReadOrCreateAppSettingsFromAppPath() { @@ -333,48 +377,21 @@ private async Task WriteAppSettingsToAppPath(AppSettings appSettings) await File.WriteAllTextAsync(AppSettingsFilename, json); } - /// - /// AppState 파일 이름을 가져옴 - /// - /// - private string GetAppStatePathByAppSettings() - { - // Read or Create AppState Data - if (_cachedAppSettings.UseGlobalConfiguration ?? false) - { - return Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - CorathingSettingsFilename - ); - } - else if (_cachedAppSettings.UseAppPathConfiguration ?? false) - { - return CorathingSettingsFilename; - } - else if (!string.IsNullOrEmpty(_cachedAppSettings.CustomConfigurationFilename)) - { - return _cachedAppSettings.CustomConfigurationFilename; - } - else - { - return CorathingSettingsFilename; - } - } - private async Task ReadOrCreateAppStateByAppSettings() { - var path = GetAppStatePathByAppSettings(); - await ReadOrCreateAppStateFromPath(path); + await ReadOrCreateAppStateFromPath(GetOrganizerSettingsFilename()); } private async Task ReadOrCreateAppStateFromPath(string path) { + _isReading = true; if (!File.Exists(path)) { if (!Directory.Exists(Path.GetDirectoryName(Path.GetFullPath(path)))) { Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(path))); } + _cachedAppPreferenceState = AppPreferenceStateFactory.Create(); _cachedAppPackageState = AppPackageStateFactory.Create(); _cachedAppDashboardState = AppDashboardStateFactory.Create(); @@ -406,14 +423,33 @@ private async Task ReadOrCreateAppStateFromPath(string path) .GetProperty("Dashboards") .Deserialize(); - _cachedAppDashboardState.Refresh(); + _cachedAppDashboardState.RefreshCache(); } + _isReading = false; } + bool _isPending = false; + bool _isReading = false; + bool _isWriting = false; + private async Task PendingWriteAppState() { - // lock or Write - // await WrtieAppState(); + if (_isPending) + return; + _isPending = true; + + while (_isWriting || _isReading) + { + await Task.Delay(1); + } + await WrtieAppState(); + + _isPending = false; + } + + public async void Flush() + { + await PendingWriteAppState(); } public async void UpdateForce() @@ -423,7 +459,8 @@ public async void UpdateForce() private async Task WrtieAppState() { - string jsonString = await File.ReadAllTextAsync(GetAppStatePathByAppSettings()); + _isWriting = true; + string jsonString = await File.ReadAllTextAsync(GetOrganizerSettingsFilename()); if (string.IsNullOrEmpty(jsonString)) jsonString = AppStateJsonDomBase; @@ -433,12 +470,11 @@ private async Task WrtieAppState() rootNode["Packages"].ReplaceWith(_cachedAppPackageState); rootNode["Dashboards"].ReplaceWith(_cachedAppDashboardState); - await File.WriteAllTextAsync(GetAppStatePathByAppSettings(), + await File.WriteAllTextAsync(GetOrganizerSettingsFilename(), rootNode.ToJsonString(_serializerOptions)); + _isWriting = false; } - - private async Task UpdateInternal(AppDashboardState appState) { diff --git a/src/Apps/Corathing.Organizer/Services/AuthService.cs b/src/Apps/Corathing.Organizer/Services/AuthService.cs index b0a9dfb..04441fa 100644 --- a/src/Apps/Corathing.Organizer/Services/AuthService.cs +++ b/src/Apps/Corathing.Organizer/Services/AuthService.cs @@ -62,6 +62,7 @@ public async Task RequestAuthentication(Task request) { var authenticationInfo = await request; + return true; } diff --git a/src/Apps/Corathing.Organizer/Services/StorageService.cs b/src/Apps/Corathing.Organizer/Services/StorageService.cs index 3404c95..448b09f 100644 --- a/src/Apps/Corathing.Organizer/Services/StorageService.cs +++ b/src/Apps/Corathing.Organizer/Services/StorageService.cs @@ -1,15 +1,167 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Corathing.Contracts.Bases; +using Corathing.Contracts.Bases.Interfaces; using Corathing.Contracts.Services; +using Microsoft.Extensions.DependencyInjection; + namespace Corathing.Organizer.Services; public class StorageService : IStorageService { + private readonly IServiceProvider _services; + + // 1. Global Settings + // Roaming + // - Corathing + // - AppData + // - Current + // - cora-organizer-settings.json + // - cora-organizer-db.db + // - Packages + // - CachedNugets + // - Cora-Widgets-Basics.nuget + // - cora-module-entry.json + // - Entities + // - 81u68ug6txxwpbqz4znzgq3hfa + // - sseik38xykrr5n99zedj96nsoy + // - Packages + // - Caches + // - Cora-Widgets-Basics.nuget + // - cora-module-entry.json + + // 2. Local Settings + // CorathingOrganizer + // - AppData + // - Current + // - cora-organizer-settings.json + // - cora-organizer-db.db + // - Packages + // - CachedNugets + // - Cora-Widgets-Basics.nuget + // - cora-module-entry.json + // - Entities + // - 81u68ug6txxwpbqz4znzgq3hfa + // - sseik38xykrr5n99zedj96nsoy + // - Packages + // - Caches + // - Cora-Widgets-Basics.nuget + // - cora-module-entry.json + + // 3. Custom Path Settings + // CorathingOrganizer + // - AppData + // - Packages + // - Caches + // - Cora-Widgets-Basics.nuget + // - cora-module-entry.json + // Custom File Path + // - cora-organizer-settings.json + // - cora-organizer-db.db + // - Packages + // - CachedNugets + // - Cora-Widgets-Basics.nuget + // - cora-module-entry.json + // - Entities + // - 81u68ug6txxwpbqz4znzgq3hfa + // - sseik38xykrr5n99zedj96nsoy + + private const string RoamingAppDataFolderName = "Corathing"; + private const string AppDataFolderName = "AppData"; + private const string PackageFolderName = "Packages"; + private const string OrganizerSettingsFolderName = "Current"; + private const string EntitiesFolderName = "Entities"; + + public StorageService(IServiceProvider services) + { + _services = services; + } + + public string GetAppDataPath() + { + var appStateService = _services.GetService(); + var appSettings = appStateService.GetAppSettings(); + + // Read or Create AppState Data + if (appSettings.UseGlobalConfiguration ?? false) + { + return Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + RoamingAppDataFolderName, + AppDataFolderName, + OrganizerSettingsFolderName + ); + } + else if (appSettings.UseAppPathConfiguration ?? false) + { + return Path.Combine( + AppDataFolderName, + OrganizerSettingsFolderName + ); + } + else if (!string.IsNullOrEmpty(appSettings.CustomConfigurationFilename)) + { + return Path.GetDirectoryName(appSettings.CustomConfigurationFilename); + } + else + { + return Path.Combine( + AppDataFolderName, + OrganizerSettingsFolderName + ); + } + } + + public string GetAppPackagePath() + { + var appStateService = _services.GetService(); + var appSettings = appStateService.GetAppSettings(); + + // Read or Create AppState Data + if (appSettings.UseGlobalConfiguration ?? false) + { + return Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + RoamingAppDataFolderName, + AppDataFolderName, + PackageFolderName + ); + } + else if ((appSettings.UseCustomConfiguration ?? false) && + !string.IsNullOrEmpty(appSettings.CustomConfigurationFilename)) + { + return Path.GetDirectoryName(appSettings.CustomConfigurationFilename); + } + else // Whene use local path + { + return Path.Combine( + AppDataFolderName, + PackageFolderName + ); + } + } + + public string GetEntityFolder(IEntity entity) + { + return Path.Combine( + GetAppDataPath(), + EntitiesFolderName, + entity.Id.ToString().Replace("-", "") + ); + } + + public FileStream OpenFile(IEntity entity, string path, FileMode mode) + { + return File.Open( + Path.Combine(GetEntityFolder(entity), path), mode); + } + public void Delete(string filename) { throw new NotImplementedException(); diff --git a/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs b/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs index 59ce23e..bd3b92e 100644 --- a/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs +++ b/src/Apps/Corathing.Organizer/ViewModels/DashboardViewModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -250,42 +251,23 @@ private void UpdateDashboard() var appStateService = _services.GetService(); var dashboardState = appStateService.GetAppDashboardState(); - List widgetContexts = new List(); - foreach (var widgetState in dashboardState.Widgets) - { - if (!packageService.TryGetWidgetGenerator(widgetState.CoreSettings.TypeName, out var generator)) - { - continue; - } - widgetContexts.Add(generator.CreateWidget(widgetState)); - } - - List workflowContexts = new List(); - foreach (var workflowState in dashboardState.Workflows) - { - var workflowContext = _services.GetService(); - workflowContext.UpdateWorkflow(workflowState); - workflowContexts.Add(workflowContext); - } - foreach (var projectState in dashboardState.Projects) { var projectContext = _services.GetService(); projectContext.Name = projectState.Settings.Name; - //projectContext.ProjectId - // TODO:::: - } + projectContext.EditMode = EditMode; + projectContext.UpdateProject(projectState); -// Projects.AddRange(new[] -//{ -// services.GetService() -// }); - SelectedProject = Projects.FirstOrDefault(); - if (SelectedProject != null) + Projects.Add(projectContext); + } + if (dashboardState.SelectedProjectId != null) { + SelectedProject = Projects.FirstOrDefault(context => context.ProjectId == dashboardState.SelectedProjectId); + } + if (SelectedProject == null) + { + SelectedProject = Projects.FirstOrDefault(); } - //dashboardState.Projects; - //Projects.AddRange() } private void UpdateAvailableWidgets() diff --git a/src/Apps/Corathing.Organizer/ViewModels/ProjectSettingsViewModel.cs b/src/Apps/Corathing.Organizer/ViewModels/ProjectSettingsViewModel.cs index 2e3c18a..af7dd80 100644 --- a/src/Apps/Corathing.Organizer/ViewModels/ProjectSettingsViewModel.cs +++ b/src/Apps/Corathing.Organizer/ViewModels/ProjectSettingsViewModel.cs @@ -103,7 +103,7 @@ public void Apply() } } - appStateService.UpdateForce(); + appStateService.Flush(); } private ProjectState CopyProject(Guid originalProjectId) diff --git a/src/Apps/Corathing.Organizer/Views/DashboardView.xaml b/src/Apps/Corathing.Organizer/Views/DashboardView.xaml index 554cd1f..67e7261 100644 --- a/src/Apps/Corathing.Organizer/Views/DashboardView.xaml +++ b/src/Apps/Corathing.Organizer/Views/DashboardView.xaml @@ -180,7 +180,7 @@ - + - + diff --git a/src/Apps/Corathing.Organizer/appsettings.json b/src/Apps/Corathing.Organizer/appsettings.json index 2ab0a5b..da6ed31 100644 --- a/src/Apps/Corathing.Organizer/appsettings.json +++ b/src/Apps/Corathing.Organizer/appsettings.json @@ -11,6 +11,7 @@ "Organizer": { "UseGlobalConfiguration": false, "UseAppPathConfiguration": true, + "UseCustomConfiguration": false, "CustomConfigurationFilename": "" } } diff --git a/src/Shared/Corathing.Contracts/Bases/AppDashboardState.cs b/src/Shared/Corathing.Contracts/Bases/AppDashboardState.cs index bdccede..500a93d 100644 --- a/src/Shared/Corathing.Contracts/Bases/AppDashboardState.cs +++ b/src/Shared/Corathing.Contracts/Bases/AppDashboardState.cs @@ -116,7 +116,7 @@ public void UpdateWidget(WidgetState widget) Widgets.Add(widget); } - public void Refresh() + public void RefreshCache() { HashedProjects.Clear(); HashedWorkflows.Clear(); diff --git a/src/Shared/Corathing.Contracts/Bases/AppSettings.cs b/src/Shared/Corathing.Contracts/Bases/AppSettings.cs index 7933f6b..6d03ce6 100644 --- a/src/Shared/Corathing.Contracts/Bases/AppSettings.cs +++ b/src/Shared/Corathing.Contracts/Bases/AppSettings.cs @@ -10,5 +10,6 @@ public class AppSettings { public bool? UseGlobalConfiguration { get; set; } public bool? UseAppPathConfiguration { get; set; } + public bool? UseCustomConfiguration { get; set; } public string? CustomConfigurationFilename { get; set; } } diff --git a/src/Shared/Corathing.Contracts/Bases/ProjectState.cs b/src/Shared/Corathing.Contracts/Bases/ProjectState.cs index 2210083..aa1d138 100644 --- a/src/Shared/Corathing.Contracts/Bases/ProjectState.cs +++ b/src/Shared/Corathing.Contracts/Bases/ProjectState.cs @@ -14,7 +14,7 @@ public class ProjectState : IProjectState public Guid Id { get; set; } public Guid? SelectedWorkflowId { get; set; } public ProjectSettings Settings { get; set; } - public List WorkflowIds { get; set; } + public List WorkflowIds { get; set; } = new List(); public static ProjectState Create() { diff --git a/src/Shared/Corathing.Contracts/Bases/WorkflowState.cs b/src/Shared/Corathing.Contracts/Bases/WorkflowState.cs index a318e67..d60e3ec 100644 --- a/src/Shared/Corathing.Contracts/Bases/WorkflowState.cs +++ b/src/Shared/Corathing.Contracts/Bases/WorkflowState.cs @@ -12,7 +12,7 @@ namespace Corathing.Contracts.Bases; public class WorkflowState : IWorkflowState { public Guid Id { get; set; } - public List WidgetIds { get; set; } + public List WidgetIds { get; set; } = new List(); public WorkflowSettings Settings { get; set; } public int MaxColumns { get; set; } = 16; public int VisibleRows { get; set; } = 8; diff --git a/src/Shared/Corathing.Contracts/Services/IAppStateService.cs b/src/Shared/Corathing.Contracts/Services/IAppStateService.cs index 07edf6c..4ecd958 100644 --- a/src/Shared/Corathing.Contracts/Services/IAppStateService.cs +++ b/src/Shared/Corathing.Contracts/Services/IAppStateService.cs @@ -11,8 +11,11 @@ namespace Corathing.Contracts.Services; public interface IAppStateService { Task InitializeAsync(); + + AppSettings GetAppSettings(); void UpdateAppSettings(AppSettings appSettings); + AppPreferenceState GetAppPreferenceState(); AppPackageState GetAppPackageState(); AppDashboardState GetAppDashboardState(); @@ -29,6 +32,8 @@ public interface IAppStateService void RemoveProject(Guid projectId); void RemoveWorkflow(WorkflowState workflow); void RemoveWorkflow(Guid workflowId); + void RemoveWidget(WidgetState widget); + void RemoveWidget(Guid widgetId); bool TryGetProject(Guid id, out ProjectState project); bool TryGetWorkflow(Guid id, out WorkflowState workflow); @@ -38,4 +43,6 @@ public interface IAppStateService void UpdateWorkflow(WorkflowState workflow); void UpdateWidget(WidgetState widget); void UpdateForce(); + + void Flush(); } diff --git a/src/Shared/Corathing.Contracts/Services/IStorageService.cs b/src/Shared/Corathing.Contracts/Services/IStorageService.cs index f3586f0..468b7ce 100644 --- a/src/Shared/Corathing.Contracts/Services/IStorageService.cs +++ b/src/Shared/Corathing.Contracts/Services/IStorageService.cs @@ -4,6 +4,8 @@ using System.Text; using System.Threading.Tasks; +using Corathing.Contracts.Bases.Interfaces; + namespace Corathing.Contracts.Services; public enum StorageHandleCode @@ -30,6 +32,14 @@ public class StorageHandleArgs : IStorageHandleArgs public interface IStorageService { + string GetAppDataPath(); + + string GetAppPackagePath(); + + string GetEntityFolder(IEntity entity); + + FileStream OpenFile(IEntity entity, string path, FileMode mode); + Task> ReadAsync(string filename); Task> SaveAsync(string filename, T content); diff --git a/src/Shared/Corathing.Contracts/Services/IWidgetService.cs b/src/Shared/Corathing.Contracts/Services/IWidgetService.cs index 1e76639..5f7dc83 100644 --- a/src/Shared/Corathing.Contracts/Services/IWidgetService.cs +++ b/src/Shared/Corathing.Contracts/Services/IWidgetService.cs @@ -4,6 +4,8 @@ using System.Text; using System.Threading.Tasks; +using Corathing.Contracts.Bases.Interfaces; + namespace Corathing.Contracts.Services; public interface IWidgetService diff --git a/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/TimerWidget.xaml b/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/TimerWidget.xaml index b7162a7..e6dd4d7 100644 --- a/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/TimerWidget.xaml +++ b/src/Widgets/Corathing.Widgets.Basics/Widgets/Timers/TimerWidget.xaml @@ -80,7 +80,7 @@ + Visibility="{Binding IsRunning, Converter={StaticResource InvertBoolNullToVisibilityConverter}}">