Ejemplo n.º 1
0
        public TerminalViewModel(ICTimeService cTimeService, IApplicationStateService applicationStateService)
        {
            Guard.NotNull(cTimeService, nameof(cTimeService));
            Guard.NotNull(applicationStateService, nameof(applicationStateService));

            this._cTimeService = cTimeService;
            this._applicationStateService = applicationStateService;

            var canStamp = this.WhenAnyValue(f => f.RfidKey, (string rfidKey) => string.IsNullOrWhiteSpace(rfidKey) == false);
            this.Stamp = UwCoreCommand.Create(canStamp, this.StampImpl)
                .HandleExceptions()
                .ShowLoadingOverlay("Stempeln...");

            this.StampMode = TerminalStampMode.Normal;
            this.WhenAnyValue(f => f.StampMode)
                .Subscribe(stampMode =>
                {
                    if (stampMode == TerminalStampMode.Normal)
                    {
                        //Stop the timer
                        this._resetModeTimer?.Change(TimeSpan.FromMilliseconds(-1), TimeSpan.FromSeconds(10));
                    }
                    else
                    {
                        //Start the timer
                        this._resetModeTimer?.Change(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10));
                    }
                });

            this._timer = new Timer(this.Tick, null, TimeSpan.Zero, TimeSpan.FromMilliseconds(100));
            this._resetModeTimer = new Timer(this.ResetModeTick, null, TimeSpan.FromMilliseconds(-1), TimeSpan.FromSeconds(10));

            this.DisplayName = "Terminal";
        }
Ejemplo n.º 2
0
        public YourTimesViewModel(IApplicationStateService applicationStateService, ICTimeService cTimeService, ISharingService sharingService)
        {
            Guard.NotNull(applicationStateService, nameof(applicationStateService));
            Guard.NotNull(cTimeService, nameof(cTimeService));
            Guard.NotNull(sharingService, nameof(sharingService));

            this._applicationStateService = applicationStateService;
            this._cTimeService = cTimeService;
            this._sharingService = sharingService;

            this.WhenAnyValue(f => f.StartDate, f => f.EndDate)
                .Select(f => CTime2Resources.GetFormatted("MyTimes.TitleFormat", this.StartDate, this.EndDate))
                .Subscribe(name => this.DisplayName = name);

            this.LoadTimes = UwCoreCommand.Create(this.LoadTimesImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.Times"))
                .HandleExceptions()
                .TrackEvent("LoadTimes");
            this.LoadTimes.ToProperty(this, f => f.Times, out this._timesHelper);

            this.Share = UwCoreCommand.Create(this.ShareImpl)
                .HandleExceptions()
                .TrackEvent("ShareMyTimes");

            this.StartDate = DateTimeOffset.Now.StartOfMonth();
            this.EndDate = DateTimeOffset.Now.WithoutTime();
        }
        public AttendingUserDetailsViewModel(ICTimeService cTimeService, IApplicationStateService applicationStateService, IContactsService contactsService, IDialogService dialogService, IPhoneService phoneService, IEmailService emailService)
        {
            Guard.NotNull(cTimeService, nameof(cTimeService));
            Guard.NotNull(applicationStateService, nameof(applicationStateService));
            Guard.NotNull(contactsService, nameof(contactsService));
            Guard.NotNull(dialogService, nameof(dialogService));
            Guard.NotNull(phoneService, nameof(phoneService));
            Guard.NotNull(emailService, nameof(emailService));

            this._cTimeService = cTimeService;
            this._applicationStateService = applicationStateService;
            this._contactsService = contactsService;
            this._dialogService = dialogService;
            this._phoneService = phoneService;
            this._emailService = emailService;

            this.LoadAttendingUser = UwCoreCommand.Create(this.LoadAttendingUserImpl)
                .HandleExceptions()
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.Employee"));
            this.LoadAttendingUser.ToProperty(this, f => f.AttendingUser, out this._attendingUserHelper);
            
            var canCall = Observable
                .Return(this._phoneService.CanCall)
                .CombineLatest(this.WhenAnyValue(f => f.AttendingUser), (serviceCanCall, user) => 
                    serviceCanCall && string.IsNullOrWhiteSpace(user?.PhoneNumber) == false);
            this.Call = UwCoreCommand.Create(canCall, this.CallImpl)
                .HandleExceptions();

            var canSendMail = this.WhenAnyValue(f => f.AttendingUser, selector: user => string.IsNullOrWhiteSpace(user?.EmailAddress) == false);
            this.SendMail = UwCoreCommand.Create(canSendMail, this.SendMailImpl)
                .HandleExceptions();

            this.AddAsContact = UwCoreCommand.Create(this.AddAsContactImpl)
                .HandleExceptions();
        }
Ejemplo n.º 4
0
        public LoginViewModel(ICTimeService cTimeService, IApplicationStateService applicationStateService, IShell shell, IDialogService dialogService, IBiometricsService biometricsService)
        {
            Guard.NotNull(cTimeService, nameof(cTimeService));
            Guard.NotNull(applicationStateService, nameof(applicationStateService));
            Guard.NotNull(shell, nameof(shell));
            Guard.NotNull(dialogService, nameof(dialogService));
            Guard.NotNull(biometricsService, nameof(biometricsService));

            this._cTimeService = cTimeService;
            this._applicationStateService = applicationStateService;
            this._shell = shell;
            this._dialogService = dialogService;
            this._biometricsService = biometricsService;
            
            var canLogin = this.WhenAnyValue(f => f.EmailAddress, f => f.Password, (email, password) =>
                string.IsNullOrWhiteSpace(email) == false && string.IsNullOrWhiteSpace(password) == false);
            this.Login = UwCoreCommand.Create(canLogin, this.LoginImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.LoggingIn"))
                .HandleExceptions()
                .TrackEvent("Login");
            
            var deviceAvailable = this._biometricsService.BiometricAuthDeviceIsAvailableAsync().ToObservable();
            var userAvailable = this._biometricsService.HasUserForBiometricAuthAsync().ToObservable();
            var canRememberedLogin = deviceAvailable
                .CombineLatest(userAvailable, (deviceAvail, userAvail) => deviceAvail && userAvail)
                .ObserveOnDispatcher();
            this.RememberedLogin = UwCoreCommand.Create(canRememberedLogin, this.RememberedLoginImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.LoggingIn"))
                .HandleExceptions()
                .TrackEvent("LoginRemembered");

            this.DisplayName = CTime2Resources.Get("Navigation.Login");
        }
Ejemplo n.º 5
0
        public BandService(IApplicationStateService applicationStateService, ICTimeService cTimeService)
        {
            this._applicationStateService = applicationStateService;
            this._cTimeService = cTimeService;

            BackgroundTileEventHandler.Instance.TileOpened += this.OnTileOpened;
            BackgroundTileEventHandler.Instance.TileButtonPressed += this.OnTileButtonPressed;
            BackgroundTileEventHandler.Instance.TileClosed += this.OnTileClosed;
        }
Ejemplo n.º 6
0
        public AttendanceListViewModel(ICTimeService cTimeService, IApplicationStateService applicationStateService, INavigationService navigationService, IEmployeeGroupService employeeGroupService, IDialogService dialogService)
        {
            Guard.NotNull(cTimeService, nameof(cTimeService));
            Guard.NotNull(applicationStateService, nameof(applicationStateService));
            Guard.NotNull(navigationService, nameof(navigationService));
            Guard.NotNull(employeeGroupService, nameof(employeeGroupService));
            Guard.NotNull(dialogService, nameof(dialogService));

            this._cTimeService = cTimeService;
            this._applicationStateService = applicationStateService;
            this._navigationService = navigationService;
            this._employeeGroupService = employeeGroupService;
            this._dialogService = dialogService;

            this.DisplayName = CTime2Resources.Get("Navigation.AttendanceList");
            this.SelectedUsers = new ReactiveList<AttendingUser>();
            this.State = AttendanceListState.Loading;

            this.LoadUsers = UwCoreCommand.Create(this.LoadUsersImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.AttendanceList"))
                .HandleExceptions()
                .TrackEvent("LoadAttendanceList");
            this.LoadUsers.ToProperty(this, f => f.Users, out this._usersHelper);

            var canShowDetails = this.WhenAnyValue(f => f.SelectedUsers).Select(f => f.Any());
            this.ShowDetails = UwCoreCommand.Create(canShowDetails, this.ShowDetailsImpl)
                .HandleExceptions()
                .TrackEvent("ShowAttendingUserDetails");

            var canCreateGroup = this.WhenAnyValue(f => f.State, mode => mode == AttendanceListState.View);
            this.CreateGroup = UwCoreCommand.Create(canCreateGroup, this.CreateGroupImpl)
                .HandleExceptions()
                .TrackEvent("CreateNewEmployeeGroup");

            var canSaveGroup = this
                .WhenAnyValue(f => f.State, f => f.GroupName,  (mode, groupName) => mode == AttendanceListState.CreateGroup && string.IsNullOrWhiteSpace(groupName) == false)
                .CombineLatest(this.SelectedUsers.Changed, (stateAndName, selectedUsers) => stateAndName && this.SelectedUsers.Any());
            this.SaveGroup = UwCoreCommand.Create(canSaveGroup, this.SaveGroupImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.SaveEmployeeGroup"))
                .HandleExceptions()
                .TrackEvent("SaveNewEmployeeGroup");

            var canCancelCreateGroup = this.WhenAnyValue(f => f.State, mode => mode == AttendanceListState.CreateGroup);
            this.CancelCreateGroup = UwCoreCommand.Create(canCancelCreateGroup, this.CancelCreateGroupImpl)
                .HandleExceptions()
                .TrackEvent("CancelCreateNewEmployeeGroup");

            var canDeleteGroup = this.WhenAnyValue(f => f.State, mode => mode == AttendanceListState.ViewGroup);
            this.DeleteGroup = UwCoreCommand.Create(canDeleteGroup, this.DeleteGroupImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.DeleteEmployeeGroup"))
                .HandleExceptions()
                .TrackEvent("DeleteEmployeeGroup");
        }
Ejemplo n.º 7
0
        public CheckedInViewModel(ICTimeService cTimeService, IApplicationStateService applicationStateService)
            : base(cTimeService, applicationStateService)
        {
            this.CheckOut = UwCoreCommand.Create(this.CheckOutImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.CheckedOut"))
                .HandleExceptions()
                .TrackEvent("CheckOut");

            this.Pause = UwCoreCommand.Create(this.PauseImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.Pause"))
                .HandleExceptions()
                .TrackEvent("Pause");
        }
Ejemplo n.º 8
0
        public CheckedOutViewModel(ICTimeService cTimeService, IApplicationStateService applicationStateService)
            : base(cTimeService, applicationStateService)
        {
            this.CheckIn = UwCoreCommand.Create(this.CheckInImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.CheckIn"))
                .HandleExceptions()
                .TrackEvent("CheckIn");

            this.CheckInHomeOffice = UwCoreCommand.Create(this.CheckInHomeOfficeImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.CheckIn"))
                .HandleExceptions()
                .TrackEvent("CheckInHomeOffice");

            this.CheckInTrip = UwCoreCommand.Create(this.CheckInTripImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.CheckIn"))
                .HandleExceptions()
                .TrackEvent("CheckInTrip");
        }
Ejemplo n.º 9
0
        public DetailedStatisticViewModel(ICTimeService cTimeService, IApplicationStateService applicationStateService, INavigationService navigationService, ISharingService sharingService)
        {
            Guard.NotNull(cTimeService, nameof(cTimeService));
            Guard.NotNull(applicationStateService, nameof(applicationStateService));
            Guard.NotNull(navigationService, nameof(navigationService));
            Guard.NotNull(sharingService, nameof(sharingService));

            this._cTimeService = cTimeService;
            this._applicationStateService = applicationStateService;
            this._navigationService = navigationService;
            this._sharingService = sharingService;

            this.LoadChart = UwCoreCommand.Create(this.LoadChartImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.LoadCharts"))
                .HandleExceptions();
            this.LoadChart.ToProperty(this, f => f.ChartItems, out this._chartItemsHelper);

            this.GoToMyTimesCommand = UwCoreCommand.Create(this.GoToMyTimes)
                .HandleExceptions();

            this.Share = UwCoreCommand.Create(this.ShareImpl)
                .HandleExceptions()
                .TrackEvent("ShareDetailedStatistic");
        }
Ejemplo n.º 10
0
 public CTimeStampHelper(IApplicationStateService applicationStateService, ICTimeService cTimeService)
 {
     this._applicationStateService = applicationStateService;
     this._cTimeService = cTimeService;
 }