bool ConnectToServer(BuildContext ctx)
{
try {
if (ctx.Connect())
{
ctx.Connected = true;
return(true);
}
else
{
if (ctx.FirstNotAuthorised)
{
LogService.WriteLine("ERROR: Connection to server not authorized.");
LogService.WriteLine("To enable connections from this service, go to the administration page");
LogService.WriteLine("in the server and click on the Change Service option.");
ctx.FirstNotAuthorised = false;
}
else
{
LogService.WriteLine("Connection not authorized. Trying again.");
}
}
} catch (Exception ex) {
LogService.WriteLine("Connection failed: " + ex.Message);
}
ctx.Connected = false;
return(false);
}