From 9e91305de15d93fda617b4da240edc50d31b7b83 Mon Sep 17 00:00:00 2001 From: fahminlb33 Date: Sun, 28 Feb 2021 11:06:42 +0700 Subject: [PATCH] Cleanup --- src/KFlearning/Services/HistoryService.cs | 16 ++------ src/KFlearning/Services/HistorySettings.cs | 11 +----- src/KFlearning/Services/ProjectService.cs | 18 ++------- src/KFlearning/Services/TelemetryService.cs | 39 +++++++++++-------- src/KFlearning/Services/TemplateService.cs | 17 ++------ .../Services/VisualStudioCodeService.cs | 16 +------- 6 files changed, 35 insertions(+), 82 deletions(-) diff --git a/src/KFlearning/Services/HistoryService.cs b/src/KFlearning/Services/HistoryService.cs index afa9fae..45b1bf7 100644 --- a/src/KFlearning/Services/HistoryService.cs +++ b/src/KFlearning/Services/HistoryService.cs @@ -1,16 +1,7 @@ -// SOLUTION : KFlearning -// PROJECT : KFlearning -// FILENAME : HistoryService.cs -// AUTHOR : Fahmi Noor Fiqri, Kodesiana.com -// WEBSITE : https://kodesiana.com -// REPO : https://github.com/Kodesiana or https://github.com/fahminlb33 -// -// This file is part of KFlearning, see LICENSE. -// See this code in repository URL above! - -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using KFlearning.Core.Services; +using KFlearning.Models; namespace KFlearning.Services { @@ -25,7 +16,7 @@ public interface IHistoryService : IUsesPersistance public class HistoryService : IHistoryService { - private const int HistorySize = 10; + private const int HistorySize = 20; private const string HistorySettingsName = "History.Settings"; private readonly List _projects = new List(); @@ -42,6 +33,7 @@ public HistoryService(IPersistanceStorage storage) public void Add(Project project) { if (!RecordHistory) return; + _projects.RemoveAll(x => x.Path == project.Path); _projects.Add(project); EnsureSize(); diff --git a/src/KFlearning/Services/HistorySettings.cs b/src/KFlearning/Services/HistorySettings.cs index 126f736..2062200 100644 --- a/src/KFlearning/Services/HistorySettings.cs +++ b/src/KFlearning/Services/HistorySettings.cs @@ -1,13 +1,4 @@ -// SOLUTION : KFlearning -// PROJECT : KFlearning -// FILENAME : HistorySettings.cs -// AUTHOR : Fahmi Noor Fiqri, Kodesiana.com -// WEBSITE : https://kodesiana.com -// REPO : https://github.com/Kodesiana or https://github.com/fahminlb33 -// -// This file is part of KFlearning, see LICENSE. -// See this code in repository URL above! - +using KFlearning.Models; using System.Collections.Generic; namespace KFlearning.Services diff --git a/src/KFlearning/Services/ProjectService.cs b/src/KFlearning/Services/ProjectService.cs index 7d86711..a9c43c4 100644 --- a/src/KFlearning/Services/ProjectService.cs +++ b/src/KFlearning/Services/ProjectService.cs @@ -1,21 +1,9 @@ -// SOLUTION : KFlearning -// PROJECT : KFlearning -// FILENAME : ProjectService.cs -// AUTHOR : Fahmi Noor Fiqri, Kodesiana.com -// WEBSITE : https://kodesiana.com -// REPO : https://github.com/Kodesiana or https://github.com/fahminlb33 -// -// This file is part of KFlearning, see LICENSE. -// See this code in repository URL above! - -#region - +using System; using System.IO; using KFlearning.Core.Services; +using KFlearning.Models; using Newtonsoft.Json; -#endregion - namespace KFlearning.Services { public interface IProjectService @@ -49,8 +37,8 @@ public Project Load(string path) var content = File.ReadAllText(Path.Combine(path, MetadataFileName)); var metadata = JsonConvert.DeserializeObject(content); - // synchronize saved path metadata.Path = path; + metadata.LastOpenAt = DateTime.Now; Save(metadata); return metadata; diff --git a/src/KFlearning/Services/TelemetryService.cs b/src/KFlearning/Services/TelemetryService.cs index 395180b..1694492 100644 --- a/src/KFlearning/Services/TelemetryService.cs +++ b/src/KFlearning/Services/TelemetryService.cs @@ -1,16 +1,5 @@ -// SOLUTION : KFlearning -// PROJECT : KFlearning -// FILENAME : TelemetryService.cs -// AUTHOR : Fahmi Noor Fiqri, Kodesiana.com -// WEBSITE : https://kodesiana.com -// REPO : https://github.com/Kodesiana or https://github.com/fahminlb33 -// -// This file is part of KFlearning, see LICENSE. -// See this code in repository URL above! - -using KFlearning.Core.API; +using KFlearning.Core.API; using KFlearning.Core.Services; -using KFlearning.Properties; using System; using System.Threading.Tasks; @@ -36,9 +25,22 @@ public void Load() try { _infoService.Query(); - Task.WaitAll(_telemetry.SendAppStart(Resources.AppName, _infoService.DeviceId), - _telemetry.SendIdentification(_infoService.DeviceId, _infoService.CPU, _infoService.RAM, - _infoService.OS, _infoService.Architecture)); + Task.WaitAll( + _telemetry.SendTelemetry(new UserEngagementModel + { + DeviceId = _infoService.DeviceId, + AppName = "kflearning", + Event = "app_start" + }), + _telemetry.SendIdentification(new DeviceIdentificationModel + { + DeviceId = _infoService.DeviceId, + CPU = _infoService.CPU, + RAM = _infoService.RAM, + OS = _infoService.OS, + Architecture = _infoService.Architecture + }) + ); } catch (Exception) { @@ -51,7 +53,12 @@ public void Save() try { _infoService.Query(); - Task.WaitAll(_telemetry.SendAppExit(Resources.AppName, _infoService.DeviceId)); + Task.WaitAll(_telemetry.SendTelemetry(new UserEngagementModel + { + DeviceId = _infoService.DeviceId, + AppName = "kflearning", + Event = "app_stop" + })); } catch (Exception) { diff --git a/src/KFlearning/Services/TemplateService.cs b/src/KFlearning/Services/TemplateService.cs index 1c7e029..ae6b26f 100644 --- a/src/KFlearning/Services/TemplateService.cs +++ b/src/KFlearning/Services/TemplateService.cs @@ -1,16 +1,5 @@ -// SOLUTION : KFlearning -// PROJECT : KFlearning -// FILENAME : TemplateService.cs -// AUTHOR : Fahmi Noor Fiqri, Kodesiana.com -// WEBSITE : https://kodesiana.com -// REPO : https://github.com/Kodesiana or https://github.com/fahminlb33 -// -// This file is part of KFlearning, see LICENSE. -// See this code in repository URL above! - -using System.Collections.Generic; -using Castle.Windsor; -using KFlearning.Core.Services; +using System.Collections.Generic; +using KFlearning.TemplateProvider; namespace KFlearning.Services { @@ -36,7 +25,7 @@ public IEnumerable GetTemplates() public void Extract(ITemplateProvider template, string outputPath) { - template.Provide(outputPath); + template.Scaffold(outputPath); } } } \ No newline at end of file diff --git a/src/KFlearning/Services/VisualStudioCodeService.cs b/src/KFlearning/Services/VisualStudioCodeService.cs index 6e032ec..83e225c 100644 --- a/src/KFlearning/Services/VisualStudioCodeService.cs +++ b/src/KFlearning/Services/VisualStudioCodeService.cs @@ -1,18 +1,4 @@ -// SOLUTION : KFlearning -// PROJECT : KFlearning -// FILENAME : VisualStudioCodeService.cs -// AUTHOR : Fahmi Noor Fiqri, Kodesiana.com -// WEBSITE : https://kodesiana.com -// REPO : https://github.com/Kodesiana or https://github.com/fahminlb33 -// -// This file is part of KFlearning, see LICENSE. -// See this code in repository URL above! - -#region - -using KFlearning.Core.Services; - -#endregion +using KFlearning.Core.Services; namespace KFlearning.Services {