I am writing an application that will run as a service and check computers once an hour to see if they are up. I have a ComputerList.xml file that I will be reading from and writing to. The format of the xml file is
<computers>
<PrimaryServers>
<Location1 type="primary">
<ipaddress>192.168.1.2</ipaddress>
<isAlive>true</ipaddress>
</Location1>
<location2></location2>
</PrimaryServers>
<SecondaryServers>
<location1 type="secondary">
<ipaddress></ipaddress>
etc...
</location1>
</SecondaryServers>
<clients>
etc... <type="client">
</clients>
</computers>
Each location has a different number of computers and I'd like to store the values for use in other methods and write back a bool to the file whether or not the host is alive after it has been checked.
The idea for this application is check if the primary server is alive, if it's not it checks to see if the clients are alive, if they are down then I know the network is down between sites and do nothing, if just the server is down, then it pushes out a hosts file to the clients that are alive, redirecting traffic to the secondary server. I would use failover clustering but the LOB application on the server does not allow this.
All I'm looking for is a way to read the xml file, discern between primaries, secondaries, and clients, retrieve the values and store them in a dictionary. I've already written the code to see if it is alive or not which will return each devices IsAlive status, I just need to write this into the xml so I have persistent data in case the server is rebooted. There are not enough computers to justify a database.
Thanks in advance.