From c22a9122ec929090ed30f9c6b42e679cd4023df9 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Sun, 8 Jun 2014 15:39:58 -0400 Subject: [PATCH] Blackberry 5 - run handheldcleanup after user creation if path exists in provider settings --- .../BlackBerry5Provider.cs | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/BlackBerry5Provider.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/BlackBerry5Provider.cs index 961d6c7f..d27ba27d 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/BlackBerry5Provider.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/BlackBerry5Provider.cs @@ -47,6 +47,20 @@ 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() { @@ -65,7 +79,9 @@ namespace WebsitePanel.Providers.HostedSolution ResultObject res = HostedSolutionLog.StartLog("CreateBlackBerryUser5Internal"); string file = Path.Combine(UtilityPath, "besuseradminclient.exe"); + string file2 = Path.Combine(HandheldcleanupPath, "handheldcleanup.exe"); + //Add user to Blackberry Server if (!File.Exists(file)) { HostedSolutionLog.EndLog("CreateBlackBerry5UserInternal", res, BlackBerryErrorsCodes.FILE_PATH_IS_INVALID); @@ -79,10 +95,12 @@ namespace WebsitePanel.Providers.HostedSolution EnterpriseServer, EnterpriseServerFQDN); - try + //run besuseradminclient.exe + + try { string output; - + int exitCode = Execute(file, arguments, out output); if (exitCode == 0) { @@ -93,15 +111,46 @@ namespace WebsitePanel.Providers.HostedSolution { throw new ApplicationException( - string.Format("Excit code is not 0. {0}, ExitCode = {1}", output, exitCode)); + string.Format("Exit code is not 0. {0}, ExitCode = {1}", output, exitCode)); } } + catch (Exception ex) { HostedSolutionLog.EndLog("CreateBlackBerry5UserInternal", res, BlackBerryErrorsCodes.CANNOT_EXECUTE_COMMAND, ex); return res; } + //run handheldcleanup.exe + if (File.Exists(file2)) + { + string arguments2 = string.Format("-u -p {0} {1}", + MAPIProfile, + "< servername.txt"); + try + { + string output; + + int exitCode = Execute(file, arguments, out output); + if (exitCode == 0) + { + Log.WriteInfo(output); + + } + else + { + + throw new ApplicationException( + string.Format("Exit code is not 0. {0}, ExitCode = {1}", output, exitCode)); + } + } + + catch (Exception ex) + { + HostedSolutionLog.EndLog("CreateBlackBerry5UserInternal", res, BlackBerryErrorsCodes.CANNOT_EXECUTE_COMMAND, ex); + return res; + } + } HostedSolutionLog.EndLog("CreateBlackBerry5UserInternal"); return res;