Exemplo n.º 1
0
 public UserCommandHandler(ILockService lockService, UserService userService, RoleService roleService, AppSystemService appSystemService)
 {
     _lockService      = lockService;
     _userService      = userService;
     _roleService      = roleService;
     _appSystemService = appSystemService;
 }
Exemplo n.º 2
0
 public AcquiredLockServices(AcquiredDbParameters acquiredDbParameters, ILockService lockService, ITimeService timeService, ILeaseLockObject lockObject)
 {
     this.AcquiredDbParameters = acquiredDbParameters;
     this.LockService          = lockService;
     this.TimeService          = timeService;
     this.LockObject           = lockObject;
 }
Exemplo n.º 3
0
 public JobService(IJobRepository jobRepository, IJobRegistory jobRegistory, ILockService lockService, IUserResolver userResolver)
 {
     _jobRepository = jobRepository ?? throw new ArgumentNullException(nameof(jobRepository));
     _jobRegistory  = jobRegistory ?? throw new ArgumentNullException(nameof(jobRegistory));
     _lockService   = lockService ?? throw new ArgumentNullException(nameof(lockService));
     _userResolver  = userResolver ?? throw new ArgumentNullException(nameof(userResolver));
 }
Exemplo n.º 4
0
        //private object

        public LeaseLockObject(ILockService lockService, TimeSpan leaseCheckTimeout, TimeSpan leaseLostTimeout)
        {
            this.lockService       = lockService;
            this.leaseCheckTimeout = leaseCheckTimeout;
            this.leaseLostTimeout  = leaseLostTimeout;
            this.timer             = new Timer(this.UpdateLeaseTimeCallback, null, leaseCheckTimeout, leaseCheckTimeout);
        }
Exemplo n.º 5
0
            public static void IsAcquired(ILockService lockService, DataObject dataObject, string userName)
            {
                var lockData = lockService.GetLock(dataObject.__PrimaryKey);

                Assert.True(lockData.Acquired);
                Assert.Equal(userName, lockData.UseName);
            }
Exemplo n.º 6
0
        public JobService(IJobRepository jobRepository, IJobRegistory jobRegistory, ILockService lockService, IUserResolver userResolver)
        {
            if (jobRepository == null)
            {
                throw new ArgumentNullException(nameof(jobRepository));
            }

            if (jobRegistory == null)
            {
                throw new ArgumentNullException(nameof(jobRegistory));
            }

            if (lockService == null)
            {
                throw new ArgumentNullException(nameof(lockService));
            }

            if (userResolver == null)
            {
                throw new ArgumentNullException(nameof(userResolver));
            }

            _jobRepository = jobRepository;
            _jobRegistory  = jobRegistory;
            _lockService   = lockService;
            _userResolver  = userResolver;
        }
Exemplo n.º 7
0
            public static void IsNotAcquired(ILockService lockService, DataObject dataObject)
            {
                var lockData = lockService.GetLock(dataObject.__PrimaryKey);

                Assert.False(lockData.Acquired);
                Assert.Null(lockData.UseName);
            }
Exemplo n.º 8
0
        public bool AquireLock()
        {
            bool result = true;

            _lockService = IoC.Container.Resolve <ILockService>(); //new LockService(_connectionString);
            foreach (string lockID in _lockKeys)
            {
                bool firstPass = _lockService.AquireLock(lockID);

                if (!firstPass)
                {
                    System.Threading.Thread.Sleep(500 * (ThreadNumber + 1));
                    result = result && _lockService.AquireLock(lockID);
                    if (!result)
                    {
                        _lockService.ReleaseAllLocks();
                        break;
                    }
                }
                else
                {
                    result = result && firstPass;
                }
            }
            return(result);
        }
Exemplo n.º 9
0
        public GroupingsPage(bool mainPage, CipherType?type = null, string folderId  = null,
                             string collectionId            = null, string pageTitle = null)
        {
            _pageName = string.Concat(nameof(GroupingsPage), "_", DateTime.UtcNow.Ticks);
            InitializeComponent();
            SetActivityIndicator(_mainContent);
            _broadcasterService      = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService");
            _syncService             = ServiceContainer.Resolve <ISyncService>("syncService");
            _pushNotificationService = ServiceContainer.Resolve <IPushNotificationService>("pushNotificationService");
            _storageService          = ServiceContainer.Resolve <IStorageService>("storageService");
            _lockService             = ServiceContainer.Resolve <ILockService>("lockService");
            _vm              = BindingContext as GroupingsPageViewModel;
            _vm.Page         = this;
            _vm.MainPage     = mainPage;
            _vm.Type         = type;
            _vm.FolderId     = folderId;
            _vm.CollectionId = collectionId;
            if (pageTitle != null)
            {
                _vm.PageTitle = pageTitle;
            }

            if (Device.RuntimePlatform == Device.iOS)
            {
                _absLayout.Children.Remove(_fab);
            }
            else
            {
                _fab.Clicked = AddButton_Clicked;
                ToolbarItems.Add(_syncItem);
                ToolbarItems.Add(_lockItem);
                ToolbarItems.Add(_exitItem);
            }
        }
        public static async Task Run([ServiceBusTrigger("lowbatteryrequest",
                                                        Connection = "ServiceBusConnectionString")] string myQueueItem,
                                     ILogger log, ExecutionContext context)
        {
            try
            {
                ServiceCollection serviceCollection = new ServiceCollection();
                serviceCollection.AddDependencies();
                ServiceProvider      Container           = serviceCollection.BuildServiceProvider();
                IServiceScopeFactory serviceScopeFactory = Container.GetRequiredService <IServiceScopeFactory>();
                using (IServiceScope scope = serviceScopeFactory.CreateScope())
                {
                    Essentials.Business.Contracts.LowBatteryRequest lowBatteryRequest = JsonConvert.DeserializeObject <Essentials.Business.Contracts.LowBatteryRequest>(myQueueItem);
                    if (lowBatteryRequest != null)
                    {
                        ILockService lockService = scope.ServiceProvider.GetService <ILockService>();

                        await lockService.LowBatteryAsync(lowBatteryRequest.LockId,
                                                          new Essentials.Business.Contracts.LowBatteryRequest
                        {
                            LockId        = lowBatteryRequest.LockId,
                            BatteryStatus = lowBatteryRequest.BatteryStatus
                        });
                    }
                }
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Exemplo n.º 11
0
        public App(
            string uri,
            IAuthService authService,
            IConnectivity connectivity,
            IUserDialogs userDialogs,
            IDatabaseService databaseService,
            ISyncService syncService,
            IFingerprint fingerprint,
            ISettings settings,
            ILockService lockService,
            IGoogleAnalyticsService googleAnalyticsService,
            ILocalizeService localizeService,
            IAppInfoService appInfoService)
        {
            _uri                    = uri;
            _databaseService        = databaseService;
            _connectivity           = connectivity;
            _userDialogs            = userDialogs;
            _syncService            = syncService;
            _authService            = authService;
            _fingerprint            = fingerprint;
            _settings               = settings;
            _lockService            = lockService;
            _googleAnalyticsService = googleAnalyticsService;
            _localizeService        = localizeService;
            _appInfoService         = appInfoService;

            SetCulture();
            SetStyles();

            if (authService.IsAuthenticated && _uri != null)
            {
                MainPage = new ExtendedNavigationPage(new VaultAutofillListLoginsPage(_uri));
            }
            else if (authService.IsAuthenticated)
            {
                MainPage = new MainPage();
            }
            else
            {
                MainPage = new ExtendedNavigationPage(new HomePage());
            }

            MessagingCenter.Subscribe <Application, bool>(Current, "Resumed", async(sender, args) =>
            {
                Device.BeginInvokeOnMainThread(async() => await CheckLockAsync(args));
                await Task.Run(() => FullSyncAsync()).ConfigureAwait(false);
            });

            MessagingCenter.Subscribe <Application, bool>(Current, "Lock", (sender, args) =>
            {
                Device.BeginInvokeOnMainThread(async() => await CheckLockAsync(args));
            });

            MessagingCenter.Subscribe <Application, string>(Current, "Logout", (sender, args) =>
            {
                Logout(args);
            });
        }
Exemplo n.º 12
0
 public ModuleCommandHandler(ILockService lockService, ModuleService moduleService,
                             PermissionService permissionService, AppSystemService appSystemService)
 {
     _lockService       = lockService;
     _moduleService     = moduleService;
     _permissionService = permissionService;
     _appSystemService  = appSystemService;
 }
Exemplo n.º 13
0
 public LeaseLockObject(ILockService lockService, TimeSpan leaseCheckTimeout, TimeSpan leaseLostTimeout)
 {
     this.lockService       = lockService;
     this.leaseCheckTimeout = leaseCheckTimeout;
     this.leaseLostTimeout  = leaseLostTimeout;
     this.disposeCts        = new CancellationTokenSource();
     this.timer             = new Timer(this.UpdateLeaseTimeCallback, null, leaseCheckTimeout, leaseCheckTimeout);
 }
Exemplo n.º 14
0
        public DefaultOfflineManager(ILockService lockService, CurrentUserService.IUser currentUser)
        {
            Contract.Requires <ArgumentNullException>(lockService != null);
            Contract.Requires <ArgumentNullException>(currentUser != null);

            _lockService = lockService;
            _currentUser = currentUser;
        }
 public LocksController(ILogger <LocksController> logger, ILockService lockService
                        , ILockRepository lockRepository, IDeviceBusService deviceBusService)
 {
     _lockService      = lockService;
     _lockRepository   = lockRepository;
     _deviceBusService = deviceBusService;
     _logger           = logger;
 }
Exemplo n.º 16
0
 public Handler(
     IAuthorizationService authorizationService,
     IIdentityResolver identityResolver,
     ILockService lockService)
 {
     _authorizationService = authorizationService;
     _user        = identityResolver.GetClaimsPrincipal();
     _lockService = lockService;
 }
Exemplo n.º 17
0
        public App(
            AppOptions options,
            IAuthService authService,
            IConnectivity connectivity,
            IDatabaseService databaseService,
            ISyncService syncService,
            ISettings settings,
            ILockService lockService,
            ILocalizeService localizeService,
            IAppInfoService appInfoService,
            IAppSettingsService appSettingsService,
            IDeviceActionService deviceActionService)
        {
            _options             = options ?? new AppOptions();
            _authService         = authService;
            _databaseService     = databaseService;
            _connectivity        = connectivity;
            _syncService         = syncService;
            _settings            = settings;
            _lockService         = lockService;
            _localizeService     = localizeService;
            _appInfoService      = appInfoService;
            _appSettingsService  = appSettingsService;
            _deviceActionService = deviceActionService;

            SetCulture();
            SetStyles();

            if (authService.IsAuthenticated)
            {
                if (_options.FromAutofillFramework && _options.SaveType.HasValue)
                {
                    MainPage = new ExtendedNavigationPage(new VaultAddCipherPage(_options));
                }
                else if (_options.Uri != null)
                {
                    MainPage = new ExtendedNavigationPage(new VaultAutofillListCiphersPage(_options));
                }
                else
                {
                    MainPage = new MainPage();
                }
            }
            else
            {
                MainPage = new ExtendedNavigationPage(new HomePage());
            }

            if (Device.RuntimePlatform == Device.iOS)
            {
                MessagingCenter.Subscribe <Application, bool>(Current, "Resumed", async(sender, args) =>
                {
                    Device.BeginInvokeOnMainThread(async() => await _lockService.CheckLockAsync(args));
                    await Task.Run(() => FullSyncAsync()).ConfigureAwait(false);
                });
            }
        }
Exemplo n.º 18
0
 public HomeController(ILogger <HomeController> logger, IBuildingService buildingService,
                       ILockService lockService, IGroupService groupService, IMediaService mediaService)
 {
     _logger          = logger;
     _buildingService = buildingService;
     _lockService     = lockService;
     _groupService    = groupService;
     _mediaService    = mediaService;
 }
Exemplo n.º 19
0
 public ImportService(
     ILockService lockService,
     CasterContext db,
     IIdentityResolver identityResolver)
 {
     _lockService = lockService;
     _db          = db;
     _isAdmin     = identityResolver.IsAdminAsync().Result;
     _userId      = identityResolver.GetClaimsPrincipal().GetId();
 }
Exemplo n.º 20
0
 public Handler(
     CasterContext db,
     IMapper mapper,
     IAuthorizationService authorizationService,
     IIdentityResolver identityResolver,
     ILockService lockService,
     IGetFileQuery fileQuery)
     : base(db, mapper, authorizationService, identityResolver, lockService, fileQuery)
 {
 }
Exemplo n.º 21
0
        private static async Task Main(string[] args)
        {
            var assemblies = new[] { Assembly.GetExecutingAssembly() };

            var enode = ECommonConfiguration.Create()
                        .UseAutofac()
                        .RegisterCommonComponents()
                        .UseLog4Net()
                        .UseJsonNet()
                        .CreateENode(new ConfigurationSetting())
                        .RegisterBusinessComponents(assemblies)
                        .RegisterENodeComponents()
                        .UseRedisLockService();

            enode.GetCommonConfiguration()
            .BuildContainer();

            enode.InitializeBusinessAssemblies(assemblies)
            .InitializeRedisLockService(_redisOptions);

            _lockService = ObjectContainer.Resolve <ILockService>();

            var listDics = new List <(int index, Dictionary <int, int> dic)>();

            for (int i = 0; i < 10; i++)
            {
                listDics.Add((i, new Dictionary <int, int>()));
            }
            var tasks     = new List <Task>();
            var stopWatch = new Stopwatch();

            var lockKey = Guid.NewGuid().ToString();

            stopWatch.Start();
            for (int i = 0; i < 1000; i++)
            {
                foreach (var item in listDics)
                {
                    tasks.Add(_lockService.ExecuteInLockAsync($"{lockKey}-{item.index}", async() =>
                    {
                        await Task.Delay(10);
                        item.dic.Add(item.dic.Count, Thread.CurrentThread.GetHashCode());
                        Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss,fff")} {Thread.CurrentThread.GetHashCode()} {item.dic.Count} complete");
                    }));
                }
            }
            await Task.WhenAll(tasks);

            stopWatch.Stop();

            Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss,fff")} all complete use time[{stopWatch.ElapsedMilliseconds}]");
            await Task.Delay(60000);

            Console.ReadKey();
        }
        public EditBikeViewModel(
            IDialogService dialogService,
            ILockService lockService,
            IBikeService bikeService,
            IMembershipService membershipService,
            ICommunityService communityService,
            ILocationPicker locationPicker,
            IQRCodeScanner qrCodeScanner,
            INavigationService navigationService,
            string communityId,
            string bikeId)
        {
            _dialogService     = dialogService;
            _lockService       = lockService;
            _bikeService       = bikeService;
            _membershipService = membershipService;
            _communityService  = communityService;
            _locationPicker    = locationPicker;
            _qrCodeScanner     = qrCodeScanner;
            _navigationService = navigationService;

            _communityId = communityId;
            _bikeId      = bikeId;

            SetLocationCommand       = CreateCommand <Bike>(SetLocation, CanSetLocation);
            RenameBikeCommand        = CreateCommand <Bike>(RenameBike, CanRenameBike);
            DeleteBikeCommand        = CreateCommand <Bike>(DeleteBike, CanDeleteBike);
            ShowCurrentLenderCommand = CreateCommand <Bike>(ShowCurrentLender, CanShowCurrentLender);
            AddLockCommand           = CreateCommand <Bike>(AddLock, CanAddLock);
            AddLockWithQRCodeCommand = CreateCommand <Bike>(AddLockWithQRCode, CanAddLock);
            OpenLockCommand          = CreateCommand <Bike>(OpenLock, CanOpenLock);
            CloseLockCommand         = CreateCommand <Bike>(CloseLock, CanCloseLock);
            RemoveLockCommand        = CreateCommand <Bike>(RemoveLock, CanRemoveLock);

            PropertyChanged += (_, args) =>
            {
                switch (args.PropertyName)
                {
                case nameof(Bike):
                {
                    OnPropertyChanged(nameof(Name));
                    OnPropertyChanged(nameof(LendState));
                    OnPropertyChanged(nameof(LockState));
                    break;
                }

                case nameof(CurrentUserMembership):
                {
                    // Needed to update permissions for the commands
                    OnPropertyChanged(nameof(Bike));
                    break;
                }
                }
            };
        }
Exemplo n.º 23
0
        public ExtendedContentPage(bool syncIndicator = false, bool updateActivity = true)
        {
            _syncIndicator          = syncIndicator;
            _updateActivity         = updateActivity;
            _syncService            = Resolver.Resolve <ISyncService>();
            _googleAnalyticsService = Resolver.Resolve <IGoogleAnalyticsService>();
            _lockService            = Resolver.Resolve <ILockService>();
            _deviceActionService    = Resolver.Resolve <IDeviceActionService>();

            BackgroundColor = Color.FromHex("efeff4");
        }
Exemplo n.º 24
0
 public Handler(
     CasterContext db,
     IMapper mapper,
     IAuthorizationService authorizationService,
     IIdentityResolver identityResolver,
     TerraformOptions terraformOptions,
     ITerraformService terraformService,
     ILockService lockService,
     ILogger <BaseOperationHandler> logger) :
     base(db, mapper, authorizationService, identityResolver, terraformOptions, terraformService, lockService, logger)
 {
 }
Exemplo n.º 25
0
        public override void ViewDidLoad()
        {
            _lockService          = ServiceContainer.Resolve <ILockService>("lockService");
            _cryptoService        = ServiceContainer.Resolve <ICryptoService>("cryptoService");
            _deviceActionService  = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _userService          = ServiceContainer.Resolve <IUserService>("userService");
            _storageService       = ServiceContainer.Resolve <IStorageService>("storageService");
            _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService");
            _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService");

            _pinSet          = _lockService.IsPinLockSetAsync().GetAwaiter().GetResult();
            _hasKey          = _cryptoService.HasKeyAsync().GetAwaiter().GetResult();
            _pinLock         = (_pinSet.Item1 && _hasKey) || _pinSet.Item2;
            _fingerprintLock = _lockService.IsFingerprintLockSetAsync().GetAwaiter().GetResult();

            BaseNavItem.Title      = _pinLock ? AppResources.VerifyPIN : AppResources.VerifyMasterPassword;
            BaseCancelButton.Title = AppResources.Cancel;
            BaseSubmitButton.Title = AppResources.Submit;

            var descriptor = UIFontDescriptor.PreferredBody;

            MasterPasswordCell.Label.Text = _pinLock ? AppResources.PIN : AppResources.MasterPassword;
            MasterPasswordCell.TextField.SecureTextEntry = true;
            MasterPasswordCell.TextField.ReturnKeyType   = UIReturnKeyType.Go;
            MasterPasswordCell.TextField.ShouldReturn   += (UITextField tf) =>
            {
                CheckPasswordAsync().GetAwaiter().GetResult();
                return(true);
            };
            if (_pinLock)
            {
                MasterPasswordCell.TextField.KeyboardType = UIKeyboardType.NumberPad;
            }

            TableView.RowHeight          = UITableView.AutomaticDimension;
            TableView.EstimatedRowHeight = 70;
            TableView.Source             = new TableSource(this);
            TableView.AllowsSelection    = true;

            base.ViewDidLoad();

            if (_fingerprintLock)
            {
                var fingerprintButtonText = _deviceActionService.SupportsFaceId() ? AppResources.UseFaceIDToUnlock :
                                            AppResources.UseFingerprintToUnlock;
                // TODO: set button text
                var tasks = Task.Run(async() =>
                {
                    await Task.Delay(500);
                    NSRunLoop.Main.BeginInvokeOnMainThread(async() => await PromptFingerprintAsync());
                });
            }
        }
Exemplo n.º 26
0
        // TODO: Model binding context?

        public SettingsPage()
        {
            _authService            = Resolver.Resolve <IAuthService>();
            _settings               = Resolver.Resolve <ISettings>();
            _fingerprint            = Resolver.Resolve <IFingerprint>();
            _pushNotification       = Resolver.Resolve <IPushNotificationService>();
            _googleAnalyticsService = Resolver.Resolve <IGoogleAnalyticsService>();
            _deviceActionService    = Resolver.Resolve <IDeviceActionService>();
            _deviceInfoService      = Resolver.Resolve <IDeviceInfoService>();
            _lockService            = Resolver.Resolve <ILockService>();

            Init();
        }
Exemplo n.º 27
0
 public Handler(
     CasterContext db,
     IMapper mapper,
     IAuthorizationService authorizationService,
     IIdentityResolver identityResolver,
     ILockService lockService)
 {
     _db     = db;
     _mapper = mapper;
     _authorizationService = authorizationService;
     _user        = identityResolver.GetClaimsPrincipal();
     _lockService = lockService;
 }
Exemplo n.º 28
0
        public static async Task GlobalRunOnceOrWaitFor(this ILockService lockService, string key, Action action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }
            var executed = await lockService.GlobalRunOnce(key, action);

            if (executed == false)
            {
                await lockService.WaitFor(key);
            }
        }
Exemplo n.º 29
0
        public LockPageViewModel()
        {
            _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService");
            _deviceActionService  = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _lockService          = ServiceContainer.Resolve <ILockService>("lockService");
            _cryptoService        = ServiceContainer.Resolve <ICryptoService>("cryptoService");
            _storageService       = ServiceContainer.Resolve <IStorageService>("storageService");
            _userService          = ServiceContainer.Resolve <IUserService>("userService");
            _messagingService     = ServiceContainer.Resolve <IMessagingService>("messagingService");

            PageTitle             = AppResources.VerifyMasterPassword;
            TogglePasswordCommand = new Command(TogglePassword);
        }
Exemplo n.º 30
0
        public static async Task WaitFor(this ILockService lockService, string key, int millisecondsDelayInLoop = 100)
        {
            while (true)
            {
                await Task.Delay(millisecondsDelayInLoop);

                var(exists, _) = await lockService.Query <string>(key);

                if (!exists)
                {
                    break;
                }
            }
        }
Exemplo n.º 31
0
        public PresentationWorker(IServerConfiguration configuration, ILockService lockService)
        {
            _configuration = configuration;
            _lockService = lockService;// new LockingService();
            _presentationDAL = new PresentationDALCaching(_configuration);
            _sourceDAL = new SourceDALCaching(_configuration, false);           //new SourceDAL(_configuration);
            ((SourceDAL)_sourceDAL).CreateHardwareSources();

            _deviceSourceDAL = new DeviceSourceDALCaching(_configuration, false);
            ((DeviceSourceDAL)_deviceSourceDAL).CreateHardwareSources();

            _presentationDAL.Init(_sourceDAL, _deviceSourceDAL);

            _serverSideSourceTransfer = new ServerSideSourceTransfer(_sourceDAL);
            _serverSidePresentationTransfer = new PresentationExportHelper((IServerConfiguration)_configuration, _presentationDAL);
            _presentationNotifier =
                NotificationManager<PresentationKey>.Instance.RegisterDuplexService
                <UserIdentity, IPresentationNotifier>
                (NotifierBehaviour.OneInstancePerKey);
            _globalNotifier = NotificationManager<IPresentationWorker>.Instance.RegisterDuplexService
                <UserIdentity, IPresentationNotifier>
                (NotifierBehaviour.OneInstance);

            Init();
            //_lockService.AddItem += new StorageAction<ObjectKey, LockingInfo>(_lockService_AddItem);
            //_lockService.RemoveItem += new StorageAction<ObjectKey, LockingInfo>(_lockService_RemoveItem);

            //_sourceDAL.OnResourceAdded += new EventHandler<SourceEventArg>(_sourceDAL_OnResourceAdded);
            //_sourceDAL.OnResourceDeleted += new EventHandler<SourceEventArg>(_sourceDAL_OnResourceDeleted);

            //_presentationDAL.OnPresentationAdded += new EventHandler<PresentationEventArg>(_presentationDAL_OnPresentationAdded);
            //_presentationDAL.OnPresentationDeleted += new EventHandler<PresentationEventArg>(_presentationDAL_OnPresentationDeleted);
            //_lockService.PresentationDAL = _presentationDAL;
            //_presentationDAL.LockService = _lockService;
        }