protected static void unmountPartition(string partitionId)
        {
            string            command = getDCCon() + @" -unmount " + partitionId + " -f";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC unmount");

            ProcessControl.CommandOutputSync(eparams);
        }
        protected static void unmountAllEncryptedPartitions()
        {
            string            command = getDCCon() + @" -unmountall -f";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC unmountall");

            ProcessControl.CommandOutputSync(eparams);
        }
        protected static void cleanupMemory()
        {
            string            command = getDCCon() + @" -clean";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC clean");

            ProcessControl.CommandOutputSync(eparams);
        }
        protected static void installDC()
        {
            string            command = getDCInst() + @" -setup";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC install");

            ProcessControl.CommandOutputSync(eparams);
        }
        protected static void deconfigureDC()
        {
            string            command = getDCCon() + @" -deconfig-mydlp";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC deconfig mydlp");

            ProcessControl.CommandOutputSync(eparams);
        }
        protected static string getPartitionId(string driveLetter)
        {
            string            command = getDCCon() + @" -enum";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC enum");
            string            output  = ProcessControl.CommandOutputSync(eparams);

            string[] lines = output.Split('\n');
            foreach (string line in lines)
            {
                if (line.Contains("reboot you system"))
                {
                    return(null);
                }

                if (line.Contains("is not compatible with the version of Windows"))
                {
                    return(null);
                }

                string[] parts = line.Split('|');
                if (parts.Length != 4)
                {
                    continue;
                }
                string drivePart = parts[1];
                if (drivePart.Contains(" " + driveLetter + ": "))
                {
                    string partitionIdPart = parts[0];
                    return(partitionIdPart.Trim());
                }
            }
            return(null);
        }
        protected static void formatPartition(string partitionId, string fsType)
        {
            string keyfile = Engine.GetShortPath(SeapClient.GetKeyfile());

            if (File.Exists(keyfile))
            {
                string            command = getDCCon() + @" -format " + partitionId + " -q -" + fsType + " -a -p mydlp -kf " + keyfile;
                ExecuteParameters eparams = new ExecuteParameters(command, "DC format");
                ProcessControl.CommandOutputSync(eparams);
                File.Delete(keyfile);
            }
        }
        protected static void mountAllEncryptedPartitions()
        {
            string keyfile = Engine.GetShortPath(SeapClient.GetKeyfile());

            if (File.Exists(keyfile))
            {
                string            command = getDCCon() + @" -mountall -p mydlp -kf " + keyfile;
                ExecuteParameters eparams = new ExecuteParameters(command, "DC mountall");
                ProcessControl.CommandOutputSync(eparams);
                File.Delete(keyfile);
            }
        }
        protected static bool isEncrypted(string partitionId)
        {
            string            command = getDCCon() + @" -info " + partitionId;
            ExecuteParameters eparams = new ExecuteParameters(command, "DC isEncrypted");
            string            output  = ProcessControl.CommandOutputSync(eparams);

            string[] lines = output.Split('\n');
            foreach (string line in lines)
            {
                if (line.StartsWith("Cipher:"))
                {
                    return(true);
                }
            }
            return(false);
        }
        public static void ExecuteCommandSync(object parameters)
        {
            ExecuteParameters param = (ExecuteParameters)parameters;

            try
            {
                System.Diagnostics.ProcessStartInfo procStartInfo =
                    new System.Diagnostics.ProcessStartInfo("cmd", "/c " + param.Command);
                procStartInfo.RedirectStandardOutput = true;
                procStartInfo.RedirectStandardError  = true;
                procStartInfo.UseShellExecute        = false;
                procStartInfo.CreateNoWindow         = true;
                procStartInfo.ErrorDialog            = false;

                foreach (EnvVar var in param.Env)
                {
                    if (var.Name == "path")
                    {
                        procStartInfo.EnvironmentVariables["path"] = procStartInfo.EnvironmentVariables["path"] + var.Value;
                    }
                    else
                    {
                        procStartInfo.EnvironmentVariables.Add(var.Name, var.Value);
                    }
                    Logger.GetInstance().Debug(param.Prefix + " EvnVar:" + var.Name + " = " + procStartInfo.EnvironmentVariables[var.Name]);
                }

                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo = procStartInfo;
                Logger.GetInstance().Debug(param.Prefix + " starting process: \"" + param.Command + "\"");
                proc.OutputDataReceived += (sender, args) => SuppressUnnecessaryDebug(param.Prefix, args.Data);
                proc.ErrorDataReceived  += (sender, args) => SuppressUnnecessaryError(param.Prefix, args.Data);
                proc.EnableRaisingEvents = true;
                proc.Start();
                proc.BeginOutputReadLine();
                proc.BeginErrorReadLine();
                proc.WaitForExit();
                proc.CancelErrorRead();
                proc.CancelOutputRead();
                Logger.GetInstance().Debug(param.Prefix + " process exited.");
            }
            catch (Exception e)
            {
                Logger.GetInstance().Error(param.Prefix + " " + e);
            }
        }
        public static string CommandOutputSync(object parameters)
        {
            ExecuteParameters param = (ExecuteParameters)parameters;

            try
            {
                System.Diagnostics.ProcessStartInfo procStartInfo =
                    new System.Diagnostics.ProcessStartInfo("cmd", "/c " + param.Command);
                procStartInfo.RedirectStandardOutput = true;
                procStartInfo.RedirectStandardError  = true;
                procStartInfo.UseShellExecute        = false;
                procStartInfo.CreateNoWindow         = true;
                procStartInfo.ErrorDialog            = false;

                foreach (EnvVar var in param.Env)
                {
                    if (var.Name == "path")
                    {
                        procStartInfo.EnvironmentVariables["path"] = procStartInfo.EnvironmentVariables["path"] + var.Value;
                    }
                    else
                    {
                        procStartInfo.EnvironmentVariables.Add(var.Name, var.Value);
                    }
                    System.Console.WriteLine(param.Prefix + " EvnVar:" + var.Name + " = " + procStartInfo.EnvironmentVariables[var.Name]);
                }

                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo           = procStartInfo;
                proc.EnableRaisingEvents = true;
                proc.Start();

                string stdoutx = proc.StandardOutput.ReadToEnd();
                string stderrx = proc.StandardError.ReadToEnd();
                proc.WaitForExit();
                return(stderrx + stdoutx);
            }
            catch (Exception e)
            {
                Logger.GetInstance().Error(param.Prefix + " " + e);
            }
            return(null);
        }
        protected static bool doesNeedFormatting(string partitionId)
        {
            string            command = getDCCon() + @" -info " + partitionId;
            ExecuteParameters eparams = new ExecuteParameters(command, "DC doesNeedFormatting");
            string            output  = ProcessControl.CommandOutputSync(eparams);

            string[] lines = output.Split('\n');
            foreach (string line in lines)
            {
                if (line.StartsWith("Status:") &&
                    (line.Contains("boot") || line.Contains("system"))
                    )
                {
                    return(false);
                }

                if (line.StartsWith("Device:") && line.Contains(@"\\Device\CdRom"))
                {
                    return(false);
                }


                if (line.StartsWith("Cipher:"))
                {
                    return(false);
                }

                if (line.Contains("reboot you system"))
                {
                    return(false);
                }

                if (line.Contains("is not compatible with the version of Windows"))
                {
                    return(false);
                }
            }
            return(true);
        }
        protected static bool doesNeedFormatting(string partitionId)
        {
            string command = getDCCon() + @" -info " + partitionId;
            ExecuteParameters eparams = new ExecuteParameters(command, "DC doesNeedFormatting");
            string output = ProcessControl.CommandOutputSync(eparams);
            string[] lines = output.Split('\n');
            foreach (string line in lines)
            {
                if (line.StartsWith("Status:") &&
                    (line.Contains("boot") || line.Contains("system"))
                    )
                    return false;

                if (line.StartsWith("Device:") && line.Contains(@"\\Device\CdRom"))
                    return false;

                if (line.StartsWith("Cipher:"))
                    return false;

                if (line.Contains("reboot you system"))
                    return false;

                if (line.Contains("is not compatible with the version of Windows"))
                    return false;
            }
            return true;
        }
 protected static void installDC()
 {
     string command = getDCInst() + @" -setup";
     ExecuteParameters eparams = new ExecuteParameters(command, "DC install");
     ProcessControl.CommandOutputSync(eparams);
 }
        protected static bool isMounted(string partitionId)
        {
            string command = getDCCon() + @" -info " + partitionId;
            ExecuteParameters eparams = new ExecuteParameters(command, "DC isMounted");
            string output = ProcessControl.CommandOutputSync(eparams);
            string[] lines = output.Split('\n');
            foreach (string line in lines)
            {
                if (line.StartsWith("Status:"))
                {
                    if (line.Contains(" mounted"))
                        return true;
                    if (line.Contains(" unmounted"))
                        return false;
                }

            }
            return false;
        }
 protected static void mountPartition(string partitionId)
 {
     string keyfile = Engine.GetShortPath(SeapClient.GetKeyfile());
     if (File.Exists(keyfile))
     {
         string command = getDCCon() + @" -mount " + partitionId + " -p mydlp -kf " + keyfile;
         ExecuteParameters eparams = new ExecuteParameters(command, "DC mount");
         ProcessControl.CommandOutputSync(eparams);
         File.Delete(keyfile);
     }
 }
 protected static void unmountAllEncryptedPartitions()
 {
     string command = getDCCon() + @" -unmountall -f";
     ExecuteParameters eparams = new ExecuteParameters(command, "DC unmountall");
     ProcessControl.CommandOutputSync(eparams);
 }
 protected static void unmountPartition(string partitionId)
 {
     string command = getDCCon() + @" -unmount " + partitionId + " -f";
     ExecuteParameters eparams = new ExecuteParameters(command, "DC unmount");
     ProcessControl.CommandOutputSync(eparams);
 }
 protected static void cleanupMemory()
 {
     string command = getDCCon() + @" -clean";
     ExecuteParameters eparams = new ExecuteParameters(command, "DC clean");
     ProcessControl.CommandOutputSync(eparams);
 }
 protected static void configureDC()
 {
     string command = getDCCon() + @" -config-mydlp";
     ExecuteParameters eparams = new ExecuteParameters(command, "DC config mydlp");
     ProcessControl.CommandOutputSync(eparams);
 }
        protected static string getPartitionId(string driveLetter)
        {
            string command = getDCCon() + @" -enum";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC enum");
            string output = ProcessControl.CommandOutputSync(eparams);
            string[] lines = output.Split('\n');
            foreach (string line in lines)
            {
                if (line.Contains("reboot you system"))
                    return null;

                if (line.Contains("is not compatible with the version of Windows"))
                    return null;

                string[] parts = line.Split('|');
                if (parts.Length != 4)
                    continue;
                string drivePart = parts[1];
                if (drivePart.Contains(" " + driveLetter + ": "))
                {
                    string partitionIdPart = parts[0];
                    return partitionIdPart.Trim();
                }
            }
            return null;
        }