Beispiel #1
0
        public TransformalizeResponse Run(TransformalizeRequest request)
        {
            var moduleVersion = _extensionManager.GetExtension("Transformalize.Orchard").Version;
            var logger        = new TransformalizeLogger(request.Part.Title(), request.Part.LogLevel, Logger, OrchardVersion, moduleVersion);
            var processes     = new List <Process>();

            //transitioning to using TflRoot instead of string configuration
            if (request.Root != null)
            {
                processes.AddRange(ProcessFactory.Create(request.Root, logger, request.Options));
            }
            else      //legacy
            {
                processes.AddRange(ProcessFactory.Create(request.Configuration, logger, request.Options, request.Query));
            }

            for (var i = 0; i < processes.Count; i++)
            {
                var process = processes[i];
                CreateInputOperation(process, request);
                process.ExecuteScaler();
            }

            return(new TransformalizeResponse()
            {
                Processes = processes.ToArray(),
                Log = logger.Dump().ToList()
            });
        }
        public ActionResult MetaData(int id) {

            Response.AddHeader("Access-Control-Allow-Origin", "*");
            ConfigurationPart part;
            ApiRequest request;

            var query = _transformalize.GetQuery();

            foreach (var rejection in _apiService.Rejections(id, out request, out part)) {
                return rejection.ContentResult(
                    query["format"],
                    query["flavor"]
                );
            }

            request.RequestType = ApiRequestType.MetaData;
            var transformalizeRequest = new TransformalizeRequest(part, query, null, Logger);
            var logger = new TransformalizeLogger(transformalizeRequest.Part.Title(), part.LogLevel, Logger, OrchardVersion, _moduleVersion);

            var errors = transformalizeRequest.Root.Errors();
            if (errors.Any()) {
                var bad = new TransformalizeResponse();
                request.Status = 501;
                request.Message = "Configuration Problem" + errors.Length.Plural();
                bad.Log.AddRange(errors.Select(p => new[] { DateTime.Now.ToString(CultureInfo.InvariantCulture), "error", ".", ".", p }));
                return new ApiResponse(request, "<tfl></tfl>", bad).ContentResult(
                    query["format"],
                    query["flavor"]
                );
            }

            var metaData = new MetaDataWriter(ProcessFactory.CreateSingle(transformalizeRequest.Root.Processes[0], logger, new Options { Mode = "metadata" })).Write();
            return new ApiResponse(request, metaData).ContentResult(
                query["format"],
                query["flavor"]
            );
        }
        public TransformalizeResponse Run(TransformalizeRequest request) {

            var moduleVersion = _extensionManager.GetExtension("Transformalize.Orchard").Version;
            var logger = new TransformalizeLogger(request.Part.Title(), request.Part.LogLevel, Logger, OrchardVersion, moduleVersion);
            var processes = new List<Process>();

            //transitioning to using TflRoot instead of string configuration
            if (request.Root != null) {
                processes.AddRange(ProcessFactory.Create(request.Root, logger, request.Options));
            } else {  //legacy
                processes.AddRange(ProcessFactory.Create(request.Configuration, logger, request.Options, request.Query));
            }

            for (var i = 0; i < processes.Count; i++) {
                var process = processes[i];
                CreateInputOperation(process, request);
                process.ExecuteScaler();
            }

            return new TransformalizeResponse() {
                Processes = processes.ToArray(),
                Log = logger.Dump().ToList()
            };
        }