public override void GatherCpuCacheTopologyInformation(ref MachineInformation information)
        {
            if (cpu == null)
            {
                return;
            }

            var cacheInfo = cpu.GetL1InstructionCacheInfo();

            if (cacheInfo != null)
            {
                var info  = cacheInfo.Value;
                var cache = information.Cpu.Caches.FirstOrDefault(cache =>
                                                                  cache.Level == Cache.CacheLevel.LEVEL1 && cache.Type == Cache.CacheType.INSTRUCTION);

                if (cache == null)
                {
                    cache = new Cache
                    {
                        Level = Cache.CacheLevel.LEVEL1,
                        Type  = Cache.CacheType.INSTRUCTION
                    };
                    var caches = new List <Cache>();
                    caches.AddRange(information.Cpu.Caches);
                    caches.Add(cache);
                    information.Cpu.Caches = caches.AsReadOnly();
                }

                cache.Associativity = (uint)info.Associativity;
                cache.Partitions    = (uint)info.Lines;
                cache.LineSize      = (uint)info.LineSize;
                cache.Capacity      = (ulong)(info.Size * 1024uL);
                cache.CapacityHRF   = Util.FormatBytes(cache.Capacity);
            }
        }
        public override void GatherCpuFeatureFlagInformation(ref MachineInformation information)
        {
            if (information.Cpu.MaxCpuIdExtendedFeatureLevel >= 1)
            {
                Opcode.Cpuid(out var result, 0x80000001, 0);

                information.Cpu.AMDFeatureFlags.ExtendedFeatureFlagsF81One =
                    (AMDFeatureFlags.ExtendedFeatureFlagsF81ECX)result.ecx;
                information.Cpu.AMDFeatureFlags.ExtendedFeatureFlagsF81Two =
                    (AMDFeatureFlags.ExtendedFeatureFlagsF81EDX)result.edx;
            }

            if (information.Cpu.MaxCpuIdExtendedFeatureLevel >= 7)
            {
                Opcode.Cpuid(out var result, 0x80000007, 0);

                information.Cpu.AMDFeatureFlags.FeatureFlagsApm =
                    (AMDFeatureFlags.FeatureFlagsAPM)result.edx;
            }

            if (information.Cpu.MaxCpuIdExtendedFeatureLevel >= 0xA)
            {
                Opcode.Cpuid(out var result, 0x8000000A, 0);

                information.Cpu.AMDFeatureFlags.FeatureFlagsSvm =
                    (AMDFeatureFlags.FeatureFlagsSVM)result.edx;
            }
        }
 public bool Available(MachineInformation information)
 {
     return((information.Cpu.Vendor == Vendors.AMD ||
             information.Cpu.Vendor == Vendors.AMD_LEGACY) &&
            (RuntimeInformation.ProcessArchitecture == Architecture.X86 ||
             RuntimeInformation.ProcessArchitecture == Architecture.X64));
 }
Example #4
0
        public override void GatherCpuInformation(ref MachineInformation information)
        {
            if (information.Cpu.MaxCpuIdFeatureLevel >= 1)
            {
                Opcode.Cpuid(out var result, 1, 0);

                information.Cpu.Stepping = result.eax & 0xF;

                var familyId = (result.eax & 0xF00) >> 8;

                if (familyId == 6 || familyId == 15)
                {
                    information.Cpu.Model = (((result.eax & 0xF0000) >> 16) << 4) + ((result.eax & 0xF0) >> 4);
                }
                else
                {
                    information.Cpu.Model = (result.eax & 0xF0) >> 4;
                }

                if (familyId == 15)
                {
                    information.Cpu.Family = ((result.eax & 0xFF00000) >> 20) + familyId;
                }
                else
                {
                    information.Cpu.Family = familyId;
                }

                information.Cpu.Type =
                    (CPU.ProcessorType)((result.eax & 0b11000000000000) >> 12);
            }
        }
        public override void GatherCpuInformation(ref MachineInformation information)
        {
            if (information.Cpu.MaxCpuIdExtendedFeatureLevel >= 4)
            {
                Opcode.Cpuid(out var partOne, 0x80000002, 0);
                Opcode.Cpuid(out var partTwo, 0x80000003, 0);
                Opcode.Cpuid(out var partThree, 0x80000004, 0);

                var results = new[] { partOne, partTwo, partThree };
                var sb      = new StringBuilder();

                foreach (var res in results)
                {
                    sb.Append(string.Format("{0}{1}{2}{3}",
                                            string.Join("", $"{res.eax:X}".HexStringToString().Reverse()),
                                            string.Join("", $"{res.ebx:X}".HexStringToString().Reverse()),
                                            string.Join("", $"{res.ecx:X}".HexStringToString().Reverse()),
                                            string.Join("", $"{res.edx:X}".HexStringToString().Reverse())));
                }

                information.Cpu.Name = sb.ToString();
            }

            try
            {
                Opcode.Cpuid(out var hammerTime, 0x8FFFFFFF, 0);

                var hammerString = string.Format("{0}{1}{2}{3}",
                                                 string.Join("", $"{hammerTime.eax:X}".HexStringToString().Reverse()),
                                                 string.Join("", $"{hammerTime.ebx:X}".HexStringToString().Reverse()),
                                                 string.Join("", $"{hammerTime.ecx:X}".HexStringToString().Reverse()),
                                                 string.Join("", $"{hammerTime.edx:X}".HexStringToString().Reverse()));

                if (!string.IsNullOrWhiteSpace(hammerString))
                {
                    MachineInformationGatherer.Logger.LogInformation("{Message}", hammerString);
                }
            }
            catch (Exception)
            {
                // No K7 or K8 :(
            }

            if (information.Cpu.Family >= 0x15 && information.Cpu.MaxCpuIdExtendedFeatureLevel >= 0x1E)
            {
                GatherPhysicalCores(ref information);
            }
            else if (information.Cpu.MaxCpuIdExtendedFeatureLevel >= 8)
            {
                Opcode.Cpuid(out var result, 0x80000008, 0);

                information.Cpu.PhysicalCores = (result.ecx & 0xFF) + 1;

                if (information.Cpu.FeatureFlagsOne.HasFlag(CPU.FeatureFlagEDX.HTT) &&
                    information.Cpu.PhysicalCores == information.Cpu.LogicalCores)
                {
                    information.Cpu.PhysicalCores /= 2;
                }
            }
        }
 public override void PostProviderUpdateInformation(ref MachineInformation information)
 {
     cpu.Dispose();
     bios.Dispose();
     platform.Dispose();
     RyzenMasterLibrary.UnInit();
 }
        public override void GatherDiskInformation(ref MachineInformation information)
        {
            var disks = new List <Disk>();

            try
            {
                using var p  = Util.StartProcess("lshw", "-class disk");
                using var sr = p.StandardOutput;
                p.WaitForExit();
                var lines = sr.ReadToEnd()
                            .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

                Disk disk = null;

                foreach (var line in lines)
                {
                    if (line.StartsWith("*-"))
                    {
                        if (disk != null)
                        {
                            disks.Add(disk);
                        }

                        disk = null;
                    }

                    if (line.StartsWith("*-disk:"))
                    {
                        disk = new Disk();
                        continue;
                    }

                    if (disk != null)
                    {
                        if (line.StartsWith("product:"))
                        {
                            disk.Model = disk.Caption = line.Replace("product:", "").Trim();
                        }
                        else if (line.StartsWith("vendor:"))
                        {
                            disk.Vendor = line.Replace("vendor:", "").Trim();
                        }
                    }
                }

                if (disk != null)
                {
                    disks.Add(disk);
                }
            }
            catch (Exception e)
            {
                MachineInformationGatherer.Logger.LogError(e, "Encountered while parsing disk info");
            }
            finally
            {
                information.Disks = disks.AsReadOnly();
            }
        }
Example #8
0
 public void GatherInformation(ref MachineInformation information)
 {
     GetCPUInformation(ref information);
     GetMainboardInformation(ref information);
     GetGPUInformation(ref information);
     GetDiskInformation(ref information);
     GetRAMInformation(ref information);
     GetUSBInformation(ref information);
 }
Example #9
0
        public BenchmarkRunner(Options options, MachineInformation machineInformation)
        {
            this.options       = options;
            MachineInformation = machineInformation;
            timings            = new long[options.Runs];

            TotalOverall         = options.Runs * options.Threads;
            SingleBenchmarkTotal = options.Runs * options.Threads;
        }
Example #10
0
 public CurrentProfile()
 {
     _machineInformation = MachineInformationGatherer.GatherInformation();
     ListBenchmarks      = new List <BenchmarkResult>();
     Cpu         = _machineInformation.Cpu;
     Gpus        = _machineInformation.Gpus;
     Motherboard = _machineInformation.SmBios;
     RAMSticks   = _machineInformation.RAMSticks;
 }
 public void AddOtherInformations(MachineInformation machineInformation)
 {
     if (otherInformations.Count <= 0 || machineInformation == null && machineInformation.Id < 0)
     {
         return;
     }
     MySQLDataAccess.AddOtherInformations(machineInformation, OtherInformations.ToList(), OtherInformationDeleted);
     OtherInformationDeleted = new List <OtherInformation>();
 }
Example #12
0
        public static void AddQueue(MachineInformation machineInformation)
        {
            IModel model = GetModel();

            var jsonified = JsonConvert.SerializeObject(machineInformation);

            byte[] messageBodyBytes = Encoding.UTF8.GetBytes(jsonified);
            model.BasicPublish(RMQConfiguration.ExchangeName, RMQConfiguration.RoutingKey, null, messageBodyBytes);
        }
Example #13
0
        private void GetDiskInformation(ref MachineInformation machineInformation)
        {
            if (machineInformation.Disks.Count == 0)
            {
                try
                {
                    var p  = Util.StartProcess("lshw", "-class disk");
                    var sr = p.StandardOutput;
                    p.WaitForExit();
                    var lines = sr.ReadToEnd()
                                .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

                    Disk disk = null;

                    foreach (var line in lines)
                    {
                        if (line.StartsWith("*-"))
                        {
                            if (disk != null)
                            {
                                machineInformation.Disks.Add(disk);
                            }

                            disk = null;
                        }

                        if (line.StartsWith("*-disk:"))
                        {
                            disk = new Disk();
                            continue;
                        }

                        if (disk != null)
                        {
                            if (line.StartsWith("product:"))
                            {
                                disk.Model = disk.Caption = line.Replace("product:", "").Trim();
                            }
                            else if (line.StartsWith("vendor:"))
                            {
                                disk.Vendor = line.Replace("vendor:", "").Trim();
                            }
                        }
                    }

                    if (disk != null)
                    {
                        machineInformation.Disks.Add(disk);
                    }
                }
                catch
                {
                    // Intentionally left blank
                }
            }
        }
 /// <summary>
 /// Constructs a new object.
 /// </summary>
 /// <param name="version"></param>
 /// <param name="username"></param>
 /// <param name="password"></param>
 /// <param name="token"></param>
 /// <param name="crc"></param>
 /// <param name="isaacGroup"></param>
 /// <param name="machineInformation"></param>
 public LoginRequest(int version, string username, string password, string token, int[] crc, IsaacRandGroup isaacGroup, MachineInformation machineInformation)
 {
     this.version            = version;
     this.username           = username;
     this.password           = password;
     this.token              = token;
     this.crc                = crc;
     this.isaacGroup         = isaacGroup;
     this.machineInformation = machineInformation;
 }
Example #15
0
        public frm_worker_home(MachineInformation information)
        {
            InitializeComponent();

            machineInfo  = information;
            MACHINE_CODE = machineInfo.MachineCode;
            MACHINE_TYPE = machineInfo.MachineType;
            initializeTileMenus();
            commonFX.setThisLanguage(this);
        }
        private static int RunScriptOption(ScriptOption opts, MachineInformation machineLogic)
        {
            string path = "C:\\Users\\DevFluence\\Desktop\\updated version\\MachineInformationApp\\MachineInformationConsole\\Powershell script\\script.ps1";

            var scriptOutput = string.Empty;

            scriptOutput = machineLogic.ExecutePowershell(path);

            Console.WriteLine(scriptOutput);
            return(Environment.ExitCode);
        }
        public void RefreshMachine(MachineInformation machineInformation)
        {
            if (machineInformation == null)
            {
                return;
            }

            RecordsMa = MySQLDataAccess.GetRecords(machineInformation.Id);

            FillCombobox();
        }
Example #18
0
        private void Lb_DoubleClick(object sender, EventArgs e)
        {
            Label lb = sender as Label;
            MachineInformation mi = new MachineInformation();

            mi.idmachine = Convert.ToInt16(lb.Name);
            if (mi.ShowDialog() == DialogResult.OK)
            {
                MachineManage_Load(sender, e);
            }
        }
Example #19
0
        public void Refresh(MachineInformation machineInformation)
        {
            if (machineInformation == null)
            {
                return;
            }


            // Records = TestData.GetRecords();
            Records = new ObservableCollection <Record>(MySQLDataAccess.GetRecords(machineInformation.Id));
        }
        public static int Main(string[] args)
        {
            var machineLogic = new MachineInformation();

            return(Parser.Default.ParseArguments <HostNameOption, IpOption, OsOption, ScriptOption>(args)
                   .MapResult(
                       (HostNameOption opts) => RunHostname(opts, machineLogic),
                       (IpOption opts) => RunIpOption(machineLogic),
                       (OsOption opts) => RunOsOption(machineLogic),
                       (ScriptOption opts) => RunScriptOption(opts, machineLogic),
                       errs => 1));
        }
Example #21
0
        public void TestMatching_DuplicateHardDriveRecords()
        {
            LoadTestMachineRecords();

            MachineInformation machineInformation = new MachineInformation();

            machineInformation.MachineValues = new List <DeviceInfo>();

            using (CSSDataContext db = new CSSDataContext())
            {
                // Get all machine records for login 12.
                var machineRecords = db.MachineRecords.Where(p => p.LoginId == 12);
                foreach (var machineRecord in machineRecords)
                {
                    machineInformation.MachineValues.Add(new DeviceInfo()
                    {
                        Name  = machineRecord.MachineRecordType.Name,
                        Type  = (DeviceType)machineRecord.MachineRecordType.Id,
                        Value = machineRecord.Identifier
                    });
                }

                machineInformation.MachineValues.Add(new DeviceInfo()
                {
                    Name  = DeviceType.HardDisk.ToString(),
                    Type  = DeviceType.HardDisk,
                    Value = "This is a test harddisk!"
                });

                var login12 = db.Logins.FirstOrDefault(p => p.Id == 12);
                var login13 = db.Logins.FirstOrDefault(p => p.Id == 13);

                Identity identity;
                bool     wasMerged;
                Identity.MatchIdentity(db, login12, machineInformation, out identity, out wasMerged);

                db.SubmitChanges();

                Assert.IsTrue(login12.Identity == identity);

                // Should be linked to account 13.
                Assert.AreEqual(2, db.Logins.FirstOrDefault(p => p.Id == 12).Identity.Logins.Count);

                Assert.AreEqual(1, login12.Identity.Logins.Where(p => p.Id != login12.Id).Count());
                Assert.AreEqual(1, login12.Identity.MachineRecords.Where(p => p.LoginId != login12.Id).Count());
                Assert.AreEqual(0, login12.Identity.PollVotes.Where(p => p.LoginId != login12.Id).Count());
                Assert.AreEqual(0, login12.Identity.Bans.Where(p => p.LoginId != login12.Id).Count());

                Assert.IsTrue(Identity.IsLinkedToAnOlderAccount(db, login13.Username));

                Assert.AreEqual(login12.Username, Identity.GetOldestLinkedAcccountUsername(db, login13.Username));
            }
        }
        public override void GatherCpuInformation(ref MachineInformation information)
        {
            if (cpu == null)
            {
                return;
            }

            information.Cpu.Vendor        = cpu.GetVendor();
            information.Cpu.Socket        = cpu.GetPackage();
            information.Cpu.Chipset       = cpu.GetChipsetName();
            information.Cpu.PhysicalCores = (uint)(cpu.GetCoreCount() != null ? cpu.GetCoreCount() ! : 0);
        }
Example #23
0
        /// <summary>
        /// 验证用户登录
        /// </summary>
        /// <param name="userParams">登录参数</param>
        /// <returns></returns>
        public static LoginResult Login(LoginParams userParams, string deviceSn, bool inTestMode = false, bool isLock = false)
        {
            var dataAdapter = DataAdapterFactory.Factory(MachinesSettings.Mode, userParams.StoreId, userParams.MachineSn, userParams.CompanyId, deviceSn);
            var userInfo    = dataAdapter.GetUser(userParams.Account);

            if (userInfo == null)
            {
                throw new LoginExecption("401", "账号错误!");
            }
            if (userInfo.LoginPwd != MD5.MD5Encrypt(userParams.Password))
            {
                throw new LoginExecption("401", "密码错误!");
            }
            //本店角色(1:店长、2:营业员、3:收银员、4:数据维护),格式:门店ID,角色ID|门店ID,角色ID
            if (!inTestMode && !(VerfyOperateAuth(userInfo, dataAdapter.StoreId, StoreOperateAuth.Cashier) || VerfyOperateAuth(userInfo, dataAdapter.StoreId, StoreOperateAuth.DataManager)))
            {
                throw new LoginExecption("402", "非销售员或数据维护员不允许登录销售!");
            }
            var key         = KeyFactory.MachineKeyFactory(userParams.CompanyId, userParams.StoreId, userParams.MachineSn, deviceSn);
            var machineInfo = new MachineInformation()
            {
                CashierName        = userInfo.FullName,
                CashierOperateAuth = userInfo.OperateAuth,
                CashierUid         = userInfo.UID,
                CashierUserCode    = userInfo.UserCode,
                StoreName          = userInfo.StoreName,
                StoreId            = userParams.StoreId,
                MachineSn          = userParams.MachineSn,
                CompanyId          = userParams.CompanyId,
                InTestMode         = inTestMode,
                DeviceSn           = deviceSn
            };

            onlineCache.Set(key, machineInfo);
#if (Local != true)
            RedisManager.Publish("SyncOnlineCache", JsonConvert.SerializeObject(machineInfo));
#endif
#if (Local)
            StoreManager.PubEvent("SyncOnlineCache", JsonConvert.SerializeObject(machineInfo));
#endif
            if (!isLock)
            {
                ShoppingCartFactory.Factory(userParams.StoreId, userParams.MachineSn, userParams.CompanyId, deviceSn, true);
            }
            return(new LoginResult()
            {
                FullName = userInfo.FullName,
                OperateAuth = userInfo.OperateAuth,
                UserCode = userInfo.UserCode,
                StoreName = userInfo.StoreName
            });
        }
Example #24
0
        private void GetMainboardInformation(ref MachineInformation information)
        {
            if (information.SmBios.BIOSVersion == default)
            {
                try
                {
                    information.SmBios.BIOSVersion = File.ReadAllText("/sys/class/dmi/id/bios_version").Trim();
                }
                catch (Exception e)
                {
                    MachineInformationGatherer.Logger.LogError(e, "Encountered while parsing BIOSVersion");
                }
            }

            if (information.SmBios.BIOSVendor == default)
            {
                try
                {
                    information.SmBios.BIOSVendor = File.ReadAllText("/sys/class/dmi/id/bios_vendor").Trim();
                }
                catch (Exception e)
                {
                    MachineInformationGatherer.Logger.LogError(e, "Encountered while parsing BIOSVendor");
                }
            }

            if (information.SmBios.BoardName == default)
            {
                try
                {
                    information.SmBios.BoardName = File.ReadAllText("/sys/class/dmi/id/board_name").Trim();
                }
                catch (Exception e)
                {
                    MachineInformationGatherer.Logger.LogError(e, "Encountered while parsing BoardName");
                }
            }

            if (information.SmBios.BoardVendor == default)
            {
                try
                {
                    information.SmBios.BoardVendor = File.ReadAllText("/sys/class/dmi/id/board_vendor").Trim();
                }
                catch (Exception e)
                {
                    MachineInformationGatherer.Logger.LogError(e, "Encountered while parsing BoardVendor");
                }
            }
        }
Example #25
0
        private static async void UpdateProductAsync(MachineInformation appListInMachineClient)
        {
            try
            {
                HttpResponseMessage response = await client.PostAsJsonAsync(
                    "api/MachineInformation/MachineInformation", appListInMachineClient);

                SaveEventLog("Machine information sent successfully!", EventLogEntryType.Information);
            }
            catch (Exception ex)
            {
                var strLog = string.Format("Error sending machine information.!\r\nException:\r\n{0}", ex.Message);
                SaveEventLog(strLog, EventLogEntryType.Error);
            }
        }
        public override void PostProviderUpdateInformation(ref MachineInformation information)
        {
            if (information.Cpu.AMDFeatureFlags.ExtendedFeatureFlagsF81One.HasFlag(AMDFeatureFlags
                                                                                   .ExtendedFeatureFlagsF81ECX.TOPOEXT) && information.Cpu.PhysicalCores != 0)
            {
                foreach (var cache in information.Cpu.Caches)
                {
                    var threadsPerCore = information.Cpu.LogicalCores / information.Cpu.PhysicalCores;

                    cache.TimesPresent++;
                    cache.TimesPresent  /= cache.CoresPerCache;
                    cache.CoresPerCache /= threadsPerCore;
                }
            }
        }
Example #27
0
        private void GatherNumberOfPhysicalCoresLegacy(ref MachineInformation information)
        {
            var threads = new List <Task>();
            var cores   = 0u;

            for (var i = 0; i < information.Cpu.LogicalCores; i++)
            {
                threads.Add(Util.RunAffinity(1uL << i, () =>
                        {
                        Opcode.Cpuid(out var result, 11, 0);

                        if ((result.edx & 0b1) != 1)
                        {
                            cores++;
                        }
                    }));
        private static int RunHostname(HostNameOption opts, MachineInformation machineLogic)
        {
            var hostname = string.Empty;

            if (opts.FullyQualified)
            {
                hostname = machineLogic.GetQualifiedHostName();
            }
            else
            {
                hostname = machineLogic.GetHostName();
            }
            Console.WriteLine(hostname);

            return(Environment.ExitCode);
        }
Example #29
0
        /*static MappageMachineInformation mapMachineInfo;
         * static TrackPerformance trackPerformance;
         * static MachineInformation machineInfo;*/

        static void Main(string[] args)
        {
            TrackPerformance   trackPerformance = new TrackPerformance();
            ObjectPerformance  performance      = new ObjectPerformance();
            MachineInformation machineInfo      = new MachineInformation();

            machineInfo = trackPerformance.getAveragePerformance();

            //convertion des "," en "." pour l'insertion des doubles dans la base de données
            string stringCPU  = machineInfo.infoCPU.ToString(CultureInfo.InvariantCulture.NumberFormat);
            string stringRAM  = machineInfo.infoRAM.ToString(CultureInfo.InvariantCulture.NumberFormat);
            string stringDisk = machineInfo.infoDisk.ToString(CultureInfo.InvariantCulture.NumberFormat);

            //insertion dans la base de données
            performance.insert(stringCPU, stringRAM, stringDisk);
        }
Example #30
0
        public override void GatherCpuInformation(ref MachineInformation information)
        {
            if (information.Cpu.MaxCpuIdFeatureLevel >= 0x1f)
            {
                GatherNumberOfPhysicalCores(ref information);
            }
            else if (information.Cpu.MaxCpuIdFeatureLevel >= 11)
            {
                GatherNumberOfPhysicalCoresLegacy(ref information);
            }

            if (information.Cpu.MaxCpuIdExtendedFeatureLevel >= 4)
            {
                GatherCpuName(ref information);
            }
        }