示例#1
0
        public static string getUltimaLeituraHD()
        {
            Models.idMachine idMachine = new Models.idMachine();

            string strConn = ConfigurationManager.ConnectionStrings["MyDB"].ToString();

            using (SqlConnection con = new SqlConnection(strConn))
            {
                con.Open();
                SqlCommand    cmd = new SqlCommand($"SELECT TOP 1 (HardDiskInf.HdTotal/1024)/1024, (HardDiskInf.HdUsage/1024)/1024 FROM Machines, HardDiskInf WHERE Machines.idMachines=HardDiskInf.idMachines AND mACHINES.idMachines='{idMachine.getIdMachines()}'  ORDER BY idHD DESC", con);
                SqlDataReader rd1 = cmd.ExecuteReader();
                if (rd1.Read())
                {
                    return(rd1[0].ToString() + "@" + rd1[1].ToString());
                }
            }

            return("");
        }
        public static string getUltimaLeituraCpu()
        {
            Models.idMachine idMachine = new Models.idMachine();

            string strConn = ConfigurationManager.ConnectionStrings["MyDB"].ToString();

            using (SqlConnection con = new SqlConnection(strConn))
            {
                con.Open();
                SqlCommand    cmd = new SqlCommand($"SELECT TOP 1 DateTime, CpuUsage FROM CpuInf WHERE idMachines='{idMachine.getIdMachines()}' ORDER BY IDCPU DESC ", con);
                SqlDataReader rd  = cmd.ExecuteReader();
                if (rd.Read())
                {
                    return(rd[0].ToString() + "@" + rd[1].ToString());
                }
            }

            return("");
        }
        public static string getUltimaLeituraRam()
        {
            Models.idMachine idMachine = new Models.idMachine();

            string strConn = ConfigurationManager.ConnectionStrings["MyDB"].ToString();

            using (SqlConnection con = new SqlConnection(strConn))
            {
                con.Open();
                SqlCommand    cmd = new SqlCommand($"SELECT TOP 1 (RamMemoryInf.RamAvailable/1024)/1024, (RamMemoryInf.RamUsage/1024)/1024 FROM Machines, RamMemoryInf WHERE Machines.idMachines=RamMemoryInf.idMachines and mACHINES.idMachines='{idMachine.getIdMachines()}' ORDER BY IdRamMemory DESC", con);
                SqlDataReader rd1 = cmd.ExecuteReader();
                if (rd1.Read())
                {
                    return(rd1[0].ToString() + "@" + rd1[1].ToString());
                }
            }

            return("");
        }