Changed old sessions

This commit is contained in:
Aareschluchtje
2015-10-20 12:03:12 +02:00
parent d5bb2d555d
commit 801c0fd25f
3 changed files with 15 additions and 11 deletions
+5 -5
View File
@@ -74,11 +74,11 @@ namespace ErgometerServer
} }
break; break;
case NetCommand.RequestType.ALLSESSIONS: case NetCommand.RequestType.ALLSESSIONS:
int[] sessions = FileHandler.GetAllSessions(); List<Tuple<int, string, double>> sessions = FileHandler.GetAllSessions();
sendToDoctor(new NetCommand(NetCommand.LengthType.SESSIONS, sessions.Length, input.Session)); sendToDoctor(new NetCommand(NetCommand.LengthType.SESSIONS, sessions.Count, input.Session));
for (int i = 0; i < sessions.Length; i++) foreach(Tuple<int,string,double> session in sessions)
{ {
sendToDoctor(new NetCommand(NetCommand.CommandType.SESSION, sessions[i])); sendToDoctor(new NetCommand(session.Item2, session.Item3, session.Item1));
} }
break; break;
case NetCommand.RequestType.SESSIONDATA: case NetCommand.RequestType.SESSIONDATA:
@@ -86,7 +86,7 @@ namespace ErgometerServer
sendToDoctor(new NetCommand(NetCommand.LengthType.SESSIONDATA, currentsessionsdata.Count, input.Session)); sendToDoctor(new NetCommand(NetCommand.LengthType.SESSIONDATA, currentsessionsdata.Count, input.Session));
foreach (Tuple<int, string> ses in currentsessionsdata) foreach (Tuple<int, string> ses in currentsessionsdata)
{ {
sendToDoctor(new NetCommand(ses.Item2, false, ses.Item1)); sendToDoctor(new NetCommand(ses.Item2, Helper.Now, ses.Item1));
} }
break; break;
default: default:
+2 -2
View File
@@ -33,9 +33,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ErgometerLibrary, Version=1.0.2.8, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="ErgometerLibrary, Version=1.0.3.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\ErgometerLibrary\ErgometerLibrary\ErgometerLibrary\bin\Debug\ErgometerLibrary.dll</HintPath> <HintPath>..\..\ErgometerLibrary\ErgometerLibrary\bin\Debug\ErgometerLibrary.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <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> <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
+8 -4
View File
@@ -82,15 +82,19 @@ namespace ErgometerServer
return metingen; return metingen;
} }
public static int[] GetAllSessions() public static List<Tuple<int, string, double>> GetAllSessions()
{ {
string[] directories = Directory.GetDirectories(DataFolder); string[] directories = Directory.GetDirectories(DataFolder);
int[] sessions = new int[directories.Length]; List<Tuple<int,string,double>> sessiondata = new List<Tuple<int, string, double>>();
for (int i = 0; i < directories.Length; i++) for (int i = 0; i < directories.Length; i++)
{ {
sessions[i] = int.Parse(directories[i]); string props = File.ReadAllText(GetSessionFile(int.Parse(directories[i])));
string[] properties = props.Split('\n');
string name = properties[0];
double date = double.Parse(properties[1]);
sessiondata.Add(new Tuple<int, string, double>(int.Parse(directories[i]), name, date));
} }
return sessions; return sessiondata;
} }
public static void WriteChat(int session, List<ChatMessage> chat) public static void WriteChat(int session, List<ChatMessage> chat)