using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Win32; namespace Danial.Utility { public class SmartpointHelper { public bool IsSmartPointInstalled() { bool installed = !string.IsNullOrEmpty(GetSmartpointPath()); return installed; } public bool IsSmartpointRunning() { var processList = Process.GetProcessesByName("Travelport.Smartpoint.App"); if (processList != null && processList.Any()) return true; else return false; } public void StarSmartpoint() { string path = GetSmartpointPath(); Process.Start(path); } public void KillSmartpoint() { var p = Process.GetProcessesByName("Travelport.Smartpoint.App"); if (p.Any()) { Process process = (Process) p.First(); process.Kill(); } } public bool DeletePluginCache() { bool deleted = false; string appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string fullPath = string.Format("{0}\\Travelport\\Smartpoint\\CachedPlugins.xml", appDataFolder); try { if (File.Exists(fullPath)) { File.Delete(fullPath); deleted = true; } } catch (Exception e) { } return deleted; } private string GetSmartpointPath() { string path = ""; RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Travelport\\Smartpoint", false); if (key != null) { string installDir = key.GetValue("SmartpointDIR").ToString(); if (Directory.Exists(installDir)) { string filePath = String.Format("{0}\\{1}", installDir, "Travelport.Smartpoint.App.exe"); if (File.Exists(filePath)) { path = filePath; } } } return path; } } }