示例#1
0
        /// <summary>
        /// Executes CSharp code and returns string for output
        /// </summary>
        /// <returns></returns>
        public override StringBuilder GetOutput()
        {
            if (_Job.IsErrored)
            {
                return(new StringBuilder());
            }

            CSharpCodeInformation csharpCodeInformation = new CSharpCodeInformation(_Job.DataSource.Keys.GetKeyValue(IdpeKeyTypes.CSharpCodeOutputWriter));
            ExecuteCSharpCode     executeCSharpcode     = new ExecuteCSharpCode("Eyedia.IDPE.Common.CSharpCode",
                                                                                ExecuteCSharpCode.CompilerVersions.v40, csharpCodeInformation.GetReferencedAssemblies());

            return(new StringBuilder(executeCSharpcode.Execute(csharpCodeInformation.CompleteCode, "ExecuteAndReturnString", new object[] { _Job }).ToString()));
        }
示例#2
0
        public static CSharpCodeInformation GetCSharpCodeInformation(List <IdpeKey> dataSourceKeys, CSharpCodeInformation csharpCodeInformation = null)
        {
            if (csharpCodeInformation == null)
            {
                csharpCodeInformation = new CSharpCodeInformation(dataSourceKeys.GetKeyValue(IdpeKeyTypes.CSharpCodeGenerateTable));
            }

            if (string.IsNullOrEmpty(csharpCodeInformation.RawString))
            {
                throw new Exception("C# Code was not defined!");
            }

            return(csharpCodeInformation);
        }
示例#3
0
        private void FeedCSharpCode()
        {
            List <string> csvRows     = new List <string>();
            List <string> warnings    = new List <string>();
            int           columnCount = 0;

            CSharpCodeInformation csharpCodeInformation = CSharpCodeToDataTable.GetCSharpCodeInformation(Job.DataSource.Keys);

            if (csharpCodeInformation.CodeType == CSharpCodeInformation.CodeTypes.DataTableGeneratorFromFileName)
            {
                Job.InputData = new CSharpCodeToDataTable(Job).Parse(Job.FileName, ref csvRows, ref warnings, ref columnCount);
            }
            else
            {
                Job.InputData = new CSharpCodeToDataTable(Job).Parse(Job.FileContent, ref csvRows, ref warnings, ref columnCount);
            }

            Job.CsvRows.AddRange(csvRows);
            Job.Warnings.AddRange(warnings);
            Job.ColumnCount = columnCount;
        }
示例#4
0
        protected override void Execute(CodeActivityContext context)
        {
            Job job = context.GetValue(this.Job);

            if (job == null)
            {
                WorkerData data = context.GetValue(this.Data);
                data.ThrowErrorIfNull(this.DisplayName);
            }

            Object obj        = context.GetValue(this.Object);
            string objectType = context.GetValue(this.ObjectType);
            string code       = context.GetValue(this.Code);
            string additionalUsingNamespace = context.GetValue(this.AdditionalUsingNamespace);
            string additionalReferences     = context.GetValue(this.AdditionalReferences);


            CSharpCodeInformation csharpCodeInformation = new CSharpCodeInformation();

            csharpCodeInformation.CodeType = CSharpCodeInformation.CodeTypes.Execute;
            csharpCodeInformation.Code     = string.Format("(({0})obj).{1}", objectType, code);
            if (string.IsNullOrEmpty(additionalUsingNamespace))
            {
                csharpCodeInformation.AdditionalUsingNamespace = additionalUsingNamespace;
            }

            if (string.IsNullOrEmpty(additionalReferences))
            {
                csharpCodeInformation.AdditionalReferences = "System.Linq.dll";
            }

            ExecuteCSharpCode cSharpCodeExecutor = new ExecuteCSharpCode("Eyedia.IDPE.Common.CSharpCode", null,
                                                                         ExecuteCSharpCode.CompilerVersions.v40, csharpCodeInformation.GetReferencedAssemblies());

            cSharpCodeExecutor.Execute(csharpCodeInformation.CompleteCode, "Execute", new object[] { obj });
        }
示例#5
0
 private ExecuteCSharpCode GetCSharpCodeExecutor(CSharpCodeInformation csharpCodeInformation)
 {
     return(new ExecuteCSharpCode("Eyedia.IDPE.Common.CSharpCodeInputFileGenerator", new object[] { this.Job },
                                  ExecuteCSharpCode.CompilerVersions.v40, csharpCodeInformation.GetReferencedAssemblies()));
 }
示例#6
0
 /// <summary>
 /// Executes defined CSharp code and return DataTable
 /// </summary>
 /// <param name="fileName">file content</param>
 /// <param name="csharpCodeInformation">Csharp code information, if not passed, will be taken from Datasource key</param>
 /// <returns></returns>
 public DataTable Parse(string fileName, CSharpCodeInformation csharpCodeInformation = null)
 {
     csharpCodeInformation = GetCSharpCodeInformation(DataSource.Keys, csharpCodeInformation);
     return((DataTable)GetCSharpCodeExecutor(csharpCodeInformation).Execute(csharpCodeInformation.CompleteCode, "GenerateFileContent", new object[] { fileName }));
 }