private void UpdateLocation(string NrTel, LatitudeLongitude Positon) { using (SqlConnection Database = new SqlConnection(_Details.DatabaseConnectionString)) { Database.Open(); SqlCommand cmd = new SqlCommand("UPDATE Utilizatori SET [LastKnowPosition]='" + Position.GetCoord() + "' WHERE [NumarTelefon]='" + NrTel + "'", Database); cmd.ExecuteNonQuery(); } }
private void Listener() { while (true) { string[] Messages = this.Receive(); try { Position = new LatitudeLongitude(Messages[0], Messages[1]); PositionString = Position.GetCoord(); Console.WriteLine(NumarTelefon + ":" + PositionString + "======>>>>>" + System.DateTime.Now.Hour + ":" + System.DateTime.Now.Minute + ":" + System.DateTime.Now.Second); UpdateLocation(NumarTelefon, Position); if (this.Data.TipCont == "Organizator") { List <string> Response = new List <string>(); Response.Add("1"); foreach (LocationableClient a in e.LocationableClients) { if (a.NumarTelefon != this.NumarTelefon) { Response.Add(NumarTelefon); Response.Add(Position.GetDistance(a.Position)); break; } } _Utils.WriteStreamString(Client.ns, CryptDecryptData.CryptData(Response.ToArray())); } else { _Utils.WriteStreamString(Client.ns, CryptDecryptData.CryptData(new string[] { "0" })); } } catch (Exception ex) { Console.WriteLine(ex.Message); foreach (LocationableClient a in e.LocationableClients) { if (a.NumarTelefon == this.NumarTelefon) { e.LocationableClients.Remove(a); foreach (NotificableClient nc in e.NotificableClients) { if (nc.NumarTelefon == this.NumarTelefon) { e.NotificableClients.Remove(nc); nc.Dispose(); break; } } e.OnClientEnterExit(); break; } } break; } } }