public static void SIN(Socket accept) { byte[] receive = new byte[1024]; byte[] clear_Receive; string back_Code = ""; MySQLConnectionClass mySQLC = new MySQLConnectionClass(); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; int len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; string[] tmp = back_Code.Split("#"); int user_Id = Convert.ToInt32(tmp[0]); bool is_Password = mySQLC.is_Password(user_Id, tmp[1]); if (is_Password) { accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; } else { accept.Send(Encoding.UTF8.GetBytes("NO")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'NO'\n"; } mySQLC.stop_Connect_To_DB(); }
public static void RSW(Socket accept) { byte[] receive = new byte[1024]; byte[] clear_Receive; int data_Count = 0; string back_Code = ""; MySQLConnectionClass mySQLC = new MySQLConnectionClass(); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; int len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; string[] tmp = back_Code.Split("#"); string temp_Name = tmp[0]; int temp_Data_Set_Serial = Convert.ToInt32(tmp[1]); int temp_Item_Count = Convert.ToInt32(tmp[2]); int temp_Cubage = Convert.ToInt32(tmp[3]); int temp_Max_Result = Convert.ToInt32(tmp[4]); try { mySQLC.write_To_resultsurface(temp_Name, temp_Data_Set_Serial, temp_Item_Count, temp_Cubage, temp_Max_Result); }catch (Exception e) { } accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; }
public static void DSD(Socket accept) { byte[] receive = new byte[1024]; byte[] clear_Receive; string back_Code = ""; MySQLConnectionClass mySQLC = new MySQLConnectionClass(); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; int len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; string[] tmp = back_Code.Split("#"); string file_Name = tmp[0]; int data_Set_Serial = Convert.ToInt32(tmp[1]); mySQLC.delete_Data_Set_Data(file_Name, data_Set_Serial); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; }
public Form1() { InitializeComponent(); networkReceptionData = new NetworkReceptionData(); ThreadPool.QueueUserWorkItem((obj) => { MySQLConnectionClass mySQL = new MySQLConnectionClass(); networkReceptionData.start_Listen_From_Client(); }); }
public static void DSR(Socket accept) { byte[] receive = new byte[1024]; byte[] clear_Receive; string back_Code = ""; MySQLConnectionClass mySQLC = new MySQLConnectionClass(); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; int len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; string[] tmp = back_Code.Split("#"); string file_Name = tmp[0]; int data_Set_Serial = Convert.ToInt32(tmp[1]); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; if (back_Code.Equals("OK")) { using (MySqlDataReader reader = mySQLC.get_Data_Set_Reader(file_Name, data_Set_Serial)) { while (reader.Read() && back_Code.Equals("OK")) { string send = reader.GetString("ItemSetSerial") + "#"; send += reader.GetString("Profit") + "#"; send += reader.GetString("Weight") + "#"; send += reader.GetString("Radio"); accept.Send(Encoding.UTF8.GetBytes(send)); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send '" + send + "'\n"; len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; } accept.Send(Encoding.UTF8.GetBytes("NO")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'NO'\n"; } } }
public static void RSR(Socket accept) { byte[] receive = new byte[1024]; byte[] clear_Receive; string back_Code = ""; MySQLConnectionClass mySQLC = new MySQLConnectionClass(); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; int len = accept.Receive(receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); string[] tmp = back_Code.Split("#"); string file_Name = tmp[0]; int data_Set_Serial = Convert.ToInt32(tmp[1]); using (MySqlDataReader reader = mySQLC.get_Result_Surface_Reader(file_Name, data_Set_Serial)) { if (reader.Read()) { accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; if (back_Code.Equals("OK")) { int temp_Item_Count = Convert.ToInt32(reader.GetString("ItemCount")); int temp_Cubage = Convert.ToInt32(reader.GetString("Cubage")); int temp_Max_Result = Convert.ToInt32(reader.GetString("MaxResult")); string send_Message = temp_Item_Count.ToString() + "#"; send_Message += temp_Cubage.ToString() + "#"; send_Message += temp_Max_Result.ToString(); accept.Send(Encoding.UTF8.GetBytes(send_Message)); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send '" + send_Message + "'\n"; } } else { accept.Send(Encoding.UTF8.GetBytes("NO")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'NO'\n"; } } }
public static void DSW(Socket accept) { byte[] receive = new byte[1024]; byte[] clear_Receive; int data_Count = 0; string back_Code = ""; MySQLConnectionClass mySQLC = new MySQLConnectionClass(); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; int len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; data_Count = Convert.ToInt32(back_Code); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; for (int i = 0; i < data_Count; i++) { len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; string[] tmp = back_Code.Split("#"); string temp_Name = tmp[0]; int temp_Data_Set_Serial = Convert.ToInt32(tmp[1]); int temp_Item_Set_Serial = Convert.ToInt32(tmp[2]); int temp_Profit = Convert.ToInt32(tmp[3]); int temp_Weight = Convert.ToInt32(tmp[4]); decimal temp_Radio = Convert.ToDecimal(tmp[5]); try { mySQLC.write_To_Data_Set_DB(temp_Name, temp_Data_Set_Serial, temp_Item_Set_Serial, temp_Profit, temp_Weight, temp_Radio); } finally { accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; } } }
public static void REG(Socket accept) { byte[] receive = new byte[1024]; byte[] clear_Receive; MySQLConnectionClass mySQLC = new MySQLConnectionClass(); string back_Code = ""; accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; int len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; string[] tmp = back_Code.Split("#"); string temp_Name = tmp[0]; int temp_ID = Convert.ToInt32(tmp[1]); string temp_Password = tmp[2]; bool have = mySQLC.search_User(temp_ID); if (have) { accept.Send(Encoding.UTF8.GetBytes("NO")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'NO'\n"; return; } else { mySQLC.write_To_usertable(temp_Name, temp_ID, temp_Password); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; } mySQLC.stop_Connect_To_DB(); }
public string[] get_Result_Items() { MySQLConnectionClass mySQLC = new MySQLConnectionClass(); return(mySQLC.get_All_Result_Str().Split("@")); }