Exemple #1
0
        protected override async Task LoadDataOverride()
        {
            try
            {
                Debug.WriteLine("Loading list of services.");
                _gaeApplication = _dataSource.Value.GetApplicationAsync();
                IList <ServiceViewModel> services = await LoadServiceList();

                Children.Clear();
                foreach (var item in services)
                {
                    Children.Add(item);
                }
                if (Children.Count == 0)
                {
                    Children.Add(s_noItemsPlacehoder);
                }
                EventsReporterWrapper.ReportEvent(GaeServicesLoadedEvent.Create(CommandStatus.Success));
            }
            catch (DataSourceException ex)
            {
                GcpOutputWindow.OutputLine(Resources.CloudExplorerGaeFailedServicesMessage);
                GcpOutputWindow.OutputLine(ex.Message);
                GcpOutputWindow.Activate();

                EventsReporterWrapper.ReportEvent(GaeServicesLoadedEvent.Create(CommandStatus.Failure));
                throw new CloudExplorerSourceException(ex.Message, ex);
            }
        }
        protected override async Task LoadDataOverrideAsync()
        {
            try
            {
                Debug.WriteLine("Loading list of services.");

                GaeApplication = await _dataSource.Value.GetApplicationAsync();

                if (GaeApplication == null)
                {
                    var noAppEngineAppPlaceholder = new TreeLeaf
                    {
                        Caption     = Resources.CloudExplorerGaeNoAppFoundCaption,
                        IsError     = true,
                        ContextMenu = new ContextMenu
                        {
                            ItemsSource = new List <MenuItem>
                            {
                                new MenuItem {
                                    Header = Resources.CloudExplorerGaeSetAppRegionMenuHeader, Command = new ProtectedAsyncCommand(OnSetAppRegionAsync)
                                }
                            }
                        }
                    };

                    Children.Clear();
                    Children.Add(noAppEngineAppPlaceholder);
                    return;
                }

                IList <ServiceViewModel> services = await LoadServiceListAsync();

                Children.Clear();
                foreach (var item in services)
                {
                    Children.Add(item);
                }
                if (Children.Count == 0)
                {
                    Children.Add(s_noItemsPlacehoder);
                }
                EventsReporterWrapper.ReportEvent(GaeServicesLoadedEvent.Create(CommandStatus.Success));
            }
            catch (DataSourceException ex)
            {
                await GcpOutputWindow.Default.OutputLineAsync(Resources.CloudExplorerGaeFailedServicesMessage);

                await GcpOutputWindow.Default.OutputLineAsync(ex.Message);

                await GcpOutputWindow.Default.ActivateAsync();

                EventsReporterWrapper.ReportEvent(GaeServicesLoadedEvent.Create(CommandStatus.Failure));
                throw new CloudExplorerSourceException(ex.Message, ex);
            }
        }
        protected override async Task LoadDataOverride()
        {
            try
            {
                Debug.WriteLine("Loading list of services.");
                Task <Application> gaeApplicationTask        = DataSource.Value.GetApplicationAsync();
                Task <List <ServiceViewModel> > servicesTask = LoadServiceList();
                await Task.WhenAll(gaeApplicationTask, servicesTask);

                GaeApplication = gaeApplicationTask.Result;
                var services = servicesTask.Result;
                Children.Clear();
                if (services == null)
                {
                    Children.Add(s_errorPlaceholder);
                }
                else
                {
                    foreach (var item in services)
                    {
                        Children.Add(item);
                    }
                    if (Children.Count == 0)
                    {
                        Children.Add(s_noItemsPlacehoder);
                    }
                }
                EventsReporterWrapper.ReportEvent(GaeServicesLoadedEvent.Create(CommandStatus.Success));
            }
            catch (DataSourceException ex)
            {
                GcpOutputWindow.OutputLine(Resources.CloudExplorerGaeFailedServicesMessage);
                GcpOutputWindow.OutputLine(ex.Message);
                GcpOutputWindow.Activate();

                EventsReporterWrapper.ReportEvent(GaeServicesLoadedEvent.Create(CommandStatus.Failure));
                throw new CloudExplorerSourceException(ex.Message, ex);
            }
        }