コード例 #1
0
        public override async void OnNavigatedTo(INavigationParameters parameters)
        {
            //TODO: xamarin essentials
            base.OnNavigatedTo(parameters);

            //try if token is still valid
            if (KutyAppClientContext.IsLoggedIn)
            {
                try
                {
                    await EnvironmentApi.AuthPingAsync();
                }
                catch (System.Exception e)
                {
                    KutyAppClientContext.RemoveApiKey();
                }
            }

            this.IsLoggedIn = KutyAppClientContext.IsLoggedIn;

            if (!KutyAppClientContext.IsLoggedIn && !LoginAsked)
            {
                await NavigationService.NavigateAsync(nameof(LoginPopupPage));

                LoginAsked = true;
            }
        }
コード例 #2
0
ファイル: StatisticsMonitor.cs プロジェクト: radtek/aims-iis
 public StatisticsMonitor(EnvironmentApi api, ILogger eventLog, TimeSpan collectTimeSpan, IEnumerable <Func <IBasePerformanceCounterCollector> > counterCreators = null)
     : base((int)collectTimeSpan.TotalMilliseconds, eventLog)
 {
     _api        = api;
     _eventLog   = eventLog;
     _collectors = Initialize(counterCreators == null ? GetCounters(eventLog) : counterCreators)
                   .ToArray();
 }
コード例 #3
0
        private async Task LoadMySittedPets()
        {
            IsBusy = true;

            var sittedPets = await EnvironmentApi.GetMySittedPetsAsync();

            if (sittedPets.Any())
            {
                Pets = new ObservableCollection <PetsListItemViewModel>(sittedPets.Select(p => new PetsListItemViewModel(EnvironmentApi, KutyAppClientContext, p)));
                await Pets.ParallelForEachAsync(async p => await p.LoadImageAsync(), maxDegreeOfParalellism : 4);
            }

            IsBusy = false;
        }
コード例 #4
0
        private async Task DeletePet(PetDto pet)
        {
            if (KutyAppClientContext.IsLoggedIn)
            {
                await EnvironmentApi.DeletePetAsync(pet.Id);
                await LoadMyPetsAsync();
            }
            else
            {
                await PageDialogService.DisplayAlertAsync("warning", "csak online lehet torolni", "OK");

                //await PetRepository.DeleteDogAsync(pet.Id);
            }
        }
コード例 #5
0
        private async Task LoadMyPetsAsync(bool isRefresh = false)
        {
            if (isRefresh)
            {
                IsRefreshing = true;
            }
            else
            {
                IsBusy = true;
            }

            IEnumerable <PetDto> pets;

            if (KutyAppClientContext.IsLoggedIn)
            {
                pets = await EnvironmentApi.GetMyPetsAsync();
            }
            else
            {
                pets = await PetRepository.GetMyPetsAsync();
            }

            //TODO: ures listanal a parallel elszal
            if (pets.Any())
            {
                Pets = new ObservableCollection <PetsListItemViewModel>(pets.Select(p => new PetsListItemViewModel(EnvironmentApi, KutyAppClientContext, p)));

                if (isRefresh)
                {
                    IsRefreshing = false;
                }
                else
                {
                    IsBusy = false;
                }
                await Pets.ParallelForEachAsync(async p => await p.LoadImageAsync(), maxDegreeOfParalellism : 4);
            }

            if (isRefresh)
            {
                IsRefreshing = false;
            }
            else
            {
                IsBusy = false;
            }
        }
コード例 #6
0
ファイル: TopologyMonitor.cs プロジェクト: radtek/aims-iis
        public TopologyMonitor(EnvironmentApi api, ILogger log, TimeSpan period)
            : base((int)period.TotalMilliseconds, log)
        {
            _api = api;
            _log = log;

            var serverNodeRefCreator  = new ServerNodeRefCreator();
            var appPoolNodeRefCreator = new AppPoolNodeRefCreator();
            var siteNodeRefCreator    = new SiteNodeRefCreator();

            _toplogyCollectors = new ITopologyCollector[]
            {
                new AppPoolTopologyCollector(appPoolNodeRefCreator, serverNodeRefCreator),
                new SiteTopologyCollector(siteNodeRefCreator, appPoolNodeRefCreator, _log),
                new ServerTopologyCollector(serverNodeRefCreator),
                new SslCertificateTopologyCollector(siteNodeRefCreator,
                                                    new SslCertificateNodeRefCreator(),
                                                    TimeSpan.FromDays(Config.SslCertFirstWarning),
                                                    TimeSpan.FromDays(Config.SslCertSecondWarning)),
            };
        }
コード例 #7
0
ファイル: StatisticsMonitor.cs プロジェクト: lulzzz/sdk
 public StatisticsMonitor(EnvironmentApi api, NodeRef nodeRef)
     : base((int)TimeSpan.FromMinutes(1).TotalMilliseconds)
 {
     _api     = api;
     _nodeRef = nodeRef;
 }
コード例 #8
0
 public void Init()
 {
     instance = new EnvironmentApi();
 }
コード例 #9
0
        private async Task LoadPoisAsync(bool isRefresh = false)
        {
            try
            {
                var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);

                if (status != PermissionStatus.Granted)
                {
                    //task.yield!
                    var tmp = await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location);

                    if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location))
                    {
                        await PageDialogService.DisplayAlertAsync("Need location", "Gunna need that location", "OK");
                    }

                    var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Location);

                    //Best practice to always check that the key exists
                    if (results.ContainsKey(Permission.Location))
                    {
                        status = results[Permission.Location];
                    }
                }

                if (status == PermissionStatus.Granted)
                {
                    if (CrossGeolocator.IsSupported && CrossGeolocator.Current.IsGeolocationAvailable)
                    {
                        var locator = CrossGeolocator.Current;
                        locator.DesiredAccuracy = 50;
                        //var location = await locator.GetLastKnownLocationAsync();

                        //UWP: only this works on desktop and only after allowing location service in location privacy settings
                        var position = await locator.GetPositionAsync();

                        //CrossLocalNotifications.Current.Show($"{position.Latitude}", $"{position.Longitude}", 101 /*DateTime.Now.AddSeconds(10)*/);

                        bool connected = false;
                        if (CrossConnectivity.IsSupported)
                        {
                            connected = CrossConnectivity.Current.IsConnected;
                        }

                        if (!connected)
                        {
                            await PageDialogService.DisplayAlertAsync("Networking", "Internet connection is down", "OK");
                        }

                        if (isRefresh)
                        {
                            IsRefreshing = true;
                        }
                        else
                        {
                            IsBusy = true;
                        }
                        var poik = await EnvironmentApi.GetClosestPoisAsync(new SearchPoiDto { Latitude = position.Latitude, Longitude = position.Longitude });

                        Pois = new ObservableCollection <PoiDto>(poik);

                        if (isRefresh)
                        {
                            IsRefreshing = false;
                        }
                        else
                        {
                            IsBusy = false;
                        }
                    }
                }
                else if (status != PermissionStatus.Unknown)
                {
                    await PageDialogService.DisplayAlertAsync("Location Denied", "Can not continue, try again.", "OK");
                }
            }
            catch (Exception ex)
            {
                IsBusy = IsRefreshing = false;
            }
            finally
            {
                IsBusy = IsRefreshing = false;
            }
        }
コード例 #10
0
 public TopologyMonitor(EnvironmentApi api, NodeRef nodeRef)
     : base((int)TimeSpan.FromMinutes(5).TotalMilliseconds)
 {
     _api     = api;
     _nodeRef = nodeRef;
 }