Esempio n. 1
0
        public void ApplyUpdate(string expression, Func <DataStorage.WarewolfAtom, DataStorage.WarewolfAtom> clause, int update)
        {
            var s = UpdateDataSourceWithIterativeValue(_datasource, update, expression);

            if (s.Contains("[[@"))
            {
                var res = _inner.Eval(s, 0);
                if (res.IsWarewolfAtomResult && res is CommonFunctions.WarewolfEvalResult.WarewolfAtomResult atom)
                {
                    var resClause = clause.Invoke(atom.Item);
                    _inner.AssignJson(new AssignValue(s, resClause.ToString()), 0);
                }
            }
            else
            {
                _inner.ApplyUpdate(s, clause, 0);
            }
        }
Esempio n. 2
0
        private void TryExecute(IDSFDataObject dataObject, int update, ErrorResultTO allErrors, IExecutionEnvironment env)
        {
            CleanArgs();

            var inputIndex  = 1;
            var outputIndex = 1;

            foreach (var item in ConvertCollection.Where(a => !String.IsNullOrEmpty(a.FromExpression)))
            {
                if (dataObject.IsDebugMode())
                {
                    var debugItem = new DebugItem();
                    AddDebugItem(new DebugItemStaticDataParams("", inputIndex.ToString(CultureInfo.InvariantCulture)), debugItem);
                    AddDebugItem(new DebugEvalResult(item.FromExpression, "Convert", env, update), debugItem);
                    AddDebugItem(new DebugItemStaticDataParams(item.FromType, "From"), debugItem);
                    AddDebugItem(new DebugItemStaticDataParams(item.ToType, "To"), debugItem);
                    _debugInputs.Add(debugItem);
                    inputIndex++;
                }

                try
                {
                    env.ApplyUpdate(item.FromExpression, TryConvertFunc(item, env, update), update);
                    IsSingleValueRule.ApplyIsSingleValueRule(item.FromExpression, allErrors);
                    if (dataObject.IsDebugMode())
                    {
                        var debugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams("", outputIndex.ToString(CultureInfo.InvariantCulture)), debugItem);
                        AddDebugItem(new DebugEvalResult(item.FromExpression, "", env, update), debugItem);
                        _debugOutputs.Add(debugItem);
                        outputIndex++;
                    }
                }
                catch (Exception e)
                {
                    Dev2Logger.Error("DSFBaseConvert", e, GlobalConstants.WarewolfError);
                    allErrors.AddError(e.Message);
                    if (dataObject.IsDebugMode())
                    {
                        outputIndex++;
                    }
                }
            }
        }
Esempio n. 3
0
        private void TryExecute(IDSFDataObject dataObject, int update, ErrorResultTO allErrors, ErrorResultTO errors, IExecutionEnvironment env)
        {
            CleanArgs();

            allErrors.MergeErrors(errors);

            var inputIndex  = 1;
            var outputIndex = 1;

            foreach (ICaseConvertTO item in ConvertCollection.Where(a => !String.IsNullOrEmpty(a.StringToConvert)))
            {
                IsSingleValueRule.ApplyIsSingleValueRule(item.ExpressionToConvert, allErrors);
                if (dataObject.IsDebugMode())
                {
                    var debugItem = new DebugItem();
                    AddDebugItem(new DebugItemStaticDataParams("", inputIndex.ToString(CultureInfo.InvariantCulture)), debugItem);
                    AddDebugItem(new DebugEvalResult(item.StringToConvert, "Convert", env, update), debugItem);
                    AddDebugItem(new DebugItemStaticDataParams(item.ConvertType, "To"), debugItem);
                    _debugInputs.Add(debugItem);
                    inputIndex++;
                }
                if (!allErrors.HasErrors())
                {
                    try
                    {
                        env.ApplyUpdate(item.StringToConvert, TryConvertFunc(item, env, update), update);
                    }
                    catch (Exception e)
                    {
                        allErrors.AddError(e.Message);
                    }

                    if (!allErrors.HasErrors() && dataObject.IsDebugMode())
                    {
                        var debugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams("", outputIndex.ToString(CultureInfo.InvariantCulture)), debugItem);
                        AddDebugItem(new DebugEvalResult(item.StringToConvert, "", env, update), debugItem);
                        _debugOutputs.Add(debugItem);
                        outputIndex++;
                    }
                }
            }
        }