Beispiel #1
0
        public Bm_Login()
        {
            InitializeComponent();



            SystemInfo.server_Ip = HubIniFile.GetIniValue("SERVER", "IP", set_Path);
            encType = HubIniFile.GetIniValue("SERVER", "ENC", set_Path);
            string id = HubIniFile.GetIniValue("LOGIN", "ID", set_Path);

            txt_Id.Text         = id;
            login_Id            = "";
            CheckSaveId.Checked = true;

            ip  = new IPEndPoint(IPAddress.Parse(SystemInfo.server_Ip), 13300);
            qm  = new QueryMaker();
            req = new Request();
        }
Beispiel #2
0
        public void insertCode()
        {
            Cursor = Cursors.WaitCursor;
            if (type.Equals("소속"))
            {
                string min = HubIniFile.GetIniValue("DEPT", "MINID", set_Path);
                string max = HubIniFile.GetIniValue("DEPT", "MAXID", set_Path);
                bmQuery = "insert into DEPARTMENT(ID,DESCRIPTION) values((select MAX(ID)+1 from DEPARTMENT where ID < 20000 ),'" + textBox1.Text + "')";
                OGQuery = "insert into DEPT(ID,NAME,SEGMENTID) values((select MAX(ID)+1 from DEPT where ID >= " + min + " and ID <= " + max + " ),'" + textBox1.Text + "',-1)";
                FPQuery = "insert into TB_USER_DEPT(sName,sDepartment,nDepth,nParentIdn) values('" + textBox1.Text + "','" + textBox1.Text + "',0,0)";

                string rCheck = req.update("BMS012", bmQuery, "BMI");



                if (rCheck.Equals("0"))
                {
                    string serverType1 = "" + Bm_Main.serverInfo.Rows[0]["SERVER_TYPE"];
                    if (serverType1.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS1I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(3발전소 등록실패)");
                        }
                    }

                    string serverType2 = "" + Bm_Main.serverInfo.Rows[1]["SERVER_TYPE"];

                    if (serverType2.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS2I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(3발전소 등록실패)");
                        }
                    }

                    string serverType3 = "" + Bm_Main.serverInfo.Rows[2]["SERVER_TYPE"];

                    if (serverType3.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS3I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(3발전소 등록실패)");
                        }
                    }

                    string serverType4 = "" + Bm_Main.serverInfo.Rows[2]["SERVER_TYPE"];

                    if (serverType4.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS4I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(3발전소 등록실패)");
                        }
                    }



                    rCheck = req.update("BMS012", FPQuery, "FP1I");
                    if (!rCheck.Equals("0"))
                    {
                        MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(지문서버 등록실패)");
                    }

                    int    ACS1Code    = 99999;
                    string selectQuery = "select top 1 ID from DEPT where NAME ='" + textBox1.Text + "'";


                    if (serverType1.Equals("3"))
                    {
                        rCheck = req.select("BMS012", selectQuery, "ACS1S");

                        ACS1Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["ID"]);
                    }

                    int ACS2Code = 99999;

                    if (serverType2.Equals("3"))
                    {
                        rCheck   = req.select("BMS012", selectQuery, "ACS2S");
                        ACS2Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["ID"]);
                    }

                    int ACS3Code = 99999;

                    if (serverType3.Equals("3"))
                    {
                        rCheck   = req.select("BMS012", selectQuery, "ACS3S");
                        ACS3Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["ID"]);
                    }


                    int ACS4Code = 99999;

                    if (serverType4.Equals("3"))
                    {
                        rCheck   = req.select("BMS012", selectQuery, "ACS3S");
                        ACS4Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["ID"]);
                    }



                    selectQuery = "select top 1 nDepartmentIdn from TB_USER_DEPT where sName = '" + textBox1.Text + "'";

                    rCheck = req.select("BMS012", selectQuery, "FP1S");

                    int FP1Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["nDepartmentIdn"]);



                    string BMUpdateQuery = "update DEPARTMENT set PLANT1_DEPT_CODE = " + ACS1Code
                                           + " ,PLANT2_DEPT_CODE = " + ACS2Code
                                           + " , FP1_DEPT_CODE = " + FP1Code
                                           + ", PLANT3_DEPT_CODE =" + ACS3Code + " , PLANT4_DEPT_CODE =" + ACS4Code + " where DESCRIPTION ='" + textBox1.Text + "'";

                    rCheck = req.update("BMS012", BMUpdateQuery, "BMI");

                    if (rCheck.Equals("0"))
                    {
                        MessageBox.Show(type + " 추가 완료!");
                    }
                    else
                    {
                        MessageBox.Show(type + " 추가 실패..");
                    }
                }
                else
                {
                    MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.");
                }
            }
            else if (type.Equals("부서"))
            {
                string min = HubIniFile.GetIniValue("DIVISION", "MINID", set_Path);
                string max = HubIniFile.GetIniValue("DIVISION", "MAXID", set_Path);

                bmQuery = "insert into DIVISION(ID,DESCRIPTION) values((select MAX(ID)+1 from DIVISION where ID < 20000),'" + textBox1.Text + "')";
                OGQuery = "insert into DIVISION(ID,NAME,SEGMENTID) values((select MAX(ID)+1 from DIVISION where ID >= " + min + " and ID <= " + max + " ),'" + textBox1.Text + "',-1)";
                ppQuery = "insert into department(description,facility,modify_date,modify_time) values('" + textBox1.Text + "',-1," + nowDate + ",0)";

                string serverType1 = "" + Bm_Main.serverInfo.Rows[0]["SERVER_TYPE"];
                string serverType2 = "" + Bm_Main.serverInfo.Rows[1]["SERVER_TYPE"];
                string serverType3 = "" + Bm_Main.serverInfo.Rows[2]["SERVER_TYPE"];
                string serverType4 = "" + Bm_Main.serverInfo.Rows[2]["SERVER_TYPE"];


                string rCheck = req.update("BMS012", bmQuery, "BMI");

                if (rCheck.Equals("0"))
                {
                    if (serverType1.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS1I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(1발전소 등록실패)");
                        }
                    }
                    else
                    {
                        rCheck = req.update("BMS012", ppQuery, "ACS1I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(1발전소 등록실패)");
                        }
                    }

                    if (serverType2.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS2I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(2발전소 등록실패)");
                        }
                    }
                    else
                    {
                        rCheck = req.update("BMS012", ppQuery, "ACS2I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(1발전소 등록실패)");
                        }
                    }



                    if (serverType3.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS3I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(3발전소 등록실패)");
                        }
                    }
                    else
                    {
                        rCheck = req.update("BMS012", ppQuery, "ACS3I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(3발전소 등록실패)");
                        }
                    }


                    if (serverType4.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS4I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(4발전소 등록실패)");
                        }
                    }
                    else
                    {
                        rCheck = req.update("BMS012", ppQuery, "ACS4I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(4발전소 등록실패)");
                        }
                    }



                    string selectQuery = "select top 1 ID from DIVISION where NAME ='" + textBox1.Text + "'";
                    selectQuery = "select first 1 id from department where description = '" + textBox1.Text + "'";


                    if (serverType1.Equals("3"))
                    {
                        selectQuery = "select top 1 ID from DIVISION where NAME ='" + textBox1.Text + "'";
                    }
                    else
                    {
                        selectQuery = "select first 1 id from department where description = '" + textBox1.Text + "'";
                    }



                    rCheck = req.select("BMS012", selectQuery, "ACS1S");

                    int ACS1Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["ID"]);

                    if (serverType2.Equals("3"))
                    {
                        selectQuery = "select top 1 ID from DIVISION where NAME ='" + textBox1.Text + "'";
                    }
                    else
                    {
                        selectQuery = "select first 1 id from department where description = '" + textBox1.Text + "'";
                    }


                    rCheck = req.select("BMS012", selectQuery, "ACS2S");

                    int ACS2Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["ID"]);

                    selectQuery = "select first 1 id from department where description = '" + textBox1.Text + "'";


                    if (serverType3.Equals("3"))
                    {
                        selectQuery = "select top 1 ID from DIVISION where NAME ='" + textBox1.Text + "'";
                    }
                    else
                    {
                        selectQuery = "select first 1 id from department where description = '" + textBox1.Text + "'";
                    }

                    rCheck = req.select("BMS012", selectQuery, "ACS3S");

                    int ACS3Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["id"]);

                    if (serverType3.Equals("4"))
                    {
                        selectQuery = "select top 1 ID from DIVISION where NAME ='" + textBox1.Text + "'";
                    }
                    else
                    {
                        selectQuery = "select first 1 id from department where description = '" + textBox1.Text + "'";
                    }

                    rCheck = req.select("BMS012", selectQuery, "ACS4S");

                    int ACS4Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["id"]);



                    string BMUpdateQuery = "update DIVISION set PLANT1_DIVISION_CODE = " + ACS1Code
                                           + " ,PLANT2_DIVISION_CODE = " + ACS2Code
                                           + " , PLANT3_DIVISION_CODE = " + ACS3Code + " , PLANT4_DIVISION_CODE = " + ACS4Code
                                           + " where DESCRIPTION ='" + textBox1.Text + "'";

                    rCheck = req.update("BMS012", BMUpdateQuery, "BMI");

                    if (rCheck.Equals("0"))
                    {
                        MessageBox.Show(type + " 추가 완료!");
                    }
                    else
                    {
                        MessageBox.Show(type + " 추가 실패..");
                    }
                }
                else
                {
                    MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.");
                }
            }
            else if (type.Equals("직위"))
            {
                string min = HubIniFile.GetIniValue("TITLE", "MINID", set_Path);
                string max = HubIniFile.GetIniValue("TITLE", "MAXID", set_Path);

                bmQuery = "insert into TITLE(ID,DESCRIPTION) values((select MAX(ID)+1 from TITLE where ID < 20000),'" + textBox1.Text + "')";
                OGQuery = "insert into TITLE(ID,NAME,SEGMENTID) values((select MAX(ID)+1 from TITLE where ID >= " + min + " and ID <= " + max + " ),'" + textBox1.Text + "',-1)";
                string rCheck = req.update("BMS012", bmQuery, "BMI");
                if (rCheck.Equals("0"))
                {
                    string serverType1 = "" + Bm_Main.serverInfo.Rows[0]["SERVER_TYPE"];
                    string serverType2 = "" + Bm_Main.serverInfo.Rows[1]["SERVER_TYPE"];
                    string serverType3 = "" + Bm_Main.serverInfo.Rows[2]["SERVER_TYPE"];
                    string serverType4 = "" + Bm_Main.serverInfo.Rows[3]["SERVER_TYPE"];

                    if (serverType1.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS1I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(1발전소 등록실패)");
                        }
                    }

                    if (serverType2.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS2I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(2발전소 등록실패)");
                        }
                    }

                    if (serverType3.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS3I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(2발전소 등록실패)");
                        }
                    }

                    if (serverType4.Equals("3"))
                    {
                        rCheck = req.update("BMS012", OGQuery, "ACS3I");
                        if (!rCheck.Equals("0"))
                        {
                            MessageBox.Show(type + " 추가중에 오류가 발생하였습니다.(2발전소 등록실패)");
                        }
                    }

                    string selectQuery = "select top 1 ID from TITLE where NAME ='" + textBox1.Text + "'";
                    int    ACS1Code    = 99999;
                    int    ACS2Code    = 99999;
                    int    ACS3Code    = 99999;
                    int    ACS4Code    = 99999;

                    if (serverType1.Equals("3"))
                    {
                        rCheck   = req.select("BMS012", selectQuery, "ACS1S");
                        ACS1Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["ID"]);
                    }


                    if (serverType2.Equals("3"))
                    {
                        rCheck   = req.select("BMS012", selectQuery, "ACS2S");
                        ACS2Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["ID"]);
                    }

                    if (serverType3.Equals("3"))
                    {
                        rCheck   = req.select("BMS012", selectQuery, "ACS3S");
                        ACS3Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["ID"]);
                    }

                    if (serverType4.Equals("3"))
                    {
                        rCheck   = req.select("BMS012", selectQuery, "ACS3S");
                        ACS4Code = Convert.ToInt32(ReturnDT.dt.Rows[0]["ID"]);
                    }



                    string BMUpdateQuery = "update TITLE set PLANT1_TITLE_CODE = " + ACS1Code
                                           + " ,PLANT2_TITLE_CODE = " + ACS2Code
                                           + " , PLANT3_TITLE_CODE = " + ACS3Code + " , PLANT4_TITLE_CODE = " + ACS4Code
                                           + " where DESCRIPTION ='" + textBox1.Text + "'";

                    rCheck = req.update("BMS012", BMUpdateQuery, "BMI");

                    if (rCheck.Equals("0"))
                    {
                        MessageBox.Show(type + " 추가 완료!");
                    }
                    else
                    {
                        MessageBox.Show(type + " 추가 실패..");
                    }
                }
            }
            Cursor = Cursors.Default;
        }
Beispiel #3
0
        public string select(string mainCode, string query, string subCode)
        {
            string serverIP = HubIniFile.GetIniValue("SERVER", "IP", set_Path);

            Log.WriteLog("[Reg.cs] select (" + mainCode + ", " + query + ", " + subCode + ")");


            ip = new IPEndPoint(IPAddress.Parse(serverIP), 13300);

            Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            server.ReceiveBufferSize = 1000000;

            try
            {
                if (!server.Connected)
                {
                    server.Connect(ip);
                }
            }
            catch (SocketException se)
            {
                if (se.NativeErrorCode == 10060)
                {
                    MessageBox.Show("Server와의 연결에 실패했습니다.");
                }
            }

            DataTable dt = new DataTable();

            try
            {
                string mSendMessage = string.Empty;

                mSendMessage  = "Start" + Bm_Login.login_Id + sDelimeter;
                mSendMessage += mainCode + sDelimeter;
                mSendMessage += subCode + sDelimeter;
                mSendMessage += query + sDelimeter;
                mSendMessage += "END" + sDelimeter;

                serverStream = new NetworkStream(server);

                Byte[] byteDateLine = Encoding.UTF8.GetBytes(mSendMessage); // string -> byte

                byte[] sendbyte = AESClass.AESClass.AESENC(byteDateLine);   // 암호화

                if (serverStream.CanWrite)
                {
                    serverStream.Write(sendbyte, 0, sendbyte.Length);
                    serverStream.Flush();
                }

                ///////////////////////// 받는부분 ////////////////////////////////

                byte[] inStream = new byte[4000000];

                int ReadBytes = 0;

                do
                {
                    ReadBytes = serverStream.Read(inStream, 0, (int)server.ReceiveBufferSize);
                } while (serverStream.DataAvailable);

                if (inStream.Length > 0)
                {
                    byte[] tData = new byte[ReadBytes];
                    Buffer.BlockCopy(inStream, 0, tData, 0, ReadBytes);
                    byte[] decryptedData = AESClass.AESClass.AESDEC(tData);

                    string sRecieved = Encoding.UTF8.GetString(decryptedData, 0, decryptedData.Length);

                    string[] arrayRData = sRecieved.Split('|');

                    // JSJ
                    // MessageBox.Show("|" + arrayRData[0] + "|" + arrayRData[1] + "|" + arrayRData[2] + "|" + arrayRData[3] + "|" + arrayRData[4]);

                    if (arrayRData[1] == "Error")
                    {
                        if (arrayRData[2] == "DBConnection")
                        {
                            MessageBox.Show("DB 연결 에러 (" + arrayRData [3] + ")");
                            return("1");
                        }

                        MessageBox.Show("네트워크에 장애가 발생했습니다. 다시 시도해주세요");
                        //BackLog.Log.LogWrite("VMS002", "비정상", "loginProcess", "Error 리턴받음", "");
                        return("1");
                    }

                    byte[] tDataTable = null;

                    int TotalLength = decryptedData.Length;

                    int StrLength = arrayRData[0].Length + arrayRData[1].Length + arrayRData[2].Length;

                    Byte[] byteData = Encoding.UTF8.GetBytes(arrayRData[0] + "|" + arrayRData[1] + "|" + arrayRData[2] + "|");

                    Byte[] byteReceiveData = new Byte[TotalLength - byteData.Length - 5];

                    Buffer.BlockCopy(decryptedData, byteData.Length, byteReceiveData, 0, TotalLength - byteData.Length - 5);

                    tDataTable = byteReceiveData;

                    dt = Util.DeserializeData(tDataTable);

                    if (dt == null)
                    {
                        //BackLog.Log.LogWrite("VMS002", "비정상", "loginProcess", "Deserialize 결과 DataTable Null 리턴", "");
                        MessageBox.Show("정보를 불러오는데 실패했습니다. 다시 시도해주세요", "경고", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return("1");
                    }
                    else
                    {
                        ReturnDT.dt = dt;

                        return("0");
                    }
                }
            }
            catch (Exception ex)
            {
                //LogWrite("loginProcess", ex.Message);
            }
            finally
            {
                //serverStream.Close();
                //server.Close();
            }

            return("1");
        }
Beispiel #4
0
        public string updateImage(string mainCode, string query, string subCode, byte[] ImageByte)
        {
            Log.WriteLogTmp("[Request.cs] updateImage (" + mainCode + ", " + query + ", " + subCode + ")");


            // ip = new IPEndPoint(IPAddress.Parse(SystemInfo.server_Ip), 13300);
            ip = new IPEndPoint(IPAddress.Parse(HubIniFile.GetIniValue("SERVER", "IP", set_Path)), 13300);


            Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            server.ReceiveBufferSize = 1000000;

            try
            {
                if (!server.Connected)
                {
                    server.Connect(ip);
                }
            }
            catch (SocketException se)
            {
                if (se.NativeErrorCode == 10060)
                {
                    MessageBox.Show("Server와의 연결에 실패했습니다.");
                }
            }

            DataTable dt = new DataTable();

            try
            {
                string mSendMessage = string.Empty;

                mSendMessage  = "Start" + HubIniFile.GetIniValue("SERVER", "IP", set_Path) + sDelimeter;
                mSendMessage += mainCode + sDelimeter;
                mSendMessage += subCode + sDelimeter;

                mSendMessage += query + sDelimeter;

                /*
                 * // mSendMessage += "update EMP set NAME_1 = '장순중' where ID = 25601^" + query + sDelimeter;
                 * Byte[] byteData1 = Encoding.UTF8.GetBytes(mSendMessage); // string -> byte
                 * Byte[] byteData2 = ImageByte; //Image
                 * // Byte [] byteData3 = Encoding.UTF8.GetBytes("^update EMP set NAME_1 = '골이-10072' where ID = 25601|END|");
                 *
                 * // mSendMessage += "END" + sDelimeter;
                 *
                 *
                 * byte[] rv = new byte [byteData1.Length + byteData2.Length];
                 *
                 * System.Buffer.BlockCopy (byteData1, 0, rv, 0, byteData1.Length);
                 * System.Buffer.BlockCopy (byteData2, 0, rv, byteData1.Length, byteData2.Length);
                 */


                if (ImageByte == null)
                {
                    Log.WriteLogTmp("[Request.cs] updateImage () : ImageByte is NULL");
                }
                else
                {
                    Log.WriteLogTmp("[Request.cs] updateImage () : ImageByte.Length : " + ImageByte.Length);
                }

                Byte[] byteData1 = Encoding.UTF8.GetBytes(mSendMessage); // string -> byte
                Byte[] byteData2 = ImageByte;                            //Image

                byte [] rv = null;
                if (ImageByte == null)
                {
                    rv = new byte[byteData1.Length];
                }
                else
                {
                    rv = new byte[byteData1.Length + byteData2.Length];
                }

                System.Buffer.BlockCopy(byteData1, 0, rv, 0, byteData1.Length);
                Log.WriteLogTmp("[Request.cs] BEFORE");
                if (ImageByte != null)
                {
                    System.Buffer.BlockCopy(byteData2, 0, rv, byteData1.Length, byteData2.Length);
                }
                Log.WriteLogTmp("[Request.cs] AFTER");


                serverStream = new NetworkStream(server);

                string s = Encoding.UTF8.GetString(rv, 0, rv.Length);


                // Log.WriteLogTmp("[Request.cs] updateImage () send msg : " + s);



                byte[] sendbyte = AESClass.AESClass.AESENC(rv); // 암호화

                if (serverStream.CanWrite)
                {
                    serverStream.Write(sendbyte, 0, sendbyte.Length);
                    serverStream.Flush();
                }

                //// ----- 받는부분 -----

                byte[] inStream = new byte[4000000];

                int ReadBytes = 0;

                do
                {
                    ReadBytes = serverStream.Read(inStream, 0, (int)server.ReceiveBufferSize);
                } while (serverStream.DataAvailable);

                if (inStream.Length > 0)
                {
                    byte[] tData = new byte[ReadBytes];
                    Buffer.BlockCopy(inStream, 0, tData, 0, ReadBytes);
                    byte[] decryptedData = AESClass.AESClass.AESDEC(tData);

                    string sRecieved = Encoding.UTF8.GetString(decryptedData, 0, decryptedData.Length);

                    string[] arrayRData = sRecieved.Split('|');

                    if (arrayRData[1] == "Error")
                    {
                        MessageBox.Show("네트워크에 장애가 발생했습니다. 다시 시도해주세요");
                        //BackLog.Log.LogWrite("VMS002", "비정상", "loginProcess", "Error 리턴받음", "");
                        return("1");
                    }
                    else if (arrayRData[3] == "Update OK" || arrayRData[3] == "Insert OK" || arrayRData[3] == "Delete OK" || arrayRData[3] == "MultiProcess OK")
                    {
                        return("0");
                    }
                }
            }
            catch (Exception ex)
            {
                //LogWrite("loginProcess", ex.Message);
            }
            finally
            {
                //serverStream.Close();
                //server.Close();
            }

            return("1");
        }
Beispiel #5
0
        public string update(string mainCode, string query, string subCode)
        {
            //ip = new IPEndPoint(IPAddress.Parse(SystemInfo.server_Ip), 13300);
            ip = new IPEndPoint(IPAddress.Parse(HubIniFile.GetIniValue("SERVER", "IP", set_Path)), 13300);


            Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            server.ReceiveBufferSize = 1000000;

            try
            {
                if (!server.Connected)
                {
                    server.Connect(ip);
                }
            }
            catch (SocketException se)
            {
                if (se.NativeErrorCode == 10060)
                {
                    MessageBox.Show("Server와의 연결에 실패했습니다.");
                }
            }

            DataTable dt = new DataTable();

            try
            {
                string mSendMessage = string.Empty;

                mSendMessage  = "Start" + Bm_Login.login_Id + sDelimeter;
                mSendMessage += mainCode + sDelimeter;
                mSendMessage += subCode + sDelimeter;
                mSendMessage += query + sDelimeter;
                mSendMessage += "END" + sDelimeter;

                serverStream = new NetworkStream(server);

                Byte[] byteDateLine = Encoding.UTF8.GetBytes(mSendMessage); // string -> byte

                byte[] sendbyte = AESClass.AESClass.AESENC(byteDateLine);   // 암호화

                if (serverStream.CanWrite)
                {
                    serverStream.Write(sendbyte, 0, sendbyte.Length);
                    serverStream.Flush();
                }

                //// ----- 받는부분 -----

                byte[] inStream = new byte[4000000];

                int ReadBytes = 0;

                do
                {
                    ReadBytes = serverStream.Read(inStream, 0, (int)server.ReceiveBufferSize);
                } while (serverStream.DataAvailable);

                if (inStream.Length > 0)
                {
                    byte[] tData = new byte[ReadBytes];
                    Buffer.BlockCopy(inStream, 0, tData, 0, ReadBytes);
                    byte[] decryptedData = AESClass.AESClass.AESDEC(tData);

                    string sRecieved = Encoding.UTF8.GetString(decryptedData, 0, decryptedData.Length);

                    string[] arrayRData = sRecieved.Split('|');


                    if (arrayRData[1] == "Error")
                    {
                        MessageBox.Show("네트워크에 장애가 발생했습니다. 다시 시도해주세요");
                        return("1");
                    }
                    else if (arrayRData[3] == "Update OK" || arrayRData[3] == "Insert OK" || arrayRData[3] == "Delete OK" || arrayRData[3] == "MultiProcess OK")
                    {
                        return("0");
                    }
                }
            }
            catch (Exception ex)
            {
                //LogWrite("loginProcess", ex.Message);
            }
            finally
            {
                //serverStream.Close();
                //server.Close();
            }

            return("1");
        }