Пример #1
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 ();
    }
Пример #2
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);
    }
Пример #3
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);
      }
    }
Пример #4
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);
    }
Пример #5
0
        internal void Request(TActionComponent component)
        {
            component.ThrowNull();

            var entityAction = TEntityAction.Create(TCategory.Registration);

            ComponentModelProperty.RequestModel(entityAction);

            TActionConverter.Select(TCategory.Registration, component, entityAction);
        }
Пример #6
0
    void RemoveDispatcher ()
    {
      var entityAction = TEntityAction.Create (TCategory.Test, TOperation.Remove);
      entityAction.Id = Model.GadgetModel.Id;

      // to parent
      var message = new TCollectionMessageInternal (TInternalMessageAction.Request, TChild.Display, TypeInfo);
      message.Support.Argument.Types.Select (entityAction);

      DelegateCommand.PublishInternalMessage.Execute (message);
    }
Пример #7
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;
            }
          }
        }
      }
    }
Пример #8
0
    void ApplyDispatcher ()
    {
      var action = TEntityAction.Create (TCategory.Settings, TOperation.Change, TExtension.Settings);

      Model.Request (action);

      // to module
      var messageModule = new TFactoryMessage (TMessageAction.Request, TypeInfo);
      messageModule.Support.Argument.Types.Select (action);

      DelegateCommand.PublishMessage.Execute (messageModule);
    } 
Пример #9
0
    void RemoveDispatcher ()
    {
      // Remove
      var action = TEntityAction.Create (Server.Models.Infrastructure.TCategory.Target, Server.Models.Infrastructure.TOperation.Remove);
      action.Id = Model.Id;

      // to parent
      var message = new TCollectionMessageInternal (TInternalMessageAction.Request, TChild.Display, TypeInfo);
      message.Support.Argument.Types.Select (action);

      DelegateCommand.PublishInternalMessage.Execute (message);
    }
Пример #10
0
    void SelectById (TModelContext context, TEntityAction action)
    {
      /*
      DATA IN
      - action.Id 
      - action.CollectionAction.CategoryRelationCollection

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

      try {
        // Id must exist
        if (action.Id.IsEmpty ()) {
          action.Result = new TValidationResult ("[Select ById] Id can NOT be NULL or EMPTY!");
        }

        else {
          action.Result = TValidationResult.Success; // desired result DO NOT MOVE FROM HERE

          // relation by id (use parent)
          action.CollectionAction.SelectComponentOperation (TComponentOperation.TInternalOperation.Id);
          action.ComponentOperation.SelectById (action.Id);

          var operationSupport = new TOperationSupport (context, action);
          operationSupport.RequestComponent (context, action);
          operationSupport.RequestExtension (context, action);
          TOperationSupport.RequestNode (context, action);
          TOperationSupport.RequestRelation (context, action);

          // use Parent relation
          if (action.ComponentOperation.ParentIdCollection.ContainsKey (action.Id)) {
            var componentRelationList = action.ComponentOperation.ParentIdCollection [action.Id];

            foreach (var relation in componentRelationList) {
              var entityAction = TEntityAction.Create (TCategoryType.FromValue (relation.ChildCategory));
              entityAction.CollectionAction.SetCollection (action.CollectionAction.CategoryRelationCollection);
              entityAction.Id = relation.ChildId;

              SelectById (context, entityAction); // my self (tree navigation)

              action.CollectionAction.EntityCollection.Add (relation.ChildId, entityAction);
            }
          }
        }
      }

      catch (Exception exception) {
        Server.Models.Infrastructure.THelper.FormatException ("Select ById", exception, action);
      }
    }
Пример #11
0
    void RemoveDispatcher ()
    {
      var component = TActionComponent.Create (TCategory.Material);
      Model.Request (component);

      var action = TEntityAction.Create (TCategory.Material, TOperation.Remove);
      action.Param2 = component;

      // to parent
      var message = new TCollectionMessageInternal (TInternalMessageAction.Request, TChild.Display, TypeInfo);
      message.Support.Argument.Types.Select (action);

      DelegateCommand.PublishInternalMessage.Execute (message);
    }
Пример #12
0
    void RequestDataDispatcher ()
    {
      // to parent
      // Material - Collection - Full (Material list - used to send RefreshModel)
      var entityAction = TEntityAction.Create (
        TCategory.Material,
        TOperation.Collection,
        TExtension.Full
      );

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

      DelegateCommand.PublishInternalMessage.Execute (message);
    }
Пример #13
0
    void RequestDataDispatcher ()
    {
      // to parent
      // Collection - Full (Target)
      var action = TEntityAction.Create (
        Server.Models.Infrastructure.TCategory.Target,
        Server.Models.Infrastructure.TOperation.Collection,
        Server.Models.Infrastructure.TExtension.Full
      );

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

      DelegateCommand.PublishInternalMessage.Execute (message);
    }
Пример #14
0
    public void OnApplyCommadClicked ()
    {
      Model.ShowPanels ();
      ApplyChanges ();

      var action = TEntityAction.Create (TCategory.Material, TOperation.Insert);

      if (IsViewModeEdit) {
        action = TEntityAction.Create (TCategory.Material, TOperation.Change, TExtension.Full);
      }

      Model.RequestModel (action);

      TDispatcher.BeginInvoke (ApplyDispatcher, action);
    }
Пример #15
0
    public void OnApplyCommadClicked ()
    {
      Model.ShowPanels ();
      ApplyChanges ();

      // Insert
      var action = TEntityAction.Create (TCategory.Result, TOperation.Insert);

      if (IsViewModeEdit) {
        // Change-Full
        action = TEntityAction.Create (TCategory.Result, TOperation.Change, TExtension.Full);
      }

      TDispatcher.BeginInvoke (RequestModelDispatcher, action);
    }
Пример #16
0
    public void OnApplyCommadClicked ()
    {
      Model.ShowPanels ();
      ApplyChanges ();

      // Insert
      var action = TEntityAction.Create (Server.Models.Infrastructure.TCategory.Report, Server.Models.Infrastructure.TOperation.Insert);

      if (IsViewModeEdit) {
        // Change-Full
        action = TEntityAction.Create (Server.Models.Infrastructure.TCategory.Report, Server.Models.Infrastructure.TOperation.Change, Server.Models.Infrastructure.TExtension.Full);
      }

      Model.RequestModel (action);

      TDispatcher.BeginInvoke (ApplyDispatcher, action);
    }
Пример #17
0
    void ItemCheckedChangedDispatcher (GadgetTest gadget)
    {
      // to parent
      // Select = ById (Test) 
      var action = TEntityAction.Create (
        TCategory.Test,
        TOperation.Select,
        TExtension.ById
      );

      action.Id = gadget.Id;
      action.Param2 = gadget; // preserve

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

      DelegateCommand.PublishInternalMessage.Execute (message);
    }
Пример #18
0
    void PropertySelect (string propertyName)
    {
      if (propertyName.Equals ("TextProperty", StringComparison.InvariantCulture)) {
        Model.ValidateProperty ();
      }

      var action = TEntityAction.Create(TCategory.Test);
      Model.RequestModel (action);

      // to Sibling
      var message = new TFactorySiblingMessageInternal (TInternalMessageAction.PropertySelect, TChild.Property, TypeInfo);
      message.Support.Argument.Types.Select (action);
      message.Support.Argument.Args.Select (propertyName);

      DelegateCommand.PublishInternalMessage.Execute (message);

      ApplyChanges ();
    }
Пример #19
0
    void ResponseDataDispatcher (TEntityAction action)
    {
      // Collection - Full (Target list)
      Model.Select (action);

      TDispatcher.Invoke (RefreshAllDispatcher);

      // to parent
      // Collection - Full (Material list - used to send RefreshModel)
      var entityAction = TEntityAction.Create (
        Server.Models.Infrastructure.TCategory.Material,
        Server.Models.Infrastructure.TOperation.Collection,
        Server.Models.Infrastructure.TExtension.Full
      );

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

      DelegateCommand.PublishInternalMessage.Execute (message);
    }
Пример #20
0
    void ModifyCommandDispatcher ()
    {
      var component = TActionComponent.Create (TCategory.Result);
      Model.Request (component);

      var gadget = component.Models.GadgetResultModel;

      var action = TEntityAction.Create (TCategory.Result);
      action.Id = gadget.Id;

      TActionConverter.Request (TCategory.Result, component, action);

      // Result - Change - Content
      var entityAction = TEntityAction.Create (TCategory.Result, TOperation.Change, TExtension.Content);
      entityAction.CollectionAction.EntityCollection.Add (gadget.Id, action);

      // to parent
      var message = new TFactoryMessageInternal (TInternalMessageAction.Request, TChild.List, TypeInfo);
      message.Support.Argument.Types.Select (entityAction);

      DelegateCommand.PublishInternalMessage.Execute (message);
    }
Пример #21
0
    void ChangeSuccessDispatcher ()
    {
      if (Model.CanLock && m_CanLock) {
        m_CanLock = false;

        var component = TActionComponent.Create (TCategory.Result);
        Model.RequestLockedStatus (component);

        // Result - Change - Status
        var entityAction = TEntityAction.Create (TCategory.Result, TOperation.Change, TExtension.Status);
        TActionConverter.ModifyStatus (TCategory.Result, component, entityAction);

        // to parent
        var message = new TFactoryMessageInternal (TInternalMessageAction.Request, TChild.List, TypeInfo);
        message.Support.Argument.Types.Select (entityAction);

        DelegateCommand.PublishInternalMessage.Execute (message);
      }

      else {
        TDispatcher.Invoke (CleanupDispatcher);
      }
    }
Пример #22
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);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }