public static User GetChatUser(string pEmail, string pPassword) { if (ConnectToDatabase()) { try { string query = "SELECT * FROM \"User\" WHERE \"Mail\"=\'" + pEmail + "\' AND \"Password\"=\'" + pPassword + "\'"; NpgsqlDataAdapter da = new NpgsqlDataAdapter(query, mDatabaseConnection); ds.Reset(); da.Fill(ds); dt = ds.Tables[0]; User u = new User(); DataRow row = dt.Rows[0]; u.UserID = row.Field<int>(dt.Columns[0]); u.Email = row.Field<string>(dt.Columns[1]); u.Username = row.Field<string>(dt.Columns[3]); u.IsAdmin = row.Field<bool>(dt.Columns[5]); //u.LastOnline = row.Field<DateTime>(dt.Columns[4]); return u; } catch (Exception ex) { LoggingService.LogToFile(ex); return null; } finally { DisconnectFromDatabase(); } } return null; }
public static User[] GetChatUsers() { if (ConnectToDatabase()) { string query = "SELECT \"Mail\", \"Username\", \"LastLogin\", \"IsAdmin\", \"ID\" FROM User"; NpgsqlDataAdapter da = new NpgsqlDataAdapter(query, mDatabaseConnection); ds.Reset(); da.Fill(ds); dt = ds.Tables[0]; User[] users = new User[dt.Rows.Count]; int count = 0; foreach (DataRow row in dt.Rows) { User u = new User(); u.UserID = row.Field<int>(dt.Columns[4]); u.Email = row.Field<string>(dt.Columns[0]); u.Username = row.Field<string>(dt.Columns[1]); u.IsAdmin = row.Field<bool>(dt.Columns[3]); u.LastOnline = row.Field<DateTime>(dt.Columns[2]); users[count] = u; count++; } DisconnectFromDatabase(); return users; } return null; }
public void ConnectToServer(string pName) { if (Users.SingleOrDefault(x => x.Username == pName) != null) { throw new InvalidOperationException("Dieser Username ist schon vorhanden!"); } IChatUser user = OperationContext.Current.GetCallbackChannel<IChatUser>(); User u = new User(); u.Username = pName; u.Callback = user; if (!ConnectedUsers.Contains(user)) { Users.Add(u); ConnectedUsers.Add(user); } LoggingService.Log(u.Username + " connected", LogStatus.INFO); SendServerMessage(u.Username + " hat den Server betreten"); //UpdateAllUserLists(); }
public ComConServer() { if (Server == null) { User u = new User(); u.Username = "******"; Server = u; } }
public ChatServerFunctions() { if (Server == null) { User u = new User(); u.Username = "******"; Users.Add(u); Server = u; } }