Cyber-Resilient Control of an Islanded Microgrid Under Latency Attacks and Random DoS Attacks