Esempio n. 1
0
 public static void InitUserStoreageService(IUserStorageService userStorageService)
 {
     foreach (var user in Users)
     {
         userStorageService.Add(user);
     }
 }
Esempio n. 2
0
 public CustomAuthSchemaHandler(
     IOptionsMonitor <CustomAuthSchemaOptions> options,
     ILoggerFactory loggerFactory,
     UrlEncoder encoder,
     ISystemClock clock,
     IUserStorageService storage)
     : base(options, loggerFactory, encoder, clock)
 {
     _storage = storage;
 }
Esempio n. 3
0
 internal VWO(AccountSettings settings, IValidator validator, IUserStorageService userStorageService, ICampaignAllocator campaignAllocator, ISegmentEvaluator segmentEvaluator, IVariationAllocator variationAllocator, bool isDevelopmentMode, string goalTypeToTrack = Constants.GoalTypes.ALL, bool shouldTrackReturningUser = false)
 {
     this._settings                 = settings;
     this._validator                = validator;
     this._userStorageService       = new UserStorageAdapter(userStorageService);
     this._campaignAllocator        = campaignAllocator;
     this._variationAllocator       = variationAllocator;
     this._isDevelopmentMode        = isDevelopmentMode;
     this._segmentEvaluator         = segmentEvaluator;
     this._goalTypeToTrack          = goalTypeToTrack;
     this._shouldTrackReturningUser = shouldTrackReturningUser;
 }
Esempio n. 4
0
        public UsersManagerViewModel()
        {
            IUserStorageService service = Locator.Current.GetService <IUserStorageService>();

            Observable.Return(Unit.Default)
            .Merge(Refresh)
            .SelectMany(async(e) =>
            {
                var v = (await service.GetUsers()).Select(u => new UserViewModel
                {
                    User = u
                }).ToList();

                return(v);
            })
            .ObserveOn(RxApp.MainThreadScheduler)
            .ToPropertyEx(this, x => x.UserViewModels);


            // TODO solve the problem
            this.WhenAnyValue(x => x.UserViewModels)
            .Where(u => u != null)
            .Subscribe(x =>
            {
                foreach (var item in x)
                {
                    item.Refresh.Subscribe(_ =>
                    {
                        Refresh.Execute().Subscribe();
                    });
                }
            });



            AddUser = ReactiveCommand.CreateFromTask <(User, string), bool>(async(input) =>
            {
                var user = input.Item1;
                return(await service.SaveUser(user.Username, user.Password, input.Item2));
            });

            AddUser.ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(_ =>
            {
                Refresh.Execute().Subscribe();
            });
        }
Esempio n. 5
0
        public void Run()
        {
            RunSlaves();

            var repositoryFileName = ConfigurationManager.AppSettings["UserMemoryCacheWithStateFileName"];
            var repository         = new UserDiskRepository(repositoryFileName);

            RepositoryManager = repository;

            Assembly assembly = Assembly.Load("UserStorageServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f46a87b3d9a80705");

            var masterServiceType = assembly.ExportedTypes
                                    .Where(t => t.GetCustomAttribute <MyApplicationServiceAttribute>() != null)
                                    .First(t => t.GetCustomAttribute <MyApplicationServiceAttribute>().ServiceMode == "UserStorageMaster");

            var storageService = (IUserStorageService)Activator.CreateInstance(
                masterServiceType,
                repository,
                slaveActions.Select(s => s.Receiver));

            MasterService = new UserStorageServiceLog(storageService);
        }
Esempio n. 6
0
 public LogService(IUserStorageService userStorageService)
 {
     this.userStorageService = userStorageService;
 }
Esempio n. 7
0
 public UserStorageController(IOrchardServices services, IUserStorageService userStorageService)
 {
     Services            = services;
     _userStorageService = userStorageService;
     T = NullLocalizer.Instance;
 }
 public UserStorageServiceLog(IUserStorageService storageService) : base(storageService)
 {
 }
Esempio n. 9
0
 public HomeController(IWorkContextAccessor wca, IUserStorageService storageService)
 {
     _wca            = wca;
     _storageService = storageService;
 }
Esempio n. 10
0
 public GetDevicesIntentHandler(IUserStorageService userStorageService)
 {
     _userStorageService = userStorageService;
 }
Esempio n. 11
0
 public AppEntry(IEnumerable <IIntentHandler> handlers, IUserStorageService userStorageService)
 {
     _handlers           = handlers;
     _userStorageService = userStorageService;
 }
Esempio n. 12
0
        public MainPageViewModel()
        {
            Activator = new ViewModelActivator();

            this.ForceDisconnect = ReactiveCommand.CreateFromTask <string, Unit>(ForceDisconnectImpl);

            this.CancelConnect = ReactiveCommand.Create(() =>
            {
                Global.ConnectStatus = ConnectStatus.Disconnected;
            });

            this.ContinueConnectWithPin = ReactiveCommand.CreateFromTask <string>(async(pin) =>
            {
                await Global.DoConnect.Execute(pin);
            });

            this.ContinueConnectWithPassword = ReactiveCommand.CreateFromTask <string>(async(password) =>
            {
                IUserStorageService service = Locator.Current.GetService <IUserStorageService>();
                try
                {
                    await service.ResetUserPassword(Global.CurrentUser.Username, password, "");
                }
                catch
                {
                    throw new Exception("新密码保存错误");
                }
                await Global.DoConnect.Execute("");
            });

            this.Toggle = ReactiveCommand.CreateFromTask(async() =>
            {
                await Global.Toggle.Execute();
            });

            this.WhenActivated(d =>
            {
                this.WhenAnyValue(x => x.Global.CurrentUser)
                .ToPropertyEx(this, x => x.SelectedUser)
                .DisposeWith(d);

                this.WhenAnyValue(x => x.Global.ConnectStatus)
                .ToPropertyEx(this, x => x.ConnectStatus)
                .DisposeWith(d);

                var errorSource = Observable.Merge(
                    this.ContinueConnectWithPin.ThrownExceptions,
                    this.Toggle.ThrownExceptions,
                    this.ContinueConnectWithPassword.ThrownExceptions
                    );

                var errorStream = errorSource
                                  .Where(u => u is ConnectionException);


                this.WhenAnyValue(x => x.ConnectStatus)
                .Where(u => u == ConnectStatus.Connected)
                .Select(u => Unit.Default)
                .Merge(Observable.Interval(TimeSpan.FromMinutes(10)).Select(p => Unit.Default))
                .SelectMany(async _ => await Locator.Current.GetService <IInternetGatewayService>().GetAccountInfo())
                .Catch(Observable.Return(new AccountInfo
                {
                    Name     = "获取失败",
                    Plan     = "N/A",
                    UsedTime = TimeSpan.FromMinutes(0)
                }))
                .ObserveOn(RxApp.MainThreadScheduler)
                .ToPropertyEx(this, x => x.AccountInfo);

                errorStream
                .Select(u => ((ConnectionException)u).ErrorType)
                .Where(u => u == ConnectionError.LostPin || u == ConnectionError.InvalidPin)
                .Select(u => true)
                .Delay(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler)
                .Merge(this.CancelConnect.Select(_ => false))
                .Merge(this.ContinueConnectWithPin.IsExecuting.Select(_ => false))
                .ObserveOn(RxApp.MainThreadScheduler)
                .ToPropertyEx(this, x => x.PinRequired)
                .DisposeWith(d);


                errorStream
                .Select(u => ((ConnectionException)u).ErrorType)
                .Where(u => u == ConnectionError.InvalidCredient)
                .Select(u => true)
                .Delay(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler)
                .Merge(this.CancelConnect.Select(_ => false))
                .Merge(this.ContinueConnectWithPassword.IsExecuting.Select(_ => false))
                .ObserveOn(RxApp.MainThreadScheduler)
                .ToPropertyEx(this, x => x.PasswordRequired)
                .DisposeWith(d);


                var errorFromDriver = errorSource.Where(u =>
                                                        ((u is ConnectionException ce) && ce.ErrorType == ConnectionError.Unclear) ||
                                                        (!(u is ConnectionException)))
                                      .Select(u => u.Message);


                errorFromDriver
                .ObserveOn(RxApp.MainThreadScheduler)
                .ToPropertyEx(this, x => x.AlertMessage)
                .DisposeWith(d);


                errorFromDriver
                .Select(u => true)
                .Merge(
                    errorFromDriver
                    .Delay(TimeSpan.FromMilliseconds(100))
                    .Select(u => false)
                    )
                .ObserveOn(RxApp.MainThreadScheduler)
                .ToPropertyEx(this, x => x.AlertRequired, false)
                .DisposeWith(d);


                errorFromDriver
                .Subscribe(x =>
                {
                    this.Global.ConnectStatus = ConnectStatus.Disconnected;
                })
                .DisposeWith(d);
            });
        }
Esempio n. 13
0
 public UserStorageServiceLog(IUserStorageService userStorageService)
     : base(userStorageService)
 {
 }
Esempio n. 14
0
 public HomeController(IWorkContextAccessor wca, IUserStorageService storageService) {
     _wca = wca;
     _storageService = storageService;
 }
Esempio n. 15
0
 protected UserStorageServiceDecorator(IUserStorageService storageService)
 {
     this.storageService = storageService;
 }
Esempio n. 16
0
 protected UserStorageDecorator(IUserStorageService _service)
 {
     Service = _service;
 }
Esempio n. 17
0
 protected UserStorageServiceDecorator(IUserStorageService userStorageService)
 {
     UserStorageService = userStorageService;
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Client"/> class.
 /// </summary>
 public Client(IUserStorageService userStorageService, IUserRepositoryManager userRepositoryManager)
 {
     this.userStorageService    = userStorageService;
     this.userRepositoryManager = userRepositoryManager;
 }
Esempio n. 19
0
 public UserStorageLog(IUserStorageService _service) : base(_service)
 {
 }
Esempio n. 20
0
        /// <summary>
        /// Instantiate a VWOClient to call Activate, GetVariation and Track apis for given user and goal.
        /// </summary>
        /// <param name="settingFile">Settings as provided by GetSettings call.</param>
        /// <param name="isDevelopmentMode">When running in development or non-production mode. This ensures no operations are tracked on VWO account.</param>
        /// <param name="userStorageService">UserStorageService to Get and Save User-assigned variations.</param>
        /// <param name="goalTypeToTrack">Specify which goalType to track.</param>
        /// <param name="shouldTrackReturningUser">Should track returning user or not.</param>
        /// <returns>
        /// IVWOClient instance to call Activate, GetVariation and Track apis for given user and goal.
        /// </returns>
        public static IVWOClient Launch(Settings settingFile, bool isDevelopmentMode = false, IUserStorageService userStorageService = null, string goalTypeToTrack = Constants.GoalTypes.ALL, bool shouldTrackReturningUser = false)
        {
            if (Validator.SettingsFile(settingFile))
            {
                LogDebugMessage.ValidConfiguration(file);
                AccountSettings accountSettings = SettingsProcessor.ProcessAndBucket(settingFile);
                LogDebugMessage.SettingsFileProcessed(file);
                if (accountSettings == null)
                {
                    return(null);
                }

                if (isDevelopmentMode)
                {
                    LogDebugMessage.SetDevelopmentMode(file);
                }

                var vwoClient = new VWO(accountSettings, Validator, userStorageService, CampaignAllocator, SegmentEvaluator, VariationAllocator, isDevelopmentMode, goalTypeToTrack, shouldTrackReturningUser);
                LogDebugMessage.SdkInitialized(file);
                return(vwoClient);
            }
            LogErrorMessage.ProjectConfigCorrupted(file);
            return(null);
        }
 public UserStorageController(IOrchardServices services, IUserStorageService userStorageService) {
     Services = services;
     _userStorageService = userStorageService;
     T = NullLocalizer.Instance;
 }
Esempio n. 22
0
 public UserStorageAdapter(IUserStorageService userStorageService)
 {
     this._userStorageService = userStorageService;
 }
Esempio n. 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Client"/> class.
 /// </summary>
 public Client(IUserStorageService _userStorageService)
 {
     this._userStorageService = _userStorageService;
 }
Esempio n. 24
0
 /// <summary>
 /// public constructor of Authorization controller
 /// </summary>
 /// <param name="loggerFactory"></param>
 public AuthorizationController(ILoggerFactory loggerFactory, IUserStorageService storage)
 {
     _logger  = loggerFactory.CreateLogger <AuthorizationController>();
     _storage = storage;
 }
Esempio n. 25
0
        public UserViewModel()
        {
            Activator = new ViewModelActivator();

            IUserStorageService service = Locator.Current.GetService <IUserStorageService>();

            #region Commands
            Refresh = ReactiveCommand.CreateFromObservable(() => Observable.Return(Unit.Default));

            Delete = ReactiveCommand.CreateFromTask(async() =>
            {
                var ret = await service.DeleteUser(User.Username);
                await Refresh.Execute();
                return(ret);
            });

            ChangePassword = ReactiveCommand.CreateFromTask <(string password, string pin), bool>(async(input) =>
            {
                var ret = await service.ResetUserPassword(User.Username, input.password, input.pin);
                await Refresh.Execute();
                return(ret);
            });

            ChangePin = ReactiveCommand.CreateFromTask <(string oldPin, string newPin), bool>(async(input) =>
            {
                var ret = await service.ResetUserPin(User.Username, input.oldPin, input.newPin);
                await Refresh.Execute();
                return(ret);
            });

            VerifyPin = ReactiveCommand.CreateFromTask <string, bool>(async(pin) =>
            {
                return(await service.CheckUserPinValid(User.Username, pin));
            });

            TogglePasswordShown = ReactiveCommand.CreateFromTask <string, bool>(async(pin) =>
            {
                if (!IsPasswordShown)
                {
                    try
                    {
                        var password  = await service.DecryptedUserPassword(User.Username, pin);
                        User.Password = password;
                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                }
                else
                {
                    User.Password = "";
                    return(false);
                }
            });


            TogglePasswordShown.ToPropertyEx(this, x => x.IsPasswordShown, false);

            SetCurrent = ReactiveCommand.CreateFromTask(async() =>
            {
                var status = GlobalStatusStore.Current.ConnectStatus;
                if (status != ConnectStatus.Disconnected)
                {
                    throw new Exception("vm_unavailable_change_user");
                }

                GlobalStatusStore.Current.CurrentUser = User;
                await service.SetDefaultUser(User.Username);
            });

            #endregion

            this.WhenActivated(d =>
            {
                this.WhenAnyValue(x => x.User).SelectMany(x => Observable.FromAsync(async() =>
                {
                    return(await service.CheckUserPinExist(x?.Username));
                }))
                .ObserveOn(RxApp.MainThreadScheduler)
                .ToPropertyEx(this, x => x.HasPin)
                .DisposeWith(d);

                this.WhenAnyValue(x => x.User)
                .CombineLatest(
                    GlobalStatusStore.Current.WhenAnyValue(x => x.CurrentUser),
                    (x, y) => (x?.Username == y?.Username)
                    )
                .ObserveOn(RxApp.MainThreadScheduler)
                .ToPropertyEx(this, x => x.IsCurrent)
                .DisposeWith(d);
            });
        }