Comparing users ID's that is connected to different servers

in programming •  7 years ago 

Compare


I was assigned a task by the teamspeak founder to right a program that can compair users from different servers and display the users that is connected to both servers and the same time.

This is the user interface I created. (for experimental purposes I used the same text-file to compare all the users)

1.png

Description:

It uses textiles to read the users and then compare them by using a quick compare algorithm

Get ID button

  public List < string > usernames2 = new List < string > ();
  private void button2_Click(object sender, EventArgs e) {

Varibles

  FileStream filestream = new FileStream("taccorgaminguserlist.txt", FileMode.Open, FileAccess.Read);
  StreamReader reader2 = new StreamReader(filestream);
  const string SEARCH = "client_unique_identifier=";

  string line = null;
  string noFormat = null;

Algorithm

  while ((line = reader2.ReadLine()) != null) {
      noFormat = noFormat + line;
  }
  reader2.Close();
  while (noFormat.IndexOf(SEARCH) != -1) {
      noFormat = noFormat.Remove(0, noFormat.IndexOf(SEARCH) + SEARCH.Length);
      if (noFormat.IndexOf("|") != -1) {
          if (noFormat.Substring(0, noFormat.IndexOf("|") + 1) != "Serveradmi" && noFormat.Substring(0, noFormat.IndexOf("|") + 1) != "ServerQuer" & noFormat.Substring(0, noFormat.IndexOf("|") + 1) != "serveradmi") {
              usernames2.Add(noFormat.Substring(0, noFormat.IndexOf("|") - 1));
          }

          Console.WriteLine();

      } else {
          usernames2.Add(noFormat.Substring(noFormat.IndexOf(SEARCH) + SEARCH.Length));
      }
  }

Writing in the rich edit

  foreach(var item in usernames2) {
      richTextBox2.AppendText(item);
      richTextBox2.AppendText("\n");
  }

}

Displaying the end result

private void button3_Click(object sender, EventArgs e) {

List < string > FinalList = new List < string > ();
foreach(var item in usernames) {
    if (usernames2.Contains(item)) {
        FinalList.Add("                       ");
        FinalList.Add(item);
    }
}
foreach(var item2 in FinalList) {
    richTextBox3.AppendText(item2);
    richTextBox2.AppendText("\n");

}

}

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!