Beispiel #1
0
    public static void FormatExtensionNotImplementedException (IEntityAction entityAction)
    {
      if (entityAction.NotNull ()) {
        string msg = $"[component: {entityAction.Operation.CategoryType.Category} - operation: {entityAction.Operation.Operation}] - extension: {entityAction.Operation.Extension.ToString ()} Extension NOT implemented!";

        entityAction.Result.CopyFrom (new TValidationResult (msg));
      }
    }
Beispiel #2
0
    public static void FormatExtensionMustExistException (IEntityAction entityAction)
    {
      if (entityAction.NotNull ()) {
        string msg = $"[component: {entityAction.Operation.CategoryType.Category} - operation: {entityAction.Operation.Operation}] - extension: Extension MUST Exist!";

        entityAction.Result.CopyFrom (new TValidationResult (msg));
      }
    }
Beispiel #3
0
    public static void FormatException (string tag, Exception exception, IEntityAction entityAction)
    {
      if (entityAction.NotNull ()) {
        if (exception.NotNull ()) {
          string msg = $"[{entityAction.Operation.CategoryType.Category} {tag} - {entityAction.Operation.Operation}] {exception.Message}";

          if (exception.InnerException.NotNull ()) {
            msg = $"[component: {entityAction.Operation.CategoryType} {tag} - operation: {entityAction.Operation.Operation}] {exception.Message}{Environment.NewLine}{exception.InnerException.Message}";
          }

          entityAction.Result.CopyFrom (new TValidationResult (msg));
        }
      }
    }
Beispiel #4
0
    public void Invoke (IModelContext modelContext, IEntityAction entityAction, TExtension extension)
    {
      if (modelContext.NotNull ()) {
        var context = TModelContext.CastTo (modelContext);

        var relationList = context.CategoryRelation
          .ToList ()
        ;

        if (entityAction.NotNull ()) {
          var action = TEntityAction.Request (entityAction);
          action.CollectionAction.SetCollection (relationList);

          if (action.Operation.HasExtension) {
            switch (extension) {
              case TExtension.Full: {
                  CollectionFull (context, action);
                }
                break;

              case TExtension.Minimum: {
                  CollectionMinimum (context, action);
                }
                break;

              case TExtension.ById:
              case TExtension.Idle:
              case TExtension.Many:
              case TExtension.Zap: {
                  Models.Infrastructure.THelper.FormatExtensionNotImplementedException (action);
                }
                break;
            }
          }

          else {
            Models.Infrastructure.THelper.FormatExtensionMustExistException (action);
          }
        }
      }
    }
Beispiel #5
0
    public void Invoke (IModelContext modelContext, IEntityAction entityAction, Server.Models.Infrastructure.TExtension extension)
    {
      if (modelContext.NotNull ()) {
        var context = TModelContext.CastTo (modelContext);

        var relationList = context.CategoryRelation
          .ToList ()
        ;

        if (entityAction.NotNull ()) {
          var action = TEntityAction.Request (entityAction);
          action.CollectionAction.SetCollection (relationList);

          if (action.Operation.HasExtension) {
            Server.Models.Infrastructure.THelper.FormatExtensionNotImplementedException (action);
          }

          else {
            Insert (context, action);
          }
        }
      }
    }
Beispiel #6
0
    public Task<IEntityAction> OperationAsync (IEntityAction entityAction)
    {
      var task = Task.Factory.StartNew (() =>
        {
          if (entityAction.NotNull ()) {
            IModelContext context = Request (entityAction.ConnectionString);

            if (context.NotNull ()) {
              try {
                if (ContainsOperation (entityAction)) {
                  Invoke (context, entityAction);
                }

                else {
                // operation not found!
                string msg = $"context: {entityAction.Operation.CategoryType.Category} - operation: {entityAction.Operation.Operation} - NOT FOUND!";
                  entityAction.Result.CopyFrom (new rr.Library.Helper.TValidationResult (msg));
                }
              }

              catch (Exception exception) {
                THelper.FormatException ("Operation", exception, entityAction);
              }
            }

            context.DisposeNow ();
          }

          return (entityAction);
        }, 
        CancellationToken.None,
        TaskCreationOptions.None,
        TaskScheduler.Default
      );

      return (task);
    }
Beispiel #7
0
    public void Invoke (IModelContext modelContext, IEntityAction entityAction, TExtension extension)
    {
      if (modelContext.NotNull ()) {
        var context = TModelContext.CastTo (modelContext);

        var relationList = context.CategoryRelation
          .ToList ()
        ;

        if (entityAction.NotNull ()) {
          var action = TEntityAction.Request (entityAction);
          action.CollectionAction.SetCollection (relationList);

          if (action.Operation.HasExtension) {
            switch (extension) {
              case TExtension.Settings: {
                  SelectSettings (context, action);
                }
                break;

              case TExtension.ById: {
                  SelectById (context, action);
                }
                break;

              case TExtension.Relation: {
                  SelectRelation (context, action);
                }
                break;

              case TExtension.Many: {
                  SelectMany (context, action);
                }
                break;

              case TExtension.Node: {
                  SelectNode (context, action);
                }
                break;

              case TExtension.Zap: {
                  SelectZap (context, action);
                }
                break;

              case TExtension.Summary: {
                  SelectSummary (context, action);
                }
                break;

              case TExtension.Idle: {
                  //SelectIdle (context, action);
                }
                break;

              case TExtension.Full: {
                  Server.Models.Infrastructure.THelper.FormatExtensionNotImplementedException (action);
                }
                break;
            }
          }

          else {
            Server.Models.Infrastructure.THelper.FormatExtensionMustExistException (action);
          }
        }
      }
    }
Beispiel #8
0
 protected bool ContainsOperation (IEntityAction entityAction)
 {
   return (entityAction.NotNull () ? Operations.ContainsKey (entityAction.Operation.Operation) : false);
 }