public void RedrawClasses() { List <string> tmp = new List <string>(); foreach (object Item in ClassChooser.CheckedItems) { tmp.Add(Item.ToString()); } ClassChooser.Items.Clear(); foreach (object Item in ServiseChooser.CheckedItems) { string ToCompare = Item.ToString(); int i = 0; while (ToCompare != Companies[i].name + " / " + Math.Round(Companies[i].rating, 1).ToString()) { i++; } int j = 0; foreach (Taxi Tax in Companies[i].taxis) { if (!ClassChooser.Items.Contains(Tax.Class)) { ClassChooser.Items.Add(Tax.Class); j++; } } for (i = 0; i < j; ++i) { if (tmp.Contains(ClassChooser.Items[i].ToString())) { ClassChooser.SetItemChecked(i, true); } } } }
private void AllClassesButton_Click(object sender, EventArgs e) { for (int i = 0; i < ClassChooser.Items.Count; ++i) { ClassChooser.SetItemChecked(i, true); } }
public static void OnReceive(UserContext aContext) { try { ClassChooser.Handle(aContext, Sessions, OnlineConnections); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void ReadCallback(IAsyncResult ar) { StateObject state = (StateObject)ar.AsyncState; try { String content = String.Empty; // Retrieve the state object and the handler socket // from the asynchronous state object. Socket handler = state.workSocket; // Read data from the client socket. int bytesRead = handler.EndReceive(ar); if (bytesRead > 0) { // There might be more data, so store the data received so far. content = Encoding.ASCII.GetString(state.buffer, 0, bytesRead); Console.WriteLine("Read {0} bytes from socket. \n Data : {1}", content.Length, content); if (Program.Server.OnlineConnections.TryGetValue(state.workSocket.RemoteEndPoint.ToString(), out Connection val)) { var responses = ClassChooser.Handle(val.Context, content, Program.Server.Sessions, Program.Server.OnlineConnections); foreach (GenericResponsePacket response in responses) { Send(response.Client.Socket, JsonConvert.SerializeObject(response.Response)); } } else { Console.WriteLine($"Nessun client connesso dall'ip {state.workSocket.RemoteEndPoint}"); } } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.InnerException?.Message); Connection conn; Program.Server.OnlineConnections.TryRemove(state.workSocket.RemoteEndPoint.ToString(), out conn); if (conn != null) //E' riuscito a rimuovere la connessione. { Session sess = Program.Server.Sessions.First(s => { bool res = (s.ID == conn.IP.ToString()); if (res) { if (s.ID != "") { if (s.user != null) { AccountMgr.SetOffline(s.user); } } } return(res); }); if (sess != null) { Program.Server.Sessions.Remove(sess); } // Dispose timer to stop sending messages to the client. conn.timer.Dispose(); } } }