Пример #1
0
        protected override bool Register(ActiveUserResponse member, string sPassword, int iPrivilege)
        {
            bool returnResult = false;

            try
            {
                returnResult = base.Register(member, sPassword, iPrivilege);

                if (returnResult)
                {
                    for (int fingerIndex = 0; fingerIndex < 10; fingerIndex++)
                    {
                        if (fingerIndex == member.fingerIndex)
                        {
                            //remove & update finger
                            AxDevice.SSR_DelUserTmpExt(_attendanceDevice.MachineNo, member.member_id.ToString(), fingerIndex);
                            var isSuccess = AxDevice.SetUserTmpExStr(_attendanceDevice.MachineNo, member.member_id, member.fingerIndex, 1, member.templateData);
                            if (isSuccess)
                            {
                                OnThrowingMessage("Register user " + member.userName + " in device with Finger " + member.member_id, MessageType.Info);
                            }
                        }
                    }
                }
                return(returnResult);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        protected override bool Register(ActiveUserResponse member, string sPassword, int iPrivilege)
        {
            bool   returnResult = false, isExitToDevice = false;
            string name, password;
            int    priv;

            try
            {
                bool isEnabled = true;
                if (!String.IsNullOrEmpty(member.cardNumber))
                {
                    bool isSet = AxDevice.SetStrCardNumber(member.cardNumber);
                    if (!isSet)
                    {
                        return(false);
                    }
                    if (isEnabled)
                    {
                        returnResult = AxDevice.SSR_SetUserInfo(_attendanceDevice.MachineNo, member.member_id.ToString(), member.userName, sPassword, iPrivilege, isEnabled);
                    }
                    else
                    {
                        //check if user exits in device. Delete User if only Exit
                        AxDevice.SSR_GetUserInfo(_attendanceDevice.MachineNo, member.member_id.ToString(), out name, out password, out priv, out isExitToDevice);
                        if (isExitToDevice)
                        {
                            returnResult = AxDevice.SSR_DeleteEnrollData(_attendanceDevice.MachineNo, member.member_id.ToString(), BusinessRules.BackupNumber);
                        }
                        else
                        {
                            return(returnResult);
                        }
                    }

                    if (returnResult)
                    {
                        OnThrowingMessage("Register user " + member.userName + " in device with pin " + member.member_id, MessageType.Info);
                    }
                    else
                    {
                        OnThrowingMessage("Failed to save user " + member.userName + " in device ", MessageType.Error);
                    }
                }
                return(returnResult);
            }
            catch (Exception ex)
            {
                //Log.Error(ex);
                return(false);
            }
        }
Пример #3
0
        public bool SaveToDevice(ActiveUserResponse member, bool useInternalConnection = false, int machineNum = 0)
        {
            bool returnResult = false;

            //Open Connection if needed
            if (useInternalConnection)
            {
                bool isSuccess = OpenConnection();
                if (!isSuccess)
                {
                    return(false);
                }
            }

            //Business logic
            try
            {
                if (member == null)
                {
                    return(false);
                }
                string sPassword  = "";
                int    iPrivilege = 0;

                returnResult = Register(member, sPassword, iPrivilege);
            }
            catch (Exception ex)
            {
                serviceLog.Error(ex);
                return(false);
            }
            finally
            {
                if (useInternalConnection)
                {
                    RefreshData();
                    CloseConnection();
                }
            }
            return(returnResult);
        }
Пример #4
0
        public async Task <IActionResult> Get()
        {
            var activeUser = await _identityService.GetCurrentUserAsync(User.GetId());

            if (activeUser == null)
            {
                return(BadRequest());
            }

            var activeUserMapped = _mapper.Map <AppUserDataModel>(activeUser);

            var likedArticlesRequestResult = await _articleService.GetLikedByUserAsync(activeUser.UserName, null);

            var mappedLikedArticles = likedArticlesRequestResult.Success ? _mapper.Map <IEnumerable <ArticlePreviewModel> >(likedArticlesRequestResult.Payload) : null;

            var response = new ActiveUserResponse
            {
                User          = activeUserMapped,
                LikedArticles = mappedLikedArticles
            };

            return(Ok(response));
        }
Пример #5
0
 protected abstract bool Register(ActiveUserResponse member, string sPassword, int iPrivilege);