diff --git a/Server/Classes/Database.cs b/Server/Classes/Database.cs index 3b63292..8e655ce 100644 --- a/Server/Classes/Database.cs +++ b/Server/Classes/Database.cs @@ -8,6 +8,7 @@ using OSTLibrary.Chats; using System.Collections.Generic; using System.Text; +using OSTLibrary.Securities; namespace Server.Classes { @@ -205,6 +206,26 @@ public static bool AddRoom(Room room) return false; } } + 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 + { + return false; + } + } public static List GetRooms(Employee emp) { List rooms = new List(); diff --git a/Server/Program.cs b/Server/Program.cs index 490fc8b..31bb127 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -28,7 +28,9 @@ static void Main(string[] args) // 데이터 베이스 접속 if (Database.Connect()) { - Log("DB", $"Server {Database.hostname} is connected."); + Log("DB", $"Server {Database.hostname} is connected"); + if (Database.CreateOfficeRoom()) + Log("DB", $"Office room is created"); employees = Database.GetEmployees(); } else