int WbemNative.IWbemServices.ExecQueryAsync(string queryLanguage, string query, int flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink) { if (((wbemContext == null) || (wbemSink == null)) || (this.wbemServices == null)) { return(-2147217400); } try { QueryRegex regex = new QueryRegex(query); ParameterContext parms = new ParameterContext(regex.ClassName, this.wbemServices, wbemContext, wbemSink); this.GetProvider(parms.ClassName).EnumInstances(new InstancesContext(parms)); WbemException.ThrowIfFail(wbemSink.SetStatus(0, 0, null, null)); } catch (WbemException exception) { DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610736), new string[] { exception.ToString() }); wbemSink.SetStatus(0, exception.ErrorCode, null, null); return(exception.ErrorCode); } catch (Exception exception2) { DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610736), new string[] { exception2.ToString() }); wbemSink.SetStatus(0, -2147217407, null, null); return(-2147217407); } finally { Marshal.ReleaseComObject(wbemSink); } return(0); }
int WbemNative.IWbemServices.ExecQueryAsync( string queryLanguage, string query, Int32 flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink) { if (wbemContext == null || wbemSink == null || this.wbemServices == null) { return((int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER); } try { QueryRegex queryRegex = new QueryRegex(query); ParameterContext parms = new ParameterContext(queryRegex.ClassName, this.wbemServices, wbemContext, wbemSink); IWmiProvider wmiProvider = this.GetProvider(parms.ClassName); //we let WMI to parse WQL to filter results from appropriate provider wmiProvider.EnumInstances(new InstancesContext(parms)); WbemException.ThrowIfFail(wbemSink.SetStatus( (int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE, (int)WbemNative.WbemStatus.WBEM_S_NO_ERROR, null, null)); } catch (WbemException e) { DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi, (uint)System.Runtime.Diagnostics.EventLogEventId.WmiExecQueryFailed, e.ToString()); wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE, e.ErrorCode, null, null); return(e.ErrorCode); } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi, (uint)System.Runtime.Diagnostics.EventLogEventId.WmiExecQueryFailed, e.ToString()); wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE, (int)WbemNative.WbemStatus.WBEM_E_FAILED, null, null); return((int)WbemNative.WbemStatus.WBEM_E_FAILED); } finally { Marshal.ReleaseComObject(wbemSink); } return((int)WbemNative.WbemStatus.WBEM_S_NO_ERROR); }
int WbemNative.IWbemServices.ExecQueryAsync(string queryLanguage, string query, int flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink) { if (((wbemContext == null) || (wbemSink == null)) || (this.wbemServices == null)) { return -2147217400; } try { QueryRegex regex = new QueryRegex(query); ParameterContext parms = new ParameterContext(regex.ClassName, this.wbemServices, wbemContext, wbemSink); this.GetProvider(parms.ClassName).EnumInstances(new InstancesContext(parms)); WbemException.ThrowIfFail(wbemSink.SetStatus(0, 0, null, null)); } catch (WbemException exception) { DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId) (-1073610736), new string[] { exception.ToString() }); wbemSink.SetStatus(0, exception.ErrorCode, null, null); return exception.ErrorCode; } catch (Exception exception2) { DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId) (-1073610736), new string[] { exception2.ToString() }); wbemSink.SetStatus(0, -2147217407, null, null); return -2147217407; } finally { Marshal.ReleaseComObject(wbemSink); } return 0; }
int WbemNative.IWbemServices.ExecQueryAsync( string queryLanguage, string query, Int32 flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink) { if (wbemContext == null || wbemSink == null || this.wbemServices == null) return (int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER; try { QueryRegex queryRegex = new QueryRegex(query); ParameterContext parms = new ParameterContext(queryRegex.ClassName, this.wbemServices, wbemContext, wbemSink); IWmiProvider wmiProvider = this.GetProvider(parms.ClassName); //we let WMI to parse WQL to filter results from appropriate provider wmiProvider.EnumInstances(new InstancesContext(parms)); WbemException.ThrowIfFail(wbemSink.SetStatus( (int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE, (int)WbemNative.WbemStatus.WBEM_S_NO_ERROR, null, null)); } catch (WbemException e) { DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi, (uint)System.Runtime.Diagnostics.EventLogEventId.WmiExecQueryFailed, e.ToString()); wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE, e.ErrorCode, null, null); return e.ErrorCode; } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi, (uint)System.Runtime.Diagnostics.EventLogEventId.WmiExecQueryFailed, e.ToString()); wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE, (int)WbemNative.WbemStatus.WBEM_E_FAILED, null, null); return (int)WbemNative.WbemStatus.WBEM_E_FAILED; } finally { Marshal.ReleaseComObject(wbemSink); } return (int)WbemNative.WbemStatus.WBEM_S_NO_ERROR; }