Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fahminlb33 committed Feb 28, 2021
1 parent 492e132 commit 9e91305
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 82 deletions.
16 changes: 4 additions & 12 deletions src/KFlearning/Services/HistoryService.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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<Project> _projects = new List<Project>();
Expand All @@ -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();
Expand Down
11 changes: 1 addition & 10 deletions src/KFlearning/Services/HistorySettings.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 3 additions & 15 deletions src/KFlearning/Services/ProjectService.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -49,8 +37,8 @@ public Project Load(string path)
var content = File.ReadAllText(Path.Combine(path, MetadataFileName));
var metadata = JsonConvert.DeserializeObject<Project>(content);

// synchronize saved path
metadata.Path = path;
metadata.LastOpenAt = DateTime.Now;
Save(metadata);

return metadata;
Expand Down
39 changes: 23 additions & 16 deletions src/KFlearning/Services/TelemetryService.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down
17 changes: 3 additions & 14 deletions src/KFlearning/Services/TemplateService.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -36,7 +25,7 @@ public IEnumerable<ITemplateProvider> GetTemplates()

public void Extract(ITemplateProvider template, string outputPath)
{
template.Provide(outputPath);
template.Scaffold(outputPath);
}
}
}
16 changes: 1 addition & 15 deletions src/KFlearning/Services/VisualStudioCodeService.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down

0 comments on commit 9e91305

Please sign in to comment.