Example #1
0
        public override async Task <IDocument> ExecuteAsync(KeyValuePair <string, string>[] args, string content, IDocument document, IExecutionContext context)
        {
            byte[] assembly = ScriptHelper.Compile(content, document, context);
            object value    = await ScriptHelper.EvaluateAsync(assembly, document, context);

            return(context.CreateDocument(await context.GetContentProviderAsync(value.ToString())));
        }
Example #2
0
        protected override async Task <IEnumerable <IDocument> > ExecuteInputAsync(IDocument input, IExecutionContext context)
        {
            byte[]       assembly = ScriptHelper.Compile(await input.GetContentStringAsync(), input, context);
            MemoryStream stream   = context.MemoryStreamFactory.GetStream(assembly);

            return(input.Clone(context.GetContentProvider(stream, ScriptMediaType)).Yield());
        }
Example #3
0
        private string value_Validate(string name, VarientType type, string value)
        {
            GlobalVarients gvs = new GlobalVarients();

            gvs.Add(new GlobalVarient(name, type, value));

            ScriptHelper sh = new ScriptHelper();

            sh.AddScript(sh.VarientString(gvs));
            sh.References.Add(ExecutePath + "UFIDA.U8.UAP.Services.ReportData.dll");
            sh.References.Add(ExecutePath + "UFIDA.U8.UAP.Services.ReportElements.dll");
            sh.References.Add(ExecutePath + "UFIDA.U8.UAP.Services.ReportFilterService.dll");
            sh.OutputAssembly = null;
            CompilerResults cr = sh.Compile();

            if (cr.Errors.Count > 0)
            {
                return(UFIDA.U8.UAP.Services.ReportResource.U8ResService.GetResString("U8.UAP.Services.ReportElements.Tx10", System.Threading.Thread.CurrentThread.CurrentUICulture.Name));
            }

            try
            {
                ITest test = ((ITest)ScriptHelper.FindInterface(cr.CompiledAssembly, "UFIDA.U8.UAP.Services.DynamicReportComponent.DRCtmp.Global"));
                test.DataHelper = _datahelper;
                test.Test();
            }
            catch
            {
                return(UFIDA.U8.UAP.Services.ReportResource.U8ResService.GetResString("U8.UAP.Services.ReportElements.Tx11", System.Threading.Thread.CurrentThread.CurrentUICulture.Name));
            }
            return("");
        }
Example #4
0
        protected override async Task <IEnumerable <IDocument> > ExecuteInputAsync(IDocument input, IExecutionContext context)
        {
            // Get the assembly
            byte[] assembly = input.GetBool(CompileScript.CompiledKey)
                ? await input.GetContentBytesAsync()
                : ScriptHelper.Compile(await input.GetContentStringAsync(), input, context);

            // Evaluate the script
            object value = await ScriptHelper.EvaluateAsync(assembly, input, context);

            return(await context.CloneOrCreateDocumentsAsync(input, input.Yield(), value));
        }
Example #5
0
        public static string Interpolate(this IDocument document, string value, IExecutionContext context)
        {
            _ = document ?? throw new ArgumentNullException(nameof(document));
            _ = context ?? throw new ArgumentNullException(nameof(context));

            if (string.IsNullOrEmpty(value))
            {
                return(string.Empty);
            }

            byte[] assembly = ScriptHelper.Compile($"return $\"{value}\";", document, context);
            return((string)ScriptHelper.EvaluateAsync(assembly, document, context).Result);
        }
Example #6
0
        protected override async Task <IEnumerable <IDocument> > ExecuteAsync(IDocument input, IExecutionContext context)
        {
            byte[]       assembly = ScriptHelper.Compile(await input.GetStringAsync(), input, context);
            MemoryStream stream   = context.MemoryStreamFactory.GetStream(assembly);

            return(input
                   .Clone(
                       new MetadataItems
            {
                { CompiledKey, true }
            },
                       context.GetContentProvider(stream))
                   .Yield());
        }