예제 #1
0
        protected internal virtual void SetLocalizedText(string key, string text)
        {
            var localizationText = context.Query <LocalizationTexts>().SingleBy(this, key) ??
                                   context.New <LocalizationText>().With(key, text, LanguageCode);

            localizationText.UpdateText(text);

            applicationCache.Remove(this, DICTIONARY);

            GetLocalizedText(key); //set işlemi sonunda tüm cache'i tekrar ayağa kaldırması için eklendi
        }
예제 #2
0
        public virtual void Remove()
        {
            String key = ctx.web.param("key");

            if (strUtil.IsNullOrEmpty(key))
            {
                echoRedirect("cache key 不能为空");
                return;
            }
            _appCache.Remove(key);
            echoRedirect(lang("opok"));
        }
        public async Task <RegisterResponse> Register(RegisterRequest request)
        {
            var response = new RegisterResponse();
            var username = request.EmailAddress;

            var duplicateResponse = await DuplicateUserCheck(new DuplicateUserCheckRequest()
            {
                EmailAddress = request.EmailAddress,
                Username     = username
            });

            if (duplicateResponse.Notifications.HasErrors)
            {
                response.Notifications.Add(duplicateResponse.Notifications);
                return(response);
            }

            int id;

            using (var uow = _uowFactory.GetUnitOfWork())
            {
                id = await uow.UserRepo.CreateUser(new Infrastructure.Repositories.UserRepo.Models.CreateUserRequest()
                {
                    Username      = username,
                    Email_Address = request.EmailAddress,
                    Password_Hash = PasswordHelper.HashPassword(request.Password),
                    Is_Enabled    = true,
                    Created_By    = ApplicationConstants.SystemUserId,
                });

                uow.Commit();
            }

            _cache.Remove(CacheConstants.UserRoles);

            await _sessionService.WriteSessionLogEvent(new Models.ServiceModels.Session.CreateSessionLogEventRequest()
            {
                EventKey = SessionEventKeys.UserRegistered
            });

            await _emailService.SendAccountActivation(new Models.ServiceModels.Email.SendAccountActivationRequest()
            {
                UserId = id
            });

            response.Notifications.Add($"You have been successfully registered, please check {request.EmailAddress} for a link to activate your account.", NotificationTypeEnum.Success);
            return(response);
        }
예제 #4
0
        private async Task CreateOrDeleteUserRoles(List <int> newRoles, int userId, int loggedInUserId)
        {
            var userRoles = await _cache.UserRoles();

            var existingRoles = userRoles.Where(ur => ur.User_Id == userId).Select(ur => ur.Role_Id);

            var rolesToBeDeleted = existingRoles.Where(ur => !newRoles.Contains(ur));
            var rolesToBeCreated = newRoles.Where(ur => !existingRoles.Contains(ur));

            if (rolesToBeDeleted.Any() || rolesToBeCreated.Any())
            {
                using (var uow = _uowFactory.GetUnitOfWork())
                {
                    foreach (var roleId in rolesToBeCreated)
                    {
                        await uow.UserRepo.CreateUserRole(new Infrastructure.Repositories.UserRepo.Models.CreateUserRoleRequest()
                        {
                            User_Id    = userId,
                            Role_Id    = roleId,
                            Created_By = loggedInUserId
                        });
                    }

                    foreach (var roleId in rolesToBeDeleted)
                    {
                        await uow.UserRepo.DeleteUserRole(new Infrastructure.Repositories.UserRepo.Models.DeleteUserRoleRequest()
                        {
                            User_Id    = userId,
                            Role_Id    = roleId,
                            Updated_By = loggedInUserId
                        });
                    }
                    uow.Commit();
                }
                _cache.Remove(CacheConstants.UserRoles);

                await _sessionService.WriteSessionLogEvent(new Models.ServiceModels.Session.CreateSessionLogEventRequest()
                {
                    EventKey = SessionEventKeys.UserRolesUpdated
                });
            }
        }
예제 #5
0
 public void Delete(Type t, int id)
 {
     appCache.Remove(CacheKey.getObject(t.FullName, id));
     logger.Debug("Delete=>" + t.FullName + id);
     CacheTime.updateTable(t);
 }