123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- using DiskAccessLibrary;
- using DiskAccessLibrary.LogicalDiskManager;
- using Utilities;
- namespace ISCSIConsole
- {
- public partial class Program
- {
- public static void OfflineCommand(string[] args)
- {
- if (args.Length > 1)
- {
- switch (args[1].ToLower())
- {
- case "disk":
- {
- if (m_selectedDisk != null)
- {
- if (m_selectedDisk is PhysicalDisk)
- {
- if (Environment.OSVersion.Version.Major >= 6)
- {
- bool isOnline = ((PhysicalDisk)m_selectedDisk).GetOnlineStatus();
- if (isOnline)
- {
- bool success = ((PhysicalDisk)m_selectedDisk).SetOnlineStatus(false, true);
- if (success)
- {
- Console.WriteLine("Disk has been taken offline.");
- }
- else
- {
- Console.WriteLine("Failed to take the disk offline.");
- }
- }
- else
- {
- Console.WriteLine("Disk is already offline.");
- }
- }
- else
- {
- Console.WriteLine("This command is only supported on Windows Vista and later.");
- }
- }
- }
- else
- {
- Console.WriteLine("No disk has been selected.");
- }
- break;
- }
- default:
- {
- Console.WriteLine("Invalid argument.");
- break;
- }
- }
- }
- else
- {
- Console.WriteLine("Invalid argument.");
- }
- }
- public static void OnlineCommand(string[] args)
- {
- if (args.Length > 1)
- {
- switch (args[1].ToLower())
- {
- case "disk":
- {
- if (m_selectedDisk != null)
- {
- if (m_selectedDisk is PhysicalDisk)
- {
- if (Environment.OSVersion.Version.Major >= 6)
- {
- bool isOnline = ((PhysicalDisk)m_selectedDisk).GetOnlineStatus();
- if (!isOnline)
- {
- bool success = ((PhysicalDisk)m_selectedDisk).SetOnlineStatus(true, true);
- if (success)
- {
- Console.WriteLine("Disk has been taken online.");
- }
- else
- {
- Console.WriteLine("Failed to take the disk online.");
- }
- }
- else
- {
- Console.WriteLine("Disk is already online.");
- }
- }
- else
- {
- Console.WriteLine("This command is only supported on Windows Vista and later.");
- }
- }
- }
- else
- {
- Console.WriteLine("No disk has been selected.");
- }
- break;
- }
- default:
- {
- Console.WriteLine("Invalid argument.");
- break;
- }
- }
- }
- else
- {
- Console.WriteLine("Invalid argument.");
- }
- }
- public static void HelpOffline()
- {
- Console.WriteLine();
- Console.WriteLine("OFFLINE DISK - Takes the selected disk offline.");
- }
- public static void HelpOnline()
- {
- Console.WriteLine();
- Console.WriteLine("ONLINE DISK - Takes the selected disk online.");
- }
- }
- }
|