Exemplo n.º 1
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;
     }
   }
 }
Exemplo 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;
            }
          }
        }
      }
    }
Exemplo n.º 3
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 ();
          }
        }
      }
    }
Exemplo n.º 4
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;
          }
        }
      }
    }
Exemplo n.º 5
0
    public static void Request (TActionComponent component, TEntityAction entityAction)
    {
      if (component.NotNull ()) {
        if (component.IsCategory (TCategory.Test)) {
          if (entityAction.NotNull ()) {
            entityAction.Id = component.Models.GadgetTestModel.Id;
            entityAction.CategoryType.Select (TCategory.Test);

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

            entityAction.ModelAction.ComponentInfoModel.Id = component.Models.GadgetTestModel.Id;
            entityAction.ModelAction.ExtensionTextModel.Id = component.Models.GadgetTestModel.Id;
            entityAction.ModelAction.ExtensionTextModel.Text = component.Models.GadgetTestModel.GadgetName;
            entityAction.ModelAction.ExtensionTextModel.Description = component.Models.GadgetTestModel.Description;
            entityAction.ModelAction.ExtensionTextModel.ExternalLink = component.Models.GadgetTestModel.ExternalLink;
            entityAction.ModelAction.ComponentInfoModel.Enabled = component.Models.GadgetTestModel.Enabled;
          }
        }
      }
    }
Exemplo n.º 6
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;
          }
        }
      }
    }
Exemplo n.º 7
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;
          }
        }
      }
    }
Exemplo n.º 8
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;
                    }
                }
            }
        }
Exemplo n.º 9
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);
                }
              }
            }
          }
        }
      }
    }
Exemplo n.º 10
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);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }