Esempio n. 1
0
        } // user 전체 삭제

        public void Proc_req_user_delete(string[] receive_data_division, ref NetworkStream stream)
        {
            DB_USERS use = new DB_USERS(receive_data_division[2], receive_data_division[3], receive_data_division[4], receive_data_division[5], receive_data_division[6], receive_data_division[7]);

            DB_MGR.Users_Delete(ref use);

            string send_data = "유저 부분삭제";

            byte[] Response_Data = Encoding.Default.GetBytes(send_data);
            stream.Write(Response_Data, 0, Response_Data.Length);
        } // user 선택 삭제
Esempio n. 2
0
        public void Server_Open()
        {
            server.Start();
            fm.textBox1.Text = "Aria Project Server Open";

            while (true)
            {
                TcpClient client = server.AcceptTcpClient();

                ((IPEndPoint)client.Client.RemoteEndPoint).ToString();

                NetworkStream stream = client.GetStream();

                int    length;
                string receive_data = null; // 클라이언트로부터 수신되는 값이 저장 될 변수
                string send_data    = null; // 클라이언트에게 송신할 값이 저장 될 변수
                byte[] bytes        = new byte[256];
                length = stream.Read(bytes, 0, bytes.Length);

                receive_data     = Encoding.Default.GetString(bytes, 0, length);// 데이터 수신
                fm.textBox2.Text = fm.textBox2.Text + receive_data;

                string[] receive_data_division = receive_data.Split(new char[] { ',' });

                if (receive_data_division[0] == "{{$00")
                {
                    if (receive_data_division[1] == "req_user_log_in") // user_login 프로토콜
                    {
                        List <DB_USERS> List_Users = new List <DB_USERS>();
                        DB_MGR.Users_Select(ref List_Users);

                        for (int i = 0; i < List_Users.Count; i++)
                        {
                            if (receive_data_division[2] == List_Users[i].User_Id && receive_data_division[3] == List_Users[i].Pass_Word) // 아이디 비밀번호 일치 판단문
                            {
                                Req_User_Log_In.result = "OK";

                                Req_User_Log_In.level = List_Users[i].Level;
                                if (Req_User_Log_In.level == "1")
                                {
                                    Req_User_Log_In.right = "OPER";
                                }
                                else if (Req_User_Log_In.level == "2")
                                {
                                    Req_User_Log_In.right = "ADMIN";
                                }
                                break;
                            }
                            else
                            {
                                Req_User_Log_In.result = "NG";
                            }
                        }
                        if (Req_User_Log_In.result == "NG")
                        {
                            Req_User_Log_In.nak_reason = "오류남";
                        }
                        send_data = "{{$00,login_req_ack," + Req_User_Log_In.result + "," + Req_User_Log_In.right + "," + Req_User_Log_In.nak_reason + ",#}}";
                        byte[] Response_Data = Encoding.Default.GetBytes(send_data);
                        stream.Write(Response_Data, 0, Response_Data.Length);
                        fm.textBox3.Text = send_data + Req_User_Log_In.level;
                    }
                }
                else if (receive_data_division[0] == "{{$01")
                {
                    if (receive_data_division[1] == "req_new_user_create")
                    {
                        DB_USERS User = new DB_USERS(receive_data_division[2], receive_data_division[3], receive_data_division[4], receive_data_division[5], receive_data_division[6], receive_data_division[7]);
                        DB_MGR.Users_Insert(ref User);

                        send_data = "{{$01,req_new_user_create_ack,result,ng_reasondddddddddddddddddddddddd$}}";
                        byte[] Response_Data = Encoding.Default.GetBytes(send_data);
                        stream.Write(Response_Data, 0, Response_Data.Length);
                        fm.textBox3.Text = send_data + Req_User_Log_In.level;
                    }
                    else if (receive_data_division[1] == "req_user_delete")
                    {
                        DB_USERS User2 = new DB_USERS();
                        User2.User_Id = receive_data_division[2];
                        DB_MGR.Users_Delete(ref User2);

                        send_data = "{{$01,req_user_delete,딜리트했슴요,ng_reason,$}}";
                        byte[] Response_Data = Encoding.Default.GetBytes(send_data);
                        stream.Write(Response_Data, 0, Response_Data.Length);
                        fm.textBox3.Text = send_data + Req_User_Log_In.level;
                    }
                    else if (receive_data_division[1] == "req_user_update")
                    {
                        //DB_MGR.Users_Update(ref User);

                        send_data = "{{$01,req_user_update,result,ng_reason$}}";
                    }
                    else if (receive_data_division[1] == "req_user_select")
                    {
                        List <DB_USERS> User = new List <DB_USERS>();
                        DB_MGR.Users_Select(ref User);
                        int a = 0;
                        foreach (DB_USERS ee in User)
                        {
                            send_data = send_data + ee.User_Id + "\n";
                            a++;
                        }

                        byte[] Response_Data = Encoding.Default.GetBytes(send_data);
                        stream.Write(Response_Data, 0, Response_Data.Length);
                        fm.textBox3.Text = send_data + Req_User_Log_In.level;
                    }
                }
            }
        }