Skip to content
This repository was archived by the owner on Apr 17, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions Minutes.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34511.84
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Minutes", "Minutes.csproj", "{F321B42E-11CB-4273-9098-49131F8A0218}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Minutes", "Minutes\Minutes.csproj", "{1C650548-4AE1-4D71-AB1F-B025A8427713}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Storage", "Storage\Storage.csproj", "{8DC74F45-E20E-4B8D-A46C-715C0235AF19}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F321B42E-11CB-4273-9098-49131F8A0218}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F321B42E-11CB-4273-9098-49131F8A0218}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F321B42E-11CB-4273-9098-49131F8A0218}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F321B42E-11CB-4273-9098-49131F8A0218}.Release|Any CPU.Build.0 = Release|Any CPU
{1C650548-4AE1-4D71-AB1F-B025A8427713}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C650548-4AE1-4D71-AB1F-B025A8427713}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C650548-4AE1-4D71-AB1F-B025A8427713}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C650548-4AE1-4D71-AB1F-B025A8427713}.Release|Any CPU.Build.0 = Release|Any CPU
{8DC74F45-E20E-4B8D-A46C-715C0235AF19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DC74F45-E20E-4B8D-A46C-715C0235AF19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DC74F45-E20E-4B8D-A46C-715C0235AF19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DC74F45-E20E-4B8D-A46C-715C0235AF19}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public async void RegisterUser(object o)
}
try
{
Message = "Creating account...";
using var httpClient = new HttpClient();
var jsonContent = new StringContent(
JsonConvert.SerializeObject(new { email = Mail, password = new System.Net.NetworkCredential(string.Empty, password).Password }),
Expand Down Expand Up @@ -84,6 +85,7 @@ public async void LoginUser(object o)
}
try
{
Message = "Logging in...";
using var httpClient = new HttpClient();
var jsonContent = new StringContent(JsonConvert.SerializeObject(
new { email = Mail, password = new System.Net.NetworkCredential(string.Empty, password).Password }), Encoding.UTF8, "application/json");
Expand Down
4 changes: 4 additions & 0 deletions Minutes.csproj → Minutes/Minutes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,8 @@
<Folder Include="Resources\Trans\" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Storage\Storage.csproj" />
</ItemGroup>

</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions Storage/IStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Storage;
public interface IStore
{
// Yes, this could be a property.
// No, it will not be a property.
// Why? Because you don't want to set it willy-nilly,
// so you will have to suffer whenever you want to change it.
public string GetLocation();
public void SetLocation(string location);
public IWriter CreateWriter(string identity);
public IReader CreateReader(string identity);
}
15 changes: 15 additions & 0 deletions Storage/Reader/IReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Storage;
public interface IReader
{
public void Read();
public DateTime Created();
public TimeOnly Duration();
public string Summary();
public string FullText();
}
49 changes: 49 additions & 0 deletions Storage/Reader/SimpleReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Storage.Reader;
public class SimpleReader : IReader
{
string _path;
string _identity;
DateTime _created;
TimeOnly _duration;
string _summary;
string _fulltext;
public SimpleReader(string path, string identity)
{
_path = path;
_identity = identity;
_created = DateTime.MinValue;
_duration = new TimeOnly();
_summary = string.Empty;
_fulltext = string.Empty;
}

public void Read()
{
string contents;
using (StreamReader reader = new StreamReader(Path.Combine(_path,_identity)))
{
contents = reader.ReadToEnd();
}
contents.ReplaceLineEndings();
var parts = contents.Split(new string[] {"###CONFIG###","###SUMMARY###","###FULLTEXT###" }, StringSplitOptions.TrimEntries);
Dictionary<string,string> dict = new Dictionary<string,string>();
foreach (var assignment in parts[1].Split(Environment.NewLine)) {
var temp = assignment.Split('=', StringSplitOptions.TrimEntries);
dict[temp[0]] = temp[1];
}
_created = DateTime.Parse(dict["created"]);
_duration = TimeOnly.Parse(dict["duration"]);
_summary = parts[2];
_fulltext = parts[3];
}
public DateTime Created() => _created;
public TimeOnly Duration() => _duration;
public string Summary() => _summary;
public string FullText() => _fulltext;
}
10 changes: 10 additions & 0 deletions Storage/Storage.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Library</OutputType>
</PropertyGroup>

</Project>
16 changes: 16 additions & 0 deletions Storage/Store.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.Win32;
using Storage.Reader;
using Storage.Writer;

namespace Storage;

public class Store : IStore
{
private static readonly string _key= "HKEY_CURRENT_USER\\Software\\TGC";

private static readonly string _valueName = "DaWae";
public string GetLocation() => (string)Registry.GetValue(_key, _valueName, "");
public void SetLocation(string location) => Registry.SetValue(_key, _valueName, location);
public IWriter CreateWriter(string identity) => new SimpleWriter(GetLocation(),identity);
public IReader CreateReader(string identity) => new SimpleReader(GetLocation(), identity);
}
21 changes: 21 additions & 0 deletions Storage/Writer/IWriter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Storage;
public interface IWriter
{
public void Created(DateTime started);
public void Duration(TimeOnly duration);


// We are using "in string" to avoid excessive copying.
// There may be better ways to do it,
// depending on how those are handled in the main implementation.
public void Summary(in string summary);
public void FullText(in string text);

public void Write();
}
43 changes: 43 additions & 0 deletions Storage/Writer/SimpleWriter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Storage.Writer;
internal class SimpleWriter : IWriter
{
string _path;
string _identity;

public SimpleWriter(string path, string identity)
{
_path = path;
_identity = identity;
}

DateTime _created;
TimeOnly _duration;
string _summary = string.Empty;
string _fulltext = string.Empty;
public void Created(DateTime started) => _created = started;
public void Duration(TimeOnly duration) => _duration = duration;
public void FullText(in string text) => _fulltext = text;
public void Summary(in string summary) => _summary = summary;
public void Write()
{
using var writer = new StreamWriter(Path.Combine(_path,_identity));
writer.Write("###CONFIG###");
writer.Write("\nname=");
writer.Write(_identity);
writer.Write("\ncreated=");
writer.Write(_created.ToString());
writer.Write("\nduration=");
writer.Write(_duration.ToString());
writer.Write("\n###SUMMARY###\n");
writer.Write(_summary);
writer.Write("\n###FULLTEXT###\n");
writer.Write(_fulltext);

}
}