private void btnGuardarMedidor_Click(object sender, EventArgs e) { Conector_DataBase conector = new Conector_DataBase(); Clientee cliente = new Clientee(); cliente.Nombre = txt_m_Nombre.Text; cliente.Apellido = txt_m_Apellido.Text; cliente.Nombre_Empresa = txt_m_NomEmpresa.Text; cliente.Responsable_Medicion = txt_m_ResMedicion.Text; cliente.DirigirReporte_A = txt_m_DirigirReporte.Text; cliente.RazonSocial = txt_m_RazonSocial.Text; cliente.Ruc = txt_m_Ruc.Text; cliente.NisCliente = txt_m_NisCliente.Text; // Mandar los datos del usuario ala base de datos en mongo conector.insertar_Cliete(cliente.Nombre, cliente.Apellido, cliente.Nombre_Empresa, cliente.Responsable_Medicion, cliente.DirigirReporte_A, cliente.RazonSocial, cliente.Ruc, cliente.NisCliente); pnlAlertaVerde.Visible = true; lbl_verde.Text = "Usuario Agregado"; txt_m_Nombre.Text = ""; txt_m_Apellido.Text = ""; txt_m_NomEmpresa.Text = ""; txt_m_ResMedicion.Text = ""; txt_m_DirigirReporte.Text = ""; txt_m_RazonSocial.Text = ""; txt_m_Ruc.Text = ""; txt_m_NisCliente.Text = ""; seAgregoUno = true; }
private void Usuarios() { var Documento = MongoConexion.DataBase.GetCollection <Client>("Clientes"); BindingList <Client> doclist = new BindingList <Client>(); Clientee Cli = new Clientee(); foreach (var deger in Documento.FindAll()) { Cli.Nombre = deger.Nombre.ToString(); Cli.Apellido = deger.Apellido.ToString(); Cli.Nombre_Empresa = deger.Nombre_Empresa.ToString(); Cli.Responsable_Medicion = deger.Responsable_Medicion.ToString(); Cli.DirigirReporte_A = deger.DirigirReporte_A.ToString(); Cli.RazonSocial = deger.RazonSocial.ToString(); Cli.Ruc = deger.Ruc.ToString(); Cli.NisCliente = deger.NisCliente.ToString(); Cli.ObjectId_Cliente = deger.Id; Cli.date_Loader = deger.date_Loader.Date; doclist.Add(deger); } var bindingList = new BindingList <Client>(doclist); var source = new BindingSource(bindingList, null); gridClientes.Rows.Clear(); gridClientes.DataSource = source; gridClientes.Refresh(); }
public static void RecibirSocket(IAsyncResult AR) { Socket current = (Socket)AR.AsyncState; int received = 0; try { received = current.EndReceive(AR); } catch (SocketException) { } byte[] datatempo = new byte[received]; string[] words = new string[5]; Array.Copy(data, datatempo, received); string text = Encoding.ASCII.GetString(datatempo); Console.WriteLine(text); words = text.Split('%'); if (words[0] == "Login") { String UserStuff = ValidarLogin(words[1], words[2]); if (UserStuff == "") { } else { Clientee user = new Clientee(); string[] words2 = new string[11]; words2 = UserStuff.Split('#'); user.userID = words2[0]; user.userName = words2[1]; user.userEmail = words2[2]; user.userState = words[3]; user.IP = words[4]; user.buzz = words2[3]; user.chat1 = words2[4]; user.chat2 = words2[5]; user.hora = words2[6]; user.camara = words2[7]; user.cuenta = words2[8]; user.jugo = words2[9]; user.mail = words2[10]; Clients.Add(user); Console.WriteLine(Clients[Clients.Count - 1].userName + " esta " + Clients[Clients.Count - 1].userState); String topaz = "Login%" + words2[2] + "%" + words2[0] + "%" + words2[3] + "%" + words2[4] + "%" + words2[5] + "%" + words2[6] + "%" + words2[7] + "%" + words2[8] + "%" + words2[9] + "%" + words2[10]; data2 = Encoding.ASCII.GetBytes(topaz); ClientSockets[ClientSockets.Count - 1].Send(data2); } } else if (words[0] == "Logro") { byte[] dataLogro = new byte[1024]; if (words[1] == "ora") { Console.WriteLine("Logro oraoraoraora!" + words[2]); loss(Int32.Parse(words[3])); String hra = "Logro%ora"; dataLogro = Encoding.ASCII.GetBytes(hra); for (int i = 1; i <= ClientSockets.Count; i++) { if (words[2] == Clients[i - 1].userName) { ClientSockets[i - 1].Send(dataLogro, dataLogro.Length, SocketFlags.None); } } } if (words[1] == "boss") { Console.WriteLine("Logro BUZZ YOGHURT LIGHT!" + words[2]); yoghurt(Int32.Parse(words[3])); String bobo = "Logro%boss"; dataLogro = Encoding.ASCII.GetBytes(bobo); for (int i = 1; i <= ClientSockets.Count; i++) { if (words[2] == Clients[i - 1].userName) { ClientSockets[i - 1].Send(dataLogro, dataLogro.Length, SocketFlags.None); } } } if (words[1] == "cind") { Console.WriteLine("Logro chat solito" + words[2]); Cind(Int32.Parse(words[3])); String indio = "Logro%cind"; dataLogro = Encoding.ASCII.GetBytes(indio); for (int i = 1; i <= ClientSockets.Count; i++) { if (words[2] == Clients[i - 1].userName) { ClientSockets[i - 1].Send(dataLogro, dataLogro.Length, SocketFlags.None); } } } if (words[1] == "cgrup") { Console.WriteLine("Logro chat no solito" + words[2]); Cgru(Int32.Parse(words[3])); String indios = "Logro%cgrup"; dataLogro = Encoding.ASCII.GetBytes(indios); for (int i = 1; i <= ClientSockets.Count; i++) { if (words[2] == Clients[i - 1].userName) { ClientSockets[i - 1].Send(dataLogro, dataLogro.Length, SocketFlags.None); } } } if (words[1] == "vidrio") { Console.WriteLine("Logro ia te vieron" + words[2]); camo(Int32.Parse(words[3])); String roio = "Logro%vidrio"; dataLogro = Encoding.ASCII.GetBytes(roio); for (int i = 1; i <= ClientSockets.Count; i++) { if (words[2] == Clients[i - 1].userName) { ClientSockets[i - 1].Send(dataLogro, dataLogro.Length, SocketFlags.None); } } } if (words[1] == "cuenta") { Console.WriteLine("Logro ya estasss aqui" + words[2]); banco(Int32.Parse(words[3])); String jej = "Logro%cuenta"; dataLogro = Encoding.ASCII.GetBytes(jej); for (int i = 1; i <= ClientSockets.Count; i++) { if (words[2] == Clients[i - 1].userName) { ClientSockets[i - 1].Send(dataLogro, dataLogro.Length, SocketFlags.None); } } } if (words[1] == "juego") { Console.WriteLine("Logro gatito" + words[2]); jugo(Int32.Parse(words[3])); String wea = "Logro%juego"; dataLogro = Encoding.ASCII.GetBytes(wea); for (int i = 1; i <= ClientSockets.Count; i++) { if (words[2] == Clients[i - 1].userName) { ClientSockets[i - 1].Send(dataLogro, dataLogro.Length, SocketFlags.None); } } } if (words[1] == "email") { Console.WriteLine("Logro el correo ya llego anunciando su cancion y con emocion grito, correo!" + words[2]); jugo(Int32.Parse(words[3])); String weas = "Logro%email"; dataLogro = Encoding.ASCII.GetBytes(weas); for (int i = 1; i <= ClientSockets.Count; i++) { if (words[2] == Clients[i - 1].userName) { ClientSockets[i - 1].Send(dataLogro, dataLogro.Length, SocketFlags.None); } } } } else if (words[0] == "Personal") { for (int i = 1; i <= ClientSockets.Count; i++) { if (words[1] == Clients[i - 1].userName || words[2] == Clients[i - 1].userName) { ClientSockets[i - 1].Send(datatempo, received, SocketFlags.None); } } } else if (words[0] == "Grupal") { for (int i = 1; i <= ClientSockets.Count; i++) { ClientSockets[i - 1].Send(datatempo, received, SocketFlags.None); } } else if (words[0] == "Buzz") { for (int i = 1; i <= ClientSockets.Count; i++) { ClientSockets[i - 1].Send(datatempo, received, SocketFlags.None); } } else if (words[0] == "Videollamada") { for (int i = 1; i <= Clients.Count; i++) { if (words[2] == Clients[i - 1].userName) { IP1 = Clients[i - 1].IP; } else if (words[1] == Clients[i - 1].userName) { IP2 = Clients[i - 1].IP; } } for (int i = 1; i <= Clients.Count; i++) { byte[] udptem = new byte[20]; string socketudp; if (words[2] == Clients[i - 1].userName) { socketudp = "VideollamadaRecibir" + "%" + IP2 + "%" + words[1]; udptem = Encoding.ASCII.GetBytes(socketudp); ClientSockets[i - 1].Send(udptem, udptem.Length, SocketFlags.None); } else if (words[1] == Clients[i - 1].userName) { socketudp = "Videollamada" + "%" + IP1; udptem = Encoding.ASCII.GetBytes(socketudp); ClientSockets[i - 1].Send(udptem, udptem.Length, SocketFlags.None); } } DUDMandaruno = new UdpClient(IP1, 667); DUDMandardos = new UdpClient(IP2, 9998); sender = new IPEndPoint(IPAddress.Any, 666); sender2 = new IPEndPoint(IPAddress.Any, 9999); video.Start(); } else if (words[0] == "YaEmpiezale") { byte[] OC = new byte[20]; string OCtl = "Abueno%"; OC = Encoding.ASCII.GetBytes(OCtl); for (int i = 1; i <= ClientSockets.Count; i++) { if (words[1] == Clients[i - 1].userName || words[2] == Clients[i - 1].userName) { ClientSockets[i - 1].Send(OC, 7, SocketFlags.None); } } } else if (words[0] == "Juego") { byte[] OC = new byte[20]; string OCtl = "juego%" + words[1]; OC = Encoding.ASCII.GetBytes(OCtl); J1 = words[1]; J2 = words[2]; for (int i = 1; i <= ClientSockets.Count; i++) { if (words[2] == Clients[i - 1].userName) { ClientSockets[i - 1].Send(OC, OC.Length, SocketFlags.None); } } } else if (words[0] == "Movimiento") { byte[] dataGame = new byte[1024]; String gamo = "Movimiento%" + words[1] + "%" + words[2]; dataGame = Encoding.ASCII.GetBytes(gamo); if (words[1] == "juno") { for (int i = 1; i <= ClientSockets.Count; i++) { if (J2 == Clients[i - 1].userName || J1 == Clients[i - 1]) { ClientSockets[i - 1].Send(dataGame, dataGame.Length, SocketFlags.None); } } } else if (words[1] == "jdos") { for (int i = 1; i <= ClientSockets.Count; i++) { if (J2 == Clients[i - 1].userName || J1 == Clients[i - 1]) { ClientSockets[i - 1].Send(dataGame, dataGame.Length, SocketFlags.None); } } } } for (int i = 1; i <= ClientSockets.Count; i++) { ClientSockets[i - 1].BeginReceive(data, 0, 1024, SocketFlags.None, RecibirSocket, ClientSockets[i - 1]); } }