private void dataGrid1_LoadingRow(object sender, DataGridRowEventArgs e) { sccmclictr.automation.functions.Win32_Service item = e.Row.Item as sccmclictr.automation.functions.Win32_Service; if (item != null) { if (Properties.Settings.Default.ServicesHighlited.Contains(item.Name)) { if (!OnlyCMServices) { e.Row.Background = new SolidColorBrush(Colors.BlanchedAlmond); } } } }
/// <summary> /// Reloads this instance. /// </summary> public void Reload() { List <Win32_Service> lCache = new List <Win32_Service>(); List <PSObject> oObj = GetObjects(@"ROOT\cimv2", "SELECT * FROM Win32_Service", true); foreach (PSObject PSObj in oObj) { Win32_Service oCIEx = new Win32_Service(PSObj, remoteRunspace, pSCode); oCIEx.remoteRunspace = remoteRunspace; oCIEx.pSCode = pSCode; lCache.Add(oCIEx); } win32_Services = lCache; }
/// <summary> /// Get a single Service Instance /// </summary> /// <param name="ServiceName">Name of the Service</param> /// <param name="Reload">true = do not get results from cache</param> /// <returns></returns> public Win32_Service GetService(string ServiceName, bool Reload = true) { //Remove cached results string sHash1 = base.CreateHash(@"ROOT\cimv2" + string.Format("SELECT * FROM Win32_Service WHERE Name ='{0}'", ServiceName)); base.Cache.Remove(sHash1); List <PSObject> oObj = GetObjects(@"ROOT\cimv2", string.Format("SELECT * FROM Win32_Service WHERE Name ='{0}'", ServiceName), Reload); foreach (PSObject PSObj in oObj) { Win32_Service oCIEx = new Win32_Service(PSObj, remoteRunspace, pSCode); oCIEx.remoteRunspace = remoteRunspace; oCIEx.pSCode = pSCode; return(oCIEx); } return(null); }