public override int GetHashCode() { var ticketRelationshipHash = (TicketRelationship?.GetHashCode()).GetValueOrDefault(19); var primaryHash = (PrimaryTicket?.GetHashCode()).GetValueOrDefault(23); var secondaryHash = (SecondaryTicket?.GetHashCode()).GetValueOrDefault(29); var relationshipHash = (Relationship?.GetHashCode()).GetValueOrDefault(37); var typeHash = Type.GetHashCode(); return(ticketRelationshipHash ^ primaryHash ^ secondaryHash ^ relationshipHash ^ typeHash); }
public void GetSecondaryTicketsFromSocket() { InvokeIfRequired(() => { tickets = new DataTable("secondaryTickets"); tickets.Columns.Add("id"); tickets.Columns.Add("originalticketId"); tickets.Columns.Add("solver"); tickets.Columns.Add("secondarysolver"); tickets.Columns.Add("date"); tickets.Columns.Add("title"); for (int i = 0; i < socketClient.secondaryTickets.Count; i++) { SecondaryTicket ticket = socketClient.secondaryTickets[i]; List <string> arr = new List <string>(); arr.Add(ticket.Id.ToString()); arr.Add(ticket.originalTicketId.ToString()); arr.Add(ticket.solver); arr.Add(ticket.secondarySolver); arr.Add(ticket.date.ToString()); arr.Add(ticket.title); for (int u = 0; u < ticket.questions.Count; u++) { if (!tickets.Columns.Contains("question:" + u)) { tickets.Columns.Add("question:" + u); } if (!tickets.Columns.Contains("answers: " + u)) { tickets.Columns.Add("answers: " + u); } arr.Add(ticket.questions[u]); arr.Add(ticket.answers[u]); } tickets.Rows.Add(arr.ToArray()); } dataGridView2.DataSource = tickets; }); }
public void ReceiveCallback(IAsyncResult ar) { try { // Retrieve the state object and the client socket // from the asynchronous state object. Tuple <byte[], Socket> tuple = (Tuple <byte[], Socket>)ar.AsyncState; byte[] buffer = tuple.Item1; Socket client = tuple.Item2; // Read data from the remote device. int bytesRead = client.EndReceive(ar); if (bytesRead > 0) { // There might be more data, so store the data received so far. sb.Append(Encoding.ASCII.GetString(buffer, 0, bytesRead)); // Get the rest of the data. client.BeginReceive(buffer, 0, SocketConstants.BUFFER_SIZE, 0, new AsyncCallback(ReceiveCallback), new Tuple <byte[], Socket>(buffer, client)); } else { string content = sb.ToString(); content = content.Replace(SocketConstants.EOF, ""); content = content.Trim(); // All the data has arrived; clear. sb.Clear(); if (content.StartsWith(SocketConstants.SECONDARYTICKETS)) { content = content.Replace(SocketConstants.SECONDARYTICKETS, ""); content = content.Trim(); List <SecondaryTicket> receivedTickets = Newtonsoft.Json.JsonConvert.DeserializeObject <List <SecondaryTicket> >(content); // Update existing SecondaryTickets and add new ones for (int i = 0; i < receivedTickets.Count; i++) { SecondaryTicket newTicket = receivedTickets[i]; int index = secondaryTickets.FindIndex((x) => x.Id == newTicket.Id); if (index == -1) { secondaryTickets.Add(newTicket); } else { secondaryTickets[index] = newTicket; } } UpdateSecondaryTicketsFile(); } if (content.StartsWith(SocketConstants.OK)) { } if (afterReceive != null) { afterReceive(); afterReceive = null; } // Signal that all bytes have been received. receiveDone.Set(); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
// ticket talks private void button10_Click(object sender, EventArgs e) { if (state != 0) { state = 3; selected(button10); position(button10); if (dataGridView2.SelectedRows.Count > 1) { CustomOkMessageBox box = new CustomOkMessageBox("It's better if you assign select one ticket at time!"); box.Show(); return; } if (TicketSelected()) { int selectedrowindex = dataGridView2.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = dataGridView2.Rows[selectedrowindex]; string id = Convert.ToString(selectedRow.Cells["originalTicketId"].Value); string title = Convert.ToString(selectedRow.Cells["title"].Value); string solver = Convert.ToString(selectedRow.Cells["solver"].Value); SecondaryTicket st = socketClient.secondaryTickets.Find(x => x.Id.ToString() == (string)selectedRow.Cells["id"].Value); List <string> q = st.questions; List <string> a = st.answers; string question = Convert.ToString(selectedRow.Cells["solver"].Value); label7.Text = "Ticket ID: " + id; label5.Text = "Ticket Title: " + title; textBox4.Text = ""; //q.Reverse(); //a.Reverse(); // Chat this.panel3.Controls.Clear(); for (int i = 0; i < q.Count; i++) { TextBox temp = new TextBox(); temp.ReadOnly = true; temp.Multiline = true; temp.Location = new Point(0, 0 + 40 * i); temp.Size = new Size(806, 20); temp.ForeColor = Color.White; temp.BackColor = Color.FromArgb(24, 26, 27); temp.Text = solver + ": " + q[i]; temp.BorderStyle = BorderStyle.None; this.panel3.Controls.Add(temp); if (!a[i].Equals("waiting for answer")) { TextBox temp2 = new TextBox(); temp2.ReadOnly = true; temp2.Multiline = true; temp2.Location = new Point(0, 20 + 40 * i); temp2.Size = new Size(806, 20); temp2.ForeColor = Color.White; temp2.BackColor = Color.FromArgb(24, 26, 27); temp2.BorderStyle = BorderStyle.None; temp2.Text = department + ": " + a[i]; this.panel3.Controls.Add(temp2); } } } UpdateByState(); } }