Example #1
0
        public ChooseTaxonsViewModel(ITaxonService taxonService)
        {
            TaxonFilter = "";
            Title       = "Välj arter";

            Device.BeginInvokeOnMainThread(async() =>
            {
                var taxons = await taxonService.GetSpecies();
                Taxons     = new ObservableCollection <TaxonItemModel>(taxons.Select(x => new TaxonItemModel {
                    Name = x.Name, Prefix = x.Prefix
                }).ToList());

                if (Taxons != null)
                {
                    foreach (var taxon in Taxons)
                    {
                        taxon.Selected = selectedTaxons.Any(t => t == taxon.Name);
                    }

                    foreach (var taxon in selectedTaxons)
                    {
                        if (!Taxons.Any(t => t.Name == taxon))
                        {
                            Taxons.Add(new TaxonItemModel {
                                Name = taxon, Selected = true
                            });
                        }
                    }
                    RaisePropertyChanged <ChooseTaxonsViewModel, ObservableCollection <TaxonItemModel> >(x => x.Taxons);
                }
            });
        }
        public ChooseTaxonsViewModel(ITaxonService taxonService)
        {
            TaxonFilter = "";
            Title = "Välj arter";

            Device.BeginInvokeOnMainThread(async () =>
            {
                var taxons = await taxonService.GetSpecies();
                Taxons = new ObservableCollection<TaxonItemModel>(taxons.Select(x => new TaxonItemModel { Name = x.Name, Prefix = x.Prefix }).ToList());

                if (Taxons != null)
                {
                    foreach (var taxon in Taxons)
                    {
                        taxon.Selected = selectedTaxons.Any(t => t == taxon.Name);
                    }

                    foreach (var taxon in selectedTaxons)
                    {
                        if (!Taxons.Any(t => t.Name == taxon))
                        {
                            Taxons.Add(new TaxonItemModel { Name = taxon, Selected = true });
                        }
                    }
                    RaisePropertyChanged<ChooseTaxonsViewModel, ObservableCollection<TaxonItemModel>>(x => x.Taxons);
                }
            });
        }
        public EditReportViewModel(IReportStorage reportStorage, ITaxonService taxonService)
        {
            _reportStorage = reportStorage;
            _taxonService  = taxonService;

            IsBusy = false;

            PropertyChanged += EditReportViewModel_PropertyChanged;
        }
        public SynonymProcessor(ISynonymService synonymService, IOriginService originService, ITaxonService taxonService)
        {
            _synonymService = synonymService;
            _originService  = originService;
            _taxonService   = taxonService;

            Taxons  = new List <Taxon>();
            Origins = new List <Origin>();
        }
        public EditReportViewModel(IReportStorage reportStorage, ITaxonService taxonService)
        {
            _reportStorage = reportStorage;
            _taxonService = taxonService;

            IsBusy = false;

            PropertyChanged += EditReportViewModel_PropertyChanged;
        }
Example #6
0
        public PlantInfoProcessor(ILifeformService lifeformService, IOriginService originService, IPlantInfoService plantInfoService, ITaxonService taxonService, ILocationService locationService)
        {
            _lifeformService  = lifeformService;
            _originService    = originService;
            _plantInfoService = plantInfoService;
            _taxonService     = taxonService;
            _locationService  = locationService;

            Lifeforms = new List <Lifeform>();
            Taxons    = new List <Taxon>();
            Origins   = new List <Origin>();
        }
Example #7
0
        public PlantInfoProcessor(ILifeformService lifeformService, IOriginService originService, IPlantInfoService plantInfoService, ITaxonService taxonService,
                                  ILocationService locationService, IIndex <SearchModels.PlantInfo, PlantInfo> plantInfoIndex, List <Lifeform> lifeforms, List <Taxon> taxons, List <Origin> origins)
        {
            _lifeformService  = lifeformService;
            _originService    = originService;
            _plantInfoService = plantInfoService;
            _taxonService     = taxonService;
            _locationService  = locationService;
            _plantInfoIndex   = plantInfoIndex;

            Origins   = origins;
            Lifeforms = lifeforms;
            Taxons    = taxons;
        }
 public ImportTransformOrchestrator(ILifeformService lifeformService, IOriginService originService, IPlantInfoService plantInfoService,
                                    ILocationService locationService, ITaxonService taxonService, ISynonymService synonymService, IRepository <PlantInfo> plantInfoRepository, IRepository <Specimen> specimenRepository,
                                    ISearchClient <SearchModels.PlantInfo> searchClient, IIndex <SearchModels.PlantInfo, Emergence.Data.Shared.Models.PlantInfo> plantInfoIndex,
                                    IIndex <SearchModels.Specimen, Emergence.Data.Shared.Models.Specimen> specimenIndex)
 {
     _lifeformService     = lifeformService;
     _originService       = originService;
     _plantInfoService    = plantInfoService;
     _locationService     = locationService;
     _taxonService        = taxonService;
     _synonymService      = synonymService;
     _plantInfoRepository = plantInfoRepository;
     _specimenRepository  = specimenRepository;
     _searchClient        = searchClient;
     _plantInfoIndex      = plantInfoIndex;
     _specimenIndex       = specimenIndex;
 }
Example #9
0
 public SearchTaxonViewModel(ITaxonService taxonService)
 {
     _taxonService = taxonService;
 }
        public TaxonManagementVM(
            IConnectivityService Connectivity,
            ITaxonService Taxa,
            IDiversityServiceClient Service,
            INotificationService Notification
            ) {
            this.Connectivity = Connectivity;
            this.Service = Service;
            this.Taxa = Taxa;
            this.Notification = Notification;

            _IsOnlineAvailable = this.ObservableToProperty(Connectivity.WifiAvailable(), x => x.IsOnlineAvailable);

            var localLists =
            this.FirstActivation()
                .SelectMany(_ =>
                    Taxa.getTaxonSelections()
                    .ToObservable(ThreadPoolScheduler.Instance)
                    .Select(list => new TaxonListVM(list)))
                    .Publish();
            LocalLists =
                localLists
                .ObserveOnDispatcher()
                .CreateCollection();



            var onlineLists =
            localLists
                .IgnoreElements() //only download lists once the local ones are loaded
                .Concat(Observable.Return(null as TaxonListVM))
                .CombineLatest(this.OnActivation(), (_, _2) => _2)
                .CheckConnectivity(Connectivity, Notification)
                .SelectMany(_ => {
                    return Service.GetTaxonLists()
                        .DisplayProgress(Notification, DiversityResources.TaxonManagement_State_DownloadingLists)
                        .TakeUntil(this.OnDeactivation());
                })
                .ObserveOnDispatcher()
                .SelectMany(lists =>
                    lists.Where(list => !LocalLists.Any(loc => loc.Model == list)) // Filter lists already present locally
                        .Select(list => new TaxonListVM(list))
                    )
                .Publish();

            PersonalLists =
                onlineLists.Where(vm => !vm.Model.IsPublicList)
                .CreateCollection();

            PublicLists =
                onlineLists.Where(vm => vm.Model.IsPublicList)
                .CreateCollection();

            onlineLists.Connect();
            localLists.Connect();

            Select = new ReactiveCommand<TaxonListVM>(vm => !vm.IsSelected && !vm.IsDownloading);
            Select.Subscribe(taxonlist => {
                foreach (var list in LocalLists) {
                    if (list.Model.TaxonomicGroup == taxonlist.Model.TaxonomicGroup)
                        list.Model.IsSelected = false;
                }

                Taxa.selectTaxonList(taxonlist.Model);
            });

            Download = new ReactiveCommand<TaxonListVM>(vm => !vm.IsDownloading);
            Download
                .CheckConnectivity(Connectivity, Notification)
                .Subscribe(taxonlist => {
                    if (Taxa.getTaxonTableFreeCount() > 0) {
                        CurrentPivot = Pivot.Local;
                        taxonlist.IsDownloading = true;

                        makeListLocal(taxonlist);

                        DownloadTaxonList(taxonlist)
                            .DisplayProgress(Notification, DiversityResources.TaxonManagement_State_DownloadingList)
                            .ObserveOnDispatcher()
                            .ShowServiceErrorNotifications(Notification)
                            .Subscribe(_ => {
                            	//Download Succeeded
                                taxonlist.IsDownloading = false;

                                if (Select.CanExecute(taxonlist))
                                    Select.Execute(taxonlist);
                            },
                                _ => //Download Failed
                                {
                                    taxonlist.IsDownloading = false;
                                    removeLocalList(taxonlist);
                                },
                                () => 
                                {

                                });
                    }
                });

            Delete = new ReactiveCommand<TaxonListVM>(vm => !vm.IsDownloading);
            Delete
                .Subscribe(taxonlist => {
                    removeLocalList(taxonlist);
                });

            Refresh = new ReactiveCommand<TaxonListVM>(vm => !vm.IsDownloading);
            Refresh
                .Subscribe(taxonlist => {
                    if (Delete.CanExecute(taxonlist)) //Deletes synchronously
                        Delete.Execute(taxonlist);

                    if (Download.CanExecute(taxonlist))
                        Download.Execute(taxonlist);
                });

            //Download all only on Personal pivot
            var canDownloadAll =
                this.WhenAny(x => x.CurrentPivot, x => x.GetValue())
                .Select(p => p == Pivot.Personal)
                .CombineLatest(Connectivity.WifiAvailable(), (p, wi) => p && wi);

            DownloadAll = new ReactiveCommand(canDownloadAll, initialCondition: false);
            DownloadAll
                .SelectMany(_ => PersonalLists.ToArray())
                .Where(vm => Download.CanExecute(vm))
                .Subscribe(Download.Execute);
        }
Example #11
0
 public TaxonController(ITaxonService taxonService)
 {
     _taxonService = taxonService;
 }