Beispiel #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);
              }
            }
          }
        }
      }
    }
Beispiel #2
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;
        }
      }
    }
Beispiel #3
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;
          }
        }
      }
    }
Beispiel #4
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();
                    }
                }
            }
        }
Beispiel #5
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);
            }
          }
        }
      }
    }
Beispiel #6
0
    public static void Collection (Collection<TActionComponent> gadgets, TEntityAction entityAction)
    {
      if (gadgets.NotNull ()) {
        gadgets.Clear ();

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

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

              gadget.Id = modelAction.ComponentInfoModel.Id;
              gadget.GadgetName = modelAction.ExtensionTextModel.Text;
              gadget.Description = modelAction.ExtensionTextModel.Description;
              gadget.ExternalLink = modelAction.ExtensionTextModel.ExternalLink;
              gadget.SetDate (modelAction.ExtensionTextModel.Date);
              gadget.Enabled = modelAction.ComponentInfoModel.Enabled;

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

              if (modelAction.ExtensionContentModel.Id.Equals (gadget.Id)) {
                string [] contentClientString = Regex.Split (modelAction.ExtensionContentModel.Contents, ";");

                // Jason serializer
                foreach (var jasonClientString in contentClientString) {
                  if (string.IsNullOrEmpty (jasonClientString).IsFalse ()) {
                    var jason = new TJasonSerializer<TContentClient> (new TContentClient ());
                    jason.ToClient (jasonClientString);
                    jason.Client.Request (gadget);
                  }
                }
              }

              gadgetCollection.Add (gadget);
            }

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

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

              gadgets.Add (component);
            }
          }
        }
      }
    }
Beispiel #7
0
 public static void ModifyStatus (TCategory category, TActionComponent component, TEntityAction entityAction)
 {
   if (component.NotNull () && entityAction.NotNull ()) {
     switch (category) {
       case TCategory.Result:
         TGadgetResultConverter.ModifyStatus (component, entityAction);
         break;
     }
   }
 }
Beispiel #8
0
    public static void Request (TActionComponent component, TEntityAction entityAction)
    {
      if (component.NotNull ()) {
        if (component.IsCategory (TCategory.Result)) {
          var gadget = component.Models.GadgetResultModel;

          if (entityAction.NotNull ()) {
            entityAction.Id = gadget.Id;
            entityAction.CategoryType.Select (TCategory.Result);

            entityAction.ModelAction.ComponentInfoModel.Id = gadget.Id;
            entityAction.ModelAction.ComponentInfoModel.Name = gadget.GadgetInfo;
            entityAction.ModelAction.ComponentInfoModel.Enabled = gadget.Enabled;

            entityAction.ModelAction.ComponentStatusModel.Id = gadget.Id;
            entityAction.ModelAction.ComponentStatusModel.Busy = gadget.Busy;
            entityAction.ModelAction.ComponentStatusModel.Locked = gadget.Locked;
            
            entityAction.ModelAction.ExtensionTextModel.Id = gadget.Id;
            entityAction.ModelAction.ExtensionTextModel.Text = gadget.GadgetName;
            entityAction.ModelAction.ExtensionTextModel.Date = gadget.Date;
            entityAction.ModelAction.ExtensionTextModel.Description = gadget.Description;

            // Jason serializer
            var clientList = new Collection<TContentClient> ();

            var contentRegistration = GadgetRegistration.CreateDefault;
            gadget.RequestContent (contentRegistration);
            clientList.Add (new TContentClient (contentRegistration));

            var contents = new Collection<GadgetTest> ();
            gadget.RequestContent (contents);

            foreach (var item in contents) {
              clientList.Add (new TContentClient (item));
            }

            StringBuilder contentString = new StringBuilder ();

            foreach (var item in clientList) {
              var jason = new TJasonSerializer<TContentClient> (item);
              jason.ToJsonString ();
              var str = jason.JasonString + ";";
              contentString.Append (str);
            }

            entityAction.ModelAction.ExtensionContentModel.Id = gadget.Id;
            entityAction.ModelAction.ExtensionContentModel.Category = TCategoryType.ToValue (TCategory.Result);
            entityAction.ModelAction.ExtensionContentModel.Contents = contentString.ToString ();
          }
        }
      }
    }
Beispiel #9
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;
            }
          }
        }
      }
    }
Beispiel #10
0
        public static void Collection(Collection <TActionComponent> gadgets, TEntityAction entityAction)
        {
            if (gadgets.NotNull())
            {
                gadgets.Clear();

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

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

                            gadget.Id           = modelAction.ComponentInfoModel.Id;
                            gadget.GadgetName   = modelAction.ExtensionTextModel.Text;
                            gadget.Description  = modelAction.ExtensionTextModel.Description;
                            gadget.ExternalLink = modelAction.ExtensionTextModel.ExternalLink;
                            gadget.SetImage(modelAction.ExtensionImageModel.Image);
                            gadget.Enabled = modelAction.ComponentInfoModel.Enabled;

                            gadget.GadgetInfo = modelAction.ComponentInfoModel.Name;
                            gadget.Busy       = modelAction.ComponentStatusModel.Busy;
                            gadget.Material   = modelAction.ExtensionTextModel.Text;

                            gadgetCollection.Add(gadget);
                        }

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

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

                            gadgets.Add(component);
                        }
                    }
                }
            }
        }
Beispiel #11
0
    public static void ModifyStatus (TActionComponent component, TEntityAction entityAction)
    {
      if (component.NotNull ()) {
        if (entityAction.NotNull ()) {
          if (component.IsCategory (TCategory.Result)) {
            var gadget = component.Models.GadgetResultModel;

            entityAction.Id = gadget.Id;
            entityAction.CategoryType.Select (TCategory.Result);

            entityAction.ModelAction.ComponentStatusModel.Id = gadget.Id;
            entityAction.ModelAction.ComponentStatusModel.Busy = gadget.Busy;
            entityAction.ModelAction.ComponentStatusModel.Locked = gadget.Locked;
          }
        }
      }
    }
Beispiel #12
0
    public static void Select (TActionComponent component, TEntityAction entityAction)
    {
      if (entityAction.NotNull ()) {
        if (entityAction.CategoryType.IsCategory (TCategory.Registration)) {
          if (component.NotNull ()) {
            component.Select (TCategory.Registration);

            var gadget = component.Models.GadgetRegistrationModel;
            gadget.Id = entityAction.ModelAction.ComponentInfoModel.Id;
            gadget.GadgetName = entityAction.ModelAction.ExtensionTextModel.Text;
            gadget.SetDate (entityAction.ModelAction.ExtensionTextModel.Date);
            gadget.Description = entityAction.ModelAction.ExtensionTextModel.Description;
            gadget.ExternalLink = entityAction.ModelAction.ExtensionTextModel.ExternalLink;
            gadget.SetImage (entityAction.ModelAction.ExtensionImageModel.Image);
            gadget.Enabled = entityAction.ModelAction.ComponentInfoModel.Enabled;

            gadget.GadgetInfo = entityAction.ModelAction.ComponentInfoModel.Name;
            gadget.Busy = entityAction.ModelAction.ComponentStatusModel.Busy;
          }
        }
      }
    }
Beispiel #13
0
    public static void Request (TActionComponent component, TEntityAction entityAction)
    {
      if (component.NotNull ()) {
        if (component.IsCategory (TCategory.Report)) {
          var gadget = component.Models.GadgetReportModel;

          if (entityAction.NotNull ()) {
            entityAction.Id = gadget.Id;
            entityAction.CategoryType.Select (TCategory.Report);

            entityAction.ModelAction.ComponentInfoModel.Name = gadget.GadgetInfo;
            entityAction.ModelAction.ComponentStatusModel.Busy = gadget.Busy;

            entityAction.ModelAction.ComponentInfoModel.Id = gadget.Id;
            entityAction.ModelAction.ExtensionTextModel.Id = gadget.Id;
            entityAction.ModelAction.ExtensionTextModel.Text = gadget.GadgetName;
            entityAction.ModelAction.ExtensionTextModel.Date = gadget.Date;
            entityAction.ModelAction.ExtensionTextModel.Description = gadget.Description;
            entityAction.ModelAction.ComponentInfoModel.Enabled = gadget.Enabled;
          }
        }
      }
    }
Beispiel #14
0
        public static void Select(TActionComponent component, TEntityAction entityAction)
        {
            if (entityAction.NotNull())
            {
                if (entityAction.CategoryType.IsCategory(TCategory.Material))
                {
                    if (component.NotNull())
                    {
                        component.Select(TCategory.Material);

                        component.Models.GadgetMaterialModel.Id           = entityAction.ModelAction.ComponentInfoModel.Id;
                        component.Models.GadgetMaterialModel.GadgetName   = entityAction.ModelAction.ExtensionTextModel.Text;
                        component.Models.GadgetMaterialModel.Description  = entityAction.ModelAction.ExtensionTextModel.Description;
                        component.Models.GadgetMaterialModel.ExternalLink = entityAction.ModelAction.ExtensionTextModel.ExternalLink;
                        component.Models.GadgetMaterialModel.SetImage(entityAction.ModelAction.ExtensionImageModel.Image);
                        component.Models.GadgetMaterialModel.Enabled = entityAction.ModelAction.ComponentInfoModel.Enabled;

                        component.Models.GadgetMaterialModel.GadgetInfo = entityAction.ModelAction.ComponentInfoModel.Name;
                        component.Models.GadgetMaterialModel.Busy       = entityAction.ModelAction.ComponentStatusModel.Busy;
                        component.Models.GadgetMaterialModel.Material   = entityAction.ModelAction.ExtensionTextModel.Text;
                    }
                }
            }
        }
Beispiel #15
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);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
Beispiel #16
0
    public static void Collection (Collection<TActionComponent> gadgets, TEntityAction entityAction)
    {
      if (gadgets.NotNull ()) {
        gadgets.Clear ();

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

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

              gadget.Id = modelAction.ComponentInfoModel.Id;
              gadget.GadgetName = modelAction.ExtensionTextModel.Text;
              gadget.Description = modelAction.ExtensionTextModel.Description;
              gadget.ExternalLink = modelAction.ExtensionTextModel.ExternalLink;
              gadget.Material = modelAction.ExtensionTextModel.Extension;
              gadget.Enabled = modelAction.ComponentInfoModel.Enabled;

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

              // update
              if (entityAction.CollectionAction.ComponentRelationCollection.Count.Equals (0)) {
                foreach (var componentRelation in entityAction.CollectionAction.ComponentOperation.ParentCategoryCollection) {
                  foreach (var relation in componentRelation.Value) {
                    entityAction.CollectionAction.ComponentRelationCollection.Add (relation);
                  }
                }
              }

              foreach (var relation in entityAction.CollectionAction.ComponentRelationCollection) {
                if (relation.ParentId.IsEmpty ()) {
                  gadget.AddContentId (relation.ChildId);
                }

                else {
                  if (gadget.Contains (relation.ParentId)) {
                    gadget.AddContentId (relation.ChildId);
                  }
                }
              }

              gadgetCollection.Add (gadget);
            }

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

            foreach (var gadgetTest in list) {
              // update Content
              if (gadgetTest.HasContent) {
                var idList = new Collection<Guid> ();
                gadgetTest.RequestContentId (idList);

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

                    // Target
                    if (action.CategoryType.IsCategory (TCategory.Target)) {
                      var componentTarget = TActionComponent.Create (TCategory.Target);
                      TGadgetTargetConverter.Select (componentTarget, action);

                      gadgetTest.AddContent (componentTarget.Models.GadgetTargetModel);
                    }

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

                      gadgetTest.AddContent (componentTest.Models.GadgetTestModel);
                    }
                  }
                }
              }

              var component = TActionComponent.Create (TCategory.Test);
              component.Models.GadgetTestModel.CopyFrom (gadgetTest);

              gadgets.Add (component);
            }
          }
        }
      }
    }
Beispiel #17
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 ());
              }
            }
          }
        }
      }
    }
Beispiel #18
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);
                }
              }
            }
          }
        }
      }
    }