/// <summary> /// 登录 /// </summary> /// <param name="account">账号</param> /// <param name="password">密码</param> /// <param name="practice">是否进行练习</param> public UserCredentials Login(string account, string password, bool practice) { IPosDeviceRepository posDeviceRepository = new PosDeviceRepository(); var deviceInfo = posDeviceRepository.Get(true); var userLogin = new LoginAction() { Account = account, Password = MD5.EncryptOutputHex(password, isUpper: false), CompanyId = deviceInfo.CompanyId, DeviceSn = deviceInfo.DeviceSn, MachineSn = deviceInfo.MachineSn, Practice = practice, StoreId = deviceInfo.StoreId }; var result = POSRestClient.Post <LoginAction, UserCredentials>("api/Session", userLogin); if (result.Successed) { loginUserInformaction = result.Data; POSRestClient.SetToken(loginUserInformaction.Token); return(loginUserInformaction); } else { throw new NetException(result.Message); } }
/// <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); }
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" }); }