Example #1
0
        public void SendRemoveMessage(Inkton.Nest.Model.Nest nest)
        {
            ManagedObjectMessage <Inkton.Nest.Model.Nest> doThis =
                new ManagedObjectMessage <Inkton.Nest.Model.Nest>("remove", nest);

            MessagingCenter.Send(doThis, doThis.Type);
        }
        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);
        }
Example #3
0
        public virtual void Send <T>(T message, Inkton.Nest.Model.Nest nest,
                                     Type type = null, string correlationId = null, int cushion = -1)
        {
            // The server sends a message to the client. The type
            // header identify the type of message arrived.

            _queueClient.Send(message, nest, type, correlationId, cushion);
        }
Example #4
0
        public NestViewModel(BackendService <UserT> backend, App app) : base(backend, app)
        {
            _nests     = new ObservableCollection <Inkton.Nest.Model.Nest>();
            _platforms = new ObservableCollection <NestPlatform>();

            _editNest         = new Inkton.Nest.Model.Nest();
            _editNest.OwnedBy = app;

            RemoveCommand = new Command <Inkton.Nest.Model.Nest>(SendRemoveMessage);
        }
Example #5
0
        private SearchQuery QueryService(SearchQuery query, string service)
        {
            Inkton.Nest.Model.Nest searchNest = _runtime.GetNest(service);

            _logger.LogInformation("Sending Query Id {0} to {1} with {2}",
                                   query.Id, service, query.Text);

            _runtime.Send(query, searchNest, typeof(SearchQuery), query.Id.ToString());

            return(query);
        }
Example #6
0
        public async Task <ResultSingle <Inkton.Nest.Model.Nest> > UpdateNestAsync(Inkton.Nest.Model.Nest nest = null,
                                                                                   bool doCache = false, bool throwIfError = true)
        {
            Inkton.Nest.Model.Nest theNest = nest == null ? _editNest : nest;

            ResultSingle <Inkton.Nest.Model.Nest> result = await ResultSingleUI <Inkton.Nest.Model.Nest> .WaitForObjectAsync(
                throwIfError, theNest, new CachedHttpRequest <Inkton.Nest.Model.Nest, ResultSingle <Inkton.Nest.Model.Nest> >(
                    Backend.UpdateAsync), doCache);

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

            return(result);
        }
        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;
        }
Example #8
0
        public async Task <ResultSingle <Inkton.Nest.Model.Nest> > RemoveNestAsync(Inkton.Nest.Model.Nest nest = null,
                                                                                   bool doCache = false, bool throwIfError = true)
        {
            Inkton.Nest.Model.Nest theNest = nest == null ? _editNest : nest;

            ResultSingle <Inkton.Nest.Model.Nest> result = await ResultSingleUI <Inkton.Nest.Model.Nest> .WaitForObjectAsync(
                throwIfError, theNest, new CachedHttpRequest <Inkton.Nest.Model.Nest, ResultSingle <Inkton.Nest.Model.Nest> >(
                    Backend.RemoveAsync), doCache);

            if (result.Code >= 0)
            {
                if (nest != null)
                {
                    _nests.Remove(nest);
                    OnPropertyChanged("Nests");
                }
            }

            return(result);
        }
        protected async override void OnAppearing()
        {
            base.OnAppearing();

            try
            {
                if (AppViewModel.NestViewModel.Nests.Any())
                {
                    Inkton.Nest.Model.Nest nest = AppViewModel.NestViewModel.Nests.First();
                    AppNestsList.SelectedItem = nest;
                }

                SetDefaults();
                DisplayMemory();
                Validate();
            }
            catch (Exception ex)
            {
                await ErrorHandler.ExceptionAsync(this, ex);
            }
        }
Example #10
0
        async void OnRemoveButtonClickedAsync(object sender, EventArgs e)
        {
            IsServiceActive = true;

            try
            {
                Inkton.Nest.Model.Nest nest = AppNestsList.SelectedItem as Inkton.Nest.Model.Nest;

                if (AppViewModel.EditApp.IsDeployed)
                {
                    if (nest.Platform.Tag != "worker")
                    {
                        await DisplayAlert("Nester", "Cannot remove the hander nest while deplyed", "Yes", "No");

                        return;
                    }
                }

                await Process(nest, true,
                              AppViewModel.NestViewModel.RemoveNestAsync,
                              new Func <Inkton.Nest.Model.Nest, Task <bool> >(
                                  async(obj) =>
                {
                    return(await DisplayAlert("Nester", "Would you like to remove this nest", "Yes", "No"));
                }
                                  )
                              );

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

            IsServiceActive = false;
        }
Example #11
0
        async void OnUpdateButtonClickedAsync(object sender, EventArgs e)
        {
            IsServiceActive = true;

            try
            {
                Inkton.Nest.Model.Nest updatingNest = AppNestsList.SelectedItem as Inkton.Nest.Model.Nest;

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

                    return;
                }

                Inkton.Nest.Model.Nest updateNest = CopyUpdate(updatingNest);
                if (updateNest != null)
                {
                    await Process(updateNest, true,
                                  AppViewModel.NestViewModel.UpdateNestAsync
                                  );

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

            IsServiceActive = false;
        }
Example #12
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;
                }
            }
        }