Ejemplo n.º 1
0
        public MultiOperationResponse ExecuteMultiple([Required, FromBody] MultiOperationRequest request)
        {
            if (request.Setters.HasItems())
            {
                var errors = ForeachMultiple(request.Lites, lite =>
                {
                    var entity = lite.RetrieveAndForget();

                    MultiSetter.SetSetters(entity, request.Setters, PropertyRoute.Root(entity.GetType()));
                    var op = request.GetOperationSymbol(entity.GetType());
                    OperationLogic.ServiceExecute(entity, op, request.ParseArgs(op));
                });

                return(new MultiOperationResponse(errors));
            }
            else
            {
                var errors = ForeachMultiple(request.Lites, lite =>
                {
                    var op = request.GetOperationSymbol(lite.EntityType);
                    OperationLogic.ServiceExecuteLite(lite, op, request.ParseArgs(op));
                });

                return(new MultiOperationResponse(errors));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Execute()
        {
            Entity entity = null;

            if (this.IsLite())
            {
                Lite <Entity> lite = this.ExtractLite <Entity>();
                entity = OperationLogic.ServiceExecuteLite(lite, this.GetOperationKeyAssert(lite.EntityType));
            }
            else
            {
                MappingContext context = this.UntypedExtractEntity().UntypedApplyChanges(this).UntypedValidate();
                entity = (Entity)context.UntypedValue;

                if (context.HasErrors())
                {
                    return(context.ToJsonModelState());
                }

                try
                {
                    entity = OperationLogic.ServiceExecute(entity, this.GetOperationKeyAssert(entity.GetType()));
                }
                catch (IntegrityCheckException e)
                {
                    context.ImportErrors(e.Errors);
                    return(context.ToJsonModelState());
                }
            }

            return(this.DefaultExecuteResult(entity));
        }
Ejemplo n.º 3
0
        public EntityPackTS ExecuteEntity(EntityOperationRequest request)
        {
            Entity entity;

            try
            {
                entity = OperationLogic.ServiceExecute(request.entity, request.GetOperationSymbol(request.entity.GetType()), request.args);
            }
            catch (IntegrityCheckException ex)
            {
                GraphExplorer.SetValidationErrors(GraphExplorer.FromRoot(request.entity), ex);
                this.Validate(request, "request");
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, this.ModelState));
            }

            return(SignumServer.GetEntityPack(entity));
        }
Ejemplo n.º 4
0
        public ActionResult <EntityPackTS> ExecuteEntity([Required, FromBody] EntityOperationRequest request)
        {
            Entity entity;

            try
            {
                entity = OperationLogic.ServiceExecute(request.entity, request.GetOperationSymbol(request.entity.GetType()), request.args);
            }
            catch (IntegrityCheckException ex)
            {
                GraphExplorer.SetValidationErrors(GraphExplorer.FromRoot(request.entity), ex);
                this.TryValidateModel(request, "request");
                return(BadRequest(this.ModelState));
            }

            return(SignumServer.GetEntityPack(entity));
        }
Ejemplo n.º 5
0
        public void Execute(ExecutingProcess executingProcess)
        {
            PackageOperationEntity package = (PackageOperationEntity)executingProcess.Data;

            OperationSymbol operationSymbol = package.Operation;

            var args = package.OperationArgs;

            executingProcess.ForEachLine(package.Lines().Where(a => a.FinishTime == null), line =>
            {
                OperationType operationType = OperationLogic.OperationType(line.Target.GetType(), operationSymbol);

                switch (operationType)
                {
                case OperationType.Execute:
                    OperationLogic.ServiceExecute(line.Target, operationSymbol, args);
                    break;

                case OperationType.Delete:
                    OperationLogic.ServiceDelete(line.Target, operationSymbol, args);
                    break;

                case OperationType.ConstructorFrom:
                    {
                        var result  = OperationLogic.ServiceConstructFrom(line.Target, operationSymbol, args);
                        line.Result = result.ToLite();
                    }
                    break;

                default:
                    throw new InvalidOperationException("Unexpected operation type {0}".FormatWith(operationType));
                }

                line.FinishTime = TimeZoneManager.Now;
                line.Save();
            });
        }
Ejemplo n.º 6
0
 public Entity ExecuteOperation(IEntity entity, OperationSymbol operationSymbol, params object[] args)
 {
     return(Return(MethodInfo.GetCurrentMethod(), operationSymbol.ToString(),
                   () => OperationLogic.ServiceExecute(entity, operationSymbol, args)));
 }