Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UiApplication.Me = CreateUiPlugin(APPLICATION_PUX_FILE) as UiApplication;
            CiApplication ciApplication = UiApplication.Me.CiApplication;


            if (!MyWebUtils.IsTimeOutReached(this) && ciApplication != null)
            {
                ASPxWebControl.GlobalTheme          = ciApplication.Theme;
                ASPxWebControl.GlobalThemeBaseColor = ciApplication.ThemeColor;

                MyWebUtils.RegisterPluginScripts(this);

                myOuterPanel.Controls.AddAt(0, UiApplication.Me);

                object justLoggedIn = Session["JustLoggedIn"];
                if (justLoggedIn != null && Convert.ToBoolean(justLoggedIn))
                {
                    Session["JustLoggedIn"] = null;
                    UiApplication.Me.RunLoginMacro();
                }

                string puxFile = MyWebUtils.QueryString[PLUGIN_SRC_KEY];
                if (MyUtils.IsEmpty(puxFile))
                {
                    puxFile = ciApplication.HomePluginSrc;
                }

                if (puxFile != APPLICATION_PUX_FILE)
                {
                    LoadUiPlugin(puxFile);
                }
            }
        }
Exemplo n.º 2
0
        // --------------------------------------------------------------------------------------------------
        // Helpers
        // --------------------------------------------------------------------------------------------------

        private DataTable SelectComboDropdown(UiComboField uiComboField)
        {
            if (uiComboField != null)
            {
                CiComboField ciComboField = uiComboField.CiField as CiComboField;
                if (ciComboField != null)
                {
                    string sql = ciComboField.DropdownSQL;
                    if (!MyUtils.IsEmpty(sql))
                    {
                        DataRow   drParams = uiComboField.GetState();
                        DataTable dt       = MyWebUtils.GetBySQL(sql, drParams);

                        if (dt != null)
                        {
                            // Add a blank row, otherwise exception is sometimes thrown in grid view
                            dt.Rows.InsertAt(dt.NewRow(), 0);
                        }

                        return(dt);
                    }
                    else
                    {
                        return(MyWebUtils.ToDataTable(ciComboField.DataSource.OuterXml));
                    }
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        // --------------------------------------------------------------------------------------------------
        // Methods
        // --------------------------------------------------------------------------------------------------

        public virtual void LoadUiPlugin(string puxFile)
        {
            try
            {
                LoadUiPlugin(CiPlugin.CreateCiPluginFromFile(puxFile));
            }
            catch (Exception ex)
            {
                MyWebUtils.ShowAlert(Page, ex.Message);
            }
        }
Exemplo n.º 4
0
        // --------------------------------------------------------------------------------------------------
        // Event Handlers
        // --------------------------------------------------------------------------------------------------

        protected void Page_PreInit(Object sender, EventArgs e)
        {
            MyWebUtils.QueryString = Request.QueryString;

            if (MyWebUtils.IsPopup(this))
            {
                this.MasterPageFile = "~/Site.Popup.Master";
            }
            else
            {
                this.MasterPageFile = "~/Site.Master";
            }
        }
Exemplo n.º 5
0
        public static bool IsUserAuthorised(string role = null)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Application").DefaultValue = Application;
            dt.Columns.Add("Role").DefaultValue        = role;

            DataRow dr = dt.NewRow();

            dt.Rows.Add(dr);

            return(MyWebUtils.IsTrueSQL("select dbo.fnIsAppOk(@CI_UserEmail, @Application, @Role)", dr, 0));
        }
Exemplo n.º 6
0
        public static string GetAuthorisedApp()
        {
            DataTable dt = new DataTable();

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

            DataRow dr = dt.NewRow();

            dt.Rows.Add(dr);

            object sqlResult = MyWebUtils.EvalSQL("select dbo.fnGetAuthorisedApp(@CI_UserEmail, @Application)", dr, 0);

            return(MyUtils.Coalesce(sqlResult, "").ToString());
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        public DataTable SelectTable(object table, string view, object parameters, ref string script)
        {
            DataRow   drParams = parameters as DataRow;
            DataTable dt       = null;

            CiTable ciTable = table as CiTable;

            if (ciTable != null)
            {
                if (parameters != null && parameters.GetType() == typeof(bool))
                {
                    // Do nothing - but can't remember what this is for???
                    throw new System.Exception("Aha!");
                }
                else if (ciTable.SelectMacro != null)
                {
                    CiMacro ciMacro = ciTable.SearchMacro;
                    if (ciMacro != null)
                    {
                        ciMacro.Run(drParams, true);
                        dt     = ciMacro.ResultTable;
                        script = ciMacro.ResultScript;
                    }
                }
                else if (ciTable.DataSource != null)
                {
                    dt = ciTable.DataTable;
                }

                if (dt == null)
                {
                    dt = new DataTable();
                }

                AddExpressionColumns(ciTable, dt, drParams);

                if (MyWebUtils.GetNumberOfColumns(dt) > 0 && !dt.Columns.Contains("RowKey"))
                {
                    dt.Columns.Add("RowKey").Expression = CreateRowKeyExpression(ciTable.RowKey);
                }
            }

            return(dt);
        }
Exemplo n.º 11
0
        protected void myCallbackPanel_Callback(object sender, CallbackEventArgsBase e)
        {
            if (!MyWebUtils.IsTimeOutReached(this))
            {
                foreach (Control control in myInnerPanel.Controls)
                {
                    control.Dispose();
                }

                myInnerPanel.Controls.Clear();

                string puxFile = e.Parameter;

                if (!MyUtils.IsEmpty(puxFile))
                {
                    LoadUiPlugin(puxFile);
                }
            }
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
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();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 15
0
        private DataTable SelectRadioDropdown(UiRadioField uiRadioField)
        {
            if (uiRadioField != null)
            {
                CiRadioField ciRadioField = uiRadioField.CiField as CiRadioField;
                if (ciRadioField != null)
                {
                    string sql = ciRadioField.DropdownSQL;
                    if (!MyUtils.IsEmpty(sql))
                    {
                        DataRow   drParams = uiRadioField.GetState();
                        DataTable dt       = MyWebUtils.GetBySQL(sql, drParams);

                        return(dt);
                    }
                    else
                    {
                        return(MyWebUtils.ToDataTable(ciRadioField.DataSource.OuterXml));
                    }
                }
            }

            return(null);
        }
Exemplo n.º 16
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);
        }