private async void LoadData(int postId, int pageIndex, bool isNeeedClear = true)
        {
            BusyCount++;
            _isLoadingNow = true;
            IsResultEmpty = false;
            LoadNextPageCommand.RaiseCanExecuteChanged();
            LoadPreviousPageCommand.RaiseCanExecuteChanged();
            RefreshCommand.RaiseCanExecuteChanged();

            var commentsResponse = await _commentsProvider.LoadCommentsAsync(postId, pageIndex, commentType);

            if (commentsResponse != null)
            {
                CurrentIndex = commentsResponse.PagerCurrent;

                if (commentsResponse.PageComments != null)
                {
                    LastIndex = commentsResponse.TotalCount / 25;

                    Comments = commentsResponse.PageComments;
                }
            }

            _isLoadingNow = false;
            IsResultEmpty = Comments.Count == 0;
            LoadNextPageCommand.RaiseCanExecuteChanged();
            LoadPreviousPageCommand.RaiseCanExecuteChanged();
            RefreshCommand.RaiseCanExecuteChanged();

            BusyCount--;
        }
        private async void EditTeamNameExecuted()
        {
            LoggingService.Trace("Executing TeamDetailsViewModel.EditTeamNameCommand");

            var promptResult = await _userDialogs.PromptAsync(new PromptConfig()
            {
                InputType  = InputType.Name,
                OkText     = "Ok",
                CancelText = "Cancel",
                Title      = "Change team name",
            });

            if (promptResult.Ok && !string.IsNullOrWhiteSpace(promptResult.Text))
            {
                var result = await _wasabeeApiV1Service.Teams_RenameTeam(Team.Id, promptResult.Text);

                if (result)
                {
                    RefreshCommand.Execute();
                    _messenger.Publish(new MessageFor <TeamsListViewModel>(this));
                }
                else
                {
                    _userDialogs.Toast("Rename failed");
                }
            }
        }
        public void Update()
        {
            imagesMapper.UpdateCollection(service.GetImages(), Images);

            RefreshCommand.UpdateState();
            DeleteImagesCommand.UpdateState();
        }
Example #4
0
 public WeatherVM()
 {
     Weather        = new AccuWeather();
     Cities         = new ObservableCollection <City>();
     SelectedCity   = new City();
     RefreshCommand = new RefreshCommand(this);
 }
Example #5
0
 public WeatherVM()
 {
     Forecasts      = new ObservableCollection <DailyForecast>();
     Cities         = new ObservableCollection <City>();
     SelectedResult = new City();
     RefreshCommand = new RefreshCommand(this);
 }
Example #6
0
 public override void LoadView(bool loadData)
 {
     if (loadData)
     {
         RefreshCommand.Execute(null);
     }
 }
 public WeatherVM()
 {
     Weather        = new WeatherUnderground();
     Cities         = new ObservableCollection <RESULT>();
     selectedResult = new RESULT();
     RefreshCommand = new RefreshCommand(this);
 }
        private void InitViewModel()
        {
            IsSearched = true;

            Repository = new StockUnitRepository();
            if (_card.IsNew)
            {
                Filter = new StockUnitFilter();
            }
            else
            {
                var filter = new StockUnitFilterParams {
                    Card = new List <Card> {
                        _card
                    }
                };
                Filter = new StockUnitFilter(filter);
            }

            Result = new List <StockUnit>();

            OkCommand     = new RelayCommand(x => OkMethod());
            CancelCommand = new RelayCommand(x => CloseAction());

            if (RefreshCommand != null)
            {
                RefreshCommand.Execute(null);
            }
        }
        // 請使用 ObservableRangeCollection 來取代 ObservableCollection,
        // 主要是在實作refresh data 這功能時,使用此類別的ReplaceRange method可以避免DataGrid 跳動
        //private ObservableRangeCollection<Device> _devicesCollection;
        //private static object _lock = new object();

        // TODO: BUG...DateTime always 以 en-US 呈現
        public AlarmsViewModel(
            ICollectionModel <eventwarn> dataModel,
            IDeviceDataService deviceDataService,
            IDialogService dialogService,
            IPrintService printService)
        {
            this._dialogService     = dialogService;
            this._deviceDataService = deviceDataService;
            this._dataModel         = dataModel;
            this._printService      = printService;
            //this._dataModel.Data.CollectionChanged += _dataCollection_CollectionChanged;
            Alarms = (ListCollectionView)CollectionViewSource.GetDefaultView((IList)_dataModel.Data);
            Alarms.CurrentChanged += Alarms_CurrentChanged;
            Messenger.Default.Register <ReceivedAlarm>(this, (msg) =>
            {
                if (msg.Alarms != null)
                {
                    var seriousAlarmEvents = (from alarm in msg.Alarms
                                              where alarm.action == "trig"
                                              select alarm).ToList();
                    if (seriousAlarmEvents.Count() > 0)
                    {
                        this._dialogService.ShowAlarmDialog(/*seriousAlarmEvents*/);
                    }
                }
            });

            RefreshCommand.Execute(null);
        }
Example #10
0
        public DialogConfigSystemSettingViewModel(
            IValidator <DialogConfigSystemSettingViewModel> validator,
            ICollectionModel <fs_province> provinceDataModel,
            ICollectionModel <fs_city> cityDataModel)
        {
            this._ProvinceDataModel = provinceDataModel;
            this._CityDataModel     = cityDataModel;

            Cities    = (ListCollectionView)CollectionViewSource.GetDefaultView((IList)_CityDataModel.Data);
            Provinces = (ListCollectionView)CollectionViewSource.GetDefaultView((IList)_ProvinceDataModel.Data);
            Provinces.CurrentChanged += Provinces_CurrentChanged;

            RefreshCommand.Execute(null);

            this.Validator = new FluentValidationAdapter <DialogConfigSystemSettingViewModel>(validator);

            this.AppName              = Config.Instance.AppName;
            this.LocalIP              = Config.Instance.LocalIP;
            this.LocalSubnetMask      = Config.Instance.LocalSubnetMask;
            this.LocalGateway         = Config.Instance.LocalGateway;
            this.OutboundIP           = Config.Instance.OutboundIP;
            this.HTTPServerPort       = Config.Instance.HTTPServerPort;
            this.NTPServerPort        = 49123;
            this.SIPServerAddress     = Config.Instance.SIPServerIP;
            this.SIPServerPort        = Config.Instance.SIPServerPort;
            this.SIPCommunicationPort = Config.Instance.SIPCommunicationPort;
            this.CloudSolution        = Config.Instance.CloudSolution;
            this.ProvinceID           = Config.Instance.WeatherOfProvince;
            this.CityID     = Config.Instance.WeatherOfCity;
            this.ProvinceID = Config.Instance.WeatherOfProvince;
        }
        public PrimaryWindowCoreLayout(PrimaryWindowCoreLayoutViewModel viewModel)
        {
            this.InitializeComponent();

            DataContext = _viewModel = viewModel;

            // Navigation Handling
            ContentFrame.Navigated += Frame_Navigated;
            SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;
            Window.Current.CoreWindow.KeyDown        += CoreWindow_KeyDown;
            Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed;

            _backNavigationEventSubscriber = _viewModel.EventAggregator.GetEvent <BackNavigationRequestEvent>()
                                             .Subscribe(() => HandleBackRequest(), keepSubscriberReferenceAlive: true);

            _refreshNavigationEventSubscriber = _viewModel.EventAggregator.GetEvent <RefreshNavigationRequestEvent>()
                                                .Subscribe(() => RefreshCommand.Execute(), keepSubscriberReferenceAlive: true);

            _themeChangeRequestEventSubscriber = _viewModel.EventAggregator.GetEvent <ThemeChangeRequestEvent>()
                                                 .Subscribe(theme => SetTheme(theme), keepSubscriberReferenceAlive: true);

            SetTheme(_viewModel.ApplicationSettings.Theme);

            AutoSuggestBox.Loaded += PrimaryWindowCoreLayout_Loaded;
        }
        private async Task AddAgentFromQrCodeExecuted(string qrCodeData)
        {
            LoggingService.Trace("Executing TeamDetailsViewModel.AddAgentFromQrCodeCommand");

            IsAddingAgent = false;

            if (string.IsNullOrEmpty(qrCodeData))
            {
                return;
            }

            if (qrCodeData.StartsWith("wasabee:"))
            {
                var userId = qrCodeData.Substring(8, qrCodeData.Length - 8);
                var user   = Team.Agents.FirstOrDefault(x => x.Id.Equals(userId)) ?? null;
                if (user != null)
                {
                    _userDialogs.Toast($"{user.Name} is already in the team !");
                    return;
                }

                var result = await _wasabeeApiV1Service.Teams_AddAgentToTeam(Team.Id, userId);

                if (result)
                {
                    RefreshCommand.Execute();
                }
                else
                {
                    _userDialogs.Toast("Agent not found");
                }
            }
        }
        private async void PromptAddUserAgentExecuted()
        {
            LoggingService.Trace("Executing TeamDetailsViewModel.PromptAddUserAgentCommand");

            IsAddingAgent = false;

            var promptResult = await _userDialogs.PromptAsync(new PromptConfig()
            {
                InputType  = InputType.Name,
                OkText     = "Add",
                CancelText = "Cancel",
                Title      = "Agent name",
            });

            if (promptResult.Ok && !string.IsNullOrWhiteSpace(promptResult.Text))
            {
                var result = await _wasabeeApiV1Service.Teams_AddAgentToTeam(Team.Id, promptResult.Text);

                if (result)
                {
                    RefreshCommand.Execute();
                }
                else
                {
                    _userDialogs.Toast("Agent not found or already in team");
                }
            }
        }
Example #14
0
        private async Task SetCurrentItem(int id)
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }
                IsBusy = true;
                await Task.Delay(300);

                var rest = await PermohonanService.GetPermohonanById(id);

                if (rest != null)
                {
                    CurrentItem = rest;
                }
                RefreshCommand.Execute(null);
            }
            catch (Exception ex)
            {
                Helper.ShowMessageError(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #15
0
        public HomeViewModel(IUserDialogs userDialogs, IParentService parentService,
                             IMvxMessenger mvxMessenger, AppHelper appHelper, IAlertService alertService) : base(userDialogs, mvxMessenger, appHelper)
        {
            _parentService = parentService;
            _alertService  = alertService;

            RefreshCommand = ReactiveCommand.CreateFromObservable <Unit, PageModel>((param) =>
            {
                RefreshBindings();

                return(Observable.Zip(
                           _parentService.GetProfileInformation(),
                           _parentService.GetChildren().OnErrorResumeNext(Observable.Return(new List <SonEntity>())),
                           _alertService.GetLastAlertsForSelfParent().OnErrorResumeNext(Observable.Return(new AlertsPageEntity())),
                           (ParentEntity, SonEntities, AlertsPageEntity) => new PageModel()
                {
                    SelfParent = ParentEntity,
                    SonEntities = SonEntities,
                    AlertsPage = AlertsPageEntity
                }));
            });

            RefreshCommand.Subscribe(OnPageModelLoadedHandler);

            RefreshCommand.IsExecuting.Subscribe((IsLoading) => IsBusy = IsLoading);

            RefreshCommand.ThrownExceptions.Subscribe(HandleExceptions);
        }
Example #16
0
        private async void RefreshReports()
        {
            if (IsBusy || !IsLoaded)
            {
                return;
            }

            IsBusy = true;
            RefreshCommand.ChangeCanExecute();

            try
            {
                Reports = null;
                var reports = await _reportStorage.GetReports();

                Reports = new List <Report>(reports);
            }
            catch (Exception)
            {
                // ignored
            }
            finally
            {
                IsBusy = false;
                RefreshCommand.ChangeCanExecute();
            }
        }
Example #17
0
        private async void RefreshRules()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            RefreshCommand.ChangeCanExecute();

            try
            {
                var rules = await _ruleStorage.GetRules();

                Rules = new ObservableCollection <Rule>(rules);
            }
            catch (Exception)
            {
                // ignored
            }
            finally
            {
                IsBusy = false;
                RefreshCommand.ChangeCanExecute();
            }
        }
Example #18
0
        private async Task UpdateNextRowsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            pageId++;
            IsBusy = true;
            RefreshCommand.ChangeCanExecute();

            string url = Url + "&page=" + pageId;

            ObservableCollection <RowData> rows = await WebManager.LoadItemsAsync(url);

            Rows.RemoveAt(Rows.Count - 1);
            foreach (RowData rowData in rows)
            {
                Rows.Add(rowData);
            }
            Rows = RemoveDuplicateRows(Rows);
            Rows.Add(GetMoreRowData());
            IsBusy = false;
            RefreshCommand.ChangeCanExecute();
        }
Example #19
0
        public void Refresh()
        {
            //if (RefreshedTooSoon()) return;

            try { RefreshCommand.ExecuteIfItCan(TriggeredBy.Code); }
            catch (Exception ex) { LogError("RefreshCommand", ex); }
        }
Example #20
0
        public void SetUp()
        {
            _refreshEvent = this._factory.Create<RefreshEvent>();

            this._aggregator = this._factory.Create<IEventAggregator>();
            this._aggregator.Setup(a => a.GetEvent<RefreshEvent>()).Returns(
                _refreshEvent.Object);
            this._refreshCommand = new RefreshCommand(this._aggregator.Object);
        }
        public HenDepreciationListViewModel(IMessageBroker broker, IClientContext clientContext,  IHenDepreciationService service,
            NewHenDepreciationCommand newCommand, EditHenDepreciationCommand editCommand, DeleteHenDepreciationCommand deleteCommand, RefreshCommand refreshCommand)
        {
            this.broker = broker;
            this.service =service;
            pageSize = clientContext.PageSize;

            NewCommand = newCommand;
            EditCommand = editCommand;
            DeleteCommand = deleteCommand;
            RefreshCommand = refreshCommand;

            RefreshCommand.MessageName = CommonMessages.RefreshHenDepreciationList;
            NavigationCommands = new List<CommandBase>() { NewCommand, DeleteCommand, RefreshCommand };

            SubscribeMessages();
        }
        public EmployeeCostListViewModel(IMessageBroker broker, IClientContext clientContext, IEmployeeCostService costService,
            NewEmployeeCostCommand newCommand, EditEmployeeCostCommand editCommand, DeleteEmployeeCostCommand deleteCommand,
            RefreshCommand refreshCommand)
        {
            this.broker = broker;
            this.costService = costService;
            pageSize = clientContext.PageSize;

            NewCommand = newCommand;
            EditCommand = editCommand;
            DeleteCommand = deleteCommand;
            RefreshCommand = refreshCommand;
            RefreshCommand.MessageName = CommonMessages.RefreshEmployeeCostList;
            NavigationCommands = new List<CommandBase>{NewCommand,  DeleteCommand, RefreshCommand};

            SubscribeMessages();
        }
        public UsageListViewModel(IMessageBroker messageBroker, IClientContext clientContext, IConsumableUsageService usageService,
            NewUsageCommand newCommand, EditUsageCommand editCommand, DeleteUsageCommand deleteCommand,
            RefreshCommand refreshCommand)
        {
            this.messageBroker = messageBroker;
            this.usageService = usageService;

            pageSize = clientContext.PageSize;

            NewCommand = newCommand;
            EditCommand = editCommand;
            DeleteCommand = deleteCommand;
            RefreshCommand = refreshCommand;

            RefreshCommand.MessageName = CommonMessages.RefreshUsageList;

            NavigationCommands = new List<CommandBase>(){NewCommand, DeleteCommand, RefreshCommand};

            SubscribeMessages();
        }