Exemplo n.º 1
0
        private void sortSelected(string item)
        {
            bool   sortDescending   = false;
            string currentSortField = string.Empty;

            if (item.EndsWith(DESCENDING))
            {
                sortDescending   = true;
                currentSortField = sortFields[item.Replace(DESCENDING, "")];
            }
            else
            {
                sortDescending   = false;
                currentSortField = sortFields[item.Replace(ASCENDING, "")];
            }
            if (currentSortField == "user")
            {
                currentSortField = $"user.firstName{(sortDescending ? " desc" : "")},user.lastName{(sortDescending ? " desc" : "")}";
                sortDescending   = false;
                var oldusersort = sortQueue.FirstOrDefault(k => k.Item1.Contains("user.firstName"));
                if (oldusersort != null)
                {
                    sortQueue.Remove(oldusersort);
                }
            }
            var oldsort = sortQueue.FirstOrDefault(k => k.Item1 == currentSortField);

            if (oldsort != null)
            {
                sortQueue.Remove(oldsort);
            }
            sortQueue.Add(new Tuple <string, bool>(currentSortField, sortDescending));
            LoadDataCommand.Execute(null);
        }
        public async System.Threading.Tasks.Task ExecuteAddressCommand(DisplayItem displayItem)
        {
            var request = displayItem.Tag as MaintenanceRequest;

            if (!await runTask(async() =>
            {
                request.IsAddressed = true;
                var toSave = Common.Clone <MaintenanceRequest>(request);
                if (toSave.AssignedTo != null)
                {
                    toSave.AssignedToId = toSave.AssignedTo.UserIdValue;
                }
                toSave.AssignedTo = null;
                if (toSave.RequestedBy != null)
                {
                    toSave.RequestedByIdValue = toSave.RequestedBy.UserIdValue;
                }
                toSave.AssignedTo = null;
                await DataService.PutItemAsync <MaintenanceRequest>("maintenanceRequests", toSave.MaintenanceRequestIdValue, toSave);
            },
                               "Are you sure you want to mark this request as addressed?"))
            {
                return;
            }

            if (UnaddressedOnly)
            {
                LoadDataCommand.Execute(null);
            }
            else
            {
                populateDisplayItem(displayItem, request);
                displayItem.Refresh();
            }
        }
Exemplo n.º 3
0
        public EventsPageModel(IMapper mapper, IEventRepository eventRepository)
        {
            _mapper          = mapper;
            _eventRepository = eventRepository;

            MessagingCenter.Subscribe <RefreshEventsMessage>(this, RefreshEventsMessage.Message, message =>
            {
                LoadDataCommand.Execute(null);
            });
        }
        public async System.Threading.Tasks.Task ExecuteDeleteCommand(DisplayItem displayItem)
        {
            var request = displayItem.Tag as MaintenanceRequest;

            if (!await runTask(async() => await DataService.DeleteItemAsync("maintenanceRequests", request.MaintenanceRequestIdValue),
                               "Are you sure you want to delete this request"))
            {
                return;
            }
            LoadDataCommand.Execute(null);
        }
        public DashboardViewModelCore(DustService dustService = null, ExcelGenerator excelGenerator = null, IScreen screen = null)
        {
            _excelGenerator = excelGenerator ?? Locator.Current.GetService <ExcelGenerator>();
            _dustService    = dustService ?? Locator.Current.GetService <DustService>();
            HostScreen      = screen ?? Locator.Current.GetService <IScreen>();

            var canLoadDataCommand = this.WhenAnyValue(p => p.SelectedStation)
                                     .Select(p => p != null);

            LoadDataCommand = ReactiveCommand.CreateFromObservable <Station, Record[]>(station =>
            {
                //Info = new DashboardInfo();
                _values.Clear();

                IObservable <Record[]> s = _dustService.GetAvailableParametersAsync(station)
                                           .Select(@params => @params.Select(p => p.Param).ToArray())
                                           .Select(@params => _dustService.GetStationRecordsAsync(station.Code, @params)).Switch();

                return(Observable.Start(() => s, RxApp.TaskpoolScheduler).Switch().TakeUntil(CancelCommand));;
            }, canLoadDataCommand);

            CancelCommand = ReactiveCommand.Create(
                () => { },
                this.LoadDataCommand.IsExecuting);

            this.WhenActivated(cleanup =>
            {
                var share = _values.Connect().Publish().RefCount();
                share.ToCollection().Select(records =>
                {
                    return(Enum.GetValues(typeof(RecordType)).Cast <RecordType>()
                           .Select(type => records.LastOrDefault(r => r.Type == type)));
                }).BindTo(this, vm => vm.LastRecords).DisposeWith(cleanup);

                share.Bind(StationData).Subscribe().DisposeWith(cleanup);

                LoadDataCommand.ThrownExceptions.Subscribe(ShowError).DisposeWith(cleanup);

                LoadDataCommand.Subscribe(records =>
                {
                    _values.Edit(e => e.AddRange(records));
                }).DisposeWith(cleanup);

                var canSaveToExcelCommand = StationData.ObserveCollectionChanges().Select(_ => StationData.Count > 0);

                SaveToExcelCommand = ReactiveCommand.CreateFromTask <IEnumerable <Record> >(data => _excelGenerator.CreateExcel(SelectedStation.Code, data), canSaveToExcelCommand);

                SaveToExcelCommand.ThrownExceptions.Subscribe(ShowError);

                this.WhenAnyValue(p => p.SelectedStation).Where(p => p != null).Do(_ => CancelCommand.Execute().Subscribe()).InvokeCommand(LoadDataCommand).DisposeWith(cleanup);;
            });
        }
 public void MaintenanceRequestSaved(MaintenanceRequest request, DisplayItem displayItem)
 {
     if (request.IsAddressedValue && !UnaddressedOnly)
     {
         if (displayItem != null)
         {
             LoadDataCommand.Execute(null);
         }
     }
     else if (displayItem == null)
     {
         LoadDataCommand.Execute(null);
     }
     else
     {
         populateDisplayItem(displayItem, request);
         displayItem.Refresh();
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Вью-модель окна.
        /// </summary>
        public MainWindowVM()
        {
            LoadDataCommand     = new LoadDataCommand();
            TrainNetworkCommand = new TrainNetworkCommand();
            ForeCastCommand     = new ForeCastCommand();

            _percentLabelVisibility = Visibility.Hidden;

            _countOfHiddenLayerNeurons = CountOfHiddenLayerNeuronsList.First();

            var configuration = new ConfigurationModel();

            _epochCount = configuration.EpochCount.ToString();
            _epsilon    = configuration.Epsilon.ToString();
            _alpha      = configuration.Alpha.ToString();

            _maxValue = 1;
            _minValue = 0;
        }
Exemplo n.º 8
0
        public MainPageViewModel(IAppNavigation appNav)
        {
            _appNav = appNav;

            LoadListCommand    = ReactiveCommand.CreateFromTask <List <StationInfoModel> >(execute: () => LoadListAsync(), outputScheduler: RxApp.MainThreadScheduler);
            LoadSensorsCommand = ReactiveCommand.CreateFromTask <StationInfoModel, List <SensorInfoModel> >(station => LoadStationSensorsAsync(station), outputScheduler: RxApp.MainThreadScheduler);
            LoadDataCommand    = ReactiveCommand.CreateFromTask <SensorInfoModel, SensorDataEntry>(sensor => LoadSensorDataAsync(sensor), outputScheduler: RxApp.MainThreadScheduler);

            _stationsInfoList = LoadListCommand.ToProperty(this, x => x.StationsList, new List <StationInfoModel>());
            _sensorInfoModels = LoadSensorsCommand.ToProperty(this, x => x.SensorsList, new List <SensorInfoModel>());
            _sensorData       = LoadDataCommand.ToProperty(this, x => x.SensorData, new SensorDataEntry());

            this.ObservableForProperty(x => x.IsBeingNavigated)
            .Select(e => new Unit())
            .InvokeCommand(LoadListCommand);

            this.ObservableForProperty(x => x.SelectedStation)
            .Select(e => e.Value)
            .InvokeCommand(LoadSensorsCommand);

            this.ObservableForProperty(x => x.SensorsList)
            .Select(e => e.Value)
            .Subscribe(x => SelectedSensor = x?.FirstOrDefault());

            this.ObservableForProperty(x => x.SelectedSensor)
            .Select(e => e.Value)
            .InvokeCommand(LoadDataCommand);


            _filteredStationsInfoList = this.WhenAnyValue(
                x => x.Filter,
                x => x.StationsList,
                (f, l) => l.CreateDerivedCollection(x => x,
                                                    x => x.StationName.Contains(string.IsNullOrEmpty(f) ? "" : f)
                                                    ).ToList()
                )
                                        .ToProperty(this, x => x.FilteredStationsList, new List <StationInfoModel>());
        }
Exemplo n.º 9
0
 private async System.Threading.Tasks.Task approveDenyHours(UserClock userClock, bool approve)
 {
     this.IsBusy = true;
     try
     {
         if (approve)
         {
             userClock.Status = 0;
             await DataService.PutItemAsync <UserClock>("userClocks", userClock.UserClockIdValue, userClock);
         }
         else
         {
             await DataService.DeleteItemAsync("userClocks", userClock.UserClockIdValue);
         }
         this.IsBusy = false;
         LoadDataCommand.Execute(null);
     }
     catch (Exception ex)
     {
         this.IsBusy = false;
         ExceptionHelper.ShowException(ex);
     }
 }
 public MainViewModel()
 {
     LoadDataCommand.Execute(null);
 }
 /// <summary>
 /// This method is to handle the Screen size changed event fired from the UI
 /// </summary>
 public void OnScreenSizeChanged()
 {
     SetDefautValues();
     LoadDataCommand.Execute(null);
 }
 public CreditCardListViewModel()
 {
     LoadDataCommand.Execute(null);
 }
Exemplo n.º 13
0
 public DateSelectionPageVM()
 {
     SelectedStartDate = DateTime.Today;
     SelectedEndDate   = DateTime.Today;
     LoadDataCommand   = new LoadDataCommand(this);
 }
Exemplo n.º 14
0
 public DashboardViewModel()
 {
     LoadDataCommand.Execute(null);
 }