Esempio n. 1
0
        void CreateRecordSetsInputs(IExecutionEnvironment outerEnvironment, IRecordSetDefinition recordSetDefinition, IExecutionEnvironment env, int update)
        {
            var emptyList = new List <string>();

            foreach (var dev2ColumnDefinition in recordSetDefinition.Columns)
            {
                if (dev2ColumnDefinition.IsRecordSet)
                {
                    var defn = "[[" + dev2ColumnDefinition.RecordSetName + "()." + dev2ColumnDefinition.Name + "]]";


                    if (string.IsNullOrEmpty(dev2ColumnDefinition.RawValue) && !emptyList.Contains(defn))
                    {
                        emptyList.Add(defn);
                        continue;
                    }

                    var warewolfEvalResult = outerEnvironment.Eval(dev2ColumnDefinition.RawValue, update);

                    if (warewolfEvalResult.IsWarewolfAtomListresult)
                    {
                        AtomListInputs(warewolfEvalResult, dev2ColumnDefinition, env);
                    }
                    if (warewolfEvalResult.IsWarewolfAtomResult)
                    {
                        AtomInputs(warewolfEvalResult, dev2ColumnDefinition, env);
                    }
                }
            }
            foreach (var defn in emptyList)
            {
                env.AssignDataShape(defn);
            }
        }
Esempio n. 2
0
        static void CreateScalarInputs(IExecutionEnvironment outerEnvironment, IDev2Definition dev2Definition, IExecutionEnvironment env, int update)
        {
            void ScalarAtomList(CommonFunctions.WarewolfEvalResult warewolfEvalResult)
            {
                if (warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult data && data.Item.Any())
                {
                    env.AssignWithFrame(new AssignValue("[[" + dev2Definition.Name + "]]", ExecutionEnvironment.WarewolfAtomToString(data.Item.Last())), 0);
                }
            }

            void ScalarAtom(CommonFunctions.WarewolfEvalResult warewolfEvalResult)
            {
                if (warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfAtomResult data)
                {
                    env.AssignWithFrame(new AssignValue("[[" + dev2Definition.Name + "]]", ExecutionEnvironment.WarewolfAtomToString(data.Item)), 0);
                }
            }

            if (!string.IsNullOrEmpty(dev2Definition.Name))
            {
                env.AssignDataShape("[[" + dev2Definition.Name + "]]");
            }
            if (!dev2Definition.IsRecordSet && !string.IsNullOrEmpty(dev2Definition.RawValue))
            {
                var warewolfEvalResult = outerEnvironment.Eval(dev2Definition.RawValue, update);
                if (warewolfEvalResult.IsWarewolfAtomListresult)
                {
                    ScalarAtomList(warewolfEvalResult);
                }
                else
                {
                    ScalarAtom(warewolfEvalResult);
                }
            }
        }
 public void CreateScalarInputs(IExecutionEnvironment outerEnvironment, IEnumerable <IDev2Definition> inputScalarList, IExecutionEnvironment env, int update)
 {
     foreach (var dev2Definition in inputScalarList)
     {
         if (!string.IsNullOrEmpty(dev2Definition.Name))
         {
             env.AssignDataShape("[[" + dev2Definition.Name + "]]");
         }
         if (!dev2Definition.IsRecordSet)
         {
             if (!string.IsNullOrEmpty(dev2Definition.RawValue))
             {
                 var warewolfEvalResult = outerEnvironment.Eval(dev2Definition.RawValue, update);
                 if (warewolfEvalResult.IsWarewolfAtomListresult)
                 {
                     ScalarAtomList(warewolfEvalResult, env, dev2Definition);
                 }
                 else
                 {
                     ScalarAtom(warewolfEvalResult, env, dev2Definition);
                 }
             }
         }
     }
 }
Esempio n. 4
0
        public static void ProcessOutputMapping(IExecutionEnvironment environment, int update, ref bool started, ref int rowIdx, DataRow row, IServiceOutputMapping serviceOutputMapping)
        {
            var rsType   = DataListUtil.GetRecordsetIndexType(serviceOutputMapping.MappedTo);
            var rowIndex = DataListUtil.ExtractIndexRegionFromRecordset(serviceOutputMapping.MappedTo);

            var rs = serviceOutputMapping.RecordSetName;

            if (!string.IsNullOrEmpty(rs) && environment.HasRecordSet(DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.MakeValueIntoHighLevelRecordset(rs, rsType == enRecordsetIndexType.Star))))
            {
                if (started)
                {
                    rowIdx  = environment.GetLength(rs) + 1;
                    started = false;
                }
            }
            else
            {
                try
                {
                    environment.AssignDataShape(serviceOutputMapping.MappedTo);
                }
                catch (Exception e)
                {
                    Dev2Logger.Error(e, GlobalConstants.WarewolfError);
                }
            }

            GetRowIndex(ref started, ref rowIdx, rsType, rowIndex);
            if (!row.Table.Columns.Contains(serviceOutputMapping.MappedFrom))
            {
                return;
            }

            var value = row[serviceOutputMapping.MappedFrom];

            var colDataType = row.Table.Columns[serviceOutputMapping.MappedFrom].DataType;

            if (colDataType.Name == "Byte[]")
            {
                value = Encoding.UTF8.GetString(value as byte[]);
            }

            if (update != 0)
            {
                rowIdx = update;
            }

            var displayExpression = DataListUtil.ReplaceRecordsetBlankWithIndex(DataListUtil.AddBracketsToValueIfNotExist(serviceOutputMapping.MappedTo), rowIdx);

            if (rsType == enRecordsetIndexType.Star)
            {
                displayExpression = DataListUtil.ReplaceStarWithFixedIndex(displayExpression, rowIdx);
            }

            environment.Assign(displayExpression, value.ToString(), update);
        }
Esempio n. 5
0
        static void ProcessOutputMapping(DataTable executeService, IExecutionEnvironment environment, int update, ref bool started, ref int rowIdx, DataRow row, IServiceOutputMapping serviceOutputMapping)
        {
            var rsType   = DataListUtil.GetRecordsetIndexType(serviceOutputMapping.MappedTo);
            var rowIndex = DataListUtil.ExtractIndexRegionFromRecordset(serviceOutputMapping.MappedTo);
            var rs       = serviceOutputMapping.RecordSetName;

            if (!string.IsNullOrEmpty(rs) && environment.HasRecordSet(rs))
            {
                if (started)
                {
                    rowIdx  = environment.GetLength(rs) + 1;
                    started = false;
                }
            }
            else
            {
                try
                {
                    environment.AssignDataShape(serviceOutputMapping.MappedTo);
                }
                catch (Exception e)
                {
                    Dev2Logger.Error(e, GlobalConstants.WarewolfError);
                }
            }
            GetRowIndex(ref started, ref rowIdx, rsType, rowIndex);
            if (!executeService.Columns.Contains(serviceOutputMapping.MappedFrom) && !executeService.Columns.Contains("ReadForXml"))
            {
                return;
            }
            var value = GetColumnValue(executeService, row, serviceOutputMapping);

            if (update != 0)
            {
                rowIdx = update;
            }
            var displayExpression = DataListUtil.ReplaceRecordsetBlankWithIndex(DataListUtil.AddBracketsToValueIfNotExist(serviceOutputMapping.MappedTo), rowIdx);

            if (rsType == enRecordsetIndexType.Star)
            {
                displayExpression = DataListUtil.ReplaceStarWithFixedIndex(displayExpression, rowIdx);
            }
            environment.Assign(displayExpression, value.ToString(), update);
        }
        public void CreateRecordSetsInputs(IExecutionEnvironment outerEnvironment, IRecordSetCollection inputRecSets, IList <IDev2Definition> inputs, IExecutionEnvironment env, int update)
        {
            foreach (var recordSetDefinition in inputRecSets.RecordSets)
            {
                var outPutRecSet = inputs.FirstOrDefault(definition => definition.IsRecordSet && DataListUtil.ExtractRecordsetNameFromValue(definition.MapsTo) == recordSetDefinition.SetName);
                if (outPutRecSet != null)
                {
                    var emptyList = new List <string>();
                    foreach (var dev2ColumnDefinition in recordSetDefinition.Columns)
                    {
                        if (dev2ColumnDefinition.IsRecordSet)
                        {
                            var defn = "[[" + dev2ColumnDefinition.RecordSetName + "()." + dev2ColumnDefinition.Name + "]]";


                            if (string.IsNullOrEmpty(dev2ColumnDefinition.RawValue))
                            {
                                if (!emptyList.Contains(defn))
                                {
                                    emptyList.Add(defn);
                                    continue;
                                }
                            }
                            var warewolfEvalResult = outerEnvironment.Eval(dev2ColumnDefinition.RawValue, update);

                            if (warewolfEvalResult.IsWarewolfAtomListresult)
                            {
                                AtomListInputs(warewolfEvalResult, dev2ColumnDefinition, env);
                            }
                            if (warewolfEvalResult.IsWarewolfAtomResult)
                            {
                                AtomInputs(warewolfEvalResult, dev2ColumnDefinition, env);
                            }
                        }
                    }
                    foreach (var defn in emptyList)
                    {
                        env.AssignDataShape(defn);
                    }
                }
            }
        }
Esempio n. 7
0
        void TranslateDataTableToEnvironment(DataTable executeService, IExecutionEnvironment environment)
        {
            if (executeService != null && InstanceOutputDefintions != null)
            {
                var defs = DataListFactory.CreateOutputParser().Parse(InstanceOutputDefintions);
                HashSet <string>          processedRecNames = new HashSet <string>();
                IDictionary <int, string> colMapping        = BuildColumnNameToIndexMap(executeService.Columns, defs);
                foreach (var def in defs)
                {
                    var expression = def.Value;
                    var rs         = def.RawValue;
                    var rsName     = DataListUtil.ExtractRecordsetNameFromValue(expression);
                    var rsType     = DataListUtil.GetRecordsetIndexType(expression);
                    var rowIndex   = DataListUtil.ExtractIndexRegionFromRecordset(expression);
                    var rsNameUse  = def.RecordSetName;
                    environment.AssignDataShape(def.RawValue);

                    if (DataListUtil.IsValueRecordset(rs))
                    {
                        if (string.IsNullOrEmpty(rsName))
                        {
                            rsName = rsNameUse;
                        }
                        if (string.IsNullOrEmpty(rsName))
                        {
                            rsName = def.Name;
                        }

                        if (processedRecNames.Contains(rsName))
                        {
                            continue;
                        }

                        processedRecNames.Add(rsName);


                        // now convert to binary datalist ;)
                        int rowIdx = 1;

                        if (environment.HasRecordSet(rs))
                        {
                            rowIdx = environment.GetLength(rs);
                        }

                        if (rsType == enRecordsetIndexType.Star)
                        {
                            rowIdx = 1;
                        }
                        if (rsType == enRecordsetIndexType.Numeric)
                        {
                            rowIdx = int.Parse(rowIndex);
                        }

                        if (executeService.Rows != null)
                        {
                            foreach (DataRow row in executeService.Rows)
                            {
                                // build up the row
                                int idx = 0;

                                foreach (var item in row.ItemArray)
                                {
                                    string colName;

                                    if (colMapping.TryGetValue(idx, out colName))
                                    {
                                        var displayExpression = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(def.Value), colName, rowIdx.ToString()));
                                        environment.Assign(displayExpression, item.ToString(), 0);
                                    }

                                    idx++;
                                }

                                rowIdx++;
                            }
                        }
                    }
                    else
                    {
                        // handle a scalar coming out ;)
                        if (executeService.Rows != null && executeService.Rows.Count == 1)
                        {
                            var row = executeService.Rows[0].ItemArray;
                            // Look up the correct index from the columns ;)

                            int pos  = 0;
                            var cols = executeService.Columns;
                            int idx  = -1;

                            while (pos < cols.Count && idx == -1)
                            {
                                if (colMapping[pos] == expression)
                                {
                                    idx = pos;
                                }
                                pos++;
                            }
                            environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(expression), row[idx].ToString(), 0);
                        }
                    }
                }
            }
        }
Esempio n. 8
0
 public void AssignDataShape(string p)
 {
     _inner.AssignDataShape(p.Replace(_alias, _datasource));
 }
Esempio n. 9
0
        private void TranslateDataTableToEnvironment(DataTable executeService, IExecutionEnvironment environment, int update)
        {
            var started = true;

            if (executeService != null && Outputs != null && Outputs.Count != 0)
            {
                if (executeService.Rows != null)
                {
                    var rowIdx = 1;
                    foreach (DataRow row in executeService.Rows)
                    {
                        foreach (var serviceOutputMapping in Outputs)
                        {
                            if (!string.IsNullOrEmpty(serviceOutputMapping.MappedTo))
                            {
                                var rsType   = DataListUtil.GetRecordsetIndexType(serviceOutputMapping.MappedTo);
                                var rowIndex = DataListUtil.ExtractIndexRegionFromRecordset(serviceOutputMapping.MappedTo);
                                var rs       = serviceOutputMapping.RecordSetName;

                                if (environment.HasRecordSet(rs))
                                {
                                    if (started)
                                    {
                                        rowIdx  = environment.GetLength(rs) + 1;
                                        started = false;
                                    }
                                }
                                else
                                {
                                    environment.AssignDataShape(serviceOutputMapping.MappedTo);
                                }
                                if (rsType == enRecordsetIndexType.Star && started)
                                {
                                    rowIdx  = 1;
                                    started = false;
                                }
                                if (rsType == enRecordsetIndexType.Numeric)
                                {
                                    rowIdx = int.Parse(rowIndex);
                                }
                                if (!executeService.Columns.Contains(serviceOutputMapping.MappedFrom))
                                {
                                    continue;
                                }
                                var value = row[serviceOutputMapping.MappedFrom];
                                if (update != 0)
                                {
                                    rowIdx = update;
                                }
                                var displayExpression = DataListUtil.ReplaceRecordsetBlankWithIndex(DataListUtil.AddBracketsToValueIfNotExist(serviceOutputMapping.MappedTo), rowIdx);
                                if (rsType == enRecordsetIndexType.Star)
                                {
                                    displayExpression = DataListUtil.ReplaceStarWithFixedIndex(displayExpression, rowIdx);
                                }
                                environment.Assign(displayExpression, value.ToString(), update);
                            }
                        }
                        rowIdx++;
                    }
                }
            }
        }