Esempio n. 1
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="account">账号</param>
        /// <param name="password">密码</param>
        /// <param name="practice">是否为练习模式</param>
        /// <returns>用户登录凭证</returns>
        public UserCredentials Login(string account, string password, bool practice)
        {
            var device = _deviceRepository.Get(_CompanyId, _StoreId, _MachineSn);

            if (device == null)
            {
                throw new UnauthorizedException("未能找到设备信息,请先注册设备!");
            }
            if (device.State == DeviceState.Disable)
            {
                throw new UnauthorizedException("设备未通过授权,请到后台启用设备!");
            }
            var user = _sysUserRepository.FindStoreUser(_CompanyId, account, password);

            if (user == null)
            {
                throw new NotFoundUserException(ConstValues.StoreUserVerfyError);
            }
            StoreUserRole storeUserRole  = new StoreUserRole(user.OperateAuth);
            var           storeUserRoles = storeUserRole.GetStoreUserRoles(_StoreId);

            if (!storeUserRoles.Any(o => o == StoreUserRoleType.Cashier || o == StoreUserRoleType.DataManager))
            {
                throw new UnauthorizedException(ConstValues.LoginAuthorizationFailures);
            }
            var userAuth = user.DoLogin(_StoreId, _MachineSn, _DeviceSn, practice, GetLoginTokenKey());

            _sysUserRepository.SaveChanges();
            _CacheService.SetObject(string.Format(ConstValues.CacheStoreUserKey, userAuth.Token), userAuth, new TimeSpan(24, 0, 0));
            return(userAuth);
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StoreShare" /> class.
 /// </summary>
 /// <param name="UserId">UserId (required).</param>
 /// <param name="UserRole">UserRole (required).</param>
 /// <param name="Links">Links.</param>
 public StoreShare(BeezUPCommonUserId UserId = default(BeezUPCommonUserId), StoreUserRole UserRole = default(StoreUserRole), StoreShareLinks Links = default(StoreShareLinks))
 {
     // to ensure "UserId" is required (not null)
     if (UserId == null)
     {
         throw new InvalidDataException("UserId is a required property for StoreShare and cannot be null");
     }
     else
     {
         this.UserId = UserId;
     }
     // to ensure "UserRole" is required (not null)
     if (UserRole == null)
     {
         throw new InvalidDataException("UserRole is a required property for StoreShare and cannot be null");
     }
     else
     {
         this.UserRole = UserRole;
     }
     this.Links = Links;
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StoreHeader" /> class.
 /// </summary>
 /// <param name="Name">Name (required).</param>
 /// <param name="Url">Url (required).</param>
 /// <param name="CountryIsoCodeAlpha3">CountryIsoCodeAlpha3 (required).</param>
 /// <param name="Sectors">Sectors (required).</param>
 /// <param name="StoreId">StoreId (required).</param>
 /// <param name="UserRole">UserRole (required).</param>
 /// <param name="Status">Status (required).</param>
 /// <param name="OwnerUserId">The user id of the owner of the store (required).</param>
 /// <param name="ShareCount">The share count related to this store (required).</param>
 /// <param name="CreationUtcDate">The creation date of the store (required).</param>
 /// <param name="Links">Links.</param>
 public StoreHeader(StoreName Name = default(StoreName), StoreUrl Url = default(StoreUrl), StoreCountryIsoCodeAlpha3 CountryIsoCodeAlpha3 = default(StoreCountryIsoCodeAlpha3), StoreSectors Sectors = default(StoreSectors), BeezUPCommonStoreId StoreId = default(BeezUPCommonStoreId), StoreUserRole UserRole = default(StoreUserRole), StoreStatus Status = default(StoreStatus), string OwnerUserId = default(string), int?ShareCount = default(int?), DateTime?CreationUtcDate = default(DateTime?), StoreHeaderLinks Links = default(StoreHeaderLinks))
 {
     // to ensure "Name" is required (not null)
     if (Name == null)
     {
         throw new InvalidDataException("Name is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.Name = Name;
     }
     // to ensure "Url" is required (not null)
     if (Url == null)
     {
         throw new InvalidDataException("Url is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.Url = Url;
     }
     // to ensure "CountryIsoCodeAlpha3" is required (not null)
     if (CountryIsoCodeAlpha3 == null)
     {
         throw new InvalidDataException("CountryIsoCodeAlpha3 is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.CountryIsoCodeAlpha3 = CountryIsoCodeAlpha3;
     }
     // to ensure "Sectors" is required (not null)
     if (Sectors == null)
     {
         throw new InvalidDataException("Sectors is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.Sectors = Sectors;
     }
     // to ensure "StoreId" is required (not null)
     if (StoreId == null)
     {
         throw new InvalidDataException("StoreId is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.StoreId = StoreId;
     }
     // to ensure "UserRole" is required (not null)
     if (UserRole == null)
     {
         throw new InvalidDataException("UserRole is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.UserRole = UserRole;
     }
     // to ensure "Status" is required (not null)
     if (Status == null)
     {
         throw new InvalidDataException("Status is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.Status = Status;
     }
     // to ensure "OwnerUserId" is required (not null)
     if (OwnerUserId == null)
     {
         throw new InvalidDataException("OwnerUserId is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.OwnerUserId = OwnerUserId;
     }
     // to ensure "ShareCount" is required (not null)
     if (ShareCount == null)
     {
         throw new InvalidDataException("ShareCount is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.ShareCount = ShareCount;
     }
     // to ensure "CreationUtcDate" is required (not null)
     if (CreationUtcDate == null)
     {
         throw new InvalidDataException("CreationUtcDate is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.CreationUtcDate = CreationUtcDate;
     }
     this.Links = Links;
 }