Add Execute Commands for HandheldCleanup

This commit is contained in:
Virtuworks 2014-06-08 17:44:26 -04:00
parent 0ab2eb287a
commit 2f2b58e130
2 changed files with 57 additions and 17 deletions

View file

@ -47,20 +47,6 @@ namespace WebsitePanel.Providers.HostedSolution
return ProviderSettings[Constants.UserName];
}
}
public string HandheldcleanupPath
{
get
{
return ProviderSettings[Constants.HandheldcleanupPath];
}
}
public string MAPIProfile
{
get
{
return ProviderSettings[Constants.MAPIProfile];
}
}
public override string[] Install()
{
@ -124,7 +110,7 @@ namespace WebsitePanel.Providers.HostedSolution
//run handheldcleanup.exe
if (File.Exists(file2))
{
string serverfilename = Path.Combine(HandheldcleanupPath, "servername.txt");
string serverfilename = "servername.txt";
string arguments2 = string.Format("-u -p {0} < {1}",
MAPIProfile,
@ -133,7 +119,7 @@ namespace WebsitePanel.Providers.HostedSolution
{
string output;
int exitCode = Execute(file2, arguments2, out output);
int exitCode = Execute2(file2, arguments2, out output);
if (exitCode == 0)
{
Log.WriteInfo(output);

View file

@ -50,7 +50,20 @@ namespace WebsitePanel.Providers.HostedSolution
return ProviderSettings[Constants.UtilityPath];
}
}
public string HandheldcleanupPath
{
get
{
return ProviderSettings[Constants.HandheldcleanupPath];
}
}
public string MAPIProfile
{
get
{
return ProviderSettings[Constants.MAPIProfile];
}
}
public string Password
{
get
@ -172,6 +185,47 @@ namespace WebsitePanel.Providers.HostedSolution
return res;
}
protected int Execute2(string file, string arguments, out string output, out string error)
{
string oldDir = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(HandheldcleanupPath);
ProcessStartInfo startInfo = new ProcessStartInfo(file, arguments);
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process proc = Process.Start(startInfo);
if (proc == null)
throw new ApplicationException("Proc is null.");
StreamReader outputReader = proc.StandardOutput;
output = outputReader.ReadToEnd();
StreamReader errorReader = proc.StandardError;
error = errorReader.ReadToEnd();
Directory.SetCurrentDirectory(oldDir);
return proc.ExitCode;
}
protected int Execute2(string file, string arguments, out string output)
{
Log.WriteInfo(file);
Log.WriteInfo(arguments);
string outputData;
string errorData;
int res = Execute2(file, arguments, out outputData, out errorData);
output = outputData.Length > 0 ? "Output stream:" + outputData : string.Empty;
output += errorData.Length > 0 ? "Error stream:" + errorData : string.Empty;
return res;
}
public ResultObject DeleteBlackBerryUser(string primaryEmailAddress)
{