Exemple #1
0
        public static object EvalSQL(string SQL, DataRow drParams, int?appID = null)
        {
            if (!MyUtils.IsEmpty(SQL))
            {
                DataTable dt = GetBySQL(SQL, drParams, appID);

                if (MyWebUtils.GetNumberOfRows(dt) > 0 && MyWebUtils.GetNumberOfColumns(dt) > 0)
                {
                    return(dt.Rows[0][0]);
                }
            }

            return(null);
        }
Exemple #2
0
        public static string GetDatabaseName(DataRow drAppKey)
        {
            DataTable dt = MyWebUtils.GetBySQL("?exec spApplication_sel @AppID", drAppKey, 0);

            if (dt != null && dt.Columns.Contains("SQLDatabaseName") && MyWebUtils.GetNumberOfRows(dt) > 0)
            {
                object objAppName = dt.Rows[0]["SQLDatabaseName"];

                if (objAppName != null)
                {
                    return(objAppName.ToString());
                }
            }

            return(null);
        }
Exemple #3
0
        public static bool IsTrueSQL(string SQL, DataRow drParams, int?appID = null)
        {
            if (!MyUtils.IsEmpty(SQL))
            {
                DataTable dt = GetBySQL(SQL, drParams, appID);

                if (MyWebUtils.GetNumberOfRows(dt) > 0 && MyWebUtils.GetNumberOfColumns(dt) > 0)
                {
                    return(Convert.ToBoolean(MyUtils.Coalesce(dt.Rows[0][0], false)));
                }

                return(false);
            }

            return(true);
        }
Exemple #4
0
        public static DataRow GetTableDetails(int appID, int tableID)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("AppID").DefaultValue   = appID;
            dt.Columns.Add("TableID").DefaultValue = tableID;

            DataRow dr = dt.NewRow();

            dt.Rows.Add(dr);

            DataTable dtResults = MyWebUtils.GetBySQL("?exec spTable_sel @AppID, @TableID", dr, 0);

            if (MyWebUtils.GetNumberOfRows(dtResults) > 0)
            {
                return(dtResults.Rows[0]);
            }

            return(null);
        }
Exemple #5
0
        public static DataRow GetTableDetails(string tableName)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Application").DefaultValue = Application;
            dt.Columns.Add("Table").DefaultValue       = tableName;

            DataRow dr = dt.NewRow();

            dt.Rows.Add(dr);

            DataTable dtResults = MyWebUtils.GetBySQL("?exec spTable_selByName @Application, @Table", dr, 0);

            if (MyWebUtils.GetNumberOfRows(dtResults) > 0)
            {
                return(dtResults.Rows[0]);
            }

            return(null);
        }
Exemple #6
0
        public void InsertTable(object table, string view, object parameters, ref string rowKey, ref string script, ref bool isInvalid)
        {
            DataRow drParams = parameters as DataRow;

            CiTable ciTable = table as CiTable;

            if (ciTable != null)
            {
                CiMacro ciMacro = ciTable.InsertMacro;
                if (ciMacro != null)
                {
                    ciMacro.Run(drParams);
                    script    = ciMacro.ResultScript;
                    isInvalid = !MyUtils.IsEmpty(ciMacro.ErrorMessage);

                    DataTable dt = ciMacro.ResultTable;
                    if (MyWebUtils.GetNumberOfRows(dt) > 0)
                    {
                        DataRow dr = dt.Rows[0];
                        int     i  = 0;
                        foreach (string key in ciTable.RowKeyNames)
                        {
                            if (i++ > 0)
                            {
                                rowKey += ",";
                            }

                            if (dt.Columns.Contains(key))
                            {
                                rowKey += MyUtils.Coalesce(dr[key], "").ToString();
                            }
                        }
                    }
                }
            }
        }
Exemple #7
0
        public static object Eval(XmlElement expressionElement, DataRow drParams, Type type)
        {
            object result = null;

            if (!MyUtils.IsEmpty(expressionElement))
            {
                eLangType language   = eLangType.literal;
                string    expression = expressionElement.InnerText;

                string languageString = expressionElement.GetAttribute("lang");
                if (!MyUtils.IsEmpty(languageString))
                {
                    try
                    {
                        language = (eLangType)Enum.Parse(typeof(eLangType), languageString);
                    }
                    catch
                    {
                        // Do nothing
                    }
                }

                switch (language)
                {
                case eLangType.literal:
                    result = expression;
                    break;

                case eLangType.column:
                    string columnName = expression;
                    if (drParams != null && drParams.Table.Columns.Contains(columnName))
                    {
                        result = drParams[columnName];
                    }
                    else
                    {
                        result = null;
                    }
                    break;

                case eLangType.sql:
                    if (!MyUtils.IsEmpty(expression))
                    {
                        DataTable dt = GetBySQL(expression, drParams);
                        if (type == typeof(DataTable))
                        {
                            result = dt;
                        }
                        else if (type == typeof(DataRow))
                        {
                            if (MyWebUtils.GetNumberOfRows(dt) > 0)
                            {
                                result = dt.Rows[0];
                            }
                        }
                        else
                        {
                            if (MyWebUtils.GetNumberOfRows(dt) > 0 && MyWebUtils.GetNumberOfColumns(dt) > 0)
                            {
                                result = dt.Rows[0][0];
                            }
                        }
                    }

                    break;

                case eLangType.xml:
                    result = expressionElement;
                    break;
                }
            }

            if (MyUtils.IsEmpty(result))
            {
                if (type == typeof(bool))
                {
                    result = false;
                }
            }

            return(result);
        }