Example #1
0
        public NotifyMessage Evaluate(dynamic vars)
        {
            Dict values;

            if (vars is Dict)
            {
                values = vars as Dict;
            }
            else
            {
                values = DynamicX.ToDictionary(vars);
            }

            Func <string, Dict, string> myFormatter = this.formatter;

            if (myFormatter == null)
            {
                myFormatter = (formatText, formatVars) => formatVars.Format(formatText);
            }

            string from     = myFormatter(this.from, values);
            string to       = myFormatter(this.to, values);
            string subject  = myFormatter(this.subject, values);
            string bodyText = myFormatter(this.bodyText, values);
            string bodyHtml = myFormatter(this.bodyHtml, values);

            return(new NotifyMessage(from, to, subject, bodyText, bodyHtml, this.priority));
        }
Example #2
0
        public SendMessage Evaluate(dynamic vars)
        {
            if (this.evaluator == null)
            {
                throw new Exception("Evaluator cannot be null");
            }

            Dict values;

            if (vars is Dict)
            {
                values = vars as Dict;
            }
            else
            {
                values = DynamicX.ToDictionary(vars);
            }

            string from     = this.evaluator(this.from, values, this.path);
            string to       = this.evaluator(this.to, values, this.path);
            string subject  = this.evaluator(this.subject, values, this.path);
            string bodyText = this.evaluator(this.bodyText, values, this.path);
            string bodyHtml = this.evaluator(this.bodyHtml, values, this.path);

            return(new SendMessage(from, to, subject, bodyText, bodyHtml, this.priority));
        }
Example #3
0
        public Dict ConvertParamsToDict(dynamic statementParams, bool allowKeyValueAsSourceParams = true)
        {
            // If statementParams is null, return empty dictionary
            if (statementParams == null)
            {
                return(new Dict());
            }

            // If statementParams is already a dictionary, return the dictionary
            else if (statementParams is Dict d)
            {
                return(new Dict(d));
            }

            // If statementParams is a single string, assume it is a primary key value
            else if (statementParams is string keyValue)
            {
                if (!allowKeyValueAsSourceParams)
                {
                    throw new Exception("Statement doesn't allow passing single key value as source params");
                }
                if (this.StatementFromRefs.Length != 1)
                {
                    throw new Exception("Statement must have exactly one table to pass single string value as where condition");
                }
                return(DictionaryX.ParseKeyValue(keyValue, this.StatementFromRefs[0].table.Indexes[0].FieldNames));
            }

            // Otherwise, convert statementParams to a dictionary
            else
            {
                return(DynamicX.ToDictionary(statementParams));
            }
        }
        protected Dict ConvertInputToDict(dynamic input)
        {
            // If is null, return empty dictionary
            if (input == null)
            {
                return(new Dict());
            }

            // If is already a dictionary, return the dictionary
            else if (input is Dict d)
            {
                return(new Dict(d));
            }

            // Otherwise, convert input to a dictionary
            else
            {
                return(DynamicX.ToDictionary(input));
            }
        }
        public NotifyMessage Evaluate(dynamic vars)
        {
            Dict values;

            if (vars is Dict)
            {
                values = vars as Dict;
            }
            else
            {
                values = DynamicX.ToDictionary(vars);
            }

            string from     = values.Format(this.from);
            string to       = values.Format(this.to);
            string subject  = values.Format(this.subject);
            string bodyText = values.Format(this.bodyText);
            string bodyHtml = values.Format(this.bodyHtml);

            return(new NotifyMessage(from, to, subject, bodyText, bodyHtml, this.priority));
        }
        public Task <Dict[]> QueryRowsAsync(string storedProcedureName, dynamic vars = null)
        {
            Dict executableParams;

            // If statementParams is null, return empty dictionary
            if (vars == null)
            {
                executableParams = new Dict();
            }

            // If statementParams is already a dictionary, return the dictionary
            else if (vars is Dict d)
            {
                executableParams = new Dict(d);
            }

            // Otherwise, convert statementParams to a dictionary
            else
            {
                executableParams = DynamicX.ToDictionary(vars);
            }

            return(this.DoQueryRowsAsync(storedProcedureName, executableParams));
        }