Skip to content

Commit

Permalink
Modify office room
Browse files Browse the repository at this point in the history
  • Loading branch information
geoje committed May 31, 2021
1 parent dad36dd commit 8577f35
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
35 changes: 22 additions & 13 deletions Server/Classes/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,21 +210,30 @@ public static bool CreateOfficeRoom()
{
// 회사 전체 톡방이 없을 경우 만듦
MySqlCommand cmd = new MySqlCommand(
"INSERT INTO room VALUES (@id, @scope, @target);",
con);

cmd.Parameters.AddWithValue("@id", MD5.NextRandom());
cmd.Parameters.AddWithValue("@scope", 0);
cmd.Parameters.AddWithValue("@target", Room.Scope[0]);
try
{
cmd.ExecuteNonQuery();
return true;
}
catch
"SELECT * FROM room WHERE scope=0;", con);
MySqlDataReader rdr = cmd.ExecuteReader();
if (!rdr.HasRows)
{
return false;
rdr.Close();
cmd = new MySqlCommand(
"INSERT INTO room VALUES (@id, @scope, @target);",
con);

cmd.Parameters.AddWithValue("@id", MD5.NextRandom());
cmd.Parameters.AddWithValue("@scope", 0);
cmd.Parameters.AddWithValue("@target", Room.Scope[0]);
try
{
cmd.ExecuteNonQuery();
return true;
}
catch
{
return false;
}
}
rdr.Close();
return false;
}
public static List<Room> GetRooms(Employee emp)
{
Expand Down
2 changes: 1 addition & 1 deletion Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static void Main(string[] args)
{
Log("DB", $"Server {Database.hostname} is connected");
if (Database.CreateOfficeRoom())
Log("DB", $"Office room is created");
Log("DB", "Office room is created");
employees = Database.GetEmployees();
}
else
Expand Down

0 comments on commit 8577f35

Please sign in to comment.