I’m creating a monitoring application which tests if the servers are running or not.
I would like the user to choose the environment that they are running as in Dev, stage or Prod and then do the testing for that particular environment.
I’m new to c# and hence would like some guidance how to go about with this..
In pseudocode,
Define all the server address for the different environments
Ask the user to choose the environment they would like to test
Read the user’s input and take them to the method (having the same name as the input) that would read the environment and start testing if the server is running.
I’m not sure how to go about this… any help?
So far this is what I have have:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please choose your environment and Username to test from below");
Console.WriteLine("Dev");
Console.WriteLine("Stage");
Console.WriteLine("Prod");
string inputtedText = "";
inputtedText = Console.ReadLine();
if (inputtedText == "Dev") { Program.TestServer(null); }
if (inputtedText == "Stage") { Program.TestServer(null); }
if (inputtedText == "Prod") { Program.TestServer(null); }
}
static void TestServer (string[] args)
{
//how to read the specific username and server for this credential creation?
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(ServerName, UserName);
}