public static object Fun_Func1(BdoScriptwordFunctionScope variable)
        {
            string value1 = variable?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();
            string value2 = variable?.Scriptword?.Parameters?.GetObjectAtIndex(1)?.ToString();

            return(value1.Equals(value2, StringComparison.OrdinalIgnoreCase));
        }
        public static object Fun_IsDifferent(BdoScriptwordFunctionScope scope)
        {
            string value1 = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();
            string value2 = scope?.Scriptword?.Parameters?.GetObjectAtIndex(1)?.ToString();

            return(value1.Equals(value2, StringComparison.OrdinalIgnoreCase) ? "false" : "true");
        }
        public static object Fun_Func2(BdoScriptwordFunctionScope variable)
        {
            string value       = variable?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();
            string parentValue = variable?.Scriptword?.Parent?.Item?.ToString();

            return(parentValue + ":" + value);
        }
        public static object Fun_FormatText(BdoScriptwordFunctionScope scope)
        {
            string textValue  = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();
            string formatText = scope?.Scriptword?.Parameters?.GetObjectAtIndex(1)?.ToString();

            return(string.Format(textValue, formatText));
        }
        public static object Fun_DateTime_Add(BdoScriptwordFunctionScope scope)
        {
            string year   = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();
            string month  = scope?.Scriptword?.Parameters?.GetObjectAtIndex(1)?.ToString();
            string day    = scope?.Scriptword?.Parameters?.GetObjectAtIndex(2)?.ToString();
            string hour   = scope?.Scriptword?.Parameters?.GetObjectAtIndex(3)?.ToString();
            string minute = scope?.Scriptword?.Parameters?.GetObjectAtIndex(4)?.ToString();
            string second = scope?.Scriptword?.Parameters?.GetObjectAtIndex(5)?.ToString();

            DateTime dateTime = DateTime.Now;

            if ((scope?.Scriptword.Parent != null) && (scope?.Scriptword.Parent.Item != null))
            {
                if (DateTime.TryParse(scope?.Scriptword.Parent.Item.ToString(), out dateTime))
                {
                    dateTime = dateTime.AddYears(int.Parse(year));
                    dateTime = dateTime.AddMonths(int.Parse(month));
                    dateTime = dateTime.AddDays(int.Parse(day));
                    dateTime = dateTime.AddHours(int.Parse(hour));
                    dateTime = dateTime.AddMinutes(int.Parse(minute));
                    dateTime = dateTime.AddSeconds(int.Parse(second));
                }
            }

            return(dateTime.ToString());
        }
        public static object Fun_Xor(BdoScriptwordFunctionScope scope)
        {
            bool b = true;

            foreach (var param in scope?.Scriptword?.Parameters)
            {
                b ^= string.Equals(param?.ToString(), "true", StringComparison.OrdinalIgnoreCase);
            }

            return(b);
        }
        public static object Var_ApplicationRoamingFolderPath(BdoScriptwordFunctionScope scope)
        {
            if (scope?.Scope?.Context == null)
            {
                return("<!--Application scope missing-->");
            }
            if (!(scope?.Scope.Context.GetSystemItem("bdoHost") is IBdoHost appHost))
            {
                return("<!--BindOpen host missing-->");
            }

            return(appHost.GetKnownPath(BdoHostPathKind.RoamingFolder) ?? string.Empty);
        }
        public static object Var_ApplicationInstanceName(BdoScriptwordFunctionScope scope)
        {
            if (scope?.Scope?.Context == null)
            {
                return("<!--Application scope missing-->");
            }
            if (!(scope?.Scope.Context.GetSystemItem("bdoHost") is IBdoHost appHost))
            {
                return("<!--BindOpen host missing-->");
            }

            return(appHost?.HostOptions.HostSettings?.ApplicationInstanceName ?? string.Empty);
        }
Пример #9
0
        public static object Fun_SqlGetCurrentDate(BdoScriptwordFunctionScope scope)
        {
            var queryBuilder = scope?.ScriptVariableSet?.GetDbBuilder();

            if (queryBuilder == null)
            {
                return("<DatabaseBuilderMissing/>");
            }
            else
            {
                return(queryBuilder.GetSqlText_CurrentDate());
            }
        }
Пример #10
0
        public static object Fun_SqlList(BdoScriptwordFunctionScope scope)
        {
            var queryBuilder = scope?.ScriptVariableSet?.GetDbBuilder();

            if (queryBuilder == null)
            {
                return("<DatabaseBuilderMissing/>");
            }
            else
            {
                return(queryBuilder.GetSqlText_List(scope?.Scriptword?.Parameters?.ToArray()));
            }
        }
        public static object Fun_DateTime_TimeStamp(BdoScriptwordFunctionScope scope)
        {
            DateTime dateTime = DateTime.Now;

            if ((scope?.Scriptword.Parent != null) && (scope?.Scriptword.Parent.Item != null))
            {
                if (!DateTime.TryParse(scope?.Scriptword.Parent.Item.ToString(), out dateTime))
                {
                    dateTime = DateTime.Now;
                }
            }

            return(dateTime.ToString("yyyyMMddHHmmss"));
        }
Пример #12
0
        public static object Fun_SqlExists(BdoScriptwordFunctionScope scope)
        {
            var queryBuilder = scope?.ScriptVariableSet?.GetDbBuilder();

            if (queryBuilder == null)
            {
                return("<DatabaseBuilderMissing/>");
            }
            else
            {
                string value = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();
                return(queryBuilder.GetSqlText_Exists(value));
            }
        }
Пример #13
0
        public static object Fun_SqlDatabase_SqlTable_SqlField(BdoScriptwordFunctionScope scope)
        {
            var queryBuilder = scope?.ScriptVariableSet?.GetDbBuilder();

            if (queryBuilder == null)
            {
                return("<DatabaseBuilderMissing/>");
            }
            else
            {
                string value1 = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();
                string value2 = scope?.Scriptword?.Parent?.Item?.ToString();
                return(queryBuilder.GetSqlText_Field(value1, value2));
            }
        }
Пример #14
0
        public static object Fun_SqlRightPadding(BdoScriptwordFunctionScope scope)
        {
            var queryBuilder = scope?.ScriptVariableSet?.GetDbBuilder();

            if (queryBuilder == null)
            {
                return("<DatabaseBuilderMissing/>");
            }
            else
            {
                string value1 = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();
                string value2 = scope?.Scriptword?.Parameters?.GetObjectAtIndex(1)?.ToString();
                string value3 = scope?.Scriptword?.Parameters?.GetObjectAtIndex(2)?.ToString();
                return(queryBuilder.GetSqlText_RPad(value1, value2, value3));
            }
        }
        public static object Fun_DateTime_Format(BdoScriptwordFunctionScope scope)
        {
            string format = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();

            format = format.GetValueFromScript();
            DateTime dateTime = DateTime.Now;

            if ((scope?.Scriptword.Parent != null) && (scope?.Scriptword.Parent.Item != null))
            {
                if (!DateTime.TryParse(scope?.Scriptword.Parent.Item.ToString(), out dateTime))
                {
                    dateTime = DateTime.Now;
                }
            }

            return(dateTime.ToString(format));
        }
        public static object Fun_DataModule_Name(BdoScriptwordFunctionScope scope)
        {
            string text = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();

            if (scope?.Scriptword.Parent?.Item != null)
            {
                if (scope.Scope?.Context != null)
                {
                    var datamoduleName = scope?.Scriptword.Parent.Item.ToString().ToUpper();

                    Hashtable dataModuleInstances = (Hashtable)scope.Scope.Context.GetSystemItem("DatabaseNames");
                    if (dataModuleInstances?.Contains(datamoduleName) == true)
                    {
                        text += dataModuleInstances[datamoduleName];
                    }
                }
            }

            return(text);
        }
Пример #17
0
        public static object Fun_SqlDatabase(BdoScriptwordFunctionScope scope)
        {
            var queryBuilder = scope?.ScriptVariableSet?.GetDbBuilder();

            if (queryBuilder == null)
            {
                return("<DatabaseBuilderMissing/>");
            }
            else
            {
                string value1 = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();

                string instanceName = scope?.Scope?.DataStore?.Get <IBdoDatasourceDepot>()?.GetInstanceName(value1);
                if (string.IsNullOrEmpty(instanceName) || instanceName == StringHelper.__NoneString)
                {
                    instanceName = value1;
                }

                return(queryBuilder.GetSqlText_Database(instanceName));
            }
        }
        public static object Fun_Not(BdoScriptwordFunctionScope scope)
        {
            string condition = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();

            return(!string.Equals(condition, "true", StringComparison.OrdinalIgnoreCase));
        }
        public static object Fun_Text(BdoScriptwordFunctionScope scope)
        {
            string value = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();

            return(value.ToQuoted());
        }
        public static object Fun_IsEmpty(BdoScriptwordFunctionScope scope)
        {
            string value = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();

            return(string.IsNullOrEmpty(value));
        }
Пример #21
0
        public static object Fun_SqlParameter(BdoScriptwordFunctionScope scope)
        {
            string value = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();

            return(value.AsParameterWildString());
        }
Пример #22
0
        public static object Fun_SqlQuery(BdoScriptwordFunctionScope scope)
        {
            string value = scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString();

            return("(" + value.AsQueryWildString() + ")");
        }
 public static object Fun_DataModule(BdoScriptwordFunctionScope scope)
 {
     return(scope?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString());
 }
 public static object Fun_Text(BdoScriptwordFunctionScope variable)
 {
     return(variable?.Scriptword?.Parameters?.GetObjectAtIndex(0)?.ToString());
 }
 public static object Fun_Func3(BdoScriptwordFunctionScope variable)
 {
     return(string.Join('-', variable?.Scriptword?.Parameters));
 }