/// <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())); }
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); }
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; }
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 }); }
private ExecuteCSharpCode GetCSharpCodeExecutor(CSharpCodeInformation csharpCodeInformation) { return(new ExecuteCSharpCode("Eyedia.IDPE.Common.CSharpCodeInputFileGenerator", new object[] { this.Job }, ExecuteCSharpCode.CompilerVersions.v40, csharpCodeInformation.GetReferencedAssemblies())); }
/// <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 })); }