Example #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";
        }
Example #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();
        }
Example #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");
        }
Example #5
0
        public AboutViewModel()
        {
            this.DisplayName = CTime2Resources.Get("Navigation.About");

            this.CurrentVersion = Package.Current.Id.Version.ToVersion();

            this.SendFeedback = UwCoreCommand.Create(this.SendFeedbackImpl)
                .HandleExceptions()
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.SendFeedback"))
                .TrackEvent("SendFeedback");
        }
Example #6
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");
        }
Example #7
0
        public TestViewModel(ILoadingService loadingService, INavigationService navigationService, IShell shell)
        {
            this._loadingService    = loadingService;
            this._navigationService = navigationService;
            this._shell             = shell;

            this.DisplayName = "Statistics from 9/1/2016 to 9/30/2016";

            this.Test = UwCoreCommand.Create(this.TestImpl)
                        .ShowLoadingOverlay("Test-Message")
                        .HandleExceptions()
                        .TrackEvent("TestCommand");

            this.Test.ToProperty(this, f => f.SomeUnit, out this._someUnitHelper);
        }
Example #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");
        }
Example #9
0
        public SettingsViewModel(IBiometricsService biometricsService, IApplicationStateService applicationStateService, IBandService bandService, IShell shell)
        {
            Guard.NotNull(biometricsService, nameof(biometricsService));
            Guard.NotNull(applicationStateService, nameof(applicationStateService));
            Guard.NotNull(bandService, nameof(bandService));

            this._biometricsService = biometricsService;
            this._applicationStateService = applicationStateService;
            this._bandService = bandService;
            this._shell = shell;

            var hasUser = new ReplaySubject<bool>(1);
            hasUser.OnNext(this._applicationStateService.GetCurrentUser() != null);
            var deviceAvailable = this._biometricsService.BiometricAuthDeviceIsAvailableAsync().ToObservable();
            var canRememberLogin = hasUser.CombineLatest(deviceAvailable, (hasUsr, deviceAvail) => hasUsr && deviceAvail);
            this.RememberLogin = UwCoreCommand.Create(canRememberLogin, this.RememberLoginImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.RememberedLogin"))
                .HandleExceptions()
                .TrackEvent("SetupRememberLogin");

            var canToggleTile = this.WhenAnyValue(f => f.State, state => state != BandState.NotConnected);
            this.ToggleBandTile = UwCoreCommand.Create(canToggleTile, this.ToggleTileImpl)
                .ShowLoadingOverlay(() => this.State == BandState.Installed
                    ? CTime2Resources.Get("Loading.RemoveTileFromBand")
                    : CTime2Resources.Get("Loading.AddTileToBand"))
                .HandleExceptions()
                .TrackEvent("ToggleBandTile");

            this.Reload = UwCoreCommand.Create(this.ReloadImpl)
                .ShowLoadingOverlay(CTime2Resources.Get("Loading.Settings"))
                .HandleExceptions()
                .TrackEvent("ReloadSettings");

            this.Theme = this._applicationStateService.GetApplicationTheme();
            this.SelectedWorkTime = this._applicationStateService.GetWorkDayHours();
            this.SelectedBreakTime = this._applicationStateService.GetWorkDayBreak();
            this.CompanyId = this._applicationStateService.GetCompanyId();

            this.WhenAnyValue(f => f.Theme)
                .Subscribe(theme =>
                {
                    this._shell.Theme = theme;
                    this._applicationStateService.SetApplicationTheme(theme);
                });

            this.WhenAnyValue(f => f.SelectedWorkTime)
                .Subscribe(workTime =>
                {
                    this._applicationStateService.SetWorkDayHours(workTime);
                });

            this.WhenAnyValue(f => f.SelectedBreakTime)
                .Subscribe(breakTime =>
                {
                    this._applicationStateService.SetWorkDayBreak(breakTime);
                });

            this.WhenAnyValue(f => f.CompanyId)
                .Subscribe(companyId =>
                {
                    this._applicationStateService.SetCompanyId(companyId);
                });

            this.DisplayName = CTime2Resources.Get("Navigation.Settings");

            this.WorkTimes = new ReactiveList<TimeSpan>(Enumerable
                .Repeat((object)null, 4 * 24)
                .Select((_, i) => TimeSpan.FromHours(0.25 * i)));

            this.BreakTimes = new ReactiveList<TimeSpan>(Enumerable
                .Repeat((object)null, 4 * 24)
                .Select((_, i) => TimeSpan.FromHours(0.25 * i)));
        }
Example #10
0
 public MahPopupViewModel()
 {
     this.Loading = UwCoreCommand
                    .Create(async _ => await Task.Delay(TimeSpan.FromSeconds(2)))
                    .ShowLoadingOverlay("asdflöjkasdfölkj asdf");
 }