private List <SubPage> PopulateSubPages(PortalContext c, TabDropDownSettings tabSettings)
        {
            IPortalContextService _contextService = ObjectFactoryWrapper.GetInstance <IPortalContextService>();
            List <SubPage>        subPages        = new List <SubPage>();

            //Grab pages and sub sections on this sub section if setting is turned on
            if (tabSettings.DisplaySubPagesPortlets)
            {
                var pages = _contextService.GetPagesFor(c, PortalUser.Current).ToList();
                foreach (var pg in pages)
                {
                    subPages.Add(new Entities.SubPage {
                        Name = pg.DisplayName, URL = pg.URL
                    });
                }

                var subsections = _contextService.FindChildContextsFor(c, PortalUser.Current).ToList();
                foreach (var sub in subsections)
                {
                    subPages.Add(new Entities.SubPage {
                        Name = sub.DisplayName, URL = sub.URL
                    });
                }
            }

            return(subPages);
        }
        public void GetLogData()
        {
            var logger     = new BCLoggerMapperService();
            var userFacade = ObjectFactoryWrapper.GetInstance <IPortalUserFacade>();

            var dt  = new DataTable();
            var dc1 = new DataColumn("SourceUser");
            var dc2 = new DataColumn("TargetUser");
            var dc3 = new DataColumn("Action");
            var dc4 = new DataColumn("DateTime");

            dt.Columns.Add(dc1);
            dt.Columns.Add(dc2);
            dt.Columns.Add(dc3);
            dt.Columns.Add(dc4);

            foreach (var log in logger.GetLogs(ParentPortlet.Portlet.PortletTemplate.ID.AsGuid).OrderByDescending(x => x.Time))
            {
                var dr = dt.NewRow();
                dr["SourceUser"] = userFacade.FindByGuid(log.SourceUser).Username;
                dr["TargetUser"] = userFacade.FindByGuid(log.TargetUser).Username;
                dr["Action"]     = log.Action.Replace("'", "\\'");
                dr["DateTime"]   = log.Time.ToShortDateString() + ' ' + log.Time.ToShortTimeString();

                dt.Rows.Add(dr);
            }
            rptLogList.DataSource = dt;
            rptLogList.DataBind();
        }
Ejemplo n.º 3
0
        public List <Student> FindUser(string term)
        {
            var portlet = PortletTemplate.FindByName("[CUS] BCProxyLogin");
            var stuList = new List <Student>();

            int userId;

            if (Int32.TryParse(term, out userId))
            {
                var puFacade = ObjectFactoryWrapper.GetInstance <IPortalUserFacade>();
                var pu       = puFacade.FindByHostID(term.PadLeft(11, '0'));
                if ((portlet.AccessCheck("CanProxyStudent") && pu.IsMemberOf(PortalGroup.Students)) ||
                    (portlet.AccessCheck("CanProxyStaff") && pu.IsMemberOf(PortalGroup.Staff)) ||
                    (portlet.AccessCheck("CanProxyFaculty") && pu.IsMemberOf(PortalGroup.Faculty)) ||
                    (portlet.AccessCheck("CanProxyCandidate") && pu.IsMemberOf(PortalGroup.FindByStatusCode("CAN"))) ||
                    (portlet.AccessCheck("CanProxyConstituent") && pu.IsMemberOf(PortalGroup.FindByStatusCode("ALM"))))
                {
                    stuList.Add(new Student(pu.FirstName, pu.LastName, Convert.ToInt32(pu.HostID), pu.Username));
                }
            }
            else
            {
                var groups = new List <PortalGroup>();
                if (portlet.AccessCheck("CanProxyStudent"))
                {
                    groups.Add(PortalGroup.Students);
                }

                if (portlet.AccessCheck("CanProxyStaff"))
                {
                    groups.Add(PortalGroup.Staff);
                }

                if (portlet.AccessCheck("CanProxyFaculty"))
                {
                    groups.Add(PortalGroup.Faculty);
                }

                if (portlet.AccessCheck("CanProxyCandidate"))
                {
                    groups.Add(PortalGroup.FindByStatusCode("CAN"));
                }

                if (portlet.AccessCheck("CanProxyConstituent"))
                {
                    groups.Add(PortalGroup.FindByStatusCode("ALM"));
                }

                if (groups.Count == 0)
                {
                    return(new List <Student>());
                }

                var userFacade = ObjectFactoryWrapper.GetInstance <IPortalUserFacade>();

                stuList.AddRange(userFacade.PartialFind(term, 100, "", groups.Select(x => x.DN).ToArray()).Select(user => new Student(user.FirstName, user.LastName, Convert.ToInt32(user.HostID), user.Username)));
            }
            return(stuList);
        }
Ejemplo n.º 4
0
        private void PopulateTabNames()
        {
            IPortalContextService _contextService = ObjectFactoryWrapper.GetInstance <IPortalContextService>();
            //Get Home tab
            PortalContext pc = _contextService.FindByPath(String.Empty);

            //Add all other tabs to the table
            foreach (PortalContext context in _contextService.FindChildContextsFor(pc, PortalUser.Current))
            {
                ltrlTabNames.Text += "<tr><td>" + Server.HtmlEncode(context.DisplayName) + "</td><td>" + Server.HtmlEncode(context.Name) + "</td></td>";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            _portletTemplateFacade = ObjectFactoryWrapper.GetInstance <IPortletTemplateFacade>();
            _portletTemplate       = _portletTemplateFacade.FindByName("[CUS] BCProxyLogin");
            if (_portletTemplate.AccessCheck("CanAccess") && _portletTemplate.AccessCheck("CanViewSideBarControl") && HttpContext.Current.Session["ProxyLoginOriginalUser"] == null)
            {
                pnlProxyLogin.Visible = true;

                if (_requirePassword)
                {
                    pnlPassword.Visible = true;
                }
            }
        }
        private PortalUser getPortalUserByUserName(string username)
        {
            var userFacade = ObjectFactoryWrapper.GetInstance <IPortalUserFacade>();

            var user = userFacade.FindByUsername(username);

            if (user == null)
            {
                try
                {
                    user = userFacade.FindByHostID(username.Trim().PadLeft(11, '0'));
                }
                catch
                {
                }
            }

            return(user);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// </summary>
        /// <param name="portlet"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        ///

        //--DRB

        //private void setParameters(Portlet portlet)
        //{
        //    try
        //    {
        //        string parameters = PortletUtilities.GetSettingValue(portlet, "SSRSParameters"); //viewerconfig.ParameterList;

        //        if (parameters != null && parameters != "")
        //        {
        //            parameters = insertReplacementParameters(portlet, parameters);

        //            List<GCReportParameter> defaultParameters = GCReportParameter.buildParameterList(parameters);


        //            //Parameter list to be populated
        //            List<ReportParameter> lstParams = new List<ReportParameter>();

        //            //Parameter list from the report
        //            ReportParameterInfoCollection rptParams = ReportViewer1.ServerReport.GetParameters();

        //            foreach (ReportParameterInfo rptparam in rptParams)
        //            {
        //                string val = String.Empty;

        //                int indx = defaultParameters.FindIndex(x => x.Name == rptparam.Name);
        //                if (indx >= 0)
        //                {
        //                    ReportParameter p = new ReportParameter(rptparam.Name, defaultParameters[indx].Value);
        //                    lstParams.Add(p);
        //                }
        //                else
        //                {
        //                    ReportParameter p = new ReportParameter(rptparam.Name, rptparam.Values.ToArray());
        //                    lstParams.Add(p);
        //                }
        //            }
        //            ReportViewer1.ServerReport.SetParameters(lstParams.ToArray());
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        litMessage.Text = ex.Message;
        //        Panel1.Visible = false;
        //        pnlMessage.Visible = true;
        //    }

        //}

        private string insertReplacementParameters(Portlet portlet, string parameters)
        {
            // Replace @@ placeholders with correct values with actual content.
            var literalStringReplacer = ObjectFactoryWrapper.GetInstance <ILiteralStringReplacer>();

            parameters = literalStringReplacer.Process(parameters, portlet.Portlet);

            StringBuilder sbParameters = new StringBuilder(parameters);

            //Replace Fields from URL Parameters
            Regex           r1 = new Regex("@@URL_(\\w|\\$)*&?");
            MatchCollection mc = r1.Matches(parameters);

            foreach (Match m in mc)
            {
                try
                {
                    Regex r2  = new Regex(m.Value + "=(\\w)+(&|$)");
                    var   val = r2.Match(HttpUtility.UrlDecode(Request.QueryString.ToString())).Value;
                    val = val.Substring(val.IndexOf("=") + 1).TrimEnd('&');
                    if (val != "" && val != null)
                    {
                        string fieldValue = val;
                        sbParameters.Replace(m.Value, fieldValue);
                    }
                    else
                    {
                        sbParameters.Replace(m.Value, String.Empty);
                    }
                }
                catch (Exception ex)
                {
                    string erMsg = PortalUser.Current.IsSiteAdmin ? "Unable to perform field replacement from querystring.  " + ex.Message : "Unable to perform field replacement from querystring";
                    Panel1.Visible     = false;
                    litMessage.Text    = erMsg;
                    pnlMessage.Visible = true;
                }
            }

            return(sbParameters.ToString());
        }
Ejemplo n.º 8
0
        private DataTable GetData(Guid _portletID)
        {
            var mapper   = new NHSimpleQuerySettingsMapper();
            var settings = mapper.GetSettings(_portletID).ToList();
            var _helper  = new SettingsHelper(settings, _portletID, mapper);
            var portlet  = ObjectFactoryWrapper.GetInstance <IPortletFacade>().FindByGuid(_portletID);

            OdbcConnectionClass3.OdbcConnectionClass3 odbcConn;
            if (_helper.GetSetting("ConfigFile").Value.EndsWith(".config"))
            {
                odbcConn = new CUS.OdbcConnectionClass3.OdbcConnectionClass3("~/ClientConfig/" + _helper.GetSetting("ConfigFile").Value);
            }
            else
            {
                odbcConn = new CUS.OdbcConnectionClass3.OdbcConnectionClass3(_helper.GetSetting("ConfigFile").Value);
            }

            odbcConn.ConnectionTest();

            Exception ex = null;
            DataTable dt;
            var       literalStringReplacer = ObjectFactoryWrapper.GetInstance <ILiteralStringReplacer>();

            var queryString = literalStringReplacer.Process(_helper.GetSetting("QueryText").Value, portlet);

            if (Convert.ToInt16(_helper.GetSetting("QueryTimeout", 0).Value) > 0)
            {
                dt = odbcConn.ConnectToERP(queryString, ref ex, Convert.ToInt16(_helper.GetSetting("QueryTimeout").Value));
            }
            else
            {
                dt = odbcConn.ConnectToERP(queryString, ref ex);
            }

            if (ex != null)
            {
                throw ex;
            }

            return(dt);
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IPortalContextFacade contextFacade = ObjectFactoryWrapper.GetInstance <IPortalContextFacade>();
            IPortletFacade       portletFacade = ObjectFactoryWrapper.GetInstance <IPortletFacade>();



            if (Request.QueryString["DN"] != null)
            {
                String dn = HttpUtility.UrlDecode(Request.QueryString["DN"].ToString());

                Portlet p = portletFacade.FindByDN(dn);

                PortletGuid = p.PortletTemplate.Guid.ToString();

                if (p.ParentPage.CanView(PortalUser.Current))
                {
                    Panel1.Visible = true;
                    if (!IsPostBack)
                    {
                        loadControlOptions(p);
                        loadCredentials();
                        //--DRB         //setParameters(p);
                    }
                }
                else
                {
                    //Response.Write("You do not have access to this page");
                    litMessage.Text    = "You do not have access to this page";
                    Panel1.Visible     = false;
                    pnlMessage.Visible = true;
                }
            }
            else
            {
                litMessage.Text    = "DN Not Defined";
                Panel1.Visible     = false;
                pnlMessage.Visible = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            _portletId       = this.ParentPortlet.PortletDisplay.Portlet.ID.AsGuid;
            _mapper          = new NHSimpleQuerySettingsMapper();
            _settings        = _mapper.GetSettings(_portletId).ToList();
            _helper          = new SettingsHelper(_settings, _portletId, _mapper);
            _jicsOutputTypes = new[] { rbJICSOutputCSV, rbJICSOutputDataTables, rbJICSOutputGrid, rbJICSOutputXML, rbJICSOutputLiteral };
            _goOutputTypes   = new[] { rbGOOutputXML, rbGOOutputNone, rbGOOutputMasterDetail, rbGOOutputGrid, rbGOOutputCSV, rbGOOutputLiteral };

            // Don't show the Go settings unless it is version 1.2 or greater.
            if (new InstalledApplicationService().IsApplicationAtLeastThisVersion("JICS Go", "1.2"))
            {
                pnlGoSettings.Visible = true;
            }
            if (IsFirstLoad)
            {
                SetDdlConfigFiles();
                ShowCurrentValues();
                var literalStringReplacer = ObjectFactoryWrapper.GetInstance <ILiteralStringReplacer>();
                rptLiteralStringReplacementsAvailable.DataSource = literalStringReplacer.GetAvailableLiterals().Where(x => new[] { "@@HostID", "@@FirstName", "@@LastName", "@@Username", "@@EmailAddress", "@@DisplayName", "@@CurrentYear", "@@CurrentSession" }.Contains(x.Key));
                rptLiteralStringReplacementsAvailable.DataBind();
            }
        }
Ejemplo n.º 11
0
        public object RunQuery(Guid _portletID)
        {
            Portlet portlet = ObjectFactoryWrapper.GetInstance <IPortletFacade>().FindByGuid(_portletID);

            if (portlet.ParentPage.CanView(PortalUser.Current))
            {
                try
                {
                    var mapper   = new NHSimpleQuerySettingsMapper();
                    var settings = mapper.GetSettings(_portletID).ToList();
                    var helper   = new SettingsHelper(settings, _portletID, mapper);

                    try
                    {
                        DataTable dt = GetData(_portletID);
                        if (dt == null)
                        {
                            return(new
                            {
                                success = false,
                                message = "No results returned."
                            });
                        }

                        if (helper.GetSetting("JICSAllowExports").BoolValue)
                        {
                            HttpContext.Current.Session["sqhtml+" + PortalUser.Current.ID.AsGuid + _portletID] = dt;
                        }

                        if (Convert.ToInt32(helper.GetSetting("RowLimit", 0).Value) > 0)
                        {
                            dt = dt.AsEnumerable().Take(Convert.ToInt32(helper.GetSetting("RowLimit", 0).Value)).CopyToDataTable();
                        }

                        var jsdtc = new JSDataTableConverter(dt, helper.GetSetting("JICSDataTablesExpandedColumns").Value.Split(','), helper.GetSetting("ColumnLabels").Value.Split(','));

                        var data = jsdtc.GetJsDataTable();

                        return(new
                        {
                            success = true,
                            data.data,
                            data.columns
                        });
                    }
                    catch (Exception ex)
                    {
                        return(new
                        {
                            success = false,
                            message = "Query results handling failed. " + (PortalUser.Current.IsSiteAdmin ? ": " + ex.Message + " " + ex.StackTrace : "")
                        });
                    }
                }
                catch (Exception ex)
                {
                    return(new
                    {
                        success = false,
                        message = "Connection failed before query was executed. " + (PortalUser.Current.IsSiteAdmin ? ": " + ex.Message + " " + ex.StackTrace : "")
                    });
                }
            }
            else
            {
                return(new
                {
                    success = false,
                    message = "You do not have permissions to view this portlet"
                });
            }
        }
Ejemplo n.º 12
0
        public object RunQueryHTML(Guid _portletID)
        {
            Portlet portlet = ObjectFactoryWrapper.GetInstance <IPortletFacade>().FindByGuid(_portletID);

            if (portlet.ParentPage.CanView(PortalUser.Current))
            {
                try
                {
                    var mapper   = new NHSimpleQuerySettingsMapper();
                    var settings = mapper.GetSettings(_portletID).ToList();
                    var _helper  = new SettingsHelper(settings, _portletID, mapper);


                    try
                    {
                        DataTable dt = GetData(_portletID);

                        String html = string.Empty;

                        if (dt != null && dt.Rows.Count > 0)
                        {
                            if (_helper.GetSetting("JICSAllowExports").BoolValue)
                            {
                                HttpContext.Current.Session["sqhtml+" + PortalUser.Current.ID.AsGuid + _portletID] = dt;
                            }

                            if (Convert.ToInt32(_helper.GetSetting("RowLimit", 0).Value) > 0)
                            {
                                dt = dt.AsEnumerable().Take(Convert.ToInt32(_helper.GetSetting("RowLimit", 0).Value)).CopyToDataTable();
                            }

                            switch (_helper.GetSetting("JICSOutput", "grid").Value)
                            {
                            case "grid":
                                var dgResults = OutputHelper.CreateDataGrid();

                                OutputHelper.ConfigureDataGrid(ref dgResults,
                                                               dt,
                                                               _helper.GetSetting("JICSGridShowColumnHeadings", false).BoolValue,
                                                               _helper.GetSetting("JICSGridAltRowColors", false).BoolValue,
                                                               _helper.GetSetting("JICSGridShowGridlines", false).BoolValue,
                                                               Convert.ToInt16(_helper.GetSetting("JICSGridCellPadding", 5).Value),
                                                               _helper.GetSetting("ColumnLabels").Value);


                                dgResults.DataSource = dt;
                                dgResults.DataBind();

                                var stringWrite = new StringWriter();
                                var htmlWrite   = new HtmlTextWriter(stringWrite);
                                dgResults.RenderControl(htmlWrite);

                                htmlWrite.Flush();

                                html = stringWrite.ToString().Replace("\n", "").Replace("\r", "").Replace("  ", "");
                                break;

                            case "xml":
                                html = "<pre>" + HttpUtility.HtmlEncode(OutputHelper.RenderXml(dt)) + "</pre>";
                                break;

                            case "csv":
                                html = "<pre>" + OutputHelper.RenderCsv(dt,
                                                                        _helper.GetSetting("JICSGridShowColumnHeadings", false).BoolValue,
                                                                        _helper.GetSetting("ColumnLabels").Value) + "</pre>";
                                break;

                            case "literal":
                                html = OutputHelper.RenderLiteral(dt, _helper.GetSetting("ExportLiteralPattern", "{0}").Value);
                                break;
                            }
                            return(new
                            {
                                success = true,
                                resultFormat = _helper.GetSetting("JICSOutput", "grid").Value,
                                html
                            });
                        }

                        return(new
                        {
                            success = true,
                            resultFormat = _helper.GetSetting("JICSOutput", "grid").Value,
                            html,
                            query =
                                (PortalUser.Current.IsSiteAdmin
                                                      ? _helper.GetSetting("QueryText").Value
                                                      : "")
                        });
                    }
                    catch (Exception ex)
                    {
                        return(new
                        {
                            success = false,
                            message = "Query Failed. " + (PortalUser.Current.IsSiteAdmin ? ": " + ex.StackTrace : "")
                        });
                    }
                }
                catch (Exception ex)
                {
                    return(new
                    {
                        success = false,
                        message = "Connection failed before query was executed." + (PortalUser.Current.IsSiteAdmin ? ": " + ex.StackTrace : "")
                    });
                }
            }

            return(new
            {
                success = false,
                message = "You do not have permissions to view this portlet"
            });
        }
Ejemplo n.º 13
0
        public String TestLiteralReplacement(Guid portletId)
        {
            var portlet = ObjectFactoryWrapper.GetInstance <IPortletFacade>().FindByGuid(portletId);

            return(portlet.AccessCheck("CanAdminQueries") ? ObjectFactoryWrapper.GetInstance <ILiteralStringReplacer>().GetAvailableReplacementsTable(portlet) : string.Empty);
        }
        public ContextPageList FindContextPagesSubSections(string path)
        {
            TabDropDownSettingMapperService tabSettingsService = new TabDropDownSettingMapperService();
            IPortalContextService           _contextService    = ObjectFactoryWrapper.GetInstance <IPortalContextService>();
            List <ContextPage> context_pages = new List <ContextPage>();

            try
            {
                //Retrieve the tab drop down settings, use defaults if null
                TabDropDownSettings tabSettings = tabSettingsService.GetSettings();
                if (tabSettings == null)
                {
                    tabSettings = new TabDropDownSettings();
                }

                //Get the PortalContext by the Tab Name
                PortalContext pc = _contextService.FindByPath(path);

                //If the drop down is disabled or the context is null, then return an empty list
                if (pc == null || !tabSettings.EnableDropDown)
                {
                    return new ContextPageList {
                               Success = false, ContextPages = null
                    }
                }
                ;

                //If we are displaying page, then grab all the pages for this context
                if (tabSettings.DisplayPages)
                {
                    List <PortalPageInfo> pages = _contextService.GetPagesFor(pc, PortalUser.Current).ToList();

                    foreach (PortalPageInfo p in pages)
                    {
                        //Retrieve the list of portlets on this page
                        List <SubPage> subPortlets = PopulateSubPortlets(p, tabSettings);

                        context_pages.Add(new ContextPage {
                            Name = p.DisplayName, URL = p.URL, SubPageList = new SubPageList(subPortlets.Count() > 1 ? true : false, subPortlets)
                        });
                    }
                }

                //If we are displaying sub sections, then grab all the sub sections for this context
                if (tabSettings.DisplaySubSections && !String.IsNullOrEmpty(path))
                {
                    List <PortalContext> contexts = _contextService.FindChildContextsFor(pc, PortalUser.Current).ToList();

                    foreach (PortalContext c in contexts)
                    {
                        //We only grab sub sections if they are setup to display in the sidebar
                        if (pc.ShowChildNodesInSideBar)
                        {
                            //Sub Sections do not have portlets beneath them
                            //We need to grab pages or more sub sections
                            List <SubPage> subPages = PopulateSubPages(c, tabSettings);

                            context_pages.Add(new ContextPage {
                                Name = c.DisplayName, URL = c.URL, SubPageList = new SubPageList(subPages.Count() > 1 ? true : false, subPages)
                            });
                        }
                    }
                }

                //Sort the list in alphabetical order before returning
                if (tabSettings.DisplayAlphaOrder)
                {
                    context_pages.Sort((x, y) => string.Compare(x.Name, y.Name));
                }

                return(new ContextPageList {
                    Success = true, ContextPages = context_pages
                });
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                return(new ContextPageList {
                    Success = false, ContextPages = null
                });
            }
        }