private void button2_Click(object sender, EventArgs e) { for (int jrows = 0; jrows < listView1.Items.Count; jrows++) { try { string mac = listView1.Items[jrows].SubItems[3].Text; string mac6 = mac.Replace(":", ""); string mac66 = mac6.Substring(0, 6); try { //for (int i = 0; i < listView1.Items.Count; i++) // { listView1.Items[jrows].SubItems[5].Text = obj_alg.algorthm(mac66); // } } catch { } } catch { } } //store the alldetails into the database for future purpose string deleteQuery = "delete from [TotalALLSignatures]"; int j = obj_data.InsUpDel(deleteQuery); for (int RowCount = 0; RowCount < listView1.Items.Count; RowCount++) { try { string hostname = listView1.Items[RowCount].SubItems[0].Text; string ipadd1 = listView1.Items[RowCount].SubItems[1].Text; string ipadd2 = listView1.Items[RowCount].SubItems[2].Text; string mac = listView1.Items[RowCount].SubItems[3].Text; string status = listView1.Items[RowCount].SubItems[4].Text; string signature = listView1.Items[RowCount].SubItems[5].Text; string datare = listView1.Items[RowCount].SubItems[6].Text; string respotime = listView1.Items[RowCount].SubItems[7].Text; string insertQuery = "insert into [TotalALLSignatures] values('" + hostname + "','" + ipadd1 + "','" + ipadd2 + "','" + mac + "','" + status + "','" + signature + "','" + datare + "','" + respotime + "')"; int i = obj_data.InsUpDel(insertQuery); if (i > 0) { insCount++; } } catch { } } MessageBox.Show(insCount + "Record(S) inserted"); }
public void ServerStarter() { try { IPAddress ipAd = IPAddress.Parse("127.0.0.1"); myList = new TcpListener(ipAd, 8001); myList.Start(); s = myList.AcceptSocket(); byte[] b = new byte[1024 * 10]; int k = s.Receive(b); for (int i = 0; i < k; i++) { str2 = str2 + Convert.ToChar(b[i]).ToString(); } // textBox2.Text = str2; iresult = checking(str2); if (iresult == true) { ASCIIEncoding asen = new ASCIIEncoding(); s.Send(asen.GetBytes("Thank u for Contacting.")); System.Threading.Thread.Sleep(100); myList.Stop(); iResult = true; obj1.SEnderIP = str2; obj1.StartServer(); // backgroundWorker1.RunWorkerAsync(); } else { ASCIIEncoding asen = new ASCIIEncoding(); s.Send(asen.GetBytes("sorry U r not Authenticated user.")); System.Threading.Thread.Sleep(100); myList.Stop(); iResult = false; string InsertDetails = "insert into [SaveALlRequests] values('" + SendIP + "','" + str2 + "','" + DateTime.Now.ToShortDateString() + "','Closed','Suspective')"; obj_data.InsUpDel(InsertDetails); //obj1.StartServer(); } //if (s.Connected != true) //{ // //s.Connected = false; // while (true) // { // ServerStarter(); // } //} //else //{ //} } catch (Exception ex) { MessageBox.Show("Error..... " + ex.StackTrace); iResult = false; } }