Exemple #1
0
        public GroupedReestrViewModel(IReestrDataService reestrDataService)
        {
            FilterModel        = new FilterModel();
            _reestrDataService = reestrDataService;
            FilterCommad       = ReactiveCommand.CreateFromTask(ExecuteFilterCommand);


            var canFilter =
                this.WhenAnyValue(x => x.FilterModel.SearchQuery,
                                  x => !string.IsNullOrWhiteSpace(x));


            var reestrCount = this.WhenAnyValue(x => x.ReestrsCollection.Count);

            _reestrCount = reestrCount
                           .Select(x => ReestrsCollection.Sum(z => z.BarrelsCount))
                           .ToProperty(this, x => x.ReestrCount);

            _netTotal = reestrCount
                        .Select(x => ReestrsCollection.Sum(z => z.TotalNet))
                        .ToProperty(this, x => x.NetTotal);


            ExportExcelCommand = ReactiveCommand.Create(ExecuteExportExcelCommand);
        }
Exemple #2
0
        public ReestrViewModel(IReestrDataService reestrDataService, IDialogNavigationService dialogNavigationService)
        {
            FilterModel              = new FilterModel();
            _reestrDataService       = reestrDataService;
            _dialogNavigationService = dialogNavigationService;
            FilterCommad             = ReactiveCommand.CreateFromTask(ExecuteFilterCommand);


            var canFilter =
                this.WhenAnyValue(x => x.FilterModel.SearchQuery,
                                  x => !string.IsNullOrWhiteSpace(x));


            var reestrCount = this.WhenAnyValue(x => x.ReestrsCollection.Count);

            _reestrCount = reestrCount
                           .Select(x => x)
                           .ToProperty(this, x => x.ReestrCount);

            _netTotal = reestrCount
                        .Select(x => ReestrsCollection.Sum(z => z.Net))
                        .ToProperty(this, x => x.NetTotal);
            this.WhenAnyValue(x => x.SelectedBarrelType)
            .Skip(1)
            .SelectMany(FilterCollectionByBarrelType)
            .Subscribe();

            FilterBySearchQueryCommand = ReactiveCommand.CreateFromTask(ExecuteFilterBySearchQueryCommand, canFilter);
            PrintCommand       = ReactiveCommand.Create <Reestr>(ExecutePrintCommand);
            EditCommand        = ReactiveCommand.Create <Reestr>(ExecuteEditCommand);
            ExportExcelCommand = ReactiveCommand.Create(ExecuteExportExcelCommand);
        }
        public StatusViewModel(IBarrelStorageDataService barrelStorageDataService, IReestrDataService reestrDataService)
        {
            _barrelStorageDataService = barrelStorageDataService;
            _reestrDataService        = reestrDataService;
            RecipeReminder            = new RecipeReminder();
            _currentRecipe            = new Recipe();

            MessageBus.Current.Listen <ReestredAddedEvent>()
            .SelectMany(x => UpdateStatus(x.Reestr))
            .Subscribe();

            MessageBus.Current.Listen <Recipe>()
            .Where(x => x.Id != _currentRecipe.Id)
            .SelectMany(CalculateReminder)
            .Subscribe();
        }
Exemple #4
0
        public ShellViewModel(IComPortProvider comPortProvider,
                              IReestrSettingDataService reestrSettingDataService,
                              IDialogNavigationService dialogNavigationService,
                              IReestrDataService reestrDataService)
        {
            _comPortProvider          = comPortProvider;
            _reestrSettingDataService = reestrSettingDataService;
            _dialogNavigationService  = dialogNavigationService;
            _reestrDataService        = reestrDataService;
            MaxProgressValue          = 3;
            IsAutoMode = true;
            Task.Run(Initialize);

            var parsedValue = this.WhenAnyValue(x => x._comPortProvider.ComPortConnector.ParsedValue);

            parsedValue.Subscribe(ValueDropped);
            parsedValue.ObserveOnDispatcher()
            .Subscribe(x => Proggress(x));

            Observable.Interval(TimeSpan.FromSeconds(1))
            .ObserveOnDispatcher()
            .Subscribe(Progress2);

            parsedValue.Throttle(TimeSpan.FromSeconds(3))
            .Where(x => IsAutoMode && _isValueDroppedToMinimum)
            .Where(ValidateParsedValue)
            .SelectMany(InsertToDataBase)
            .Catch((Func <Exception, IObservable <ReestrObject> >)HandleException)
            .Where(x => x != null)
            .Select(x => x)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(InsertToCollection);

            var reestrCount = this.WhenAnyValue(x => x.ReestrsCollection.Count);

            _reestrCount = reestrCount
                           .Select(x => x)
                           .ToProperty(this, x => x.ReestrCount);

            _netTotal = reestrCount
                        .Select(x => ReestrsCollection.Sum(z => z.Net))
                        .ToProperty(this, x => x.NetTotal);


            _itemWeight = parsedValue.Select(x => x)
                          .ObserveOn(RxApp.MainThreadScheduler)
                          .ToProperty(this, x => x.ItemWeigth);

            var canExecute = this
                             .WhenAnyValue(x => x.IsAutoMode,
                                           isAutoMode => isAutoMode == false);

            Imitation   = ReactiveCommand.CreateFromTask(ExecuteImitation);
            SaveCommand = ReactiveCommand.CreateFromTask(ExecuteSaveCommand, canExecute);
            SaveCommand
            .Catch((Func <Exception, IObservable <ReestrObject> >)HandleException)
            .Where(x => x != null)
            .Select(x => x)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(InsertToCollection);


            var canEditAndCanPrint = this
                                     .WhenAnyValue(x => x.SelectedReestr)
                                     .Select(x => x != null);


            EditCommand  = ReactiveCommand.Create <ReestrObject>(ExecuteEditViewCommand, canEditAndCanPrint);
            PrintCommand = ReactiveCommand.Create <ReestrObject>(ExecutePrintViewCommand, canEditAndCanPrint);
            ExecuteOpenReestrSettingCommand();
        }