Ejemplo n.º 1
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);
              }
            }
          }
        }
      }
    }
Ejemplo n.º 2
0
    public static void Select (TActionComponent component, TEntityAction entityAction)
    {
      if (entityAction.NotNull ()) {
        if (entityAction.CategoryType.IsCategory (TCategory.Target)) {
          if (component.NotNull ()) {
            component.Select (TCategory.Target);

            component.Models.GadgetTargetModel.Id = entityAction.ModelAction.ComponentInfoModel.Id;
            component.Models.GadgetTargetModel.MaterialId = entityAction.ModelAction.ExtensionNodeModel.ParentId;
            component.Models.GadgetTargetModel.GadgetName = entityAction.ModelAction.ExtensionTextModel.Text;
            component.Models.GadgetTargetModel.Description = entityAction.ModelAction.ExtensionTextModel.Description;
            component.Models.GadgetTargetModel.Reference = entityAction.ModelAction.ExtensionTextModel.Reference;
            component.Models.GadgetTargetModel.Value = entityAction.ModelAction.ExtensionTextModel.Value;
            component.Models.GadgetTargetModel.ExternalLink = entityAction.ModelAction.ExtensionTextModel.ExternalLink;
            component.Models.GadgetTargetModel.Enabled = entityAction.ModelAction.ComponentInfoModel.Enabled;

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

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

                component.Models.GadgetTargetModel.MaterialId = component.Models.GadgetTargetModel.MaterialId.IsEmpty () ? node.ParentId : component.Models.GadgetTargetModel.MaterialId;  // must be child

                break;
              }
            }

            // update Material
            var materialId = component.Models.GadgetTargetModel.MaterialId;

            if (entityAction.CollectionAction.ModelCollection.ContainsKey (materialId)) {
              var action = TEntityAction.Create (TCategory.Material);
              action.ModelAction.CopyFrom (entityAction.CollectionAction.ModelCollection [materialId]);

              var componentMaterial = TActionComponent.Create (TCategory.Material);
              TActionConverter.Select (TCategory.Material, componentMaterial, action);

              var gadgetMaterial = componentMaterial.Models.GadgetMaterialModel;

              component.Models.GadgetMaterialModel.CopyFrom (gadgetMaterial);
              component.Models.GadgetTargetModel.Material = gadgetMaterial.Material;
            }
          }
        }
      }
    }
Ejemplo n.º 3
0
    public static void SelectMany (Collection<TActionComponent> gadgets, TEntityAction entityAction)
    {
      //entityAction.CollectionAction.EntityCollection

      if (entityAction.NotNull ()) {
        if (entityAction.CategoryType.IsCategory (TCategory.Test)) {
          if (gadgets.NotNull ()) {
            foreach (var component in gadgets) {
              var gadget = component.Models.GadgetTestModel;

              if (entityAction.CollectionAction.EntityCollection.ContainsKey (gadget.Id)) {
                var action = entityAction.CollectionAction.EntityCollection [gadget.Id];

                var idCollection = new Collection<Guid> ();
                gadget.RequestContentId (idCollection);

                // target
                if (gadget.HasContentTarget) {
                  foreach (var id in idCollection) {
                    if (action.CollectionAction.EntityCollection.ContainsKey (id)) {
                      var gadgetEntityAction = action.CollectionAction.EntityCollection [id];
                      var someComponent = TActionComponent.Create (TCategory.Target);

                      TActionConverter.Select (TCategory.Target, someComponent, gadgetEntityAction);

                      gadget.AddContent (someComponent.Models.GadgetTargetModel);

                      // same material always
                      if (component.Models.GadgetMaterialModel.ValidateId.IsFalse ()) {
                        component.Models.GadgetMaterialModel.CopyFrom (someComponent.Models.GadgetMaterialModel);
                      }
                    }
                  }
                }

                // test
                if (gadget.HasContentTest) {
                  foreach (var id in idCollection) {
                    if (action.CollectionAction.EntityCollection.ContainsKey (id)) {
                      var gadgetEntityAction = action.CollectionAction.EntityCollection [id];
                      var someComponent = TActionComponent.Create (TCategory.Test);

                      TActionConverter.Select (TCategory.Test, someComponent, gadgetEntityAction);

                      gadget.AddContent (someComponent.Models.GadgetTestModel);

                      // update Material
                      if (component.Models.GadgetMaterialModel.ValidateId.IsFalse ()) {
                        component.Models.GadgetMaterialModel.CopyFrom (someComponent.Models.GadgetMaterialModel);
                      }
                    }
                  }
                }

                // update image
                gadget.SetImage (component.Models.GadgetMaterialModel.GetImage ());
              }
            }
          }
        }
      }
    }
Ejemplo n.º 4
0
    public static void Select (TActionComponent component, TEntityAction entityAction)
    {
      if (entityAction.NotNull ()) {
        if (entityAction.CategoryType.IsCategory (TCategory.Test)) {
          if (component.NotNull ()) {
            component.Select (TCategory.Test);

            component.Models.GadgetTestModel.Id = entityAction.ModelAction.ComponentInfoModel.Id;
            component.Models.GadgetTestModel.GadgetName = entityAction.ModelAction.ExtensionTextModel.Text;
            component.Models.GadgetTestModel.Description = entityAction.ModelAction.ExtensionTextModel.Description;
            component.Models.GadgetTestModel.ExternalLink = entityAction.ModelAction.ExtensionTextModel.ExternalLink;
            component.Models.GadgetTestModel.Material = entityAction.ModelAction.ExtensionTextModel.Extension;
            component.Models.GadgetTestModel.Enabled = entityAction.ModelAction.ComponentInfoModel.Enabled;

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

            // update
            if (component.Models.GadgetTestModel.ValidateId) {
              // content list
              foreach (var item in entityAction.ComponentOperation.ParentIdCollection) {
                foreach (var relation in item.Value) {
                  component.Models.GadgetTestModel.AddContentId (relation.ChildId);
                }
              }

              var idCollection = new Collection<Guid> ();
              component.Models.GadgetTestModel.RequestContentId (idCollection);

              foreach (var id in idCollection) {
                if (entityAction.CollectionAction.EntityCollection.ContainsKey (id)) {
                  var gadgetEntityAction = entityAction.CollectionAction.EntityCollection [id];

                  // target
                  if (gadgetEntityAction.CategoryType.IsCategory (TCategory.Target)) {
                    var componentTarget = TActionComponent.Create (TCategory.Target);
                    TActionConverter.Select (TCategory.Target, componentTarget, gadgetEntityAction);

                    component.Models.GadgetTestModel.AddContent (componentTarget.Models.GadgetTargetModel);

                    // same material always
                    if (component.Models.GadgetMaterialModel.ValidateId.IsFalse ()) {
                      component.Models.GadgetMaterialModel.CopyFrom (componentTarget.Models.GadgetMaterialModel);
                    }
                  }

                  // test
                  if (gadgetEntityAction.CategoryType.IsCategory (TCategory.Test)) {
                    var componentTest = TActionComponent.Create (TCategory.Test);
                    TActionConverter.Select (TCategory.Test, componentTest, gadgetEntityAction);

                    component.Models.GadgetTestModel.AddContent (componentTest.Models.GadgetTestModel);

                    // update Material
                    if (component.Models.GadgetMaterialModel.ValidateId.IsFalse ()) {
                      component.Models.GadgetMaterialModel.CopyFrom (componentTest.Models.GadgetMaterialModel);
                    }
                  }

                  // update image
                  component.Models.GadgetTestModel.Select (component.Models.GadgetMaterialModel);
                }
              }
            }
          }
        }
      }
    }
Ejemplo n.º 5
0
    public static void ModifyValue (TActionComponent component, TEntityAction entityAction)
    {
      if (component.NotNull ()) {
        if (entityAction.NotNull ()) {
          entityAction.CollectionAction.EntityCollection.Clear ();

          if (component.IsCategory (TCategory.Result)) {
            var gadgetResult = component.Models.GadgetResultModel;

            if (gadgetResult.HasContent) {
              var gadgetTestContent = new Collection<GadgetTest> ();
              gadgetResult.RequestContent (gadgetTestContent);

              foreach (var gadget in gadgetTestContent) {
                if (gadget.HasContent) {
                  // Target
                  if (gadget.HasContentTarget) {
                    var contentGadgetTarget = new Collection<GadgetTarget> ();
                    gadget.RequestContent (contentGadgetTarget);

                    foreach (var gadgetTarget in contentGadgetTarget) {
                      var action = TEntityAction.Create (TCategory.Target);
                      action.Id = gadgetTarget.Id;

                      var componentTarget = TActionComponent.Create (TCategory.Target);
                      componentTarget.Models.GadgetTargetModel.CopyFrom (gadgetTarget);

                      TActionConverter.Request (TCategory.Target, componentTarget, action);

                      entityAction.CollectionAction.EntityCollection.Add (gadgetTarget.Id, action);
                    }
                  }

                  // Test
                  if (gadget.HasContentTest) {
                    var contentGadgetTest = new Collection<GadgetTest> ();
                    gadget.RequestContent (contentGadgetTest);

                    foreach (var gadgetTest in contentGadgetTest) {
                      if (gadgetTest.HasContent) {
                        if (gadgetTest.HasContentTarget) {
                          var contentGadgetTarget = new Collection<GadgetTarget> ();
                          gadgetTest.RequestContent (contentGadgetTarget);

                          foreach (var gadgetTarget in contentGadgetTarget) {
                            var action = TEntityAction.Create (TCategory.Target);
                            action.Id = gadgetTarget.Id;

                            var componentTarget = TActionComponent.Create (TCategory.Target);
                            componentTarget.Models.GadgetTargetModel.CopyFrom (gadgetTarget);

                            TActionConverter.Request (TCategory.Target, componentTarget, action);

                            entityAction.CollectionAction.EntityCollection.Add (gadgetTarget.Id, action);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }