public void UpsertBuilder_AssignStyleAppend_Expect_10RecordSetEntries_And_Scalar()
        {
            IDev2DataListUpsertPayloadBuilder <string> tmp = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder();
            string error;

            tmp.Add("[[scalar]]", "myScalar");
            tmp.FlushIterationFrame();
            tmp.Add("[[recset().f1]]", "field1_value1a");
            tmp.Add("[[recset().f2]]", "field2_value1a");
            tmp.FlushIterationFrame();
            tmp.Add("[[recset(10).f1]]", "field1_value2a");
            tmp.Add("[[recset(10).f2]]", "field2_value2a");

            ErrorResultTO errors;
            Guid          id = _compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), _adlData.ToStringBuilder(), new StringBuilder(_dlShape), out errors);


            _compiler.Upsert(id, tmp, out errors);
            IBinaryDataList bdl = _compiler.FetchBinaryDataList(id, out errors);

            // Else we good to go, normal asserts ;)
            IBinaryDataListEntry recset;

            bdl.TryGetEntry("recset", out recset, out error);
            IBinaryDataListEntry scalar;

            bdl.TryGetEntry("scalar", out scalar, out error);

            var res1 = scalar.FetchScalar().TheValue;
            var res2 = recset.FetchLastRecordsetIndex();

            // we have a single scalar
            Assert.AreEqual("myScalar", res1);
            Assert.AreEqual(10, res2);
        }
        public void UpsertBuilder_AssignStyleAppend_Expect_Scalar_WithLastRecord()
        {
            IDev2DataListUpsertPayloadBuilder <string> tmp = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder();

            tmp.Add("[[recset().f1]]", "field1_value1a");
            tmp.Add("[[recset().f2]]", "field2_value1a");
            tmp.FlushIterationFrame();
            tmp.Add("[[scalar]]", "[[recset(*).f1]]");
            tmp.FlushIterationFrame();

            ErrorResultTO errors;
            Guid          id = _compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), _adlData.ToStringBuilder(), new StringBuilder(_dlShape), out errors);

            _compiler.Upsert(id, tmp, out errors);
            IBinaryDataList bdl = _compiler.FetchBinaryDataList(id, out errors);


            IBinaryDataListEntry scalar;
            string error;

            bdl.TryGetEntry("scalar", out scalar, out error);

            var res = scalar.FetchScalar().TheValue;

            // we have a single scalar
            Assert.AreEqual("field1_value1a", res);
        }
Ejemplo n.º 3
0
        public void TryFetchLastIndexedRecordsetUpsertPayload_ColumnName_FetchesForColumn()
        {
            //------------Setup for test--------------------------
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            IDev2DataListUpsertPayloadBuilder <List <string> > toUpsert = Dev2DataListBuilderFactory.CreateStringListDataListUpsertBuilder();

            toUpsert.Add("[[rec().f1]]", new List <string> {
                "test11", "test12"
            });
            toUpsert.Add("[[rec().f2]]", new List <string> {
                "test21", "test22"
            });
            IBinaryDataList dataList = Dev2BinaryDataListFactory.CreateDataList();
            string          creationError;

            dataList.TryCreateRecordsetTemplate("rec", "recset", new List <Dev2Column> {
                DataListFactory.CreateDev2Column("f1", "f1"), DataListFactory.CreateDev2Column("f2", "f2")
            }, true, out creationError);
            ErrorResultTO localErrors;

            compiler.PushBinaryDataList(dataList.UID, dataList, out localErrors);
            compiler.Upsert(dataList.UID, toUpsert, out _errors);
            IBinaryDataListEntry recEntry;
            string error;

            dataList.TryGetEntry("rec", out recEntry, out error);
            //------------Assert Preconditions-------------------
            Assert.IsNotNull(recEntry);
            //------------Execute Test---------------------------
            var listItem = recEntry.TryFetchLastIndexedRecordsetUpsertPayload(out error, "f2");

            //------------Assert Results-------------------------
            Assert.AreEqual("test22", listItem.TheValue);
        }
Ejemplo n.º 4
0
 void UpdateResultRegions(string expression, IDev2DataListUpsertPayloadBuilder <string> toUpsert, string result)
 {
     foreach (var region in DataListCleaningUtils.SplitIntoRegions(expression))
     {
         toUpsert.Add(region, result);
         toUpsert.FlushIterationFrame();
     }
 }
        public void UpsertPayloadBuilder_Without_Flush_Valid_Entries()
        {
            IDev2DataListUpsertPayloadBuilder <string> tmp = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder();

            tmp.Add("[[scalar]]", "zzz");
            tmp.Add("[[scalar2]]", "aaa");

            Assert.AreEqual(1, tmp.FetchFrames().Count);
        }
        public void UpsertPayloadBuilder_MultFrames_Expect_Valid_Entries()
        {
            IDev2DataListUpsertPayloadBuilder <string> tmp = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder();

            tmp.Add("[[scalar]]", "zzz");
            tmp.FlushIterationFrame();
            tmp.Add("[[scalar2]]", "aaa");

            Assert.AreEqual(2, tmp.FetchFrames().Count);
        }
Ejemplo n.º 7
0
 void PushResultsToDataList(string expression, IDev2DataListUpsertPayloadBuilder <string> toUpsert, string result, IDSFDataObject dataObject, Guid executionId, IDataListCompiler compiler, ErrorResultTO allErrors)
 {
     UpdateResultRegions(expression, toUpsert, result);
     compiler.Upsert(executionId, toUpsert, out errorsTo);
     if (dataObject.IsDebugMode())
     {
         foreach (var debugOutputTo in toUpsert.DebugOutputs)
         {
             AddDebugOutputItem(new DebugItemVariableParams(debugOutputTo));
         }
     }
     allErrors.MergeErrors(errorsTo);
 }
Ejemplo n.º 8
0
        static int CompletedRow(HashSet <string> usedTokens, IDev2DataListUpsertPayloadBuilder <string> toUpsert, bool singleInnerIteration, ref int opCnt, ref bool exit)
        {
            opCnt++;

            // clear token cache
            usedTokens.Clear();

            toUpsert.FlushIterationFrame();

            if (singleInnerIteration)
            {
                exit = true;
            }
            return(0);
        }
        public void UpsertBuilder_AssignStyleAppend_Expect_2RecordSetEntries_And_Scalar_AsDebug()
        {
            IDev2DataListUpsertPayloadBuilder <string> tmp = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true);

            tmp.IsDebug = true;
            tmp.Add("[[scalar]]", "myScalar");
            tmp.FlushIterationFrame();
            tmp.Add("[[recset().f1]]", "field1_value1");
            tmp.Add("[[recset().f2]]", "field2_value1");
            tmp.FlushIterationFrame();
            tmp.Add("[[recset().f1]]", "field1_value2");
            tmp.Add("[[recset().f2]]", "field2_value2");

            ErrorResultTO errors;
            Guid          id = _compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), string.Empty.ToStringBuilder(), new StringBuilder(_dlShape), out errors);

            _compiler.Upsert(id, tmp, out errors);
            IBinaryDataList bdl = _compiler.FetchBinaryDataList(id, out errors);

            // Else we good to go, normal asserts ;)
            IBinaryDataListEntry recset;
            string error;

            bdl.TryGetEntry("recset", out recset, out error);

            IBinaryDataListEntry scalar;

            bdl.TryGetEntry("scalar", out scalar, out error);

            var res1 = scalar.FetchScalar().TheValue;
            var res2 = recset.FetchLastRecordsetIndex();

            // we have a single scalar
            Assert.AreEqual("myScalar", res1);
            Assert.AreEqual(2, res2);

            Assert.IsNotNull(tmp.DebugOutputs);
            Assert.IsNotNull(tmp.DebugOutputs[0].LeftEntry);
            Assert.IsNotNull(tmp.DebugOutputs[0].RightEntry);
            Assert.IsNotNull(tmp.DebugOutputs[0].TargetEntry);
            Assert.IsNotNull(tmp.DebugOutputs[0].RightEntry.ComplexExpressionAuditor);
            Assert.IsNotNull(tmp.DebugOutputs[0].LeftEntry.ComplexExpressionAuditor);
            Assert.IsNotNull(tmp.DebugOutputs[0].TargetEntry.ComplexExpressionAuditor);
            Assert.AreEqual(1, tmp.DebugOutputs[0].RightEntry.ComplexExpressionAuditor.FetchAuditItems().Count);
            Assert.AreEqual(1, tmp.DebugOutputs[0].LeftEntry.ComplexExpressionAuditor.FetchAuditItems().Count);
            Assert.AreEqual(5, tmp.DebugOutputs[0].TargetEntry.ComplexExpressionAuditor.FetchAuditItems().Count);
        }
Ejemplo n.º 10
0
        public void Replace_CaseMatch_Recorset_Expected_No_Replaces()
        {
            ErrorResultTO     errors;
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            Guid exidx = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), TestStrings.ReplaceDataListWithData, TestStrings.ReplaceDataListShape.ToStringBuilder(), out errors);
            IDev2DataListUpsertPayloadBuilder <string> payloadBuilder = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true);
            IBinaryDataListEntry  entry;
            IDev2ReplaceOperation replaceOperation = Dev2OperationsFactory.CreateReplaceOperation();
            const string          Expression       = "[[results(*).resfield]]";
            int replaceCount;

            // ReSharper disable RedundantAssignment
            payloadBuilder = replaceOperation.Replace(exidx, Expression, "hello", "World", true, payloadBuilder, out errors, out replaceCount, out entry);
            // ReSharper restore RedundantAssignment

            Assert.AreEqual(0, replaceCount);
        }
        public void Dev2DataListUpsertPayloadBuilder_UnitTest_KeepsStarIndexingWhenNotReplacing()
        {
            IDev2DataListUpsertPayloadBuilder <string> builder = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder();

            builder.Add("[[rs(*).val]]", "aaa");
            builder.FlushIterationFrame();
            builder.Add("[[rs(*).val]]", "aaa");

            var items = builder.FetchFrames(true);

            foreach (var itm in items)
            {
                var          exp      = itm.FetchNextFrameItem().Expression;
                const string Expected = "rs(*).val";

                StringAssert.Contains(exp, Expected, "Index substitution occurred when not active");
            }
        }
Ejemplo n.º 12
0
        public void UpsertWhereListStringExpectUpsertCorrectlyMultipleRecordset()
        {
            //------------Setup for test--------------------------
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            IDev2DataListUpsertPayloadBuilder <List <string> > toUpsert = Dev2DataListBuilderFactory.CreateStringListDataListUpsertBuilder();

            toUpsert.Add("[[rec().f1]]", new List <string> {
                "test11", "test12"
            });
            toUpsert.Add("[[rec().f2]]", new List <string> {
                "test21", "test22"
            });
            IBinaryDataList dataList = Dev2BinaryDataListFactory.CreateDataList();
            string          creationError;

            dataList.TryCreateRecordsetTemplate("rec", "recset", new List <Dev2Column> {
                DataListFactory.CreateDev2Column("f1", "f1"), DataListFactory.CreateDev2Column("f2", "f2")
            }, true, out creationError);
            ErrorResultTO localErrors;

            compiler.PushBinaryDataList(dataList.UID, dataList, out localErrors);
            //------------Execute Test---------------------------
            compiler.Upsert(dataList.UID, toUpsert, out _errors);
            //------------Assert Results-------------------------
            IList <IBinaryDataListEntry> binaryDataListEntries = dataList.FetchRecordsetEntries();
            IBinaryDataListEntry         binaryDataListEntry   = binaryDataListEntries[0];
            string errString;
            IList <IBinaryDataListItem> binaryDataListItems = binaryDataListEntry.FetchRecordAt(1, out errString);
            IBinaryDataListItem         binaryDataListItem  = binaryDataListItems[0];
            IBinaryDataListItem         binaryDataListItem2 = binaryDataListItems[1];
            string theValue = binaryDataListItem.TheValue;

            Assert.AreEqual("test11", theValue);
            theValue = binaryDataListItem2.TheValue;
            Assert.AreEqual("test21", theValue);
            binaryDataListItems = binaryDataListEntry.FetchRecordAt(2, out errString);
            binaryDataListItem  = binaryDataListItems[0];
            binaryDataListItem2 = binaryDataListItems[1];
            theValue            = binaryDataListItem.TheValue;
            Assert.AreEqual("test12", theValue);
            theValue = binaryDataListItem2.TheValue;

            Assert.AreEqual("test22", theValue);
        }
Ejemplo n.º 13
0
        void UpdateOutputVariableWithValue(int pos, HashSet <string> usedTokens, IDev2DataListUpsertPayloadBuilder <string> toUpsert, string tmp)
        {
            var dataSplitDto   = ResultsCollection[pos];
            var outputVariable = dataSplitDto.OutputVariable;

            CheckIndex(outputVariable);

            CheckIndex(dataSplitDto.EscapeChar);
            if (!string.IsNullOrEmpty(outputVariable))
            {
                //2013.06.03: Ashley Lewis for bug 9498 - handle multiple regions in result

                // if it already exist, flush this round ;)
                if (!usedTokens.Add(outputVariable))
                {
                    toUpsert.FlushIterationFrame();
                }

                toUpsert.Add(outputVariable, tmp);
            }
        }
Ejemplo n.º 14
0
        public void Replace_NoCaseMatch_Recorset_Expected_Correct_Data_Returned_ReplaceCount_Twenty()
        {
            ErrorResultTO     errors;
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            Guid exidx = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), TestStrings.ReplaceDataListWithData.ToStringBuilder(), TestStrings.ReplaceDataListShape.ToStringBuilder(), out errors);
            IDev2DataListUpsertPayloadBuilder <string> payloadBuilder = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true);
            IDev2ReplaceOperation replaceOperation = Dev2OperationsFactory.CreateReplaceOperation();
            IBinaryDataListEntry  entry;
            const string          Expected   = "World0";
            const string          Expression = "[[results(*).resfield]]";
            int replaceCount;

            payloadBuilder = replaceOperation.Replace(exidx, Expression, "hello", "World", false, payloadBuilder, out errors, out replaceCount, out entry);

            var frames = payloadBuilder.FetchFrames();
            var frame  = frames[0].FetchNextFrameItem();

            Assert.AreEqual(20, replaceCount);
            Assert.AreEqual("[[results(1).resfield]]", frame.Expression);
            Assert.AreEqual(Expected, frame.Value);
        }
Ejemplo n.º 15
0
        private int UpsertResult(int indexToUpsertTo, IDev2DataListUpsertPayloadBuilder <string> toUpsert, string result)
        {
            string expression;

            if (DataListUtil.IsValueRecordset(Result) && DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Star)
            {
                expression = Result.Replace(GlobalConstants.StarExpression, indexToUpsertTo.ToString(CultureInfo.InvariantCulture));
            }
            else
            {
                expression = Result;
            }
            //2013.06.03: Ashley Lewis for bug 9498 - handle multiple regions in result
            foreach (var region in DataListCleaningUtils.SplitIntoRegions(expression))
            {
                toUpsert.Add(region, result);
                toUpsert.FlushIterationFrame();

                indexToUpsertTo++;
            }
            return(indexToUpsertTo);
        }
Ejemplo n.º 16
0
        public void Dev2DataListUpsertPayloadBuilder_UnitTest_CanReplaceStarWithFixedIndexOnFlush()
        {
            IDev2DataListUpsertPayloadBuilder <string> builder = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder();

            builder.ReplaceStarWithFixedIndex = true;

            builder.Add("[[rs(*).val]]", "aaa");
            builder.FlushIterationFrame();
            builder.Add("[[rs(*).val]]", "aaa");

            var items = builder.FetchFrames(true);
            int idx   = 1;

            foreach (var itm in items)
            {
                var exp      = itm.FetchNextFrameItem().Expression;
                var expected = "rs(" + idx + ").val";

                StringAssert.Contains(exp, expected, "Index substitution did not occur correctly");

                idx++;
            }
        }
Ejemplo n.º 17
0
        // ReSharper disable UnusedParameter.Local
        void AddDebugTos(IDev2DataListUpsertPayloadBuilder <string> toUpsert, Guid executionId)
        // ReSharper restore UnusedParameter.Local
        {
            int          innerCount        = 1;
            const string VariableLabelText = "Variable";
            const string NewFieldLabelText = "New Value";

            foreach (DebugTO debugOutputTo in toUpsert.DebugOutputs)
            {
                if (debugOutputTo != null &&
                    debugOutputTo.TargetEntry != null &&
                    debugOutputTo.TargetEntry.ComplexExpressionAuditor != null)
                {
                    var debugItem = new DebugItem();
                    AddDebugItem(new DebugItemStaticDataParams("", innerCount.ToString(CultureInfo.InvariantCulture)), debugItem);
                    AddDebugItem(new DebugTOParams(debugOutputTo, true, VariableLabelText, NewFieldLabelText), debugItem);
                    innerCount++;
                    _debugInputs.Add(debugItem);
                }
            }

            innerCount = 1;

            foreach (DebugTO debugOutputTo in toUpsert.DebugOutputs)
            {
                if (debugOutputTo != null &&
                    debugOutputTo.TargetEntry != null &&
                    debugOutputTo.TargetEntry.ComplexExpressionAuditor != null)
                {
                    var debugItem = new DebugItem();
                    AddDebugItem(new DebugItemStaticDataParams("", innerCount.ToString(CultureInfo.InvariantCulture)), debugItem);
                    AddDebugItem(new DebugItemVariableParams(debugOutputTo), debugItem);
                    _debugOutputs.Add(debugItem);
                    innerCount++;
                }
            }
        }
Ejemplo n.º 18
0
        public void UpsertPayloadBuilder_FetchFrames_Expect_Ordered_Valid_Entries()
        {
            IDev2DataListUpsertPayloadBuilder <string> tmp = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder();

            tmp.Add("[[scalar]]", "zzz");
            tmp.FlushIterationFrame();
            tmp.Add("[[scalar2]]", "aaa");

            IList <string> expressions = new List <string>();
            IList <string> values      = new List <string>();

            IList <IDataListPayloadIterationFrame <string> > frames = tmp.FetchFrames();

            int frameID = 1;

            foreach (IDataListPayloadIterationFrame <string> f in frames)
            {
                while (f.HasData())
                {
                    DataListPayloadFrameTO <string> t2 = f.FetchNextFrameItem();

                    expressions.Add(t2.Expression + "." + frameID);
                    values.Add(t2.Value + "." + frameID);
                }

                frameID++;
            }

            IList <string> expectedExpressions = new List <string> {
                "[[scalar]].1", "[[scalar2]].2"
            };


            CollectionAssert.AreEqual(expectedExpressions.ToArray(), expressions.ToArray());
            CollectionAssert.AreEqual(expectedExpressions.ToArray(), expressions.ToArray());
        }
Ejemplo n.º 19
0
        // ReSharper restore RedundantOverridenMember

        /// <summary>
        /// The execute method that is called when the activity is executed at run time and will hold all the logic of the activity
        /// </summary>
        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>();

            IDataListCompiler compiler    = DataListFactory.CreateDataListCompiler();
            IDev2IndexFinder  indexFinder = new Dev2IndexFinder();
            ErrorResultTO     allErrors   = new ErrorResultTO();
            ErrorResultTO     errors      = new ErrorResultTO();
            Guid executionId = DataListExecutionID.Get(context);

            InitializeDebug(dataObject);
            IDev2DataListUpsertPayloadBuilder <List <string> > toUpsert       = Dev2DataListBuilderFactory.CreateStringListDataListUpsertBuilder();
            IDev2DataListUpsertPayloadBuilder <string>         toUpsertScalar = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder();

            toUpsert.IsDebug       = dataObject.IsDebugMode();
            toUpsertScalar.IsDebug = dataObject.IsDebugMode();
            try
            {
                IDev2IteratorCollection outerIteratorCollection = Dev2ValueObjectFactory.CreateIteratorCollection();
                IDev2IteratorCollection innerIteratorCollection = Dev2ValueObjectFactory.CreateIteratorCollection();

                allErrors.MergeErrors(errors);


                IBinaryDataListEntry expressionsEntry = compiler.Evaluate(executionId, enActionType.User, Characters, false, out errors);
                allErrors.MergeErrors(errors);
                IDev2DataListEvaluateIterator itrChar = Dev2ValueObjectFactory.CreateEvaluateIterator(expressionsEntry);

                outerIteratorCollection.AddIterator(itrChar);

                #region Iterate and Find Index

                expressionsEntry = compiler.Evaluate(executionId, enActionType.User, InField, false, out errors);

                if (dataObject.IsDebugMode())
                {
                    AddDebugInputItem(new DebugItemVariableParams(InField, "In Field", expressionsEntry, executionId));
                    AddDebugInputItem(new DebugItemStaticDataParams(Index, "Index"));
                    AddDebugInputItem(new DebugItemVariableParams(Characters, "Characters", itrChar.FetchEntry(), executionId));
                    AddDebugInputItem(new DebugItemStaticDataParams(Direction, "Direction"));
                }

                var completeResultList = new List <string>();

                while (outerIteratorCollection.HasMoreData())
                {
                    allErrors.MergeErrors(errors);
                    errors.ClearErrors();
                    IDev2DataListEvaluateIterator itrInField = Dev2ValueObjectFactory.CreateEvaluateIterator(expressionsEntry);
                    innerIteratorCollection.AddIterator(itrInField);

                    string chars = outerIteratorCollection.FetchNextRow(itrChar).TheValue;
                    while (innerIteratorCollection.HasMoreData())
                    {
                        if (!string.IsNullOrEmpty(InField) && !string.IsNullOrEmpty(Characters))
                        {
                            var val = innerIteratorCollection.FetchNextRow(itrInField);
                            if (val != null)
                            {
                                IEnumerable <int> returedData = indexFinder.FindIndex(val.TheValue, Index, chars, Direction, MatchCase, StartIndex);
                                completeResultList.AddRange(returedData.Select(value => value.ToString(CultureInfo.InvariantCulture)).ToList());
                                //2013.06.03: Ashley Lewis for bug 9498 - handle multiple regions in result
                            }
                        }
                    }
                }
                var rule   = new IsSingleValueRule(() => Result);
                var single = rule.Check();
                if (single != null)
                {
                    allErrors.AddError(single.Message);
                }
                else
                {
                    var rsType = DataListUtil.GetRecordsetIndexType(Result);
                    if (rsType == enRecordsetIndexType.Numeric)
                    {
                        toUpsertScalar.Add(Result, string.Join(",", completeResultList));
                        compiler.Upsert(executionId, toUpsertScalar, out errors);
                        allErrors.MergeErrors(errors);
                        if (!allErrors.HasErrors() && dataObject.IsDebugMode())
                        {
                            foreach (var debugOutputTo in toUpsertScalar.DebugOutputs)
                            {
                                AddDebugOutputItem(new DebugItemVariableParams(debugOutputTo));
                            }
                            toUpsert.DebugOutputs.Clear();
                        }
                    }
                    else
                    {
                        toUpsert.Add(Result, completeResultList);
                        compiler.Upsert(executionId, toUpsert, out errors);
                        allErrors.MergeErrors(errors);
                        if (!allErrors.HasErrors() && dataObject.IsDebugMode())
                        {
                            foreach (var debugOutputTo in toUpsert.DebugOutputs)
                            {
                                AddDebugOutputItem(new DebugItemVariableParams(debugOutputTo));
                            }
                            toUpsert.DebugOutputs.Clear();
                        }
                    }
                }
                #endregion
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error("DSFFindActivity", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                #region Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfIndexActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                    compiler.Upsert(executionId, Result, (string)null, out errors);
                }

                #endregion

                if (dataObject.IsDebugMode())
                {
                    if (hasErrors)
                    {
                        foreach (var debugOutputTo in toUpsert.DebugOutputs)
                        {
                            AddDebugOutputItem(new DebugItemVariableParams(debugOutputTo));
                        }
                    }
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// When overridden runs the activity's execution logic
        /// </summary>
        /// <param name="context">The context to be used.</param>
        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            IDSFDataObject    dataObject = context.GetExtension <IDSFDataObject>();
            IDataListCompiler compiler   = DataListFactory.CreateDataListCompiler();
            Guid          dlId           = dataObject.DataListID;
            var           allErrors      = new ErrorResultTO();
            ErrorResultTO errors;
            Guid          executionId = DataListExecutionID.Get(context);

            InitializeDebug(dataObject);
            IDev2DataListUpsertPayloadBuilder <IBinaryDataListEntry> toUpsert = Dev2DataListBuilderFactory.CreateBinaryDataListUpsertBuilder(true);

            try
            {
                toUpsert.IsDebug = dataObject.IsDebugMode();
                toUpsert.AttachDebugFromExpression  = false;
                toUpsert.RecordSetDataAsCSVToScalar = true;
                toUpsert.ReplaceStarWithFixedIndex  = true;
                IBinaryDataListEntry rsEntry;

                // We need to break up by , for InFields ;)
                List <string> cols = BreakAndValidate(dlId, compiler, InFields, dataObject, true, out errors,
                                                      out rsEntry);
                allErrors.MergeErrors(errors);



                // Use row data?!, nope use row indexes ;)
                List <string> resultFields = BreakAndValidate(dlId, compiler, ResultFields, dataObject,
                                                              false, out errors, out rsEntry);
                allErrors.MergeErrors(errors);

                compiler.Evaluate(dlId, enActionType.User, ResultFields, false, out errors);
                allErrors.MergeErrors(errors);

                compiler.Evaluate(dlId, enActionType.User, InFields, false, out errors);
                allErrors.MergeErrors(errors);

                // Fetch the unique data ;)
                if (!allErrors.HasErrors())
                {
                    List <int> uniqueRowIndexes = rsEntry.GetDistinctRows(cols);

                    var shadowList = new List <IBinaryDataListEntry>();

                    // And break and validate the target expressions ;)
                    List <string> targetExpressions = DataListCleaningUtils.SplitIntoRegions(Result);

                    if (!allErrors.HasErrors())
                    {
                        // process each row ;)
                        foreach (var uidx in uniqueRowIndexes)
                        {
                            int idx = 0;

                            // something in here is off ;)
                            foreach (var targetExp in targetExpressions)
                            {
                                string error;
                                // clone, prep and shove into the upsert payload builder ;)
                                var clone = rsEntry.Clone(enTranslationDepth.Data, dlId, out error);
                                allErrors.AddError(error);
                                clone.MakeRecordsetEvaluateReady(uidx, resultFields[idx], out error);
                                allErrors.AddError(error);

                                // We need to replace * with fixed index? else we will over write all data all the time ;)
                                toUpsert.Add(targetExp, clone);

                                shadowList.Add(clone);

                                idx++;
                            }

                            toUpsert.FlushIterationFrame();
                        }

                        compiler.Upsert(executionId, toUpsert, out errors);
                        allErrors.MergeErrors(errors);
                        // If in debug mode, we have data and there is the correct debug info balance ;)
                        if (dataObject.IsDebugMode() && !allErrors.HasErrors())
                        {
                            int innerCount = 1;
                            foreach (var debugOutputTo in toUpsert.DebugOutputs)
                            {
                                var itemToAdd = new DebugItem();
                                AddDebugItem(new DebugItemStaticDataParams("", innerCount.ToString(CultureInfo.InvariantCulture)), itemToAdd);

                                AddDebugItem(new DebugItemVariableParams(debugOutputTo, targetExpressions.ToList()), itemToAdd);

                                UpdateStarNotationColumns(itemToAdd);
                                _debugOutputs.Add(itemToAdd);
                                innerCount++;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error("DSFUnique", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfUniqueActivity", allErrors);
                    compiler.UpsertSystemTag(dlId, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                    compiler.Upsert(executionId, Result, (string)null, out errors);
                }

                if (dataObject.IsDebugMode())
                {
                    if (hasErrors && !String.IsNullOrEmpty(Result))
                    {
                        IBinaryDataListEntry entry = compiler.Evaluate(dlId, enActionType.User, Result, false, out errors);
                        AddDebugOutputItem(new DebugItemVariableParams(Result, "", entry, dlId));
                    }
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// When overridden runs the activity's execution logic
        /// </summary>
        /// <param name="context">The context to be used.</param>
        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>();

            _dataObject = dataObject;
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            Guid          dlId         = dataObject.DataListID;
            ErrorResultTO allErrors    = new ErrorResultTO();
            ErrorResultTO errors;
            Guid          executionId     = DataListExecutionID.Get(context);
            int           indexToUpsertTo = 0;
            IDev2DataListUpsertPayloadBuilder <string> toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true);

            toUpsert.IsDebug = dataObject.IsDebugMode();

            InitializeDebug(dataObject);
            try
            {
                var colItr = Dev2ValueObjectFactory.CreateIteratorCollection();

                IBinaryDataListEntry fromAccountEntry = compiler.Evaluate(dlId, enActionType.User, FromAccount ?? string.Empty, false, out errors);

                allErrors.MergeErrors(errors);
                IDev2DataListEvaluateIterator fromAccountItr = Dev2ValueObjectFactory.CreateEvaluateIterator(fromAccountEntry);
                colItr.AddIterator(fromAccountItr);

                IBinaryDataListEntry passwordEntry = compiler.Evaluate(dlId, enActionType.User, Password, false, out errors);
                allErrors.MergeErrors(errors);
                IDev2DataListEvaluateIterator passwordItr = Dev2ValueObjectFactory.CreateEvaluateIterator(passwordEntry);
                colItr.AddIterator(passwordItr);

                IBinaryDataListEntry toEntry = compiler.Evaluate(dlId, enActionType.User, To, false, out errors);
                allErrors.MergeErrors(errors);
                IDev2DataListEvaluateIterator toItr = Dev2ValueObjectFactory.CreateEvaluateIterator(toEntry);
                colItr.AddIterator(toItr);

                IBinaryDataListEntry ccEntry = compiler.Evaluate(dlId, enActionType.User, Cc ?? string.Empty, false, out errors);
                allErrors.MergeErrors(errors);
                IDev2DataListEvaluateIterator ccItr = Dev2ValueObjectFactory.CreateEvaluateIterator(ccEntry);
                colItr.AddIterator(ccItr);

                IBinaryDataListEntry bccEntry = compiler.Evaluate(dlId, enActionType.User, Bcc ?? string.Empty, false, out errors);
                allErrors.MergeErrors(errors);
                IDev2DataListEvaluateIterator bccItr = Dev2ValueObjectFactory.CreateEvaluateIterator(bccEntry);
                colItr.AddIterator(bccItr);

                IBinaryDataListEntry subjectEntry = compiler.Evaluate(dlId, enActionType.User, Subject ?? string.Empty, false, out errors);
                allErrors.MergeErrors(errors);
                IDev2DataListEvaluateIterator subjectItr = Dev2ValueObjectFactory.CreateEvaluateIterator(subjectEntry);
                colItr.AddIterator(subjectItr);

                IBinaryDataListEntry bodyEntry = compiler.Evaluate(dlId, enActionType.User, Body ?? string.Empty, false, out errors);
                allErrors.MergeErrors(errors);
                IDev2DataListEvaluateIterator bodyItr = Dev2ValueObjectFactory.CreateEvaluateIterator(bodyEntry);
                colItr.AddIterator(bodyItr);

                IBinaryDataListEntry attachmentsEntry = compiler.Evaluate(dlId, enActionType.User, Attachments ?? string.Empty, false, out errors);
                allErrors.MergeErrors(errors);
                IDev2DataListEvaluateIterator attachmentsItr = Dev2ValueObjectFactory.CreateEvaluateIterator(attachmentsEntry);
                colItr.AddIterator(attachmentsItr);

                var runtimeSource = ResourceCatalog.Instance.GetResource <EmailSource>(dataObject.WorkspaceID, SelectedEmailSource.ResourceID);

                if (!allErrors.HasErrors())
                {
                    while (colItr.HasMoreData())
                    {
                        if (IsDebug)
                        {
                            var fromAccount = FromAccount;
                            if (String.IsNullOrEmpty(fromAccount))
                            {
                                fromAccount = runtimeSource.UserName;
                                AddDebugInputItem(fromAccount, "From Account");
                            }
                            else
                            {
                                AddDebugInputItem(new DebugItemVariableParams(FromAccount, "From Account", fromAccountEntry, executionId));
                            }
                            AddDebugInputItem(new DebugItemVariableParams(To, "To", toEntry, executionId));
                            AddDebugInputItem(new DebugItemVariableParams(Subject, "Subject", subjectEntry, executionId));
                            AddDebugInputItem(new DebugItemVariableParams(Body, "Body", bodyEntry, executionId));
                        }

                        var result = SendEmail(runtimeSource, colItr, fromAccountItr, passwordItr, toItr, ccItr, bccItr, subjectItr, bodyItr, attachmentsItr, out errors);
                        allErrors.MergeErrors(errors);
                        if (!allErrors.HasErrors())
                        {
                            indexToUpsertTo = UpsertResult(indexToUpsertTo, toUpsert, result);
                        }
                    }
                    compiler.Upsert(executionId, toUpsert, out errors);
                    allErrors.MergeErrors(errors);
                    if (IsDebug && !allErrors.HasErrors())
                    {
                        foreach (var debugOutputTo in toUpsert.DebugOutputs)
                        {
                            AddDebugOutputItem(new DebugItemVariableParams(debugOutputTo));
                        }
                    }
                }
                else
                {
                    if (IsDebug)
                    {
                        AddDebugInputItem(FromAccount, "From Account");
                        AddDebugInputItem(To, "To");
                        AddDebugInputItem(Subject, "Subject");
                        AddDebugInputItem(Body, "Body");
                    }
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error("DSFEmail", e);
                allErrors.AddError(e.Message);
            }

            finally
            {
                // Handle Errors

                if (allErrors.HasErrors())
                {
                    UpsertResult(indexToUpsertTo, toUpsert, null);
                    compiler.Upsert(executionId, toUpsert, out errors);
                    if (dataObject.IsDebugMode())
                    {
                        AddDebugOutputItem(new DebugItemStaticDataParams("", Result, ""));
                    }
                    DisplayAndWriteError("DsfSendEmailActivity", allErrors);
                    compiler.UpsertSystemTag(dlId, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                }
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }
Ejemplo n.º 22
0
        // ReSharper restore RedundantOverridenMember

        protected override void OnExecute(NativeActivityContext context)
        {
            _debugOutputs.Clear();
            _debugInputs.Clear();

            IDSFDataObject    dataObject = context.GetExtension <IDSFDataObject>();
            IDataListCompiler compiler   = DataListFactory.CreateDataListCompiler();
            IDev2DataListUpsertPayloadBuilder <string> toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(false);

            toUpsert.IsDebug    = (dataObject.IsDebugMode());
            toUpsert.ResourceID = dataObject.ResourceID;

            InitializeDebug(dataObject);

            ErrorResultTO errors      = new ErrorResultTO();
            ErrorResultTO allErrors   = new ErrorResultTO();
            Guid          executionId = DataListExecutionID.Get(context);

            try
            {
                if (!errors.HasErrors())
                {
                    foreach (ActivityDTO t in FieldsCollection)
                    {
                        if (!string.IsNullOrEmpty(t.FieldName))
                        {
                            var fieldName = t.FieldName;
                            fieldName = DataListUtil.IsValueRecordset(fieldName) ? DataListUtil.ReplaceRecordsetIndexWithBlank(fieldName) : fieldName;
                            var datalist = compiler.ConvertFrom(dataObject.DataListID, DataListFormat.CreateFormat(GlobalConstants._Studio_XML), enTranslationDepth.Shape, out errors).ToString();
                            if (!string.IsNullOrEmpty(datalist))
                            {
                                var isValidExpr = new IsValidExpressionRule(() => fieldName, datalist)
                                {
                                    LabelText = fieldName
                                };

                                var errorInfo = isValidExpr.Check();
                                if (errorInfo != null)
                                {
                                    t.FieldName = "";
                                    errors.AddError(errorInfo.Message);
                                }
                                allErrors.MergeErrors(errors);
                            }

                            string eval = t.FieldValue;

                            if (eval.StartsWith("@"))
                            {
                                eval = GetEnviromentVariable(dataObject, context, eval);
                            }

                            toUpsert.Add(t.FieldName, eval);
                        }
                    }

                    compiler.Upsert(executionId, toUpsert, out errors);
                    allErrors.MergeErrors(errors);

                    if (dataObject.IsDebugMode() && !allErrors.HasErrors())
                    {
                        AddDebugTos(toUpsert, executionId);
                    }
                    allErrors.MergeErrors(errors);
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error(e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfAssignActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                }
                if (dataObject.IsDebugMode())
                {
                    if (hasErrors)
                    {
                        AddDebugTos(toUpsert, executionId);
                    }
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }
Ejemplo n.º 23
0
        // ReSharper restore RedundantOverridenMember

        /// <summary>
        /// The execute method that is called when the activity is executed at run time and will hold all the logic of the activity
        /// </summary>
        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();

            IDSFDataObject    dataObject = context.GetExtension <IDSFDataObject>();
            IDataListCompiler compiler   = DataListFactory.CreateDataListCompiler();

            IDev2DataListUpsertPayloadBuilder <string> toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true);

            toUpsert.IsDebug = dataObject.IsDebugMode();
            toUpsert.ReplaceStarWithFixedIndex = true;

            ErrorResultTO allErrors   = new ErrorResultTO();
            ErrorResultTO errors      = new ErrorResultTO();
            Guid          executionId = DataListExecutionID.Get(context);

            InitializeDebug(dataObject);
            try
            {
                CleanArgs();
                ICaseConverter converter = CaseConverterFactory.CreateCaseConverter();

                allErrors.MergeErrors(errors);

                int index    = 1;
                int outIndex = 0;
                foreach (ICaseConvertTO item in ConvertCollection)
                {
                    outIndex++;
                    IBinaryDataListEntry tmp = compiler.Evaluate(executionId, enActionType.User, item.StringToConvert, false, out errors);
                    allErrors.MergeErrors(errors);
                    ValidateVariable(item.Result, compiler, dataObject, out errors);
                    allErrors.MergeErrors(errors);
                    IsSingleValueRule.ApplyIsSingleValueRule(item.ExpressionToConvert, allErrors);
                    if (dataObject.IsDebugMode())
                    {
                        var debugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams("", index.ToString(CultureInfo.InvariantCulture)), debugItem);
                        AddDebugItem(new DebugItemVariableParams(item.StringToConvert, "Convert", tmp, executionId), debugItem);
                        AddDebugItem(new DebugItemStaticDataParams(item.ConvertType, "To"), debugItem);
                        _debugInputs.Add(debugItem);
                        index++;
                    }

                    if (tmp != null)
                    {
                        IDev2DataListEvaluateIterator itr = Dev2ValueObjectFactory.CreateEvaluateIterator(tmp);

                        while (itr.HasMoreRecords())
                        {
                            foreach (IBinaryDataListItem itm in itr.FetchNextRowData())
                            {
                                try
                                {
                                    IBinaryDataListItem res = converter.TryConvert(item.ConvertType, itm);
                                    string expression       = item.Result;

                                    // 27.08.2013
                                    // NOTE : The result must remain [ as this is how the fliping studio generates the result when using (*) notation
                                    // There is a proper bug in to fix this issue, but since the studio is spaghetti I will leave this to the experts ;)
                                    // This is a tmp fix to the issue
                                    if (expression == "[" || DataListUtil.GetRecordsetIndexType(expression) == enRecordsetIndexType.Star)
                                    {
                                        expression = DataListUtil.AddBracketsToValueIfNotExist(res.DisplayValue);
                                    }
                                    //2013.06.03: Ashley Lewis for bug 9498 - handle multiple regions in result
                                    IsSingleValueRule rule = new IsSingleValueRule(() => expression);
                                    var singleresError     = rule.Check();
                                    if (singleresError != null)
                                    {
                                        allErrors.AddError(singleresError.Message);
                                    }
                                    else
                                    {
                                        toUpsert.Add(expression, res.TheValue);
                                        // Upsert the entire payload
                                    }
                                    allErrors.MergeErrors(errors);
                                }
                                catch (Exception e)
                                {
                                    allErrors.AddError(e.Message);
                                    toUpsert.Add(item.Result, null);
                                }
                            }
                        }
                        compiler.Upsert(executionId, toUpsert, out errors);
                        if (!allErrors.HasErrors() && dataObject.IsDebugMode())
                        {
                            foreach (var debugOutputTo in toUpsert.DebugOutputs)
                            {
                                var debugItem = new DebugItem();
                                AddDebugItem(new DebugItemStaticDataParams("", outIndex.ToString(CultureInfo.InvariantCulture)), debugItem);
                                AddDebugItem(new DebugItemVariableParams(debugOutputTo), debugItem);
                                _debugOutputs.Add(debugItem);
                            }
                            toUpsert.DebugOutputs.Clear();
                        }
                    }
                }
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfCaseConvertActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                }
                if (dataObject.IsDebugMode())
                {
                    if (hasErrors)
                    {
                        int outIndex = 1;
                        foreach (ICaseConvertTO item in ConvertCollection)
                        {
                            IBinaryDataListEntry tmp = compiler.Evaluate(executionId, enActionType.User, item.StringToConvert, false, out errors);
                            var debugItem            = new DebugItem();
                            AddDebugItem(new DebugItemStaticDataParams("", outIndex.ToString(CultureInfo.InvariantCulture)), debugItem);
                            AddDebugItem(new DebugItemVariableParams(item.Result, "", tmp, executionId), debugItem);
                            _debugOutputs.Add(debugItem);
                            outIndex++;
                        }
                    }
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// When overridden runs the activity's execution logic
        /// </summary>
        /// <param name="context">The context to be used.</param>
        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>();

            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();

            Guid          dlId          = dataObject.DataListID;
            ErrorResultTO allErrors     = new ErrorResultTO();
            ErrorResultTO errorResultTo = new ErrorResultTO();
            Guid          executionId   = dlId;

            allErrors.MergeErrors(errorResultTo);


            try
            {
                if (!errorResultTo.HasErrors())
                {
                    IDev2DataListUpsertPayloadBuilder <string> toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true);
                    IDev2IteratorCollection colItr = Dev2ValueObjectFactory.CreateIteratorCollection();

                    if (allErrors.HasErrors())
                    {
                        return;
                    }
                    IBinaryDataListEntry scriptEntry = compiler.Evaluate(executionId, enActionType.User, Script, false, out errorResultTo);
                    allErrors.MergeErrors(errorResultTo);
                    if (allErrors.HasErrors())
                    {
                        return;
                    }

                    if (dataObject.IsDebugMode())
                    {
                        AddDebugInputItem(Script, scriptEntry, executionId);
                    }

                    int iterationCounter = 0;

                    while (colItr.HasMoreData())
                    {
                        dynamic value = null;

                        //2013.06.03: Ashley Lewis for bug 9498 - handle multiple regions in result
                        foreach (var region in DataListCleaningUtils.SplitIntoRegions(Result))
                        {
                            toUpsert.Add(region, null);
                            toUpsert.FlushIterationFrame();

                            if (dataObject.IsDebugMode())
                            {
                                // ReSharper disable ExpressionIsAlwaysNull
                                AddDebugOutputItem(new DebugOutputParams(region, value, executionId, iterationCounter));
                                // ReSharper restore ExpressionIsAlwaysNull
                            }
                        }

                        iterationCounter++;
                    }

                    compiler.Upsert(executionId, toUpsert, out errorResultTo);
                    allErrors.MergeErrors(errorResultTo);
                }
            }
            catch (Exception e)
            {
                allErrors.AddError(e.GetType() == typeof(NullReferenceException) ? "There was an error when returning a value from the javascript, remember to use the 'Return' keyword when returning the result" : e.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfScriptingJavaScriptActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errorResultTo);
                    compiler.Upsert(executionId, Result, (string)null, out errorResultTo);
                }

                if (dataObject.IsDebugMode())
                {
                    if (hasErrors)
                    {
                        AddDebugOutputItem(new DebugItemStaticDataParams("", Result, ""));
                    }

                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }
Ejemplo n.º 25
0
        // ReSharper restore RedundantOverridenMember

        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            IDSFDataObject       dataObject      = context.GetExtension <IDSFDataObject>();
            IDataListCompiler    compiler        = DataListFactory.CreateDataListCompiler();
            IDev2MergeOperations mergeOperations = new Dev2MergeOperations();
            ErrorResultTO        allErrors       = new ErrorResultTO();
            ErrorResultTO        errorResultTo   = new ErrorResultTO();
            Guid executionId = DataListExecutionID.Get(context);
            IDev2DataListUpsertPayloadBuilder <string> toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true);

            toUpsert.IsDebug    = dataObject.IsDebugMode();
            toUpsert.ResourceID = dataObject.ResourceID;

            InitializeDebug(dataObject);
            try
            {
                CleanArguments(MergeCollection);

                if (MergeCollection.Count <= 0)
                {
                    return;
                }

                IDev2IteratorCollection iteratorCollection = Dev2ValueObjectFactory.CreateIteratorCollection();


                allErrors.MergeErrors(errorResultTo);
                Dictionary <int, List <IDev2DataListEvaluateIterator> > listOfIterators = new Dictionary <int, List <IDev2DataListEvaluateIterator> >();

                #region Create a iterator for each row in the data grid in the designer so that the right iteration happen on the data

                int dictionaryKey = 0;
                foreach (DataMergeDTO row in MergeCollection)
                {
                    IBinaryDataListEntry inputVariableExpressionEntry = compiler.Evaluate(executionId, enActionType.User, row.InputVariable, false, out errorResultTo);
                    allErrors.MergeErrors(errorResultTo);

                    IBinaryDataListEntry atExpressionEntry = compiler.Evaluate(executionId, enActionType.User, row.At, false, out errorResultTo);
                    allErrors.MergeErrors(errorResultTo);

                    IBinaryDataListEntry paddingExpressionEntry = compiler.Evaluate(executionId, enActionType.User, row.Padding, false, out errorResultTo);
                    allErrors.MergeErrors(errorResultTo);

                    var fieldName        = row.InputVariable;
                    var splitIntoRegions = DataListCleaningUtils.FindAllLanguagePieces(fieldName);
                    var datalist         = compiler.ConvertFrom(dataObject.DataListID, DataListFormat.CreateFormat(GlobalConstants._Studio_XML), enTranslationDepth.Shape, out errorResultTo).ToString();
                    if (!string.IsNullOrEmpty(datalist))
                    {
                        foreach (var region in splitIntoRegions)
                        {
                            var r           = DataListUtil.IsValueRecordset(region) ? DataListUtil.ReplaceRecordsetIndexWithBlank(region) : region;
                            var isValidExpr = new IsValidExpressionRule(() => r, datalist)
                            {
                                LabelText = fieldName
                            };

                            var errorInfo = isValidExpr.Check();
                            if (errorInfo != null)
                            {
                                row.InputVariable = "";
                                errorResultTo.AddError(errorInfo.Message);
                            }
                            allErrors.MergeErrors(errorResultTo);
                        }
                    }

                    allErrors.MergeErrors(errorResultTo);

                    if (dataObject.IsDebugMode())
                    {
                        DebugItem debugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams("", (MergeCollection.IndexOf(row) + 1).ToString(CultureInfo.InvariantCulture)), debugItem);
                        AddDebugItem(new DebugItemVariableParams(row.InputVariable, "", inputVariableExpressionEntry, executionId), debugItem);
                        AddDebugItem(new DebugItemStaticDataParams(row.MergeType, "With"), debugItem);
                        AddDebugItem(new DebugItemVariableParams(row.At, "Using", atExpressionEntry, executionId), debugItem);
                        AddDebugItem(new DebugItemVariableParams(row.Padding, "Pad", paddingExpressionEntry, executionId), debugItem);

                        //Old workflows don't have this set.
                        if (row.Alignment == null)
                        {
                            row.Alignment = string.Empty;
                        }

                        AddDebugItem(DataListUtil.IsEvaluated(row.Alignment) ? new DebugItemStaticDataParams("", row.Alignment, "Align") : new DebugItemStaticDataParams(row.Alignment, "Align"), debugItem);

                        _debugInputs.Add(debugItem);
                    }

                    IDev2DataListEvaluateIterator itr    = Dev2ValueObjectFactory.CreateEvaluateIterator(inputVariableExpressionEntry);
                    IDev2DataListEvaluateIterator atItr  = Dev2ValueObjectFactory.CreateEvaluateIterator(atExpressionEntry);
                    IDev2DataListEvaluateIterator padItr = Dev2ValueObjectFactory.CreateEvaluateIterator(paddingExpressionEntry);

                    iteratorCollection.AddIterator(itr);
                    iteratorCollection.AddIterator(atItr);
                    iteratorCollection.AddIterator(padItr);

                    listOfIterators.Add(dictionaryKey, new List <IDev2DataListEvaluateIterator> {
                        itr, atItr, padItr
                    });
                    dictionaryKey++;
                }

                #endregion

                #region Iterate and Merge Data
                if (!allErrors.HasErrors())
                {
                    while (iteratorCollection.HasMoreData())
                    {
                        int pos = 0;
                        foreach (var iterator in listOfIterators)
                        {
                            var val = iteratorCollection.FetchNextRow(iterator.Value[0]);
                            var at  = iteratorCollection.FetchNextRow(iterator.Value[1]);
                            var pad = iteratorCollection.FetchNextRow(iterator.Value[2]);

                            if (val != null)
                            {
                                if (at != null)
                                {
                                    if (pad != null)
                                    {
                                        if (MergeCollection[pos].MergeType == "Index")
                                        {
                                            if (string.IsNullOrEmpty(at.TheValue))
                                            {
                                                allErrors.AddError("The 'Using' value cannot be blank.");
                                            }

                                            int atValue;
                                            if (!Int32.TryParse(at.TheValue, out atValue) || atValue < 0)
                                            {
                                                allErrors.AddError("The 'Using' value must be a real number.");
                                            }
                                            if (pad.TheValue.Length > 1)
                                            {
                                                allErrors.AddError("'Padding' must be a single character");
                                            }
                                        }
                                        else
                                        {
                                            if (MergeCollection[pos].MergeType == "Chars" && string.IsNullOrEmpty(at.TheValue))
                                            {
                                                allErrors.AddError("The 'Using' value cannot be blank.");
                                            }
                                        }
                                        mergeOperations.Merge(val.TheValue, MergeCollection[pos].MergeType, at.TheValue, pad.TheValue, MergeCollection[pos].Alignment);
                                        pos++;
                                    }
                                }
                            }
                        }
                    }
                    if (!allErrors.HasErrors())
                    {
                        if (string.IsNullOrEmpty(Result))
                        {
                            AddDebugOutputItem(new DebugItemStaticDataParams("", ""));
                        }
                        else
                        {
                            var rule   = new IsSingleValueRule(() => Result);
                            var single = rule.Check();
                            if (single != null)
                            {
                                allErrors.AddError(single.Message);
                            }
                            else
                            {
                                toUpsert.Add(Result, mergeOperations.MergeData.ToString());
                                toUpsert.FlushIterationFrame();
                                compiler.Upsert(executionId, toUpsert, out errorResultTo);
                                allErrors.MergeErrors(errorResultTo);

                                if (dataObject.IsDebugMode() && !allErrors.HasErrors())
                                {
                                    foreach (var debugOutputTo in toUpsert.DebugOutputs)
                                    {
                                        if (debugOutputTo.LeftEntry != null && debugOutputTo.TargetEntry != null)
                                        {
                                            AddDebugOutputItem(new DebugItemVariableParams(debugOutputTo));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                #endregion Iterate and Merge Data
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error("DSFDataMerge", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                #region Handle Errors

                if (allErrors.HasErrors())
                {
                    if (dataObject.IsDebugMode())
                    {
                        AddDebugOutputItem(new DebugItemStaticDataParams("", Result, ""));
                    }
                    DisplayAndWriteError("DsfDataMergeActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errorResultTo);
                    compiler.Upsert(executionId, Result, (string)null, out errorResultTo);
                }

                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }

                #endregion
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Executes the logic of the activity and calls the backend code to do the work
        /// Also responsible for adding the results to the data list
        /// </summary>
        /// <param name="context"></param>
        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            IDataListCompiler     compiler         = DataListFactory.CreateDataListCompiler();
            IDSFDataObject        dataObject       = context.GetExtension <IDSFDataObject>();
            IDev2ReplaceOperation replaceOperation = Dev2OperationsFactory.CreateReplaceOperation();
            IDev2DataListUpsertPayloadBuilder <string> toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(false);

            toUpsert.IsDebug = dataObject.IsDebugMode();
            ErrorResultTO errors;
            ErrorResultTO allErrors   = new ErrorResultTO();
            Guid          executionId = DataListExecutionID.Get(context);

            IDev2IteratorCollection iteratorCollection = Dev2ValueObjectFactory.CreateIteratorCollection();

            IBinaryDataListEntry expressionsEntryFind = compiler.Evaluate(executionId, enActionType.User, Find, false, out errors);

            allErrors.MergeErrors(errors);
            IDev2DataListEvaluateIterator itrFind = Dev2ValueObjectFactory.CreateEvaluateIterator(expressionsEntryFind);

            iteratorCollection.AddIterator(itrFind);

            IBinaryDataListEntry expressionsEntryReplaceWith = compiler.Evaluate(executionId, enActionType.User, ReplaceWith, false, out errors);

            allErrors.MergeErrors(errors);
            IDev2DataListEvaluateIterator itrReplace = Dev2ValueObjectFactory.CreateEvaluateIterator(expressionsEntryReplaceWith);

            iteratorCollection.AddIterator(itrReplace);
            int replacementCount = 0;
            int replacementTotal = 0;

            InitializeDebug(dataObject);
            try
            {
                IList <string> toSearch = FieldsToSearch.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var s in toSearch)
                {
                    if (dataObject.IsDebugMode())
                    {
                        IBinaryDataListEntry inFieldsEntry = compiler.Evaluate(executionId, enActionType.User, s, false, out errors);
                        AddDebugInputItem(new DebugItemVariableParams(s, "In Field(s)", inFieldsEntry, executionId));
                    }
                }
                var rule   = new IsSingleValueRule(() => Result);
                var single = rule.Check();
                if (single != null)
                {
                    allErrors.AddError(single.Message);
                }
                else
                {
                    while (iteratorCollection.HasMoreData())
                    {
                        // now process each field for entire evaluated Where expression....
                        var findValue        = iteratorCollection.FetchNextRow(itrFind).TheValue;
                        var replaceWithValue = iteratorCollection.FetchNextRow(itrReplace).TheValue;
                        foreach (string s in toSearch)
                        {
                            if (!DataListUtil.IsEvaluated(s))
                            {
                                allErrors.AddError("Please insert only variables into Fields To Search");
                                return;
                            }
                            if (!string.IsNullOrEmpty(findValue))
                            {
                                IBinaryDataListEntry entryToReplaceIn;
                                toUpsert = replaceOperation.Replace(executionId, s.Trim(), findValue, replaceWithValue, CaseMatch, toUpsert, out errors, out replacementCount, out entryToReplaceIn);
                            }

                            replacementTotal += replacementCount;

                            allErrors.MergeErrors(errors);
                        }
                    }
                }
                if (dataObject.IsDebugMode())
                {
                    AddDebugInputItem(new DebugItemVariableParams(Find, "Find", expressionsEntryFind, executionId));
                    AddDebugInputItem(new DebugItemVariableParams(ReplaceWith, "Replace With", expressionsEntryReplaceWith, executionId));
                }

                toUpsert.Add(Result, replacementTotal.ToString(CultureInfo.InvariantCulture));


                // now push the result to the server
                compiler.Upsert(executionId, toUpsert, out errors);
                allErrors.MergeErrors(errors);
                if (dataObject.IsDebugMode() && !allErrors.HasErrors())
                {
                    foreach (var debugOutputTo in toUpsert.DebugOutputs)
                    {
                        AddDebugOutputItem(new DebugItemVariableParams(debugOutputTo));
                    }
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch (Exception ex)
            {
                Dev2Logger.Log.Error("DSFReplace", ex);
                allErrors.AddError(ex.Message);
            }
            finally
            {
                if (allErrors.HasErrors())
                {
                    if (dataObject.IsDebugMode())
                    {
                        AddDebugOutputItem(new DebugItemStaticDataParams("", Result, ""));
                    }
                    DisplayAndWriteError("DsfReplaceActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                    compiler.Upsert(executionId, Result, (string)null, out errors);
                }

                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }
Ejemplo n.º 27
0
        protected override void OnExecute(NativeActivityContext context)
        {
            _debugOutputs.Clear();

            IDSFDataObject    dataObject = context.GetExtension <IDSFDataObject>();
            IDataListCompiler compiler   = DataListFactory.CreateDataListCompiler();
            IDev2DataListUpsertPayloadBuilder <List <string> > toUpsert = Dev2DataListBuilderFactory.CreateStringListDataListUpsertBuilder();

            _isDebugMode        = dataObject.IsDebugMode();
            toUpsert.IsDebug    = _isDebugMode;
            toUpsert.ResourceID = dataObject.ResourceID;
            ErrorResultTO errors      = new ErrorResultTO();
            ErrorResultTO allErrors   = new ErrorResultTO();
            Guid          executionId = DataListExecutionID.Get(context);
            XPathParser   parser      = new XPathParser();
            int           i           = 0;

            InitializeDebug(dataObject);
            try
            {
                if (!errors.HasErrors())
                {
                    IBinaryDataListEntry expressionsEntry = compiler.Evaluate(executionId, enActionType.User, SourceString, false, out errors);

                    if (_isDebugMode)
                    {
                        AddSourceStringDebugInputItem(SourceString, expressionsEntry, executionId);
                        AddResultDebugInputs(ResultsCollection, executionId, compiler, out errors);
                        allErrors.MergeErrors(errors);
                    }
                    if (!allErrors.HasErrors())
                    {
                        IDev2DataListEvaluateIterator itr = Dev2ValueObjectFactory.CreateEvaluateIterator(expressionsEntry);
                        while (itr.HasMoreRecords())
                        {
                            IList <IBinaryDataListItem> cols = itr.FetchNextRowData();
                            foreach (IBinaryDataListItem c in cols)
                            {
                                for (i = 0; i < ResultsCollection.Count; i++)
                                {
                                    if (!string.IsNullOrEmpty(ResultsCollection[i].OutputVariable))
                                    {
                                        IBinaryDataListEntry          xpathEntry = compiler.Evaluate(executionId, enActionType.User, ResultsCollection[i].XPath, false, out errors);
                                        IDev2DataListEvaluateIterator xpathItr   = Dev2ValueObjectFactory.CreateEvaluateIterator(xpathEntry);
                                        while (xpathItr.HasMoreRecords())
                                        {
                                            IList <IBinaryDataListItem> xpathCols = xpathItr.FetchNextRowData();
                                            foreach (IBinaryDataListItem xPathCol in xpathCols)
                                            {
                                                try
                                                {
                                                    List <string> eval = parser.ExecuteXPath(c.TheValue, xPathCol.TheValue).ToList();

                                                    //2013.06.03: Ashley Lewis for bug 9498 - handle line breaks in multi assign
                                                    string[] openParts  = Regex.Split(ResultsCollection[i].OutputVariable, @"\[\[");
                                                    string[] closeParts = Regex.Split(ResultsCollection[i].OutputVariable, @"\]\]");
                                                    if (openParts.Count() == closeParts.Count() && openParts.Count() > 2 && closeParts.Count() > 2)
                                                    {
                                                        foreach (var newFieldName in openParts)
                                                        {
                                                            if (!string.IsNullOrEmpty(newFieldName))
                                                            {
                                                                string cleanFieldName;
                                                                if (newFieldName.IndexOf("]]", StringComparison.Ordinal) + 2 < newFieldName.Length)
                                                                {
                                                                    cleanFieldName = "[[" + newFieldName.Remove(newFieldName.IndexOf("]]", StringComparison.Ordinal) + 2);
                                                                }
                                                                else
                                                                {
                                                                    cleanFieldName = "[[" + newFieldName;
                                                                }
                                                                toUpsert.Add(cleanFieldName, eval);
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        toUpsert.Add(ResultsCollection[i].OutputVariable, eval);
                                                    }
                                                }
                                                catch (Exception)
                                                {
                                                    toUpsert.Add(ResultsCollection[i].OutputVariable, null);
                                                }
                                            }
                                        }
                                    }
                                }
                                compiler.Upsert(executionId, toUpsert, out errors);
                            }

                            allErrors.MergeErrors(errors);
                        }
                    }
                    if (_isDebugMode && !allErrors.HasErrors())
                    {
                        var innerCount = 1;
                        foreach (var debugOutputTo in toUpsert.DebugOutputs)
                        {
                            var itemToAdd = new DebugItem();
                            AddDebugItem(new DebugItemStaticDataParams("", innerCount.ToString(CultureInfo.InvariantCulture)), itemToAdd);
                            AddDebugItem(new DebugItemVariableParams(debugOutputTo), itemToAdd);
                            _debugOutputs.Add(itemToAdd);
                            innerCount++;
                        }
                        toUpsert.DebugOutputs.Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                allErrors.AddError(ex.Message);
            }
            finally
            {
                // Handle Errors

                var actualIndex = i - 1;
                var hasErrors   = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfXPathActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                    compiler.Upsert(executionId, ResultsCollection[actualIndex].OutputVariable, (string)null, out errors);
                }
                if (_isDebugMode)
                {
                    if (hasErrors)
                    {
                        if (_isDebugMode)
                        {
                            ResultsCollection[actualIndex].XPath = "";
                            var itemToAdd = new DebugItem();
                            AddDebugItem(new DebugItemStaticDataParams("", (actualIndex + 1).ToString(CultureInfo.InvariantCulture)), itemToAdd);
                            AddDebugItem(new DebugOutputParams(ResultsCollection[actualIndex].OutputVariable, "", executionId, actualIndex + 1), itemToAdd);
                            _debugOutputs.Add(itemToAdd);
                        }
                    }
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }
Ejemplo n.º 28
0
        public IDev2DataListUpsertPayloadBuilder <string> Replace(Guid exIdx, string expression, string oldString, string newString, bool caseMatch, IDev2DataListUpsertPayloadBuilder <string> payloadBuilder, out ErrorResultTO errors, out int ReplaceCount, out IBinaryDataListEntry entryToReplaceIn)
        {
            ReplaceCount = 0;
            oldString    = oldString.Replace("\\", "\\\\");
            // ReSharper disable RedundantAssignment
            ErrorResultTO allErrors = new ErrorResultTO();

            errors = new ErrorResultTO();
            // ReSharper restore RedundantAssignment
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();

            entryToReplaceIn = compiler.Evaluate(exIdx, enActionType.User, expression, false, out errors);
            allErrors.MergeErrors(errors);

            if (entryToReplaceIn != null)
            {
                RegexOptions regexOptions;
                if (caseMatch)
                {
                    regexOptions = NoneCompiled;
                }
                else
                {
                    regexOptions = IgnoreCaseCompiled;
                }

                //Massimo Guerrera -  Added the Regex.Escape to escape certain characters - Bug 9937
                Regex regex = new Regex(Regex.Escape(oldString), regexOptions);

                IDev2DataListEvaluateIterator itr = Dev2ValueObjectFactory.CreateEvaluateIterator(entryToReplaceIn);
                while (itr.HasMoreRecords())
                {
                    IList <IBinaryDataListItem> rowList = itr.FetchNextRowData();
                    if (rowList != null)
                    {
                        foreach (IBinaryDataListItem binaryDataListItem in rowList)
                        {
                            int    tmpCount = ReplaceCount;
                            string tmpVal   = binaryDataListItem.TheValue;
                            if (tmpVal.Contains("\\") && oldString.Contains("\\"))
                            {
                                tmpVal = tmpVal.Replace("\\", "\\\\");
                            }

                            ReplaceCount += regex.Matches(tmpVal).Count;
                            if (ReplaceCount > tmpCount)
                            {
                                if (entryToReplaceIn.IsRecordset)
                                {
                                    string recsetDisplayValue =
                                        DataListUtil.CreateRecordsetDisplayValue(entryToReplaceIn.Namespace, binaryDataListItem.FieldName, binaryDataListItem.ItemCollectionIndex.ToString());
                                    expression = string.Concat("[[", recsetDisplayValue, "]]");
                                }

                                var replaceValue = regex.Replace(tmpVal, newString);
                                payloadBuilder.Add(expression, replaceValue);
                            }
                        }
                    }
                }
                payloadBuilder.FlushIterationFrame();
            }
            else
            {
                allErrors.AddError("DataList entry is null.");
            }

            errors = allErrors;

            return(payloadBuilder);
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Upserts the specified cur DLID.
 /// </summary>
 /// <param name="curDlid">The cur DLID.</param>
 /// <param name="payload">The payload.</param>
 /// <param name="errors">The errors.</param>
 /// <returns></returns>
 public Guid Upsert(Guid curDlid, IDev2DataListUpsertPayloadBuilder <IBinaryDataListEntry> payload, out ErrorResultTO errors)
 {
     return(_svrCompiler.Upsert(null, curDlid, payload, out errors));
 }
Ejemplo n.º 30
0
        // ReSharper restore RedundantOverridenMember


        /// <summary>
        /// The execute method that is called when the activity is executed at run time and will hold all the logic of the activity
        /// </summary>
        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            _indexCounter = 0;
            IDSFDataObject    dataObject = context.GetExtension <IDSFDataObject>();
            IDataListCompiler compiler   = DataListFactory.CreateDataListCompiler();

            ErrorResultTO allErrors = new ErrorResultTO();
            ErrorResultTO errors;
            Guid          executionId = DataListExecutionID.Get(context);
            IDev2DataListUpsertPayloadBuilder <string> toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(false);

            InitializeDebug(dataObject);

            try
            {
                CleanArgs();

                toUpsert.IsDebug = dataObject.IsDebugMode();

                foreach (var item in ConvertCollection)
                {
                    try
                    {
                        _indexCounter++;
                        // Travis.Frisinger - This needs to be in the ViewModel not here ;)
                        if (item.ToExpression == string.Empty)
                        {
                            item.ToExpression = item.FromExpression;
                        }
                        IsSingleValueRule.ApplyIsSingleValueRule(item.FromExpression, allErrors);
                        var fieldName = item.FromExpression;
                        fieldName = DataListUtil.IsValueRecordset(fieldName) ? DataListUtil.ReplaceRecordsetIndexWithBlank(fieldName) : fieldName;
                        var datalist = compiler.ConvertFrom(dataObject.DataListID, DataListFormat.CreateFormat(GlobalConstants._Studio_XML), Dev2.DataList.Contract.enTranslationDepth.Shape, out errors);
                        if (!datalist.IsNullOrEmpty())
                        {
                            var isValidExpr = new IsValidExpressionRule(() => fieldName, datalist.ToString())
                            {
                                LabelText = fieldName
                            };

                            var errorInfo = isValidExpr.Check();
                            if (errorInfo != null)
                            {
                                item.FromExpression = "";
                                errors.AddError(errorInfo.Message);
                            }
                            allErrors.MergeErrors(errors);
                        }

                        IBinaryDataListEntry tmp = compiler.Evaluate(executionId, enActionType.User, item.FromExpression, false, out errors);
                        if (dataObject.IsDebugMode())
                        {
                            AddDebugInputItem(item.FromExpression, tmp, executionId, item.FromType, item.ToType);
                        }
                        allErrors.MergeErrors(errors);
                        if (tmp != null)
                        {
                            IDev2DataListEvaluateIterator itr = Dev2ValueObjectFactory.CreateEvaluateIterator(tmp);

                            IBaseConverter        from   = _fac.CreateConverter((enDev2BaseConvertType)Dev2EnumConverter.GetEnumFromStringDiscription(item.FromType, typeof(enDev2BaseConvertType)));
                            IBaseConverter        to     = _fac.CreateConverter((enDev2BaseConvertType)Dev2EnumConverter.GetEnumFromStringDiscription(item.ToType, typeof(enDev2BaseConvertType)));
                            IBaseConversionBroker broker = _fac.CreateBroker(from, to);

                            // process result information
                            while (itr.HasMoreRecords())
                            {
                                IList <IBinaryDataListItem> cols = itr.FetchNextRowData();
                                foreach (IBinaryDataListItem c in cols)
                                {
                                    // set up live flushing iterator details
                                    if (c.IsDeferredRead)
                                    {
                                        if (toUpsert != null)
                                        {
                                            toUpsert.HasLiveFlushing      = true;
                                            toUpsert.LiveFlushingLocation = executionId;
                                        }
                                    }

                                    int indexToUpsertTo = c.ItemCollectionIndex;

                                    string val        = string.IsNullOrEmpty(c.TheValue) ? "" : broker.Convert(c.TheValue);
                                    string expression = item.ToExpression;

                                    if (DataListUtil.IsValueRecordset(item.ToExpression) && DataListUtil.GetRecordsetIndexType(item.ToExpression) == enRecordsetIndexType.Star)
                                    {
                                        expression = item.ToExpression.Replace(GlobalConstants.StarExpression, indexToUpsertTo.ToString(CultureInfo.InvariantCulture));
                                    }
                                    toUpsert.Add(expression, val);
                                    if (toUpsert != null && toUpsert.HasLiveFlushing)
                                    {
                                        toUpsert.FlushIterationFrame();
                                        toUpsert = null;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Dev2Logger.Log.Error("DSFBaseConvert", e);
                        allErrors.AddError(e.Message);
                    }
                    finally
                    {
                        if (allErrors.HasErrors())
                        {
                            toUpsert.Add(item.ToExpression, null);
                        }
                    }
                }

                if (toUpsert != null && toUpsert.HasLiveFlushing)
                {
                    try
                    {
                        toUpsert.FlushIterationFrame();
                    }
                    catch (Exception e)
                    {
                        Dev2Logger.Log.Error("DSFBaseConvert", e);
                        allErrors.AddError(e.Message);
                    }
                }
                else
                {
                    compiler.Upsert(executionId, toUpsert, out errors);
                    allErrors.MergeErrors(errors);
                }

                if (!allErrors.HasErrors() && toUpsert != null)
                {
                    var outIndex = 1;
                    foreach (var debugOutputTo in toUpsert.DebugOutputs)
                    {
                        var debugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams("", outIndex.ToString(CultureInfo.InvariantCulture)), debugItem);
                        AddDebugItem(new DebugItemVariableParams(debugOutputTo), debugItem);
                        _debugOutputs.Add(debugItem);
                        outIndex++;
                    }
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error("DSFBaseConvert", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfBaseConvertActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                }
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }