Exemplo n.º 1
0
        private Inkton.Nest.Model.Nest CopyUpdate(Inkton.Nest.Model.Nest browseNest)
        {
            browseNest.OwnedBy    = AppViewModel.EditApp;
            browseNest.Tag        = Inkton.Nester.Helpers.Tag.Clean(Tag.Text);
            browseNest.Name       = Name.Text;
            browseNest.NestStatus = "active";

            NestPlatform platform = null;

            if (AppViewModel.EditApp.Type == "uniflow")
            {
                /*
                 * The standard webserver can be a mvc or api type
                 * + worker makes 3 nest types
                 */
                System.Diagnostics.Debug.Assert(Type.Items.Count == 3);

                if (Type.SelectedIndex == 0)
                {
                    platform = AppViewModel.NestViewModel.Platforms.First(
                        x => x.Tag == "mvc");
                }
                else if (Type.SelectedIndex == 1)
                {
                    platform = AppViewModel.NestViewModel.Platforms.First(
                        x => x.Tag == "api");
                }
                else if (Type.SelectedIndex == 2)
                {
                    platform = AppViewModel.NestViewModel.Platforms.First(
                        x => x.Tag == "worker");
                }
            }
            else if (AppViewModel.EditApp.Type == "biflow")
            {
                /*
                 * The websocket can be a mvc type only
                 * + worker makes 2 nest types
                 */
                System.Diagnostics.Debug.Assert(Type.Items.Count == 2);

                if (Type.SelectedIndex == 0)
                {
                    platform = AppViewModel.NestViewModel.Platforms.First(
                        x => x.Tag == "mvc");
                }
                else if (Type.SelectedIndex == 1)
                {
                    platform = AppViewModel.NestViewModel.Platforms.First(
                        x => x.Tag == "worker");
                }
            }

            browseNest.Platform  = platform;
            browseNest.Scale     = (int)Scaling.Value;
            browseNest.ScaleSize = Memory.Items[Memory.SelectedIndex];

            return(browseNest);
        }
Exemplo n.º 2
0
        async void OnAddButtonClickedAsync(object sender, EventArgs e)
        {
            IsServiceActive = true;

            try
            {
                var existNests = from nest in AppViewModel.NestViewModel.Nests
                                 where nest.Tag == Tag.Text
                                 select nest;
                if (existNests.Any())
                {
                    IsServiceActive = false;
                    await ErrorHandler.ExceptionAsync(this, "The nest with this tag already exist");

                    return;
                }

                Inkton.Nest.Model.Nest newNest        = CopyUpdate(new Inkton.Nest.Model.Nest());
                NestPlatform           workerPlatform = AppViewModel.NestViewModel.Platforms.First(
                    x => x.Tag == "worker");

                // the new nest is a handler
                var handlerNests = from nest in AppViewModel.NestViewModel.Nests
                                   where nest.PlatformId != workerPlatform.Id
                                   select nest;

                if (newNest.PlatformId != workerPlatform.Id &&
                    handlerNests.Any())
                {
                    IsServiceActive = false;
                    await ErrorHandler.ExceptionAsync(this, "Only one handler type nest can exist.");

                    return;
                }

                await AppViewModel.NestViewModel.CreateNestAsync(newNest);

                Clear();
            }
            catch (Exception ex)
            {
                await ErrorHandler.ExceptionAsync(this, ex);
            }

            IsServiceActive = false;
        }
Exemplo n.º 3
0
        async private void ButtonAppDeploy_ClickedAsync(object sender, EventArgs e)
        {
            IsServiceActive = true;

            try
            {
                await AppViewModel
                .ServicesViewModel
                .SetAppUpgradingAsync(false);

                NestPlatform workerPlatform = AppViewModel.NestViewModel.Platforms.First(
                    x => x.Tag == "worker");

                var handlerNests = from nest in AppViewModel.NestViewModel.Nests
                                   where nest.PlatformId != workerPlatform.Id
                                   select nest;

                if (handlerNests.ToArray().Length == 0)
                {
                    IsServiceActive = false;
                    await DisplayAlert("Nester", "Please add a handler nest to process queries", "OK");

                    return;
                }

                await AppViewModel.DeploymentViewModel.CollectInfoAsync();

                if (!AppViewModel.DeploymentViewModel.Deployments.Any())
                {
                    ResultMultiple <Forest> result = await AppViewModel.QueryAppServiceTierLocationsAsync(
                        AppViewModel.ServicesViewModel.SelectedAppServiceTableItem.Tier, false);

                    await MainView.StackViewAsync(new AppLocationView(AppViewModel, result.Data.Payload));
                }
                else
                {
                    await MainView.StackViewAsync(new AppSummaryView(AppViewModel));
                }
            }
            catch (Exception ex)
            {
                await ErrorHandler.ExceptionAsync(this, ex);
            }

            IsServiceActive = false;
        }
Exemplo n.º 4
0
        public async Task <ResultMultiple <NestPlatform> > QueryNestPlatformsAsync(
            bool doCache = false, bool throwIfError = true)
        {
            NestPlatform platformSeed = new NestPlatform();

            platformSeed.OwnedBy = _editApp;

            ResultMultiple <NestPlatform> result = await ResultMultipleUI <NestPlatform> .WaitForObjectsAsync(
                true, platformSeed, new CachedHttpRequest <NestPlatform, ResultMultiple <NestPlatform> >(
                    Backend.QueryAsyncListAsync), true);

            if (result.Code >= 0)
            {
                _platforms = result.Data.Payload;
            }

            return(result);
        }
Exemplo n.º 5
0
        async void OnDoneButtonClickedAsync(object sender, EventArgs e)
        {
            try
            {
                NestPlatform workerPlatform = AppViewModel.NestViewModel.Platforms.First(
                    x => x.Tag == "worker");

                var handlerNests = from nest in AppViewModel.NestViewModel.Nests
                                   where nest.PlatformId != workerPlatform.Id
                                   select nest;

                if (handlerNests.ToArray().Length == 0)
                {
                    await ErrorHandler.ExceptionAsync(this, "Please add a handler nest to process queries");

                    return;
                }

                if (_wizardMode)
                {
                    await AppViewModel.ContactViewModel.InitAsync();

                    // if currently trvelling back and forth on the
                    // app wizard - move to the next
                    await MainView.StackViewAsync(
                        new ContactsView(AppViewModel, _wizardMode));
                }
                else
                {
                    // Head back to homepage if the
                    // page was called from here
                    await MainView.UnstackViewAsync();
                }
            }
            catch (Exception ex)
            {
                await ErrorHandler.ExceptionAsync(this, ex);
            }
        }
Exemplo n.º 6
0
        private void SetDefaults()
        {
            Memory.SelectedIndex = 0;
            Type.SelectedIndex   = 0;

            if (AppNestsList.SelectedItem == null)
            {
                Type.IsEnabled = true;
                return;
            }
            else
            {
                Type.IsEnabled = false;
            }

            Inkton.Nest.Model.Nest browseNest = AppNestsList.SelectedItem as Inkton.Nest.Model.Nest;
            Inkton.Nest.Model.Nest copy       = new Inkton.Nest.Model.Nest();
            browseNest.CopyTo(copy);
            AppViewModel.NestViewModel.EditNest = copy;

            int index = 0;

            foreach (string memory in Memory.Items)
            {
                if (memory == browseNest.ScaleSize)
                {
                    Memory.SelectedIndex = index;
                }
                ++index;
            }

            Scaling.Value = browseNest.Scale;
            NestPlatform platform = AppViewModel.NestViewModel.Platforms.First(
                x => x.Id == browseNest.PlatformId);

            if (AppViewModel.EditApp.Type == "uniflow")
            {
                /*
                 * The standard webserver can be a mvc or api type
                 * + worker makes 3 nest types
                 */
                System.Diagnostics.Debug.Assert(Type.Items.Count == 3);

                if (platform.Tag == "mvc")
                {
                    Type.SelectedIndex = 0;
                }
                else if (platform.Tag == "api")
                {
                    Type.SelectedIndex = 1;
                }
                else
                {
                    Type.SelectedIndex = 2;
                }
            }
            else if (AppViewModel.EditApp.Type == "biflow")
            {
                /*
                 * The websocket can be a mvc type only
                 * + worker makes 2 nest types
                 */
                System.Diagnostics.Debug.Assert(Type.Items.Count == 2);

                if (platform.Tag == "mvc")
                {
                    Type.SelectedIndex = 0;
                }
                else
                {
                    Type.SelectedIndex = 1;
                }
            }
        }