public static void ConnectServer(XeQuaTram Xe) { try { Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPHostEntry hostEntry = Dns.GetHostEntry(ModuleKhaiBaoConst.IPMayGiamSatMain); IPAddress[] addressList = hostEntry.AddressList; IPAddress[] array = addressList; IPAddress address = default(IPAddress); foreach (IPAddress iPAddress in array) { if (iPAddress.AddressFamily == AddressFamily.InterNetwork) { address = iPAddress; break; } } IPEndPoint remoteEP = new IPEndPoint(address, ModuleKhaiBaoConst.PortDuLieuChinhMain); socket.Connect(remoteEP); byte[] bytes = Encoding.ASCII.GetBytes(Xe.ToString()); socket.Send(bytes, bytes.Length, SocketFlags.None); } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception ex2 = ex; ProjectData.ClearProjectError(); } CSDL.InsertXeQuaTram(ModuleKhaiBaoConst.StrConnectMain, Xe); try { CSDL.InsertXeQuaTram(ModuleKhaiBaoConst.StrConnectMain_mas, Xe); } catch (Exception ex3) { ProjectData.SetProjectError(ex3); Exception ex4 = ex3; ProjectData.ClearProjectError(); } }
public static void SendOldData_TienPhong() { try { Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPHostEntry hostEntry = Dns.GetHostEntry(ModuleKhaiBaoConst.IPMayGiamSatMain); IPAddress[] addressList = hostEntry.AddressList; IPAddress[] array = addressList; IPAddress address = default(IPAddress); foreach (IPAddress iPAddress in array) { if (iPAddress.AddressFamily == AddressFamily.InterNetwork) { address = iPAddress; break; } } IPEndPoint remoteEP = new IPEndPoint(address, ModuleKhaiBaoConst.PortDuLieuCuMain); string text = ""; long phi = 0L; long num = 0L; long num2 = 0L; string bSXeThangQui = ""; string text2 = ""; DataTable dataTable = new DataTable(); dataTable = CSDL.SelectXeQuaTram_TienPhong(ModuleKhaiBaoConst.StrConnectMain); socket.Connect(remoteEP); socket.ReceiveTimeout = 5000; IEnumerator enumerator = default(IEnumerator); try { enumerator = dataTable.Rows.GetEnumerator(); while (enumerator.MoveNext()) { DataRow dataRow = (DataRow)enumerator.Current; XeQuaTram xeQuaTram = new XeQuaTram(); xeQuaTram.BienSo = Conversions.ToString(dataRow["BienSo"]); xeQuaTram.CaTruc = RuntimeHelpers.GetObjectValue(dataRow["CaTruc"]); xeQuaTram.GioQuaTram = Conversions.ToString(dataRow["GioQuaTram"]); xeQuaTram.LanXe = Conversions.ToByte(dataRow["LanXe"]); xeQuaTram.MSNV = Conversions.ToString(dataRow["MSNV"]); xeQuaTram.NgayQuaTram = Conversions.ToString(dataRow["NgayQuaTram"]); xeQuaTram.PLXeSau = 0; xeQuaTram.PLXeTruoc = 0; xeQuaTram.TenHinhXe = Conversions.ToString(dataRow["TenHinhXe"]); text = (xeQuaTram.SoVe = Conversions.ToString(dataRow["SoVe"])); int num3 = VeXe.LoaiVe(text); int num4 = VeXe.PhanLoaiVe(text); checked { xeQuaTram.PLVe = (byte)num4; xeQuaTram.PTTT = (byte)num3; switch (num3) { case 1: CSDL.SelectMenhGiaVe(ModuleKhaiBaoConst.StrConnectMain, Conversions.ToString(num4), ref phi, ref num, ref num2); xeQuaTram.Phi = phi; xeQuaTram.BSXeThangQui = ModuleKhaiBaoConst.EnumStrNull.BienSoNull; break; case 2: CSDL.TimBienSoTuVeThang(ModuleKhaiBaoConst.StrConnectMain, text, ref bSXeThangQui, ref text2); xeQuaTram.BSXeThangQui = bSXeThangQui; xeQuaTram.Phi = 0L; break; case 11: xeQuaTram.Phi = 0L; xeQuaTram.BSXeThangQui = ModuleKhaiBaoConst.EnumStrNull.BienSoNull; break; default: xeQuaTram.Phi = 0L; xeQuaTram.BSXeThangQui = ModuleKhaiBaoConst.EnumStrNull.BienSoNull; break; } byte[] bytes = Encoding.ASCII.GetBytes(xeQuaTram.ToString()); socket.Send(bytes, bytes.Length, SocketFlags.None); byte[] array2 = new byte[31]; int num5 = 0; num5 = socket.Receive(array2, array2.Length, SocketFlags.None); string @string = Encoding.ASCII.GetString(array2, 0, num5); CSDL.DeleteXeQuaTram_TienPhong(ModuleKhaiBaoConst.StrConnectMain, @string); } } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } goto end_IL_0000; IL_02f1: end_IL_0000 :; } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception ex2 = ex; ProjectData.ClearProjectError(); } }
public static void SendOldData() { try { Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPHostEntry hostEntry = Dns.GetHostEntry(ModuleKhaiBaoConst.IPMayGiamSatMain); IPAddress[] addressList = hostEntry.AddressList; IPAddress[] array = addressList; IPAddress address = default(IPAddress); foreach (IPAddress iPAddress in array) { if (iPAddress.AddressFamily == AddressFamily.InterNetwork) { address = iPAddress; break; } } IPEndPoint remoteEP = new IPEndPoint(address, ModuleKhaiBaoConst.PortDuLieuCuMain); DataTable dataTable = new DataTable(); dataTable = CSDL.SelectXeQuaTram(ModuleKhaiBaoConst.StrConnectMain); socket.Connect(remoteEP); socket.ReceiveTimeout = 5000; IEnumerator enumerator = default(IEnumerator); try { enumerator = dataTable.Rows.GetEnumerator(); while (enumerator.MoveNext()) { DataRow dataRow = (DataRow)enumerator.Current; XeQuaTram xeQuaTram = new XeQuaTram(); xeQuaTram.BienSo = Conversions.ToString(dataRow["BienSo"]); xeQuaTram.CaTruc = RuntimeHelpers.GetObjectValue(dataRow["CaTruc"]); xeQuaTram.GioQuaTram = Conversions.ToString(dataRow["GioQuaTram"]); xeQuaTram.LanXe = Conversions.ToByte(dataRow["LanXe"]); xeQuaTram.MSNV = Conversions.ToString(dataRow["MSNV"]); xeQuaTram.NgayQuaTram = Conversions.ToString(dataRow["NgayQuaTram"]); xeQuaTram.Phi = Conversions.ToLong(dataRow["Phi"]); xeQuaTram.PLVe = Conversions.ToByte(dataRow["PLVe"]); xeQuaTram.PLXeSau = Conversions.ToByte(dataRow["PLXeSau"]); xeQuaTram.PLXeTruoc = Conversions.ToByte(dataRow["PLXeTruoc"]); xeQuaTram.PTTT = Conversions.ToByte(dataRow["PTTT"]); xeQuaTram.SoVe = Conversions.ToString(dataRow["SoVe"]); xeQuaTram.TenHinhXe = Conversions.ToString(dataRow["TenHinhXe"]); xeQuaTram.BSXeThangQui = Conversions.ToString(dataRow["BSXeThangQui"]); if (xeQuaTram.LanXe <= 0) { CSDL.DeleteXeQuaTram(ModuleKhaiBaoConst.StrConnectMain, xeQuaTram.TenHinhXe); } else { byte[] bytes = Encoding.ASCII.GetBytes(xeQuaTram.ToString()); socket.Send(bytes, bytes.Length, SocketFlags.None); byte[] array2 = new byte[31]; int num = 0; num = socket.Receive(array2, array2.Length, SocketFlags.None); string @string = Encoding.ASCII.GetString(array2, 0, num); CSDL.DeleteXeQuaTram(ModuleKhaiBaoConst.StrConnectMain, @string); } } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } goto end_IL_0000; IL_028c: end_IL_0000 :; } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception ex2 = ex; ProjectData.ClearProjectError(); } }