public ErrorResponse(ModelStateDictionary modelState) : this() { ErrorCount = modelState.ErrorCount; foreach (var key in modelState.Keys) { InvalidKeys.Add(key); } foreach (var value in modelState.Values) { foreach (var error in value.Errors) { if (!string.IsNullOrEmpty(error.ErrorMessage)) { ErrorMessages.Add(error.ErrorMessage); } var exceptionMessage = error.Exception?.Message; if (!string.IsNullOrEmpty(exceptionMessage)) { ErrorMessages.Add(exceptionMessage); } var innerExceptionMessage = error.Exception?.InnerException?.Message; if (innerExceptionMessage != null) { ErrorMessages.Add(innerExceptionMessage); } } } }
public void BackUpRegistrykey(InvalidKeys badkey) { DataRow dr = dtRegistryKeyDeleted.NewRow(); string strKey = String.Empty; string strCommnd = String.Empty; string strLocationToSave = Path.Combine(strRegistryBackupFolderPath, Guid.NewGuid().ToString() + ".dat"); if (badkey.Root.Name == "HKEY_CLASSES_ROOT") { strKey = "HKCR " + badkey.Subkey; } else if (badkey.Root.Name == "HKEY_LOCAL_MACHINE") { strKey = "HKLM " + badkey.Subkey; strCommnd = "RegSaveRestore /S " + strKey + " " + strLocationToSave; } else if (badkey.Root.Name == "HKEY_CURRENT_USER") { strKey = "HKCU " + badkey.Subkey; strCommnd = "RegSaveRestore /S " + strKey + " " + strLocationToSave; } var startInfo = new ProcessStartInfo { FileName = "cmd.exe", RedirectStandardInput = true, RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true, WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory }; var process = new Process { StartInfo = startInfo }; process.Start(); process.StandardInput.WriteLine("cd " + AppDomain.CurrentDomain.BaseDirectory); process.StandardInput.WriteLine(strCommnd); process.StandardInput.WriteLine("exit"); process.WaitForExit(); dr["RegistryKeyFullPath"] = strKey; dr["Location"] = strLocationToSave; dtRegistryKeyDeleted.Rows.Add(dr); }
public void BackUpRegistrykey(InvalidKeys badkey) { DataRow dr = dtRegistryKeyDeleted.NewRow(); string strKey = String.Empty; string strCommnd = String.Empty; string strLocationToSave = Path.Combine(strRegistryBackupFolderPath, Guid.NewGuid().ToString() + ".dat"); if (badkey.Root.Name == "HKEY_CLASSES_ROOT") strKey = "HKCR " + badkey.Subkey; else if (badkey.Root.Name == "HKEY_LOCAL_MACHINE") { strKey = "HKLM " + badkey.Subkey; strCommnd = "RegSaveRestore /S " + strKey + " " + strLocationToSave; } else if (badkey.Root.Name == "HKEY_CURRENT_USER") { strKey = "HKCU " + badkey.Subkey; strCommnd = "RegSaveRestore /S " + strKey + " " + strLocationToSave; } var startInfo = new ProcessStartInfo { FileName = "cmd.exe", RedirectStandardInput = true, RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true, WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory }; var process = new Process { StartInfo = startInfo }; process.Start(); process.StandardInput.WriteLine("cd " + AppDomain.CurrentDomain.BaseDirectory); process.StandardInput.WriteLine(strCommnd); process.StandardInput.WriteLine("exit"); process.WaitForExit(); dr["RegistryKeyFullPath"] = strKey; dr["Location"] = strLocationToSave; dtRegistryKeyDeleted.Rows.Add(dr); }