//Uncomment the following line to cleanup kvp
        //[TestMethod]
        public void CleanupKVP()
        {
            using (var vm = WMIHelper.QueryFirstInstacne(@"root\virtualization\v2", "Msvm_ComputerSystem ", "enabledstate = 2 and caption = 'Virtual Machine'"))
            {
                Assert.IsNotNull(vm);
                Console.WriteLine("Clean up kvp for: " + vm.Properties["ElementName"].Value);
                var writer = KeyValuePairWriter.CreateInstance(new KvpConfiguration());

                var NULL = new Object();

                var data = new Dictionary <String, Object>();
                data.Add(testKey, NULL);
                data.Add(testKey2, NULL);

                var args = new Dictionary <String, Object>()
                {
                    { "VirtualMachinePath", vm.Path.ToString() },
                    { "VirtualMachineName", vm.Properties["Name"].Value },
                };

                writer.Remove(args, data);

                data.Clear();
                for (int i = 0; i < 50; i++)
                {
                    data.Add("Enhanced_Monitoring_Metric_Data_Item_Part_" + i, NULL);
                }
                writer.Remove(args, data);
            }
        }
Exemple #2
0
        //private void NotifyIcon1_DoubleClick(object Sender, EventArgs e)
        //{
        //    // Show the form when the user double clicks on the notify icon.

        //    // Set the WindowState to normal if the form is minimized.
        //    if (WindowState == FormWindowState.Minimized)
        //        WindowState = FormWindowState.Normal;

        //    // Activate the form.
        //    Activate();
        //}

        //private void MenuItemExit_Click(object Sender, EventArgs e)
        //{
        //    // Cleanup and close the app.
        //    shutdown();

        //}
        //private void MenuItemSetIP_Click(object Sender, EventArgs e)
        //{
        //    // Set a Static IP
        //    SetStaticIP();

        //}



        private void BtnQuit_Click(object sender, EventArgs e)
        {
            bool   dhcpstatus;
            string NicName = (string)CboNic.SelectedItem;

            WMIHelper.GetDHCP(NicName, out dhcpstatus);
            if (dhcpstatus == true)
            {
                //if DHCP is true... just exit
                shutdown();
            }
            if (dhcpstatus == !true)
            {
                string       ExitMessage  = "You have a Static IP set.\n\nThis could disable internet access when plugged back\ninto the network. \n\nTo Re-enable Internet access re-run this software and \nchoose Return to DHCP \n\nAre you sure you want to exit this program\nwith a Static IP still Set? ";
                DialogResult dialogResult = MessageBox.Show(ExitMessage, "Are You sure you want to exit.", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dialogResult == DialogResult.Yes)
                {
                    shutdown();
                }
                else if (dialogResult == DialogResult.No)
                {
                }
            }

            // shutdown();
        }
Exemple #3
0
 private void BtnDHCP_Click(object sender, EventArgs e)
 {
     try
     {
         string NicName = (string)CboNic.SelectedItem;
         WMIHelper.SetDHCP(NicName);
         RetSettings();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Unable to set IP \nError : " + ex.Message);
     }
 }
        public override Object CollectData(IDictionary <String, Object> args)
        {
            using (var vmMgmt = WMIHelper.GetFirstInstance(WMI_Namespace, WMI_Class_Msvm_VirtualSystemManagementService))
                using (var vm = WMIHelper.QueryFirstInstacne(WMI_Namespace, WMI_Class_Msvm_ComputerSystem,
                                                             String.Format("Name='{0}'", args["VirtualMachineName"])))
                    using (var vmSettings = vm.GetRelated(WMI_Class_Msvm_VirtualSystemSettingData))
                        using (var inParams = vmMgmt.GetMethodParameters(WMI_Method_GetSummaryInformation))
                        {
                            String[] settingDataPath = new String[vmSettings.Count];
                            int      i = 0;
                            foreach (ManagementObject vmSetting in vmSettings)
                            {
                                settingDataPath[i++] = vmSetting.Path.Path;
                                break;
                            }
                            var data = new Dictionary <String, Object>()
                            {
                                { KeyName_MemoryUsage, null },
                                { KeyName_MemoryAvailable, null },
                                { KeyName_AvailableMemoryBuffer, null },
                            };

                            if (settingDataPath.Length != 0)
                            {
                                inParams["SettingData"]          = settingDataPath;
                                inParams["RequestedInformation"] = new UInt32[]
                                {
                                    RequestedInformation_MemoryUsage,
                                    RequestedInformation_MemoryAvailable,
                                    RequestedInformation_AvaiableMemoryBuffer
                                };

                                var outParams = vmMgmt.InvokeMethod(WMI_Method_GetSummaryInformation, inParams, null);
                                if ((UInt32)outParams["ReturnValue"] == 0)//Completed
                                {
                                    var summaryInfoList = (ManagementBaseObject[])outParams["SummaryInformation"];
                                    var summaryInfo     = summaryInfoList.FirstOrDefault();
                                    data[KeyName_MemoryUsage]           = summaryInfo[KeyName_MemoryUsage];
                                    data[KeyName_MemoryAvailable]       = summaryInfo[KeyName_MemoryAvailable];
                                    data[KeyName_AvailableMemoryBuffer] = summaryInfo[KeyName_AvailableMemoryBuffer];
                                }
                                else
                                {
                                    throw new ManagementException(String.Format("Method {0} returns error:{1}", WMI_Method_GetSummaryInformation,
                                                                                (UInt32)outParams["ReturnValue"]));
                                }
                            }
                            return(data);
                        }
        }
Exemple #5
0
        public string GetEnvironmentVariable(string ip, string username, string password, string envVarName)
        {
            string value = null;

            try
            {
                WMIHelper helper = new WMIHelper(ip, username, password);
                value = helper.GetEnvironmentVariable(envVarName);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Can not get the Environment Variable {0} of remote machine {1}. {2}", envVarName, Name, ex.Message));
            }
            return(value);
        }
        public void GetServerMemory_Int()
        {
            //Arrange
            var server = new Server()
            {
                ServerName = "localhost", ServerIpAddress = "127.0.0.1"
            };
            var logger    = new Mock <ILogger>();
            var wmiHelper = new WMIHelper(logger.Object);

            //Act
            var task   = new AnalyticsCheckMemoryCheck(wmiHelper, _workspaceRepo.Object, _logger.Object, _sqlRepo.Object, 1);
            var result = task.GetServerMemory(server);

            //Assert
        }
Exemple #7
0
        //***************************************************************************************************
        // Port série
        //***************************************************************************************************
        private String GetPortName()
        {
            String    str    = "";
            WMIHelper helper = new WMIHelper("root\\CimV2");
            Device    device = helper.Query <Device>().ToList()
                               .Where(p => (p.Name ?? "")
                                      .Contains("u-blox GNSS Receiver")).SingleOrDefault();

            if (device != null)
            {
                str = device.Name;
                int i = str.IndexOf("(");
                int j = str.LastIndexOf(")");
                str = str.Substring(i + 1, j - i - 1);
            }
            return(str);
        }
Exemple #8
0
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            string NicName = (string)CboNic.SelectedItem;
            string IpAdd   = TextIP.Text;
            string SubNet  = TextSubnet.Text;
            string Gateway = TextGateway.Text;
            string dnses   = TextDNS.Text;

            try
            {
                WMIHelper.SetIP(NicName, IpAdd, SubNet, Gateway, dnses);
                RetSettings();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to set IP \nError : " + ex.Message);
            }
        }
Exemple #9
0
        //public string GetLocalIPv4(NetworkInterfaceType _type)
        //{
        //    // in order to get a wireless IPaddress use the follwoing code
        //    //GetLocalIPv4(NetworkInterfaceType.Wireless80211);

        //    //in order to get the ethernet ip address use the following code
        //    //GetLocalIPv4(NetworkInterfaceType.Ethernet);
        //    string output = "";
        //    foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces())
        //    {
        //        if (item.NetworkInterfaceType == _type && item.OperationalStatus == OperationalStatus.Up)
        //        {
        //            foreach (UnicastIPAddressInformation ip in item.GetIPProperties().UnicastAddresses)
        //            {
        //                if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
        //                {
        //                    output = ip.Address.ToString();
        //                }
        //            }
        //        }
        //    }
        //    return output;
        //}
        public void RetSettings()
        {
            // Needs work, the NicCard method needs more data sent to it?
            string[] ipAddresses;
            string[] subnets;
            string[] gateways;
            string[] dnses;


            // Load current IP configuration for the selected NIC
            string nicName = (string)CboNic.SelectedItem;

            WMIHelper.GetIP(nicName, out ipAddresses, out subnets, out gateways, out dnses);

            // if network connection is disabled, no information will be available
            if (null == ipAddresses || null == subnets || null == gateways || null == dnses)
            {
                return;
            }
            ////Trim up the strings to more usable formats
            string strIP = string.Join(",", ipAddresses);
            string extIP = strIP.Substring(0, strIP.LastIndexOf(","));

            TextIP.Text       = extIP;
            LblCurrentIp.Text = "Current IP: " + extIP;

            string strSUB = string.Join(",", subnets);
            string extSUB = strSUB.Substring(0, strSUB.LastIndexOf(","));

            TextSubnet.Text = extSUB;

            //string strGATE = string.Join(",", gateways);
            //string extGATE = strGATE.Substring(0, strGATE.LastIndexOf(","));
            //TextGateway.Text = extGATE;



            // Show the setting

            //TextSubnet.Text = string.Join(",", subnets);
            TextGateway.Text = string.Join(",", gateways);
            TextDNS.Text     = string.Join(",", dnses);
            // MessageBox.Show(string.Join(",", dchpstatus));
        }
Exemple #10
0
        private void loadNICs()
        {
            // get the NIC names
            ArrayList nicNames = WMIHelper.GetNICNames();

            // populate the NIC list
            CboNic.Items.Clear();
            foreach (string name in nicNames)
            {
                CboNic.Items.Add(name);
            }

            // if NIC found, select the first one
            if (CboNic.Items.Count > 0)
            {
                CboNic.SelectedIndex = 0;
                //GrpNIC.Enabled = true;   //Not Used
            }
        }
Exemple #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args">Named arguments used in "Where" field of WQL query</param>
        /// <returns></returns>
        public override Object CollectData(IDictionary <String, Object> args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            if (this.conf.PerfCounters == null)
            {
                return(null);
            }

            String condition = String.Empty;

            condition = NamedArgumentHelper.Resolve(this.conf.Where, this.conf.WhereArgs, args);

            if (this.conf.PerfCounters == null || this.conf.PerfCounters.Count == 0)
            {
                return(null);
            }

            using (var result = WMIHelper.QueryInstacnes(this.conf.Namespace, this.conf.From, condition, this.selectedProperties))
            {
                var mgmtObjs = result.Cast <ManagementObject>();
                if (this.conf.ReturnValueType == MgmtObjectReturnValueType.Single)
                {
                    var mgmtObj = mgmtObjs.FirstOrDefault();
                    return(SelectPerfCounter(mgmtObj, args));
                }
                else
                {
                    var list = new List <Object>();
                    foreach (var mgmtObj in mgmtObjs)
                    {
                        list.Add(SelectPerfCounter(mgmtObj, args));
                    }
                    return(list);
                }
            }
        }
Exemple #12
0
        static LisenceHelper()
        {
            //解析Lisence
            //本机机器码
            string serialNo = WMIHelper.GetDiskSerialNumber() + WMIHelper.GetCPUSerialNumber();

            if (serialNo.Length >= 24)
            {
                LocalMachineNumber = serialNo.Substring(0, 24);
            }
            else
            {
                LocalMachineNumber = serialNo.PadRight(24 - serialNo.Length, '0');
            }
            string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lisence");

            if (File.Exists(fileName) == false)
            {
                IsLisenceFileExist = false;
                return;
            }
            IsLisenceFileExist = true;
            string resutl = "";

            using (var fs = new FileStream(fileName, FileMode.Open))
            {
                byte[] data = new byte[fs.Length];
                fs.Read(data, 0, data.Length);
                resutl = Encoding.UTF8.GetString(data);
            }
            string  json       = RSAHelper.PublicKeyDecrypt(xmlPublicKey, resutl);
            object  objLicense = JsonConvert.DeserializeObject(json);
            JObject jobj       = objLicense as JObject;

            Type          = jobj["Type"].ToString();
            MachineNumber = jobj["MachineNumber"].ToString();
            ExpiredDate   = jobj["ExpiredDate"].ToString();
            CreationDate  = jobj["CreationDate"].ToString();
        }
        public void TestWriteKVP()
        {
            var vm = WMIHelper.QueryFirstInstacne(@"root\virtualization\v2", "Msvm_ComputerSystem ", "enabledstate = 2 and caption = 'Virtual Machine'");

            Assert.IsNotNull(vm);

            var writer = KeyValuePairWriter.CreateInstance(new KvpConfiguration());
            var data   = new Dictionary <String, Object>();

            data.Add(testKey, DateTime.Now.ToString());
            data.Add(testKey2, DateTime.Now.ToString());

            var args = new Dictionary <String, Object>()
            {
                { "VirtualMachinePath", vm.Path.ToString() },
                { "VirtualMachineName", vm.Properties["Name"].Value },
            };

            writer.Remove(args, data);
            writer.Write(args, data);

            vm.Dispose();
        }
Exemple #14
0
        private void btnIPSet_Click(object sender, EventArgs e)
        {
            string[] ipaddrs, masks, gateways, dns;
            string   currentIps = null;

            WMIHelper.GetIP(_wlnMgr.HostedNetworkInterfaceGuid, out ipaddrs, out masks, out gateways, out dns);
            ipaddrs = (ipaddrs ?? Enumerable.Empty <String>()).Where(_ => RegexIP.IsMatch(_)).ToArray();
            if (ipaddrs.Any())
            {
                currentIps = String.Join(" | ", ipaddrs);
            }
            bool ok = false;

            do
            {
                string ipAddr = Interaction.InputBox("输入IP地址:", currentIps == null ? "设置IP" : "当前IP:" + currentIps).Replace(" ", "");
                if (ipAddr.Length == 0)
                {
                    ok = true;
                }
                else
                {
                    if (!RegexIP.IsMatch(ipAddr))
                    {
                        this.Warn("IP地址格式不正确!");
                        ok = false;
                    }
                    else
                    {
                        WMIHelper.SetIP(_wlnMgr.HostedNetworkInterfaceGuid, ipAddr, "255.255.255.0", "", "");
                        this.Info("设置成功!");
                        ok = true;
                    }
                }
            } while (!ok);
        }
        //[TestMethod]
        public void TestOverloadKVP()
        {
            var vm = WMIHelper.QueryFirstInstacne(@"root\virtualization\v2", "Msvm_ComputerSystem ", "enabledstate = 2 and caption = 'Virtual Machine'");

            Assert.IsNotNull(vm);

            var writer = KeyValuePairWriter.CreateInstance(new KvpConfiguration());
            var data   = new Dictionary <String, Object>();

            var chars = new char[1000];

            for (int i = 0; i < chars.Length; i++)
            {
                chars[i] = 'a';
            }
            var val = new String(chars);

            for (int i = 0; i < 1000; i++)
            {
                data.Clear();
                for (int j = 0; j < 10; j++)
                {
                    data.Add(String.Format("TestKVP_{0}", j), val);
                }

                var args = new Dictionary <String, Object>()
                {
                    { "VirtualMachinePath", vm.Path.ToString() },
                    { "VirtualMachineName", vm.Properties["Name"].Value },
                };

                writer.Remove(args, data);
                writer.Write(args, data);
            }
            vm.Dispose();
        }
Exemple #16
0
        internal GeneralInfo(SerializableException serializableException)
        {
            // this.HostApplication = Settings.EntryAssembly.GetName().Name; // Does not get the extensions of the file!
            this.HostApplication = Settings.EntryAssembly.GetLoadedModules()[0].Name;

            // this.HostApplicationVersion = Settings.EntryAssembly.GetName().Version.ToString(); // Gets AssemblyVersion not AssemblyFileVersion
            this.HostApplicationVersion = this.NBugVersion = FileVersionInfo.GetVersionInfo(Settings.EntryAssembly.Location).ProductVersion;

            // this.NBugVersion = System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString(); // Gets AssemblyVersion not AssemblyFileVersion
            this.NBugVersion = FileVersionInfo.GetVersionInfo(Assembly.GetCallingAssembly().Location).ProductVersion;

            this.CLRVersion = Environment.Version.ToString();

            this.DateTime = System.DateTime.UtcNow.ToString();

            SystemOS              = WMIHelper.FillOSInformation(Environment.MachineName, null, null, nameof(QueryAreaDescription.Win32_OperatingSystem));
            SystemHotFixes        = WMIHelper.FillHotFixes(Environment.MachineName, null, null, nameof(QueryAreaDescription.Win32_QuickFixEngineering));
            SystemProcessor       = WMIHelper.FillProcessorInformation(Environment.MachineName, null, null, nameof(QueryAreaDescription.Win32_Processor));
            SystemVideoController = WMIHelper.FillVideoController(Environment.MachineName, null, null, nameof(QueryAreaDescription.Win32_VideoController));

            if (serializableException != null)
            {
                this.ExceptionType = serializableException.Type;

                if (!string.IsNullOrEmpty(serializableException.TargetSite))
                {
                    this.TargetSite = serializableException.TargetSite;
                }
                else if (serializableException.InnerException != null && !string.IsNullOrEmpty(serializableException.InnerException.TargetSite))
                {
                    this.TargetSite = serializableException.InnerException.TargetSite;
                }

                this.ExceptionMessage = serializableException.Message;
            }
        }
Exemple #17
0
        static void Main(string[] args)
        {
            WMIHelper helper = new WMIHelper("root\\CimV2");

            //List<NetworkAdapterConfiguration> interfaces = helper.Query<NetworkAdapterConfiguration>().ToList();

            //Printer printer = helper.QueryFirstOrDefault<Printer>();

            //List<Printer> printers = helper.Query<Printer>().ToList();

            //foreach (Printer p in printers)
            //{
            //    p.RenamePrinter("Newly renamed printer");
            //}

            //Output outp = new Output
            //{
            //    PanelID = 10,
            //    ReaderID = 1,
            //    Hostname = "ONGUARD01",
            //    Name = "ONGUARD01"
            //};

            //outp.Activate();

            //List<Process> processes = helper.Query<Process>().ToList();

            //foreach (Process p in processes)
            //{
            //    //dynamic d = p.GetOwnerSid();
            //    ProcessOwner po = p.GetOwner();
            //    //int res = p.AttachDebugger();
            //}

            //var dynDevices = helper.Query("SELECT * FROM Win32_PnPEntity");

            //var processors = helper.Query<Processor>();

            //List<Processor> procesors = helper.Query<Processor>().ToList();

            List <Device> devices = helper.Query <Device>().ToList()
                                    .Where(p => (p.Name ?? "")
                                           .Contains("Intel")).ToList();

            foreach (Device d in devices)
            {
                Console.WriteLine(d.Name);
            }

            //Person person = new Person
            //{
            //    FirstName = "John",
            //    DocumentNumber = "9995",
            //};

            //helper.AddInstance(person);

            //Person queryPersonSingle = helper.Query<Person>("SELECT * FROM Lnl_Cardholder WHERE LASTNAME = 'Doe Modified'").SingleOrDefault();

            //queryPersonSingle.Lastname = "Doe Modified";

            //helper.UpdateInstance(queryPersonSingle);

            //List<Person> queryPerson = helper.Query<Person>("SELECT * FROM Lnl_Cardholder WHERE LASTNAME = 'Lopez'").ToList();

            //WMIWatcher watcher = new WMIWatcher("root\\CimV2", "SELECT * FROM Win32_ProcessStartTrace", typeof(Process));
            //WMIWatcher watcher = new WMIWatcher("root\\CimV2", "SELECT * FROM Win32_ProcessStartTrace");
            //watcher.WMIEventArrived += Watcher_WMIEventArrived;

            Console.ReadLine();
        }
        private Telnet() : base(Config.Instance.ServerIP, Config.Instance.ServerPort, true)
        {
            DataReceived += async(s, e) =>
            {
                var command = e.Content.Command;
                Debug.WriteLine("客户端接收到:" + command);


                switch (command)
                {
                //以下为通用
                case S_ClientsUpdate:
                    ClientInfo[] clients = e.Content.Data as ClientInfo[];
                    ClientsUpdate?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                case S_LoginFeedback:
                    LoginFeedback feedback = e.Content.Data as LoginFeedback;
                    LoginFeedback?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                case S_NoSuchClient:
                    NoSuchClient?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                //以下为控制端
                case Screen_NewScreen:
                    ReceivedNewImage?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                case WMI_Namespace:
                    WMINamespacesReceived?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                case WMI_Classes:
                    WMIClassesReceived?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                case WMI_Props:
                    WMIPropsReceived?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                case File_RootDirectory:
                    FileSystemRootReceived?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                case File_DirectoryContent:
                    FileSystemDirectoryContentReceived?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                case File_Download:
                    FileSystemDownloadPartReceived?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                case File_ReadDownloadingFileError:
                    FileSystemDownloadErrorReceived?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                case File_PrepareUploadingFeedback:
                    FileSystemPrepareForUploadingReceived?.Invoke(this, new DataReceivedEventArgs(e.Content));

                    break;

                case File_CanSendNextUploadPart:
                    Control.FileUploadHelper.CanSendNextPart.Add((Guid)e.Content.Data);
                    break;

                case File_WriteUploadingFileError:
                    Control.FileUploadHelper.Error.TryAdd((e.Content.Data as FileFolderFeedback).ID, (e.Content.Data as FileFolderFeedback).Message);
                    break;

                case File_OperationFeedback:
                    FileSystemFileFolderOperationFeedback?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                //以下为被控端
                case Screen_AskForStartScreen:
                    await ScreenHelper.StartSendScreen();

                    break;

                case Screen_AskForStopScreen:
                    ScreenHelper.StopSendScreen();
                    break;

                case Screen_AskForNextScreen:
                    SendNextScreen?.Invoke(this, new DataReceivedEventArgs(e.Content));
                    break;

                case WMI_AskForNamespaces:
                    WMIHelper.SendNamespaces(e.Content);
                    break;

                case WMI_AskForClasses:
                    WMIHelper.SendWMIClasses(e.Content.Data as string, e.Content);
                    break;

                case WMI_AskForProps:
                    WMIHelper.SendProperties(e.Content.Data as WMIClassInfo, e.Content);
                    break;


                case File_AskForRootDirectory:
                    FileSystemHelper.SendDiskDrives(e.Content);
                    break;

                case File_AskForDirectoryContent:
                    FileSystemHelper.SendDirectoryContent(e.Content);
                    break;

                case File_AskForDownloading:
                    FileSystemHelper.StartDownloadingToA(e.Content);
                    break;

                case File_CanSendNextDownloadPart:
                    FileSystemHelper.CanSendNextPart.Add((Guid)e.Content.Data);
                    break;

                case File_AskForCancelDownload:
                    FileSystemHelper.Cancle.Add((Guid)e.Content.Data);
                    break;

                case File_AskForStartUpload:
                    FileSystemHelper.StartAcceptingUploading(e.Content);
                    break;

                case File_Upload:
                    FileSystemHelper.AcceptUploadPartFromA(e.Content);
                    break;

                case File_AskForCancelUpload:
                    FileSystemHelper.CancelUploadFromA(e.Content);
                    break;

                case File_Operation:
                    FileSystemHelper.FileFolderOperate(e.Content);
                    break;
                }
            };
        }
 public override string ToString()
 {
     return(WMIHelper.toString(this));
 }
 public EnvironmentCheckServerInfoTask(ILogger logger, ISqlServerRepository sqlRepo, int agentId)
     : base(logger, sqlRepo, agentId)
 {
     _wmiHelper      = new WMIHelper(logger);
     initialDatabase = Names.Database.EddsQoS;
 }
Exemple #21
0
        private object GetWmiObject()
        {
            ComboObject item = cbxQuery.SelectedItem as ComboObject;

            if (item == null)
            {
                return(null);
            }
            switch (item.DisplayText)
            {
            case "WMI_COMPUTER_INFORMATION":
                return
                    (WMIHelper.FillComputerInformation(txtMachine.Text.Trim(), txtUser.Text.Trim(),
                                                       txtPass.Text.Trim(), item.ValueText));

            case "WMI_PROCESSOR_INFORMATION":
                return(WMIHelper.FillProcessorInformation(txtMachine.Text.Trim(), txtUser.Text.Trim(),
                                                          txtPass.Text.Trim(), item.ValueText));

            //case "WMI_PROCESSOR_INFORMATION":
            //          return WMIHelper.FillProcessorInformation(txtMachine.Text.Trim(), txtUser.Text.Trim(),
            //                                                    txtPass.Text.Trim(), "Win32_Processor");



            case "WMI_BIOS_INFORMATION":
                return(WMIHelper.FillBiosInformation(txtMachine.Text.Trim(), txtUser.Text.Trim(),
                                                     txtPass.Text.Trim(), item.ValueText));

            case "WMI_OS_INFORMATION":
                return(WMIHelper.FillOSInformation(txtMachine.Text.Trim(), txtUser.Text.Trim(),
                                                   txtPass.Text.Trim(), item.ValueText));

            case "WMI_HOTFIX_INFORMATION":
                return(WMIHelper.FillHotFixes(txtMachine.Text.Trim(), txtUser.Text.Trim(),
                                              txtPass.Text.Trim(), item.ValueText));

            case "WMI_NETWORK_ADAPTER_INFORMATION":
                return(WMIHelper.FillNetworkAdapter(txtMachine.Text.Trim(), txtUser.Text.Trim(),
                                                    txtPass.Text.Trim(), item.ValueText));

            case "WMI_PRINTER_INFORMATION":
                return(WMIHelper.FillPrinters(txtMachine.Text.Trim(), txtUser.Text.Trim(),
                                              txtPass.Text.Trim(), item.ValueText));

            case "WMI_DISK_DRIVE_INFORMATION":
                return(WMIHelper.FillDisks(txtMachine.Text.Trim(), txtUser.Text.Trim(),
                                           txtPass.Text.Trim(), item.ValueText));

            case "WMI_LOGICAL_DISK_INFORMATION":
                return(WMIHelper.FillLogicalDisks(txtMachine.Text.Trim(), txtUser.Text.Trim(),
                                                  txtPass.Text.Trim(), item.ValueText));

            case "WMI_VIDEO_CONTROLLER_INFORMATION":
                return(WMIHelper.FillVideoController(txtMachine.Text.Trim(), txtUser.Text.Trim(),
                                                     txtPass.Text.Trim(), item.ValueText));

            case "WMI_SOUND_CARD_INFORMATION":
                return(WMIHelper.FillSoundCard(txtMachine.Text.Trim(), txtUser.Text.Trim(),
                                               txtPass.Text.Trim(), item.ValueText));
            }
            return(null);
        }
Exemple #22
0
 public void SetUp()
 => _Helper = new WMIHelper("root\\CimV2");