static public Hashtable DiscoverCachesViaWMI() { ServiceController sc = new ServiceController("Winmgmt"); runningcaches = new Hashtable(); if (sc.Status == ServiceControllerStatus.Running) { try { foreach (Process process in processes) { string cmdLine = GetCommandLine(process); string[] tmp = cmdLine.Split(' '); if (tmp != null && tmp.Length > 0) { object param = new CacheHostParam(); SeperateHostArgumentParser.CommandLineParser(ref param, tmp); CacheHostParam cParam = (CacheHostParam)param; CacheHostInfo cacheInfo = null; if (!runningcaches.ContainsKey(cParam.CacheName.ToLower())) { cacheInfo = new CacheHostInfo(); cacheInfo.ProcessId = process.Id; cacheInfo.ManagementPort = cParam.ManagementPort; runningcaches.Add(cParam.CacheName.ToLower(), cacheInfo); } else { cacheInfo = runningcaches[cParam.CacheName.ToLower()] as CacheHostInfo; cacheInfo.ProcessId = process.Id; cacheInfo.ManagementPort = cParam.ManagementPort; } } } } catch (Exception ex) { return(runningcaches); } return(runningcaches); } else { return(runningcaches); } }
public static bool populateValues(string[] args) { bool isValid = false; String errorMessage = ""; try { if (args != null && args.Length > 0) { object param = new CacheHostParam(); SeperateHostArgumentParser.CommandLineParser(ref param, args); cParam = (CacheHostParam)param; if (cParam.Debug) { while (!Debugger.IsAttached) { Thread.Sleep(500); } } if (cParam.IsUsage) { AssemblyUsage.PrintLogo(cParam.IsLogo); AssemblyUsage.PrintUsage(); return(false); } if (!String.IsNullOrEmpty(cParam.CacheName)) { cacheName = cParam.CacheName; isValid = true; } else { if (File.Exists(cParam.CacheConfigPath)) { { try { if (isCacheExist(cParam.CacheConfigPath)) { String cName = getCacheName(cParam.CacheConfigPath); if (!String.IsNullOrEmpty(cName)) { cacheName = cName; isValid = true; } else { errorMessage = "Provided config.conf is not valid cache configurations."; isValid = false; ErrorCode = 1; } } else { errorMessage = "Multiple cache configurations provided in config.conf."; isValid = false; ErrorCode = 2; } } catch (Exception ex) { errorMessage = ex.Message; isValid = false; } } } else { errorMessage = "Cache configuration [config.conf] path is not provided or File does not exist."; isValid = false; ErrorCode = 3; } } throwError(errorMessage, isValid); if (cParam.ManagementPort != -1 && cParam.ManagementPort != 0) { managementPort = cParam.ManagementPort; isValid = true; } throwError(errorMessage, isValid); } else { errorMessage = "Arguments not specified"; isValid = false; throwError(errorMessage, isValid); } } catch (Exception ex) { throwError(ex.ToString(), false); } return(true); }