Пример #1
0
        } // 로그인 관리

        public void Proc_req_user_all_select(string [] receive_data_division, ref NetworkStream stream)
        {
            List <DB_USERS> User = new List <DB_USERS>();

            DB_MGR.Users_Select(ref User);
            string send_data = null;
            int    a         = 0;

            foreach (DB_USERS ee in User)
            {
                a++;
                if (User.Count == a)
                {
                    send_data = send_data + ee.User_Id + "," + ee.Pass_Word + "," + ee.Level + "," + ee.E_Mail + "," +
                                ee.First_Name + "," + ee.Last_Name;
                }
                else
                {
                    send_data = send_data + ee.User_Id + "," + ee.Pass_Word + "," + ee.Level + "," + ee.E_Mail + "," +
                                ee.First_Name + "," + ee.Last_Name + ",\n";
                }
            }
            byte[] Response_Data = Encoding.Default.GetBytes(send_data);
            stream.Write(Response_Data, 0, Response_Data.Length);
        } // user 전체 검색
Пример #2
0
        /* 아래는 함수 리스트 */
        public void Proc_req_user_login(string[] receive_data_division, ref NetworkStream stream)
        {
            string          send_data  = null;
            List <DB_USERS> List_Users = new List <DB_USERS>();

            DB_MGR.Users_Select(ref List_Users);
            string Yes_Or_No = "";
            string user_id   = "";
            string pw        = "";
            string level     = "";

            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";
                    Yes_Or_No = "OK";

                    user_id = List_Users[i].User_Id;
                    pw      = List_Users[i].Pass_Word;
                    level   = List_Users[i].Level;

                    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";
                    Yes_Or_No = "NO";
                }
            }
            if (Req_User_Log_In.result == "NG")
            {
                Req_User_Log_In.nak_reason = "오류남";
            }
            send_data = Yes_Or_No + "," + user_id + "," + pw + "," + level;
            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;
        } // 로그인 관리
Пример #3
0
        public string User_select(string send_data, string receive_data_division)
        {
            List <DB_USERS> User = new List <DB_USERS>();

            DB_MGR.Users_Select(ref User);

            foreach (DB_USERS ee in User)
            {
                if (receive_data_division == ee.User_Id)
                {
                    send_data = ee.User_Id + "," + ee.Pass_Word + "," + ee.Level + "," + ee.E_Mail + "," +
                                ee.First_Name + "," + ee.Last_Name;
                }
            }
            return(send_data);
        }
Пример #4
0
        public string User_All_select(string send_data)
        {
            List <DB_USERS> User = new List <DB_USERS>();

            DB_MGR.Users_Select(ref User);
            int a = 0;

            foreach (DB_USERS ee in User)
            {
                a++;
                if (User.Count == a)
                {
                    send_data = send_data + ee.User_Id + "," + ee.Pass_Word + "," + ee.Level + "," + ee.E_Mail + "," +
                                ee.First_Name + "," + ee.Last_Name;
                }
                else
                {
                    send_data = send_data + ee.User_Id + "," + ee.Pass_Word + "," + ee.Level + "," + ee.E_Mail + "," +
                                ee.First_Name + "," + ee.Last_Name + ",\n";
                }
            }
            return(send_data);
        }
Пример #5
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;
                    }
                }
            }
        }