Added chat to old sessions

This commit is contained in:
2015-10-20 12:58:37 +02:00
parent 558d569e05
commit c69bfda291
3 changed files with 26 additions and 5 deletions
+9 -2
View File
@@ -57,13 +57,20 @@ namespace ErgometerServer
sendToDoctor(new NetCommand(user.Key, user.Value, input.Session));
}
break;
case NetCommand.RequestType.CHAT:
List<ChatMessage> chat = FileHandler.ReadChat(input.Session);
foreach (ChatMessage msg in chat)
{
Thread.Sleep(10);
sendToDoctor(new NetCommand(msg.Message, msg.IsDoctor, input.Session));
}
break;
case NetCommand.RequestType.OLDDATA:
List<Meting> metingen = FileHandler.ReadMetingen(input.Session);
foreach (Meting meting in metingen)
{
Thread.Sleep(10);
sendToDoctor(new NetCommand(meting, input.Session));
Console.WriteLine(new NetCommand(meting, input.Session));
sendToDoctor(new NetCommand(meting, input.Session));
}
break;
case NetCommand.RequestType.ALLSESSIONS:
+2 -2
View File
@@ -33,9 +33,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ErgometerLibrary, Version=1.0.3.1, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="ErgometerLibrary, Version=1.0.3.5, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\ErgometerLibrary\ErgometerLibrary\bin\Debug\ErgometerLibrary.dll</HintPath>
<HintPath>..\..\..\ErgometerLibrary\ErgometerLibrary\ErgometerLibrary\bin\Debug\ErgometerLibrary.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
+15 -1
View File
@@ -71,6 +71,7 @@ namespace ErgometerServer
File.WriteAllText(GetSessionMetingen(session), json);
Console.WriteLine("Writing metingen: " + GetSessionMetingen(session));
}
File.WriteAllText(GetSessionFile(session), File.ReadAllText(GetSessionFile(session)) + Environment.NewLine + Helper.Now);
}
public static List<Meting> ReadMetingen(int session)
@@ -101,6 +102,7 @@ namespace ErgometerServer
{
if (Directory.Exists(GetSessionFolder(session)))
{
/*
string write = "";
foreach (ChatMessage c in chat)
{
@@ -109,9 +111,21 @@ namespace ErgometerServer
File.WriteAllText(GetSessionChat(session), write);
Console.WriteLine("Writing chat: " + GetSessionChat(session));
*/
string json = Newtonsoft.Json.JsonConvert.SerializeObject(chat.ToArray());
File.WriteAllText(GetSessionChat(session), json);
Console.WriteLine("Writing chat: " + GetSessionChat(session));
}
}
public static List<ChatMessage> ReadChat(int session)
{
string json = File.ReadAllText(GetSessionChat(session));
List<ChatMessage> chat = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ChatMessage>>(json);
return chat;
}
private static string GetSessionFolder(int session)
{
return Path.Combine(DataFolder, session.ToString());
@@ -126,7 +140,7 @@ namespace ErgometerServer
}
private static string GetSessionChat(int session)
{
return Path.Combine(DataFolder, session.ToString(), "chat.log");
return Path.Combine(DataFolder, session.ToString(), "chat.ergo");
}
//USER MANAGEMENT