public ActionResult Index(User user)
        {
            if (user.Username == "Guest")
            {
                return(View("Error", new Models.Error {
                    Message = "User Not Loged In"
                }));
            }

            return(!_portletTemplateFacade.FindByName("[CUS] BCProxyLogin").AccessCheck("CANACCESS", _portalUserFacade.FindByUsername(user.Username))
                ? View("Error", new Models.Error {
                Message = "You are not authorized for this function."
            })
                : View("Index", new Models.Main {
                RequiresPassword = _requirePassword
            }));
        }
Example #2
0
        public ActionResult Index(ContentIdentifier cid, User user)
        {
            var helper = GetHelper(cid.PortletId.Value);

            ViewBag.Title = helper.GetSetting("QueryTitle").Value;

            switch (helper.GetSetting("GOOutput").Value)
            {
            case "grid":
                DataTable dt;
                try
                {
                    dt = GetData(helper);

                    if (Convert.ToInt32(helper.GetSetting("RowLimit", 0).Value) > 0)
                    {
                        dt = dt.AsEnumerable().Take(Convert.ToInt32(helper.GetSetting("RowLimit", 0).Value)).CopyToDataTable();
                    }
                }
                catch (Exception ex)
                {
                    return(View("Error",
                                new Error
                    {
                        ErrorMessage = "An error occurred while querying the database.",
                        Exception =
                            _userFacade.FindByUsername(user.Username).IsSiteAdmin
                                                    ? ex.ToString().Replace("\n", "<br />")
                                                    : String.Empty
                    }));
                }
                var gridmodel = new SimpleQueryDataGrid
                {
                    CellPadding       = Convert.ToInt16(helper.GetSetting("GOSGridCellPadding", 5).Value),
                    ShowAltColors     = helper.GetSetting("GOGridAltRowColors", false).BoolValue,
                    ShowColumnHeaders =
                        helper.GetSetting("GOGridShowColumnHeadings", false).BoolValue,
                    ShowGridlines = helper.GetSetting("GOGridShowGridlines", false).BoolValue,
                    AllowExports  = helper.GetSetting("GOAllowExports").BoolValue,
                    Data          = dt
                };
                return(View("DataGrid", gridmodel));

            case "masterdetail":
                List <SimpleQueryDataRow> dataRows;
                try
                {
                    dataRows = GetMasterDetailData(helper, user.Username);
                }
                catch (Exception ex)
                {
                    return(View("Error",
                                new Error
                    {
                        ErrorMessage = "An error occurred while querying the database.",
                        Exception =
                            _userFacade.FindByUsername(user.Username).IsSiteAdmin
                                                    ? ex.ToString().Replace("\n", "<br />")
                                                    : String.Empty
                    }));
                }
                var mdmodel = new SimpleQueryMasterDetail
                {
                    AllowExports     = helper.GetSetting("GOAllowExports").BoolValue,
                    MasterDetailData = dataRows
                };
                return(View("MasterDetail", mdmodel));

            case "xml":
                return(Xml(cid, user));

            case "csv":
                return(Csv(cid, user));

            case "literal":
                return(Literal(cid, user));

            case "none":
                return(View("Error", new Error {
                    ErrorMessage = "Results for this portlet are not enabled for JICS Go"
                }));

            default:
                return(View("Error", new Error {
                    ErrorMessage = "This portlet has not yet been configured."
                }));
            }
        }