Skip to content

Commit

Permalink
Create office room automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
geoje committed May 31, 2021
1 parent 0a3bde5 commit f5ae2e2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Server/Classes/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using OSTLibrary.Chats;
using System.Collections.Generic;
using System.Text;
using OSTLibrary.Securities;

namespace Server.Classes
{
Expand Down Expand Up @@ -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<Room> GetRooms(Employee emp)
{
List<Room> rooms = new List<Room>();
Expand Down
4 changes: 3 additions & 1 deletion Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f5ae2e2

Please sign in to comment.