/// <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> /// POS 登出 /// </summary> public void Logout() { var result = POSRestClient.Delete <object>("api/Session"); if (!result.Successed) { throw new NetException(result.Message); } }
public ProductRecord FindProductByProductCode(string productCode) { var parameters = new Dictionary <string, string>(); parameters.Add("productCode", productCode); var result = POSRestClient.Post <ProductRecord>("Api/Product/FindProductByProductCode", parameters); if (result.Successed) { return(result.Data); } else { throw new NotFoundProductException(result.Message); } }
public IEnumerable <ProductRecord> FindProductByBarcode(string barcode) { var parameters = new Dictionary <string, string>(); parameters.Add("barcode", barcode); var result = POSRestClient.Post <List <ProductRecord> >("Api/Product/FindProductByBarcode", parameters); if (result.Successed) { return(result.Data); } else { throw new NotFoundProductException(result.Message); } }
private string DeviceRegisterToServer(int companyId, string storeId, string deviceSn, string securityCode, DeviceType deviceType) { var parameters = new Dictionary <string, string>(); parameters.Add("deviceSn", deviceSn); parameters.Add("storeId", storeId); parameters.Add("companyId", companyId.ToString()); parameters.Add("securityCode", securityCode); parameters.Add("deviceType", ((short)deviceType).ToString()); var result = POSRestClient.Post <string>("Api/Device", parameters); if (result.Successed) { return(result.Data); } else { throw new SettingException(result.Message); } }