Skip to content

Commit

Permalink
Writting about this project & Fix db connection
Browse files Browse the repository at this point in the history
  • Loading branch information
geoje committed Jul 14, 2021
1 parent 9c47487 commit ff5871b
Show file tree
Hide file tree
Showing 19 changed files with 280 additions and 14 deletions.
18 changes: 12 additions & 6 deletions Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>true</IsWebBootstrapper>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>D:\var\www\html\ost\</PublishUrl>
<Install>true</Install>
<InstallFrom>Web</InstallFrom>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<InstallUrl>http://www.ygh.kr/ost/</InstallUrl>
<UpdateUrl>http://www.ygh.kr/ost/</UpdateUrl>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>index.html</WebPage>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down Expand Up @@ -63,11 +62,17 @@
<ManifestKeyFile>Client_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a, processorArchitecture=MSIL">
<HintPath>..\packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.dll</HintPath>
Expand Down Expand Up @@ -202,6 +207,7 @@
</EmbeddedResource>
<None Include="Client_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
2 changes: 1 addition & 1 deletion Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static void Main()
callback = new Dictionary<PacketType, Action<Packet>>();

string[] args = Environment.GetCommandLineArgs();
hostname = args.Length > 1 ? args[1] : "www.ygh.kr";
hostname = args.Length > 1 ? args[1] : "127.0.0.1";


Application.EnableVisualStyles();
Expand Down
73 changes: 73 additions & 0 deletions Client/Properties/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 매니페스트 옵션
Windows 사용자 계정 컨트롤 수준을 변경하려면
requestedExecutionLevel 노드를 다음 중 하나로 바꿉니다.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
requestedExecutionLevel 요소를 지정하면 파일 및 레지스트리 가상화를 사용하지 않습니다.
이전 버전과의 호환성을 위해 애플리케이션에 가상화가 필요한 경우
이 요소를 제거합니다.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 이 애플리케이션이 테스트되고 함께 작동하도록 설계된 Windows 버전
목록입니다. 해당 요소의 주석 처리를 제거하면 Windows에서
호환 가능성이 가장 큰 환경을 자동으로 선택합니다. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 애플리케이션이 DPI를 인식하며 높은 DPI에서 Windows가 자동으로 스케일링하지
않음을 나타냅니다. WPF(Windows Presentation Foundation) 애플리케이션은 자동으로 DPI를 인식하며
옵트인할 필요가 없습니다. 이 설정에 옵트인한 .NET Framework 4.6을 대상으로 하는
Windows Forms 애플리케이션은 app.config에서 'EnableWindowsFormsHighDpiAutoResizing' 설정도 'true'로 설정해야 합니다.
애플리케이션이 긴 경로를 인식하도록 설정합니다. https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation을 참조하세요. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->
<!-- Windows 공용 컨트롤 및 대화 상자의 테마 사용(Windows XP 이상) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>
Binary file added Document/CentralChat.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/ChatSeperated.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/Connection.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/ERDiagram.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/LoginAndMain.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/OfficeChat.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/OneToOneChat.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/Organizaiton.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/Regist.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/TableChat.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/TableEmployee.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/TableEmployeePassword.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/TableRoom.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Document/TeamChat.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
193 changes: 190 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,190 @@
# OST
Office messenger Supporting Telecommuting
2021년 1학기 3학년 응용소프트웨어실습 수업 팀프로젝트
# 💬 OST [서버](https://github.com/geoje/KwUniversity/raw/master/ApplicationSoftwarePractice/CatchMind_Server/CatchMind_Server.zip) / [클라이언트](https://github.com/geoje/KwUniversity/raw/master/ApplicationSoftwarePractice/CatchMind_Client/CatchMind_Client.zip)
#### 🏢 Office messenger Supporting Telecommuting
<br><br>

## 개발 기간
##### 3학년 1학기 응용소프트웨어실습 (2021-03-12 ~ 2021-06-11)
카카오톡을 모티브로 `C#``MySQL` 등을 사용해 만든 **사내 채팅 프로그램** 팀프로젝트 입니다.

실행하기 위해서는 몇가지 설정이 필요합니다.
<br><br>

## 데이터 베이스 및 유저 생성
서버 프로그램을 돌리기 위해 `.Net Core``MySQL` 프로그램이 설치될 수 있는 `Ubuntu 20.04 LTS` 운영체제에서 우선 `MySQL` 을 설치하고 `DB``User` 를 생성합니다.
##### bash
``` bash
sudo mysql -u root -p
```
##### sql
``` sql
CREATE DATABASE ost DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER ost@localhost identified BY 'dr@M@0st';
GRANT ALL PRIVILEGES ON ost.* TO ost@localhost;
FLUSH PRIVILEGES;
```
<br><br>

## 테이블 생성
##### sql
``` sql
CREATE TABLE `ost`.`employee` (
`id` INT NOT NULL,
`password` VARCHAR(64) NOT NULL,
`name` VARCHAR(20) NOT NULL,
`phone` VARCHAR(14) NULL,
`central` VARCHAR(45) NOT NULL,
`team` VARCHAR(45) NOT NULL,
`rank` VARCHAR(45) NOT NULL,
`profile` LONGBLOB NULL,
`profile_length` INT UNSIGNED NULL,
PRIMARY KEY (`id`));

CREATE TABLE `ost`.`schedule` (
`author` INT NOT NULL,
`title` VARCHAR(45) NULL,
`start` DATETIME NOT NULL,
`end` DATETIME NOT NULL,
`scope` VARCHAR(45) NULL,
`contents` LONGTEXT NULL,
`target` VARCHAR(45) NULL,
CONSTRAINT `schedule_id`
FOREIGN KEY (`author`)
REFERENCES `ost`.`employee` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);

CREATE TABLE `ost`.`room` (
`id` VARCHAR(32) NOT NULL,
`scope` INT NULL,
`target` VARCHAR(45) NULL,
PRIMARY KEY (`id`));

CREATE TABLE `ost`.`chat` (
`room_id` VARCHAR(32) NOT NULL,
`chat_date` DATETIME(6) NOT NULL,
`employee_id` INT NOT NULL,
`data` LONGBLOB NULL,
`data_length` INT NULL,
`data_type` INT NULL,
UNIQUE INDEX `chat_date_UNIQUE` (`chat_date` ASC) VISIBLE,
INDEX `chat_room_id_idx` (`room_id` ASC) VISIBLE,
INDEX `chat_date_idx` (`chat_date` ASC) VISIBLE,
INDEX `chat_employee_id_idx` (`employee_id` ASC) VISIBLE,
CONSTRAINT `chat_room_id`
FOREIGN KEY (`room_id`)
REFERENCES `ost`.`room` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `chat_employee_id`
FOREIGN KEY (`employee_id`)
REFERENCES `ost`.`employee` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
```

이로써 사전 세팅이 모두 끝났습니다.
<br><br>

## 서버 실행
`Release` 탭에서 `OSTServer.zip` 을 다운받고 압축을 풀어주세요.

> #### 잠깐!
> 서버는 `.Net Core 3.1` 를 사용하며 실행하는 곳에 설치가 되어 있어야합니다.
또한 `MySQL` 또는 `MariaDB`가 설치되어 있어야하며 데이터 베이스는 `127.0.0.1` 로 접속하기 때문에 로컬에 설치되어 있어야합니다. (프로젝트 `Server/Classes/Database.cs` 에서 변경 가능)
#### Linux (Bash)
``` bash
dotnet [server-ip] [server-port]
```
#### Window (Powershell)
``` powershell
.\OSTServer.exe [port]
```
> `OSTServer.exe` 를 그냥 실행해도 되지만 포트는 기본값인 `6756` 으로만 실행됩니다.
#### 실행 결과
``` powershell
PS C:\Users\chchc\Downloads\OSTServer> .\OSTServer.exe
[2021-07-14 13:40:19] DB | Server 127.0.0.1 is connected
[2021-07-14 13:40:19] System | Server is opend with port 6756
```
<br><br>

## 프로그램 실행
`.Net Framework 4.7.2` 기반이며 `Window Forms` 로 제작되어 윈도우에서만 실행하시길 바랍니다.
리눅스와 같은 운영체제에서 실행가능한 방법도 있으나 여기서 다루진 않겠습니다.
#### Window (Powershell)
``` powershell
.\OfficeMessengarST.exe [server-ip] [server-port]
```
> `OfficeMessengarST.exe` 를 그냥 실행해도 되지만 기본값인 `127.0.0.1:6756` 으로만 실행됩니다.
<br><br>

## 소개
이제부터 프로그램 기능을 파해쳐 보도록 하겠습니다.

#### 접속
![](Document/Connection.gif)
<br>

#### 사원 등록
![](Document/Regist.gif)
<br>

#### 로그인 및 메인 화면
![](Document/LoginAndMain.gif)
<br>

#### 조직도 및 사원 정보
![](Document/Organizaiton.gif)
<br>

#### 1:1 채팅
![](Document/OneToOneChat.gif)
<br>

#### 팀 채팅
![](Document/TeamChat.gif)
<br>

#### 본부 채팅
![](Document/CentralChat.gif)
<br>

#### 회사 전체 채팅
![](Document/OfficeChat.gif)
<br>

#### ER Diagram
![](Document/ERDiagram.PNG)
<br>

#### Table: Employee
![](Document\TableEmployee.PNG)
<br>

#### Table: Room
`target` 컬럼이 제1정규화도 만족하지 못한다는 점이 아쉽긴 합니다.
![](Document\TableRoom.PNG)
<br>

#### Table: Chat
채팅 테이블의 `key` 를 지정하기 위해 `chat_date` 컬럼을 `DATETIME(6)` 으로 지정하여 `millisecond` 까지 저장하도록 하였습니다.
![](Document\TableChat.PNG)
<br>


<br><br>

## 특징
#### 채팅 화면 간소화
카카오톡 처럼 같은사람, 같은 시간(분 단위 까지) 일 경우 채팅이 연결되도록 되어있습니다.

![](Document/ChatSeperated.gif)
<br>

#### 비밀번호 일방향 암호화 저장
데이터베이스에 사원 정보가 저장될 때 비밀번호를 `SHA-512` 암호화 알고리즘을 적용하여 저장하여 보안을 한 층 더 강화하였습니다.

![](Document\TableEmployeePassword.PNG)
<br>
8 changes: 4 additions & 4 deletions Server/Classes/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Server.Classes
static class Database
{
public static MySqlConnection con; // DB 연결 정보
public static readonly string hostname = "www.ygh.kr"; // DB 서버 주소
public static readonly string hostname = "127.0.0.1"; // DB 서버 주소
public static readonly string id = "ost"; // DB 유저 이름
public static readonly string password = "dr@M@0st"; // DB 비밀 번호
public static readonly string dbName = "ost"; // DB 기본 데베
Expand Down Expand Up @@ -45,7 +45,7 @@ public static bool Connect()
// 사원
public static Dictionary<int, Employee> GetEmployees()
{
string sql = $"SELECT id, name, phone, central, team, rank, profile, profile_length FROM employee";
string sql = $"SELECT id, name, phone, central, team, `rank`, profile, profile_length FROM employee";
MySqlCommand cmd = new MySqlCommand(sql, con);
Dictionary<int, Employee> employees = new Dictionary<int, Employee>();

Expand All @@ -71,7 +71,7 @@ public static Dictionary<int, Employee> GetEmployees()
}
public static Employee Login(int empId, string password)
{
string sql = $"SELECT id, name, phone, central, team, rank, profile, profile_length FROM employee WHERE id={empId} AND password='{Filter(password)}'";
string sql = $"SELECT id, name, phone, central, team, `rank`, profile, profile_length FROM employee WHERE id={empId} AND password='{Filter(password)}'";
MySqlCommand cmd = new MySqlCommand(sql, con);

using (MySqlDataReader rdr = cmd.ExecuteReader())
Expand Down Expand Up @@ -196,7 +196,7 @@ public static List<Schedule> GetSchedule(Employee emp)
public static bool AddRoom(Room room)
{
MySqlCommand cmd = new MySqlCommand(
"INSERT INTO room VALUES (@id, @range, @target);",
"INSERT INTO room VALUES (@id, @scope, @target);",
con);

cmd.Parameters.AddWithValue("@id", room.id);
Expand Down

0 comments on commit ff5871b

Please sign in to comment.