/// <summary>
        /// 设备注册
        /// </summary>
        /// <param name="certificate">门店证书</param>
        /// <returns>设备注册信息</returns>
        public POSDeviceInformation DeviceRegister(string certificate)
        {
            var securityCode     = DES.DESDecryptBase64WithKeyIVToMd5Base64(certificate, ConstValues.DESKEY, ConstValues.DESKEY);
            var storeInfo        = JsonHelper.ToObject <StoreInformation>(securityCode);
            var deviceInfo       = new POSDeviceInformation(storeInfo);
            var deviceSn         = GetDeviceSn();
            var needSaveDeviceSn = false;

            if (string.IsNullOrWhiteSpace(deviceSn))
            {
                deviceSn         = CreateDeviceSn();
                needSaveDeviceSn = true;
            }
            var machineSn = DeviceRegisterToServer(storeInfo.CompanyId, storeInfo.StoreId, deviceSn, certificate, DeviceType.PC);

            if (string.IsNullOrWhiteSpace(machineSn))
            {
                throw new SettingException("未能正确从后台获取设备编号!");
            }
            if (needSaveDeviceSn)
            {
                BuildDeviceSn(deviceSn);
            }
            deviceInfo.SetMachine(machineSn, deviceSn);
            IPosDeviceRepository posDeviceRepository = new PosDeviceRepository();

            posDeviceRepository.Save(deviceInfo);
            return(deviceInfo);
        }
Example #2
0
        public void SaveDeviceInfo()
        {
            IPosDeviceRepository posDeviceRepository = new PosDeviceRepository();

            posDeviceRepository.Save(new Settings.POSDeviceInformation()
            {
                CompanyId = 1, CompanyName = "hsaidohsa", CompanyShorterName = "sadas", DeviceSn = "FCAA147DBADC", MachineSn = "01", StoreId = "16", StoreName = "sadasd"
            });
        }