Exemple #1
0
        public void AssignStrict(string exp, string value, bool throwsifnotexists, int update)
        {
            if (string.IsNullOrEmpty(exp))
            {
                return;
            }

            try
            {
                var envTemp = PublicFunctions.EvalAssignWithFrameStrict(new AssignValue(exp, value), update, _env);

                _env = envTemp;
                CommitAssign();
            }
            catch (Exception err)
            {
                var msg = err.Message;
                if (throwsifnotexists && err.Message.Contains("parse error"))
                {
                    throw new WarewolfExecutionEnvironmentException(msg + ": " + "{ " + DataListUtilBase.StripLeadingAndTrailingBracketsFromValue(exp) + " }");
                }
                if (throwsifnotexists && err.Message.Contains("invalid variable assigned to"))
                {
                    throw new WarewolfExecutionEnvironmentException(msg);
                }
                //NOTE:This have a possibility to duplicate error add if caller is also catching exceptions and adding error, use with caution
                Errors.Add(msg + ": " + "{ " + DataListUtilBase.StripLeadingAndTrailingBracketsFromValue(exp) + " }");
            }
        }
Exemple #2
0
        public void Assign(string exp, string value, bool throwsifnotexists, int update)
        {
            if (string.IsNullOrEmpty(exp))
            {
                return;
            }

            try
            {
                var envTemp = PublicFunctions.EvalAssignWithFrame(new AssignValue(exp, value), update, _env);

                _env = envTemp;
                CommitAssign();
            }
            catch (Exception err)
            {
                var msg = err.Message;
                var msgWithVariableName = msg + ": " + "{ " + DataListUtilBase.StripLeadingAndTrailingBracketsFromValue(exp) + " }";
                if (err is NullValueInVariableException variableException && err.Message.Contains("Scalar value "))
                {
                    throw new WarewolfExecutionEnvironmentException(err.Message);
                }
                if (throwsifnotexists)
                {
                    throw new WarewolfExecutionEnvironmentException(msgWithVariableName);
                }

                Errors.Add(msgWithVariableName);
            }
        }
Exemple #3
0
        public void AssignString(string exp, string value, bool throwsifnotexists, int update)
        {
            if (string.IsNullOrEmpty(exp))
            {
                return;
            }

            try
            {
                var envTemp = PublicFunctions.EvalAssignWithFrameTypeCast(new AssignValue(exp, value), update, _env, ShouldTypeCast.No);

                _env = envTemp;
                CommitAssign();
            }
            catch (Exception err)
            {
                var msg = err.Message;
                if (throwsifnotexists)
                {
                    throw new WarewolfExecutionEnvironmentException(msg + ": " + "{ " + DataListUtilBase.StripLeadingAndTrailingBracketsFromValue(exp) + " }");
                }

                Errors.Add(msg + ": " + "{ " + DataListUtilBase.StripLeadingAndTrailingBracketsFromValue(exp) + " }");
            }
        }
Exemple #4
0
        public ExecutionEnvironment()
        {
            _env      = PublicFunctions.CreateEnv(@"");
            Errors    = new HashSet <string>();
            AllErrors = new HashSet <string>();
            Id        = Guid.NewGuid();

            _buildIndexMap = new BuildJObjectArrayIndexMapHelper(this);
        }
Exemple #5
0
            static protected string VariablesToJson(DataStorage.WarewolfEnvironment _env)
            {
                var stringList = PublicFunctions.EvalEnv(_env);
                var sb         = new StringBuilder(4096);

                foreach (var @string in stringList)
                {
                    sb.Append(@string);
                }
                return(sb.ToString());
            }
Exemple #6
0
 public void AssignWithFrame(IAssignValue values, int update)
 {
     try
     {
         var envTemp = PublicFunctions.EvalAssignWithFrame(values, update, _env);
         _env = envTemp;
     }
     catch (Exception err)
     {
         throw new WarewolfExecutionEnvironmentException(err.Message + ": " + "{ " + DataListUtilBase.StripLeadingAndTrailingBracketsFromValue(values.Name) + " }");
     }
 }
Exemple #7
0
        public void EvalAssignFromNestedLast(string exp, CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult recsetResult, int update)
        {
            var expression = exp;
            var exists     = PublicFunctions.RecordsetExpressionExists(expression, _env);

            if (!exists)
            {
                expression = ToStar(expression);
            }

            _env = PublicFunctions.EvalAssignFromList(expression, recsetResult.Item, _env, update, exists);
        }
Exemple #8
0
 public void AssignWithFrame(IAssignValue values, int update)
 {
     try
     {
         var envTemp = PublicFunctions.EvalAssignWithFrame(values, update, _env);
         _env = envTemp;
     }
     catch (Exception err)
     {
         Errors.Add(err.Message);
         throw;
     }
 }
Exemple #9
0
 public void AssignJson(IAssignValue value, int update)
 {
     try
     {
         if (string.IsNullOrEmpty(value.Name))
         {
             return;
         }
         var envTemp = AssignEvaluation.evalJsonAssign(value, update, _env, ShouldTypeCast.Yes);
         _env = envTemp;
     }
     catch (Exception err)
     {
         Errors.Add(err.Message);
         throw;
     }
 }
Exemple #10
0
        public void AssignString(string exp, string value, int update)
        {
            if (string.IsNullOrEmpty(exp))
            {
                return;
            }
            try
            {
                var envTemp = PublicFunctions.EvalAssignWithFrameTypeCast(new AssignValue(exp, value), update, _env, ShouldTypeCast.No);

                _env = envTemp;
                CommitAssign();
            }
            catch (Exception err)
            {
                Errors.Add(err.Message);
            }
        }
Exemple #11
0
        public void AssignJson(IAssignValue value, int update)
        {
            try
            {
                if (string.IsNullOrEmpty(value.Name))
                {
                    return;
                }

                var envTemp = AssignEvaluation.evalJsonAssign(value, update, _env, ShouldTypeCast.Yes);
                _env = envTemp;
            }
            catch (Exception err)
            {
                var res = err.Message + ": " + "{ " + DataListUtilBase.StripLeadingAndTrailingBracketsFromValue(value.Name) + " }";
                Errors.Add(res);
                throw new WarewolfExecutionEnvironmentException(res);
            }
        }
Exemple #12
0
 public void EvalAssignFromNestedStar(string exp, CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult recsetResult, int update)
 {
     _env = PublicFunctions.EvalAssignFromList(exp, recsetResult.Item, _env, update, false);
 }
Exemple #13
0
 public void WriteVariables(DataStorage.WarewolfEnvironment _env)
 {
     _jsonWriter.WritePropertyName("Environment");
     _jsonWriter.WriteRawValue(VariablesToJson(_env));
 }
Exemple #14
0
        public void ApplyUpdate(string expression, Func <DataStorage.WarewolfAtom, DataStorage.WarewolfAtom> clause, int update)
        {
            var temp = PublicFunctions.EvalUpdate(expression, _env, update, clause);

            _env = temp;
        }
Exemple #15
0
        public void AssignDataShape(string p)
        {
            var env = PublicFunctions.EvalDataShape(p, _env);

            _env = env;
        }
Exemple #16
0
 public void SortRecordSet(string sortField, bool descOrder, int update)
 {
     _env = PublicFunctions.SortRecset(sortField, descOrder, update, _env);
 }
Exemple #17
0
 public void CommitAssign()
 {
     _env = PublicFunctions.RemoveFraming(_env);
 }
Exemple #18
0
 public void EvalDelete(string exp, int update)
 {
     _env = PublicFunctions.EvalDelete(exp, update, _env);
 }
Exemple #19
0
 public void AddToJsonObjects(string exp, JContainer jContainer)
 {
     _env = WarewolfDataEvaluationCommon.addToJsonObjects(_env, exp, jContainer);
 }
Exemple #20
0
        public void AssignUnique(IEnumerable <string> distinctList, IEnumerable <string> valueList, IEnumerable <string> resList, int update)
        {
            var output = Distinct.evalDistinct(_env, distinctList, valueList, update, resList);

            _env = output;
        }