Hi Leute ich will eigenscjhaften von Reporting services auslesen per WMi. Eigenschaften wie Datenbankname ud sowas. Dann auch Methoden Benutzen aber bekomme es nicht hin hier mein Quelltext.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61:
| try { const string machineWmiNamespace = @"\\.\root\Microsoft\SqlServer\ReportServer\RS_sqlexpress\v10"; const string wmiNamespace = @"\\.\root\Microsoft\SqlServer\ReportServer\RS_sqlexpress\v10:MSReportServer_ConfigurationSetting";
ConnectionOptions connOptions = new ConnectionOptions(); connOptions.Authentication = AuthenticationLevel.Default;
ObjectGetOptions getOptions = new ObjectGetOptions(); getOptions.Timeout = new System.TimeSpan(0, 0, 40);
ManagementScope machineScope = new ManagementScope(machineWmiNamespace, connOptions); machineScope.Connect();
ManagementScope scope = null; scope = new ManagementScope(wmiNamespace, connOptions); scope.Connect(); ManagementPath path = new ManagementPath("MSReportServer_Instance"); ManagementClass serverClass = new ManagementClass(scope, path, getOptions);
serverClass.Get(); MessageBox.Show(serverClass.Path.ToString());
ManagementObjectCollection instances = serverClass.GetInstances();
foreach (ManagementObject instance in instances) { listBox1.Items.Add("Server Status"); PropertyDataCollection instProps = instance.Properties; MessageBox.Show(instance.Scope.ToString());
foreach (PropertyData prop in instProps) { MessageBox.Show(prop.Name + " " + prop.Value); if (prop.Name == "DatabaseServerName") { string name = prop.Name; object val = prop.Value; Console.Out.Write("Property Name: " + name); if (val != null) { listBox1.Items.Add(" Value: " + val.ToString()); } else { listBox1.Items.Add(" Value: <null>"); } } } } }catch(Exception ex) { MessageBox.Show(ex.Message); } |
Ich habe keine erfahrung mit sowas.
Danke schonmal