Beispiel #1
0
        /// <summary>
        /// Runs the install process using windows command line tools.
        /// </summary>
        /// <param name="processInfo">ProcessStartInfo, formatted as required.</param>
        /// <returns>Returns results formatted --> InstallResult.</returns>
        private static InstallResult RunProcess(ProcessStartInfo processInfo)
        {
            var result = new InstallResult();

            // The following WindowsUninstaller.WindowsExitCode used below might be Windows specific.
            // Third party apps might not use same code.
            try
            {
                using (var process = Process.Start(processInfo))
                {
                    process.WaitForExit();

                    result.ExitCode        = process.ExitCode;
                    result.ExitCodeMessage = new Win32Exception(process.ExitCode).Message;

                    switch (result.ExitCode)
                    {
                    case (int)WindowsUninstaller.WindowsExitCode.Restart:
                    case (int)WindowsUninstaller.WindowsExitCode.Reboot:
                        result.Restart = true;
                        result.Success = true;
                        break;

                    case (int)WindowsUninstaller.WindowsExitCode.Sucessful:
                        result.Success = true;
                        break;

                    default:
                        result.Success = false;
                        break;
                    }

                    var output = process.StandardOutput;
                    result.Output = output.ReadToEnd();
                }
                return(result);
            }
            catch (Exception e)
            {
                Logger.Log("Supported App Installer failed to install: {0}.", LogLevel.Error, processInfo.FileName);
                Logger.LogException(e);

                result.ExitCode        = -1;
                result.ExitCodeMessage = String.Format("Supported App Installer failed to install {0}.", processInfo.FileName);
                result.Output          = String.Empty;
                result.Restart         = false;
                result.Success         = false;

                return(result);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the initial json send from server.
        /// Seperates the opertaion depending on which supported app is been installed.
        /// </summary>
        /// <param name="supportedApp">Json file from server.</param>
        /// <returns>Return SavedOpData populated with results.</returns>
        public static Operations.SavedOpData InstallSupportedAppsOperation(Operations.SavedOpData supportedApp)
        {
            var installResult = new InstallResult();

            try
            {
                if (supportedApp.filedata_app_name.ToLowerInvariant().Contains("flash"))
                {
                    installResult = ProcessFlash(supportedApp);
                }

                if (supportedApp.filedata_app_name.ToLowerInvariant().Contains("java"))
                {
                    installResult = ProcessJava(supportedApp);
                }

                if (supportedApp.filedata_app_name.ToLowerInvariant().Contains("reader") ||
                    supportedApp.filedata_app_name.ToLowerInvariant().Contains("acrobat"))
                {
                    installResult = ProcessReader(supportedApp);
                }

                //Supported App Failed to Install.
                if (!installResult.Success)
                {
                    supportedApp.success         = false.ToString().ToLower();
                    supportedApp.error           = String.Format("Failed: {0}", installResult.ExitCodeMessage);
                    supportedApp.reboot_required = false.ToString().ToLower();

                    Logger.Log("Supported ThirdParty App Failed to Install, Exit code {0}: {1}", LogLevel.Info, installResult.ExitCode, supportedApp.filedata_app_name + ", Error: " + supportedApp.error);
                    return(supportedApp);
                }

                //Supported App Installed OK
                supportedApp.success         = true.ToString().ToLower();
                supportedApp.error           = string.Empty;
                supportedApp.reboot_required = installResult.Restart.ToString().ToLower();

                Logger.Log("Supported ThirdParty App Installed Successfully: {0}", LogLevel.Info, supportedApp.filedata_app_name);
                return(supportedApp);
            }
            catch (Exception e)
            {
                supportedApp.success = false.ToString().ToLower();
                supportedApp.error   = String.Format("Failed to install Supported ThirdParty App, Exception error: {0}", e.Message);

                Logger.Log("Supported ThirdParty App failed to Install: {0}", LogLevel.Info, supportedApp.filedata_app_name + ", Error: " + supportedApp.error);
                return(supportedApp);
            }
        }
        private static InstallResult RunProcess(ProcessStartInfo processInfo)
        {
            var result = new InstallResult();

            // The following WindowsUninstaller.WindowsExitCode used below might be Windows specific.
            // Third party apps might not use same code. Good luck!
            try
            {
                using (Process process = Process.Start(processInfo))
                {
                    process.WaitForExit();

                    result.ExitCode = process.ExitCode;
                    result.ExitCodeMessage = new Win32Exception(process.ExitCode).Message;

                    switch (result.ExitCode)
                    {
                        case (int)WindowsUninstaller.WindowsExitCode.Restart:
                        case (int)WindowsUninstaller.WindowsExitCode.Reboot:
                            result.Restart = true;
                            result.Success = true;
                            break;
                        case (int)WindowsUninstaller.WindowsExitCode.Sucessful:
                            result.Success = true;
                            break;
                        default:
                            result.Success = false;
                            break;
                    }

                    StreamReader output = process.StandardOutput;
                    result.Output = output.ReadToEnd();
                }
            }
            catch (Exception e)
            {
                Logger.Log("Could not run {0}.", LogLevel.Error, processInfo.FileName);
                Logger.LogException(e);

                result.ExitCode = -1;
                result.ExitCodeMessage = String.Format("Error trying to run {0}.", processInfo.FileName);
                result.Output = String.Empty;
            }

            return result;
        }
        /// <summary>
        /// Gets the initial json send from server.
        /// Seperates the opertaion depending on which supported app is been installed.
        /// </summary>
        /// <param name="supportedApp">Json file from server.</param>
        /// <returns>Return SavedOpData populated with results.</returns>
        public static Operations.SavedOpData InstallSupportedAppsOperation(Operations.SavedOpData supportedApp)
        {
            var installResult = new InstallResult();

            try
            {
                if (supportedApp.filedata_app_name.ToLowerInvariant().Contains("flash"))
                    installResult = ProcessFlash(supportedApp);

                if (supportedApp.filedata_app_name.ToLowerInvariant().Contains("java"))
                    installResult = ProcessJava(supportedApp);

                if (supportedApp.filedata_app_name.ToLowerInvariant().Contains("reader") ||
                    supportedApp.filedata_app_name.ToLowerInvariant().Contains("acrobat"))
                    installResult = ProcessReader(supportedApp);

                //Supported App Failed to Install.
                if (!installResult.Success)
                {
                    supportedApp.success = false.ToString().ToLower();
                    supportedApp.error = String.Format("Failed: {0}", installResult.ExitCodeMessage);
                    supportedApp.reboot_required = false.ToString().ToLower();

                    Logger.Log("Supported ThirdParty App Failed to Install, Exit code {0}: {1}", LogLevel.Info, installResult.ExitCode, supportedApp.filedata_app_name + ", Error: " + supportedApp.error);
                    return supportedApp;
                }

                //Supported App Installed OK
                supportedApp.success = true.ToString().ToLower();
                supportedApp.error = string.Empty;
                supportedApp.reboot_required = installResult.Restart.ToString().ToLower();

                Logger.Log("Supported ThirdParty App Installed Successfully: {0}", LogLevel.Info, supportedApp.filedata_app_name);
                return supportedApp;

            }
            catch (Exception e)
            {
                supportedApp.success = false.ToString().ToLower();
                supportedApp.error = String.Format("Failed to install Supported ThirdParty App, Exception error: {0}", e.Message);

                Logger.Log("Supported ThirdParty App failed to Install: {0}", LogLevel.Info, supportedApp.filedata_app_name + ", Error: " + supportedApp.error);
                return supportedApp;
            }
        }