private void UpdateCoreValues(ISensor sensor)
 {
     if (sensor.Name.ToLower().Contains("core"))
     {
         HardwareHelper.Queueue(sensor.Name, sensor.Value, sensor.SensorType, Cores);
     }
 }
Beispiel #2
0
#pragma warning disable IDE0060 // Remove unused parameter
        public static void Main(string[] args)
#pragma warning restore IDE0060 // Remove unused parameter
        {
            // TODO add debug modifiers to tweak stuff while debugging

            // Load app settings:
            SettingsManager.LoadSettings();
            // Init all HTTP actions
            ActionRegister.Register();

            if (!CoreState.SettingsInstance.IsFirstLaunch)
            {
                HardwareHelper.InitHardware();
            }
            else
            {
                ConsoleManager.LogInfo("Waiting for hardware initialization.");
            }

            // Server initialization:
            HttpServer server = new HttpServer(CoreState.SettingsInstance.LocalServerAddress, CoreState.SettingsInstance.LocalServerPort);
            Task       listen = server.Listen();

            listen.GetAwaiter().GetResult();
        }
Beispiel #3
0
 private void SaveTransaction(decimal amt, decimal tnd)
 {
     if (tnd < amt)
     {
         return;
     }
     try
     {
         transaction.TenderAmount = tnd;
         if (!DataHandler.SaveTransaction(transaction))
         {
             FncFilter.Alert(globalvariables.saving_failed);
             return;
         }
         else
         {
             HardwareHelper.Print(transaction, false, false);
             FncFilter.Alert(globalvariables.saving_success);
             transComplete = true;
             this.Close();
         }
     }
     catch
     {
         FncFilter.Alert(globalvariables.saving_failed);
         return;
     }
 }
Beispiel #4
0
        private void btnOkay_Click(object sender, EventArgs e)
        {
            txtInvoice.Text.Trim();
            if (txtInvoice.Text.Length == 0)
            {
                return;
            }
            string      invoicenumber = txtInvoice.Text;
            Transaction trans         = DataHandler.GetTransactionByInvoice(invoicenumber);

            if (trans == null)
            {
                FncFilter.Alert("Invalid Invoice Number.");
            }
            else
            {
                if (IsReprint)
                {
                    HardwareHelper.Print(trans, true, false);
                    this.Close();
                }
                else
                {
                    DataHandler.VoidTransaction(trans);
                    HardwareHelper.Print(trans, false, true);
                    this.Close();
                }
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            LogHelper.InitLogPath();
            LogHelper.AddLog("Instance is starting.");

            var list = HardwareHelper.GetCpuId();

            list.ForEach(Console.WriteLine);

            var disks = HardwareHelper.GetRemovableDisk();

            disks.ForEach(Console.WriteLine);

            AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) =>
            {
                _instanceMutex?.ReleaseMutex();
                _instanceMutex = null;
                LogHelper.AddLog("Instance is shutting down.");
            };

            CheckSingleInstance();
            AddThreadExceptionHandler();

            GlobalConfig.Instance.Init();

            Run();
        }
Beispiel #6
0
 private void SetDeviceStatus(string hardwareId, bool status)
 {
     foreach (var deviceInfo in HardwareHelper.EnumerateDevices())
     {
         if (deviceInfo.GetProperty(SPDRP.SPDRP_HARDWAREID) == hardwareId)
         {
             HardwareHelper.EnableDevice(deviceInfo.HDevInfo, deviceInfo.DeviceData, status);
             return;
         }
     }
 }
Beispiel #7
0
        /// <summary>
        /// 判断是否注册
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private bool bRegister(out string info)
        {
            info = string.Empty;
            //读取MAC地址
            string macAddress = HardwareHelper.GetMacAddress();
            //配置文件中的MAC地址
            string appAddress = null;

            if (string.IsNullOrEmpty(macAddress))
            {
                info = "系统信息获取失败!";
                return(false);
            }

            //读取配置文件中的MAC地址
            appAddress = System.Configuration.ConfigurationManager.AppSettings["regCode"];
            if (string.IsNullOrEmpty(appAddress))
            {
                info = "获取注册信息失败,请先注册!";
                return(false);
            }

            //比对信息是否一致
            string[] myAddress = null;
            //反序列化
            try
            {
                myAddress = DESEncrypt.Decrypt(appAddress).Split('|'); //EncodeHelper.DecryptString(appAddress, true).Split('|');
            }
            catch
            {
                info = "系统注册错误,注册码不正确!";
                return(false);
            }
            if (!myAddress[0].Equals(macAddress))
            {
                info = "系统注册错误,注册码不正确!";
                return(false);
            }

            if (myAddress.Length > 1 && !myAddress[1].Trim().Equals(string.Empty))
            {
                if (DateTime.Now.CompareTo(Convert.ToDateTime(myAddress[1])) > 0)
                {
                    //判断是否过期
                    info = "当前注册已到期,请联系供应商!";
                    return(false);
                }
            }

            return(true);
        }
Beispiel #8
0
 private void btnZRead_Click(object sender, EventArgs e)
 {
     if (report.Date == DateTime.Now.Date && !globalvariables.LockedPOS)
     {
         if (FncFilter.ConfirmYesNo(globalvariables.confirm_lock_pos))
         {
             GenerateReport.ZRead(report.Date);
         }
     }
     else
     {
         report.Type = 3;
         HardwareHelper.PrintReport(null, null, null, report);
     }
     this.Close();
 }
Beispiel #9
0
        private long CreateExecutionRecord(PlanEntity plan)
        {
            ExecutionEntity execution = new ExecutionEntity()
            {
                PlanID           = plan.ID,
                Url              = ExecutionContext.Url,
                Browser          = ExecutionContext.Browser,
                Language         = ExecutionContext.Language,
                CpuCount         = HardwareHelper.GetCpuCount(),
                CpuFrequency     = HardwareHelper.GetCpuFrequency(),
                MemorySize       = HardwareHelper.GetTotalPhysicalMemory(),
                StartTime        = DateTime.Now,
                EndTime          = null,
                Owner            = HardwareHelper.GetUserName(),
                ScreenResolution = HardwareHelper.GetScreenResolution(),
            };

            return(ExecutionDA.Create(execution));
        }
Beispiel #10
0
        /// <summary>
        /// 添加 BDO 客户端日志
        /// </summary>
        /// <param name="logs"></param>
        /// <returns></returns>
        public static bool AddBDOClientLogs(HrmResource loginUser, string userName, string slKeyCode, string itMark, string logType, string logData)
        {
            try
            {
                ClientLogsV2 clientLogsV2 = new ClientLogsV2();
                clientLogsV2.company    = !string.IsNullOrEmpty(loginUser.subcompanyname) ? loginUser.subcompanyname : "";
                clientLogsV2.department = !string.IsNullOrEmpty(loginUser.departmentname) ? loginUser.departmentname : "";
                //clientLogsV2.userName = !string.IsNullOrEmpty(userName) ? userName : "";
                //clientLogsV2.loginId = !string.IsNullOrEmpty(loginUser.userId) ? loginUser.userId : "";
                clientLogsV2.userName   = !string.IsNullOrEmpty(loginUser.name) ? loginUser.name : "";
                clientLogsV2.loginId    = !string.IsNullOrEmpty(loginUser.loginid) ? loginUser.loginid : "";
                clientLogsV2.userSlCode = !string.IsNullOrEmpty(slKeyCode) ? slKeyCode : "";
                clientLogsV2.itMark     = !string.IsNullOrEmpty(itMark) ? itMark : "";

                HardwareHelper hardwareInfo = HardwareHelper.Instance();
                clientLogsV2.pcName       = hardwareInfo.ComputerName;
                clientLogsV2.cpuId        = hardwareInfo.CpuID;
                clientLogsV2.cpuName      = hardwareInfo.CpuName;
                clientLogsV2.diskName     = hardwareInfo.DiskID;
                clientLogsV2.mcAddress    = hardwareInfo.MacAddress;
                clientLogsV2.ip           = hardwareInfo.IpAddress;
                clientLogsV2.ram          = Math.Ceiling(Convert.ToDecimal(hardwareInfo.TotalPhysicalMemory) / 1024 / 1024 / 1024).ToString() + "G";
                clientLogsV2.logDate      = DateTime.Now.ToString("yyyy-MM-dd");
                clientLogsV2.logTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                clientLogsV2.logType      = logType;            //TODO: ....
                clientLogsV2.logTypeValue = "1";                //TODO: ....
                clientLogsV2.logData      = logData;            //

                string           bdoClientLogURL = GetEoopAppSettings("EOOP_BDO_CLIENT_LOG");
                string           requesstBody    = JsonConvert.SerializeObject(clientLogsV2);
                string           result          = POSTEoopHttpRequest(bdoClientLogURL, requesstBody);
                BaseEoopResponse resultResponse  = (BaseEoopResponse)JsonConvert.DeserializeObject(result, typeof(BaseEoopResponse));
                return(resultResponse.ok);
            }
            catch (Exception ex)
            {
                //Exception clientEx = new Exception("添加客户端日志失败:" + ex.Message, ex);
                //throw clientEx;
                return(false);
            }
        }
        public void Update()
        {
            _hardware.Update();

            foreach (ISensor sensor in _hardware.Sensors)
            {
                switch (sensor.SensorType)
                {
                case SensorType.Load:
                    if (sensor.Name == "CPU Total")
                    {
                        HardwareHelper.Queue(sensor.Value, Load);
                    }
                    CurrentLoad = sensor.Value ?? 0;
                    break;

                case SensorType.Clock:
                    if (sensor.Name == "Bus Speed")
                    {
                        HardwareHelper.Queue(sensor.Value, Clock);
                    }
                    break;

                case SensorType.Temperature:
                    if (sensor.Name == "CPU Package")
                    {
                        HardwareHelper.Queue(sensor.Value, Temperature);
                        CurrentTemp = sensor.Value ?? 0;
                    }
                    break;
                }
                if (coresEnabled)
                {
                    UpdateCoreValues(sensor);
                }
            }
        }
        public bool Logon(Guid guid, out string errorMessage)
        {
            Guard.AssertNotEmpty(_appName, "Не определено название приложения");
            Guard.AssertNotEmpty(_version, "Не определена версия");
            Guard.AssertNotEmpty(_serverUrl, "не определен Url");
            Guard.Against <ArgumentException>(_key == Guid.Empty, "Не определен ключ");
            //Guard.AssertNotNull(_getResult, "Не определен прокси сервис");

            var info = new LogonInfo()
            {
                LicenseGuid = guid
            };
            var reg = RegistryHelper.Create();

            info.History = new LogonHistory()
            {
                RegisteredOwner = reg?.RegisteredOwner,
                CurrentBuild    = reg?.CurrentBuild,
                CSDVersion      = reg?.CSDVersion,
                CSDBuildNumber  = reg?.CSDBuildNumber,
                ProductName     = reg?.ProductName,
                ProductId       = reg?.ProductId,
                MachineName     = Environment.MachineName,
                UserName        = Environment.UserName,
                UserDomainName  = Environment.UserDomainName,
                HardwareId      = HardwareHelper.GetId(),
                ServerUrl       = _serverUrl,
                ApplicationName = _appName,
                CurrentVersion  = _version
            };

            var res = Logon(info);

            errorMessage = res?.Message;
            return(res?.Success ?? false);
        }
Beispiel #13
0
 public string GetRegInfo()
 {
     return(HardwareHelper.GetMacAddress());
 }
Beispiel #14
0
 private void btnXRead_Click(object sender, EventArgs e)
 {
     HardwareHelper.PrintReport(null, null, null, report);
     this.Close();
 }
Beispiel #15
0
 public void GetCpuId()
 {
     var code = HardwareHelper.GetCpuId();
 }