Fixed duplicate old sessions

This commit is contained in:
2015-10-20 15:09:51 +02:00
parent 7bfa7def9a
commit ad74945882
3 changed files with 25 additions and 5 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ namespace ErgometerServer
foreach(Tuple<int,string,double> session in sessions)
{
sendToDoctor(new NetCommand(session.Item2, session.Item3, session.Item1));
Console.WriteLine(new NetCommand(session.Item2, session.Item3, session.Item1));
Thread.Sleep(10);
}
break;
+23 -2
View File
@@ -87,15 +87,36 @@ namespace ErgometerServer
{
string[] directories = Directory.GetDirectories(DataFolder);
List<Tuple<int,string,double>> sessiondata = new List<Tuple<int, string, double>>();
for (int i = 0; i < directories.Length; i++)
{
string directoryname = Path.GetFileName(directories[i]);
string props = File.ReadAllText(GetSessionFile(int.Parse(directoryname)));
string[] properties = props.Split('\n');
string[] stringSeparators = new string[] { "\r\n" };
string[] properties = props.Split(stringSeparators, StringSplitOptions.None);
int session = int.Parse(directoryname);
bool active = false;
foreach(ClientThread t in Server.clients)
{
if (t.session == session)
active = true;
}
string name = properties[0];
double date = double.Parse(properties[1]);
sessiondata.Add(new Tuple<int, string, double>(int.Parse(directoryname), name, date));
if (!active)
{
Tuple<int, string, double> tup = new Tuple<int, string, double>(session, name, date);
sessiondata.Add(tup);
}
}
return sessiondata;
}
+1 -2
View File
@@ -17,7 +17,7 @@ namespace ErgometerServer
new Server();
}
public List<ClientThread> clients { get; }
public static List<ClientThread> clients = new List<ClientThread>();
private DoctorThread doctor;
public Dictionary<string, string> users;
@@ -28,7 +28,6 @@ namespace ErgometerServer
FileHandler.CheckStorage();
users = FileHandler.LoadUsers();
clients = new List<ClientThread>();
TcpListener listener = new TcpListener(NetHelper.GetIP("127.0.0.1"), 8888);
//TcpListener listener = new TcpListener(NetHelper.GetIP(GetIp()), 8888);