public ViewDoubleSolutions(DisplayResultsForm frm, PlagCheck_Server.Solution sol1, PlagCheck_Server.Solution sol2, string sol1Name, string sol2Name, float similarity) { sourceForm = frm; sourceSolution1 = sol1; sourceSolution2 = sol2; InitializeComponent(); contentBox1.Text = sourceSolution1.Content.Replace("\r\n", "\n").Replace("\n", "\r\n"); contentBox2.Text = sourceSolution2.Content.Replace("\r\n", "\n").Replace("\n", "\r\n"); solNameBox1.Text = sol1Name; solNameBox2.Text = sol2Name; similarityBox.Text = string.Format("Similarity percentage: {0:00.00}%", similarity); }
public void AddSolution(PlagCheck_Server.Solution sol) { try { ipHostInfo = Dns.GetHostEntry(Dns.GetHostName()); ipAddress = ipHostInfo.AddressList[1]; clientSocket = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); clientSocket.SendBufferSize = 1048576; clientSocket.ReceiveBufferSize = 1048576; string ip = ipTextBox.Text; int port = int.Parse(portTextBox.Text); clientSocket.Connect(ip, port); string message = ""; using (StringWriter sw = new StringWriter()) { solutionSerializer.Serialize(sw, sol); message = sw.ToString(); } byte[] messageSent = Encoding.UTF8.GetBytes("<ADD>" + message + "<EOM>"); int byteSent = clientSocket.Send(messageSent); byte[] messageReceived = new byte[16]; int byteRecv = clientSocket.Receive(messageReceived); string received = Encoding.UTF8.GetString(messageReceived, 0, byteRecv); AddLogs(String.Format("Text received at {0} -> {1}", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss tt"), ((received.Length > 64 || received.Contains("\n")) ? (received.Substring(0, (received.IndexOf("\n") > 64) ? 64 : received.IndexOf("\n")) + "...") : received))); if (received.Length >= 5 && received.Substring(0, 5).Equals("<ACK>")) { AddLogs("Addtion request sent successfully."); } else { AddLogs("Failed to send addition request."); } } catch (Exception exc) { AddLogs(exc.Message); } clientSocket.Dispose(); }
public ViewSingleSolution(DisplayResultsForm frm, PlagCheck_Server.Solution sol) { sourceForm = frm; sourceSolution = sol; InitializeComponent(); contentBox.Text = sourceSolution.Content.Replace("\r\n", "\n").Replace("\n", "\r\n"); }