Esempio n. 1
0
        internal void RefreshModel(TEntityAction action)
        {
            //if (action.NotNull ()) {
            //  if (action.CollectionAction.GadgetMaterialCollection.Count.Equals (0)) {
            //    ComponentModelProperty.ValidateModel (false);

            //    // show alerts
            //    var message = $"Material list is EMPTY!";

            //    AlertsModel.Select (TAlertsModel.TKind.Warning);
            //    AlertsModel.Select ("EMPTY", message);
            //    AlertsModel.Select (isOpen: true);
            //  }

            //  else {
            //    foreach (var item in action.CollectionAction.GadgetMaterialCollection) {
            //      var selection = Server.Models.Infrastructure.TSelectionInfo.Create (item.Material, item.Id, item.Enabled);
            //      selection.SetImage (item.GetImage ());

            //      action.SupportAction.SelectionCollection.Add (selection);
            //    }

            //    ComponentModelProperty.ValidateModel (true);
            //    ComponentModelProperty.ExtensionModel.SelectModel (Server.Models.Infrastructure.TCategory.Report, action); // update Selection Property (Material list)

            //    AlertsModel.Select (isOpen: false); // default
            //  }
            //}
        }
Esempio n. 2
0
    public TOperationSupport (TModelContext context, TEntityAction action)
      : this ()
    {
      /*
      DATA IN
      - action.Id 
      - action.CollectionAction.CategoryRelationCollection

      DATA OUT
      - action.ModelAction (model)
      - action.CollectionAction.ModeCollection {id, model} (for each node)
      */

      if (action.NotNull ()) {
        Id = action.Id;

        if (context.NotNull ()) {
          var descriptors = context.ComponentDescriptor.AsQueryable ()
          .Where (p => p.Id.Equals (Id))
          .ToList ()
        ;

          // found (request Category)
          if (descriptors.Any ()) {
            CategoryValue = descriptors [0].Category;
          }
        }
      }
    }
Esempio n. 3
0
    public static void SelectMany (Collection<TActionComponent> gadgets, TEntityAction entityAction)
    {
      //entityAction.CollectionAction.EntityCollection

      if (entityAction.NotNull ()) {
        if (entityAction.CategoryType.IsCategory (TCategory.Result)) {
          if (gadgets.NotNull ()) {
            if (gadgets.Any ()) {
              foreach (var component in gadgets) {
                // TODO:??
              }
            }

            else {
              foreach (var item in entityAction.CollectionAction.EntityCollection) {
                var someEntity = item.Value;

                var component = TActionComponent.Create (someEntity.CategoryType.Category);
                TActionConverter.Select (someEntity.CategoryType.Category, component, someEntity);

                gadgets.Add (component);
              }
            }
          }
        }
      }
    }
Esempio n. 4
0
        internal void RequestModel(TEntityAction action)
        {
            if (action.NotNull())
            {
                action.SelectCategoryType(TCategoryType.Create(TCategory.Target));
                action.CollectionAction.ExtensionNodeCollection.Clear();

                ComponentModelProperty.RequestModel(action);

                if (action.SupportAction.SelectionInfo.Tag is Guid materialId)
                {
                    action.ModelAction.ComponentStatusModel.UseNodeModel = true;
                    action.ModelAction.ComponentStatusModel.NodeReverse  = true;

                    //  Here gadget Material must be Parent
                    action.ModelAction.ExtensionNodeModel.ChildId        = ComponentModelProperty.Id;
                    action.ModelAction.ExtensionNodeModel.ChildCategory  = TCategoryType.ToValue(TCategory.Target);
                    action.ModelAction.ExtensionNodeModel.ParentId       = materialId;
                    action.ModelAction.ExtensionNodeModel.ParentCategory = TCategoryType.ToValue(TCategory.Material);

                    // update collection
                    action.CollectionAction.ExtensionNodeCollection.Add(action.ModelAction.ExtensionNodeModel);
                }
            }
        }
Esempio n. 5
0
        internal void RefreshModel(TEntityAction entityAction)
        {
            if (entityAction.NotNull())
            {
                var gadgets = new Collection <TActionComponent> ();
                TActionConverter.Collection(TCategory.Material, gadgets, entityAction);

                if (gadgets.Any())
                {
                    foreach (var component in gadgets)
                    {
                        var selection = TSelectionInfo.Create(component.Models.GadgetMaterialModel.GadgetName, component.Models.GadgetMaterialModel.Id, component.Models.GadgetMaterialModel.Enabled);
                        selection.SetImage(component.Models.GadgetMaterialModel.GetImage());

                        entityAction.SupportAction.SelectionCollection.Add(selection);
                    }

                    ComponentModelProperty.ValidateModel(true);
                    ComponentModelProperty.ExtensionModel.SelectModel(TCategory.Target, entityAction); // update Selection Property (Material list)

                    AlertsModel.Select(isOpen: false);                                                 // default
                }

                else
                {
                    ComponentModelProperty.ValidateModel(false);

                    // show alerts
                    AlertsModel.Select(TAlertsModel.TKind.Warning);
                    AlertsModel.Select(Properties.Resource.RES_EMPTY, Properties.Resource.RES_LIST_EMPTY);
                    AlertsModel.Select(isOpen: true);
                }
            }
        }
Esempio n. 6
0
 void MaterialCollectionFullDispatcher (TEntityAction action)
 {
   // refresh model
   Model.MaterialRefreshModel (action);
   
   TDispatcher.Invoke (RefreshAllDispatcher);
 }
Esempio n. 7
0
    public void Handle (TMessageInternal message)
    {
      if (message.NotNull ()) {
        if (message.IsModule (TResource.TModule.Factory)) {
          // from parent
          if (message.Node.IsParentToMe (TChild.List)) {
            // DatabaseValidated
            if (message.IsAction (TInternalMessageAction.DatabaseValidated)) {
              TDispatcher.Invoke (RequestDataDispatcher);
            }

            // Response
            if (message.IsAction (TInternalMessageAction.Response)) {
              // Collection-Full
              if (message.Support.Argument.Types.IsOperation (TOperation.Collection, TExtension.Full)) {
                if (message.Result.IsValid) {
                  // Gadget Material
                  if (message.Support.Argument.Types.IsOperationCategory (TCategory.Material)) {
                    var action = TEntityAction.Request (message.Support.Argument.Types.EntityAction);
                    TDispatcher.BeginInvoke (MaterialCollectionFullDispatcher, action);
                  }
                }
              }
            }
          }

          // from sibilig
          if (message.Node.IsSiblingToMe (TChild.List, TypeInfo)) {
            // PropertySelect
            if (message.IsAction (TInternalMessageAction.PropertySelect)) {
              var propertyName = message.Support.Argument.Args.PropertyName;

              if (propertyName.Equals ("edit", StringComparison.InvariantCulture)) {
                if (message.Support.Argument.Args.Param1 is TActionComponent component) {
                  TDispatcher.BeginInvoke (EditDispatcher, component);
                }
              }

              if (propertyName.Equals ("GadgetAdd", StringComparison.InvariantCulture) || propertyName.Equals ("GadgetRemove", StringComparison.InvariantCulture)) {
                Model.PropertyChanged (message.Support.Argument.Args.PropertyName, message.Support.Argument.Types.ReportData.Locked);

                TDispatcher.Invoke (RefreshAllDispatcher);
              }
            }

            // Reload
            if (message.IsAction (TInternalMessageAction.Reload)) {
              // to parent
              DelegateCommand.PublishInternalMessage.Execute (message);
            }

            // Cleanup
            if (message.IsAction (TInternalMessageAction.Cleanup)) {
              Model.Cleanup ();
              TDispatcher.Invoke (RefreshAllDispatcher);
            }
          }
        }
      }
    }
Esempio n. 8
0
    void DatabaseValidateDispatcher ()
    {
      if (m_DatabaseValidatingInProgress.IsFalse ()) {
        Model.ClearPanels ();
        Model.DatabaseStatus (true);
        Model.Unlock ();

        // open and validate current database (for sure)
        if (DatabaseConnection.IsAuthentication) {
          // to services (Select - Settings)
          var action = TEntityAction.Create (TCategory.Settings, TOperation.Select, TExtension.Settings);

          var message = new TShellMessage (TMessageAction.Request, TypeInfo);
          message.Support.Argument.Types.Select (action);

          DelegateCommand.PublishModuleMessage.Execute (message);

          m_DatabaseValidatingInProgress = true;

          Model.Lock ();
          Model.MenuLeftDisable ();
        }
      }

      ApplyChanges ();
    }
Esempio n. 9
0
    void SelectSettingsDispatcher (TEntityAction action)
    {
      m_DatabaseValidatingInProgress = false;

      if (action.Result.IsValid) {
        Model.Unlock ();
        Model.MenuLeftEnable ();

        Model.Select (action);

        // to module
        var entityAction = TEntityAction.CreateDefault;
        entityAction.Param1 = Model.ComponentModelItem;

        var message = new TShellMessage (TMessageAction.DatabaseValidated, TypeInfo);
        message.Support.Argument.Types.Select (entityAction);

        DelegateCommand.PublishModuleMessage.Execute (message);

        // update INI support section
        //SupportSettings.Change ("ColumnWidth", action.ModelAction.SettingsModel.ColumnWidth.ToString ()); 

        OnSettingsReportCommadClicked (); // show current settings
      }

      else {
        Model.MenuLeftDisable ();
      }

      ApplyChanges ();
    }
Esempio n. 10
0
    void ResponseDataDispatcher (TEntityAction entityAction)
    {
      if (entityAction.NotNull ()) {
        // request
        if (entityAction.IdCollection.Any ()) {
          // to parent
          // Dummy - Select - Many
          var action = TEntityAction.Create (
            TCategory.Dummy,
            TOperation.Select,
            TExtension.Many
          );

          foreach (var item in entityAction.IdCollection) {
            action.IdCollection.Add (item);
          }

          action.Param2 = entityAction; // preserve

          var message = new TCollectionMessageInternal (TInternalMessageAction.Request, TChild.List, TypeInfo);
          message.Support.Argument.Types.Select (action);

          DelegateCommand.PublishInternalMessage.Execute (message);
        }

        else {
          var gadgets = new Collection<TActionComponent> ();
          TActionConverter.Collection (TCategory.Test, gadgets, entityAction);

          Model.Select (gadgets);
        }
      }

      TDispatcher.Invoke (RefreshAllDispatcher);
    }
Esempio n. 11
0
    void SelectionChangedDispatcher (GadgetTest gadget)
    {
      if (Model.SelectionChanged (gadget)) {
        // to parent
        // Select - ById
        var entityAction = TEntityAction.Create (
          TCategory.Test,
          TOperation.Select,
          TExtension.ById
        );

        entityAction.Id = Model.Current.Id;

        var message = new TCollectionMessageInternal (TInternalMessageAction.Request, TChild.List, TypeInfo);
        message.Support.Argument.Types.Select (entityAction);

        DelegateCommand.PublishInternalMessage.Execute (message);
      }

      else {
        // to Sibling
        var message = new TCollectionSiblingMessageInternal (TInternalMessageAction.Cleanup, TChild.List, TypeInfo);
        DelegateCommand.PublishInternalMessage.Execute (message);
      }
    }
Esempio n. 12
0
        internal void RequestModel(TEntityAction action)
        {
            action.ThrowNull();

            foreach (var item in GadgetCheckedCollection)
            {
                // ensure ChildId diferent from ParentId
                if (item.Id.NotEquals(action.Id))
                {
                    var componentRelation = ComponentRelation.CreateDefault;
                    componentRelation.ChildId        = item.Id;
                    componentRelation.ChildCategory  = TCategoryType.ToValue(TCategory.Test);
                    componentRelation.ParentId       = action.Id;
                    componentRelation.ParentCategory = TCategoryType.ToValue(action.CategoryType.Category);

                    // Extension
                    if (string.IsNullOrEmpty(action.ModelAction.ExtensionTextModel.Extension))
                    {
                        action.ModelAction.ExtensionTextModel.Extension = m_CurrentMaterialGadget.GadgetName;
                    }

                    action.CollectionAction.ComponentRelationCollection.Add(componentRelation);
                }
            }

            // update rule
            action.SupportAction.Rule.Pump("gadget");
        }
Esempio n. 13
0
    public static void Select (TCategory category, TActionComponent component, TEntityAction entityAction)
    {
      if (component.NotNull () && entityAction.NotNull ()) {
        switch (category) {
          case TCategory.Material:
            TGadgetMaterialConverter.Select (component, entityAction);
            break;

          case TCategory.Target:
            TGadgetTargetConverter.Select (component, entityAction);
            break;

          case TCategory.Test:
            TGadgetTestConverter.Select (component, entityAction);
            break;

          case TCategory.Registration:
            TGadgetRegistrationConverter.Select (component, entityAction);
            break;

          case TCategory.Result:
            TGadgetResultConverter.Select (component, entityAction);
            break;

          case TCategory.Report:
            TGadgetReportConverter.Select (component, entityAction);
            break;
        }
      }
    }
Esempio n. 14
0
 void RefreshModelDispatcher (TEntityAction action)
 {
   action.ThrowNull ();
   //TODO: what for??
   
   ApplyChanges ();
 }
Esempio n. 15
0
    public static void Request (TActionComponent component, TEntityAction entityAction)
    {
      if (component.NotNull ()) {
        if (component.IsCategory (TCategory.Target)) {
          if (entityAction.NotNull ()) {
            entityAction.Id = component.Models.GadgetTargetModel.Id;
            entityAction.CategoryType.Select (TCategory.Target);

            entityAction.ModelAction.ComponentInfoModel.Name = component.Models.GadgetTargetModel.GadgetInfo;
            entityAction.ModelAction.ComponentStatusModel.Busy = component.Models.GadgetTargetModel.Busy;

            entityAction.ModelAction.ComponentInfoModel.Id = component.Models.GadgetTargetModel.Id;
            entityAction.ModelAction.ExtensionNodeModel.ChildId = component.Models.GadgetTargetModel.Id;
            entityAction.ModelAction.ExtensionNodeModel.ChildCategory = TCategoryType.ToValue (TCategory.Target);
            entityAction.ModelAction.ExtensionNodeModel.ParentId = component.Models.GadgetTargetModel.MaterialId;
            entityAction.ModelAction.ExtensionNodeModel.ParentCategory = TCategoryType.ToValue (TCategory.Material);
            entityAction.ModelAction.ExtensionTextModel.Id = component.Models.GadgetTargetModel.Id;
            entityAction.ModelAction.ExtensionTextModel.Text = component.Models.GadgetTargetModel.GadgetName;
            entityAction.ModelAction.ExtensionTextModel.Description = component.Models.GadgetTargetModel.Description;
            entityAction.ModelAction.ExtensionTextModel.Reference = component.Models.GadgetTargetModel.Reference;
            entityAction.ModelAction.ExtensionTextModel.Value = component.Models.GadgetTargetModel.Value;
            entityAction.ModelAction.ExtensionTextModel.ExternalLink = component.Models.GadgetTargetModel.ExternalLink;
            entityAction.ModelAction.ComponentInfoModel.Enabled = component.Models.GadgetTargetModel.Enabled;
          }
        }
      }
    }
Esempio n. 16
0
    void ChangeSettings (TModelContext context, TEntityAction action)
    {
      /*
      DATA IN
      - action.ModelAction (Settings model)
      */

      try {
        var modelList = context.Settings
          .ToList ()
        ;

        // only one record
        if (modelList.Count.Equals (1)) {
          var model = modelList [0];
          model.Change (action.ModelAction.SettingsModel);

          context.Settings.Update (model);// change Settings model
          context.SaveChanges (); // done

          action.Result = TValidationResult.Success;
        }

        // wrong record count
        else {
          action.Result = new TValidationResult ($"[{action.Operation.CategoryType.Category} - Change Settings] Wrong record count!");
        }
      }

      catch (Exception exception) {
        Models.Infrastructure.THelper.FormatException ("Change - Settings", exception, action);
      }
    }
Esempio n. 17
0
    void RefreshModelDispatcher (TEntityAction action)
    {
      action.ThrowNull ();

      Model.RefreshModel (action);
      ApplyChanges ();
    }
Esempio n. 18
0
    void ResponseDataDispatcher (TEntityAction action)
    {
      var gadgets = new Collection<TActionComponent> ();

      // Registration - Collection - Full (Registration)
      if (action.CategoryType.IsCategory (TCategory.Registration)) {
        TActionConverter.Collection (TCategory.Registration, gadgets, action);
        Model.SelectRegistration (gadgets);
      }

      // Result - Collection - Full (Result )
      if (action.CategoryType.IsCategory (TCategory.Result)) {
        action.IdCollection.Clear (); // empty for sure

        TActionConverter.Collection (TCategory.Result, gadgets, action);

        Model.SelectResult (gadgets, action.IdDictionary);

        // update
        // Dummy - Select - Many
        if (action.IdDictionary.Any ()) {
          action.Operation.Select (TCategory.Dummy, TOperation.Select, TExtension.Many);

          var message = new TCollectionMessageInternal (TInternalMessageAction.Request, TChild.List, TypeInfo);
          message.Support.Argument.Types.Select (action);

          DelegateCommand.PublishInternalMessage.Execute (message);
        }
      }

      TDispatcher.Invoke (RefreshAllDispatcher);
    }
Esempio n. 19
0
        public static void Request(TActionComponent component, TEntityAction entityAction)
        {
            if (component.NotNull())
            {
                if (component.IsCategory(TCategory.Material))
                {
                    if (entityAction != null)
                    {
                        entityAction.Id = component.Models.GadgetMaterialModel.Id;
                        entityAction.CategoryType.Select(TCategory.Material);

                        entityAction.ModelAction.ComponentInfoModel.Name   = component.Models.GadgetMaterialModel.GadgetInfo;
                        entityAction.ModelAction.ComponentStatusModel.Busy = component.Models.GadgetMaterialModel.Busy;

                        entityAction.ModelAction.ComponentInfoModel.Id           = component.Models.GadgetMaterialModel.Id;
                        entityAction.ModelAction.ExtensionTextModel.Id           = component.Models.GadgetMaterialModel.Id;
                        entityAction.ModelAction.ExtensionTextModel.Text         = component.Models.GadgetMaterialModel.GadgetName;
                        entityAction.ModelAction.ExtensionTextModel.Description  = component.Models.GadgetMaterialModel.Description;
                        entityAction.ModelAction.ExtensionTextModel.ExternalLink = component.Models.GadgetMaterialModel.ExternalLink;
                        entityAction.ModelAction.ComponentInfoModel.Enabled      = component.Models.GadgetMaterialModel.Enabled;
                        entityAction.ModelAction.ExtensionImageModel.Image       = component.Models.GadgetMaterialModel.GetImage();
                    }
                }
            }
        }
Esempio n. 20
0
    void SelectSettings (TModelContext context, TEntityAction action)
    {
      try {
        var modelList = context.Settings
          .ToList ()
        ;

        if (modelList.Count.Equals (1)) {
          var model = modelList [0];

          if (model.MyName.Equals ("robjuca", StringComparison.InvariantCulture)) {
            action.ModelAction.SettingsModel.CopyFrom (model);

            action.Result = TValidationResult.Success;
          }

          // bad name
          else {
            action.Result = new TValidationResult ($"[{action.Operation.CategoryType.Category} - Settings] My Name can NOT be NULL or EMPTY or VALIDATE!");
          }
        }

        // wrong record count
        else {
          action.Result = new TValidationResult ($"[{action.Operation.CategoryType.Category} - Settings] Wrong record count!");
        }
      }

      catch (Exception exception) {
        Server.Models.Infrastructure.THelper.FormatException ("Select Settings", exception, action);
      }
    }
Esempio n. 21
0
    public static TComponentModelItem Create (TEntityAction action)
    {
      var modelItem = CreateDefault;

      if (action.NotNull ()) {
        var model = Create (action.ModelAction);

        modelItem.CopyFrom (model);
        modelItem.Select (action.CategoryType.Category);

        switch (modelItem.Category) {
          case Server.Models.Infrastructure.TCategory.Material: {
            }
            break;

          case Server.Models.Infrastructure.TCategory.Target: {
              //modelItem.GadgetTargetModel.UpdateModel (modelItem, action);
            }
            break;

          case Server.Models.Infrastructure.TCategory.Test: {
              //modelItem.GadgetTestModel.UpdateModel (action);
            }
            break;
        }
      }

      return (modelItem);
    }
Esempio n. 22
0
    void RequestDataDispatcher ()
    {
      // to parent
      // Result - Collection - Full (Result)
      var action = TEntityAction.Create (
        TCategory.Result,
        TOperation.Collection,
        TExtension.Full
      );

      var message = new TCollectionMessageInternal (TInternalMessageAction.Request, TChild.List, TypeInfo);
      message.Support.Argument.Types.Select (action);

      DelegateCommand.PublishInternalMessage.Execute (message);

      // to parent
      // Registration - Collection - Full (Registration)
      action = TEntityAction.Create (
        TCategory.Registration,
        TOperation.Collection,
        TExtension.Full
      );

      message = new TCollectionMessageInternal (TInternalMessageAction.Request, TChild.List, TypeInfo);
      message.Support.Argument.Types.Select (action);

      DelegateCommand.PublishInternalMessage.Execute (message);
    }
Esempio n. 23
0
    void ResponseSelectByIdDispatcher (TEntityAction entityAction)
    {
      entityAction.ThrowNull ();

      if (entityAction.Param2 is GadgetTest gadget) {
        if (gadget.HasContentTarget) {
          var component = TActionComponent.Create (TCategory.Test);
          component.Models.GadgetTestModel.CopyFrom (gadget);

          TActionConverter.Select (TCategory.Test, component, entityAction);
          gadget.CopyFrom (component.Models.GadgetTestModel);

          Model.GadgetItemChecked (gadget, isChecked: gadget.IsChecked);

          // to Sibling
          var message = new TFactorySiblingMessageInternal (TInternalMessageAction.PropertySelect, TChild.List, TypeInfo);
          message.Support.Argument.Args.Select (component);
          message.Support.Argument.Args.Select (gadget.IsChecked ? "GadgetAdd" : "GadgetRemove");

          if (Model.IsEditMode || Model.HasGadgetChecked) {
            message.Support.Argument.Types.ReportData.SelectLock ();
          }

          DelegateCommand.PublishInternalMessage.Execute (message);
        }

        TDispatcher.Invoke (RefreshAllDispatcher);
      }
    }
Esempio n. 24
0
    public void Handle (TMessageInternal message)
    {
      if (message.NotNull ()) {
        if (message.IsModule (TResource.TModule.Factory)) {
          // from Sibling
          if (message.Node.IsSiblingToMe (TChild.Design, TypeInfo)) {
            // PropertySelect
            if (message.IsAction (TInternalMessageAction.PropertySelect)) {
              if (message.Support.Argument.Args.Param1 is TActionComponent component) {
                var propertyName = message.Support.Argument.Args.PropertyName;

                Model.SelectModel (component);
              }

              TDispatcher.Invoke (RefreshDesignDispatcher);
            }

            // Request
            if (message.IsAction (TInternalMessageAction.Request)) {
              TDispatcher.BeginInvoke (RequestDesignDispatcher, TEntityAction.Request (message.Support.Argument.Types.EntityAction));
            }

            // Cleanup
            if (message.IsAction (TInternalMessageAction.Cleanup)) {
              TDispatcher.Invoke (RefreshDesignDispatcher);
            }
          }
        }
      }
    }
Esempio n. 25
0
        internal void Select(TEntityAction entityAction)
        {
            // DATA IN:
            // action.CollectionAction.ModelCollection

            entityAction.ThrowNull();

            //Registrations.Clear ();
            ItemsSource.Clear();

            var gadgets = new Collection <TActionComponent> ();

            TActionConverter.Collection(TCategory.Registration, gadgets, entityAction);

            foreach (var model in gadgets)
            {
                ItemsSource.Add(model.Models.GadgetRegistrationModel);
            }

            //foreach (var gadget in action.CollectionAction.GadgetRegistrationCollection) {
            //  if (action.CollectionAction.ModelCollection.ContainsKey (gadget.Id)) {
            //    var modelAction = action.CollectionAction.ModelCollection [gadget.Id];
            //    modelAction.GadgetRegistrationModel.CopyFrom (gadget);

            //    action.ModelAction.CopyFrom (modelAction);

            //    var item = TComponentModelItem.Create (action);

            //    Registrations.Add (item);
            //    RegistrationItemsSource.Add (item);
            //  }
            //}

            SelectedIndex = ItemsSource.Any() ? 0 : -1;
        }
Esempio n. 26
0
    void ResponseDataDispatcher (TEntityAction action)
    {
      // Collection - Full (Target list)
      Model.Select (action);

      TDispatcher.Invoke (RefreshAllDispatcher);
    }
Esempio n. 27
0
    public static void Collection (Collection<TActionComponent> gadgets, TEntityAction entityAction)
    {
      if (gadgets.NotNull ()) {
        gadgets.Clear ();

        if (entityAction.NotNull ()) {
          if (entityAction.CategoryType.IsCategory (TCategory.Target)) {
            var gadgetCollection = new Collection<GadgetTarget> ();

            foreach (var item in entityAction.CollectionAction.ModelCollection) {
              var modelAction = item.Value;
              var gadget = GadgetTarget.CreateDefault;

              gadget.Id = modelAction.ComponentInfoModel.Id;
              gadget.MaterialId = modelAction.ExtensionNodeModel.ParentId;
              gadget.GadgetName = modelAction.ExtensionTextModel.Text;
              gadget.Description = modelAction.ExtensionTextModel.Description;
              gadget.Reference = modelAction.ExtensionTextModel.Reference;
              gadget.Value = modelAction.ExtensionTextModel.Value;
              gadget.ExternalLink = modelAction.ExtensionTextModel.ExternalLink;
              gadget.Enabled = modelAction.ComponentInfoModel.Enabled;

              gadget.GadgetInfo = modelAction.ComponentInfoModel.Name;
              gadget.Busy = modelAction.ComponentStatusModel.Busy;

              //  // Has only one child node (GadgetMaterial)
              foreach (var node in entityAction.CollectionAction.ExtensionNodeCollection) {
                // gadget Target must be child here
                if (gadget.Contains (node.ChildId)) {
                  modelAction.ExtensionNodeModel.ChildId = node.ChildId;
                  modelAction.ExtensionNodeModel.ChildCategory = node.ChildCategory;
                  modelAction.ExtensionNodeModel.ParentId = node.ParentId;
                  modelAction.ExtensionNodeModel.ParentCategory = node.ParentCategory;

                  gadget.MaterialId = gadget.MaterialId.IsEmpty () ? node.ParentId : gadget.MaterialId;  // must be child

                  break;
                }
              }

              gadgetCollection.Add (gadget);
            }

            // sort
            var list = gadgetCollection
              .OrderBy (p => p.GadgetInfo)
              .ToList ()
            ;

            foreach (var model in list) {
              var component = TActionComponent.Create (TCategory.Target);
              component.Models.GadgetTargetModel.CopyFrom (model);

              gadgets.Add (component);
            }
          }
        }
      }
    }
Esempio n. 28
0
    void ApplyDispatcher (TEntityAction action)
    {
      // to parent
      var message = new TFactoryMessageInternal (TInternalMessageAction.Request, TChild.Property, TypeInfo);
      message.Support.Argument.Types.Select (action);

      DelegateCommand.PublishInternalMessage.Execute (message);
    }
Esempio n. 29
0
    void RequestModelDispatcher (TEntityAction action)
    {
      // request from Sibling
      var message = new TFactorySiblingMessageInternal (TInternalMessageAction.Request, TChild.Property, TypeInfo);
      message.Support.Argument.Types.Select (action);

      DelegateCommand.PublishInternalMessage.Execute (message);
    }
Esempio n. 30
0
    void ResponseSelectByIdDispatcher (TEntityAction action)
    {
      // to Sibling (Select)
      var message = new TCollectionSiblingMessageInternal (TInternalMessageAction.Select, TChild.List, TypeInfo);
      message.Support.Argument.Types.Item.CopyFrom (TComponentModelItem.Create (action));

      DelegateCommand.PublishInternalMessage.Execute (message);
    }