コード例 #1
0
        //Need to process this at the page level for the framework data
        //to process the presentation XML
        public void LoadRDFSearchResults()
        {
            XmlDocument xml           = new XmlDocument();
            Namespace   rdfnamespaces = new Namespace();

            Utilities.DataIO data = new Utilities.DataIO();

            string searchtype  = string.Empty;
            string lname       = string.Empty;
            string fname       = string.Empty;
            string institution = string.Empty;
            string department  = string.Empty;
            string division    = string.Empty;

            string searchfor            = string.Empty;
            string classgroupuri        = string.Empty;
            string classuri             = string.Empty;
            string perpage              = string.Empty;
            string offset               = string.Empty;
            string searchrequest        = string.Empty;
            string otherfilters         = string.Empty;
            string institutionallexcept = string.Empty;
            string departmentallexcept  = string.Empty;
            string divisionallexcept    = string.Empty;
            string exactphrase          = string.Empty;
            string nodeuri              = string.Empty;
            string nodeid               = string.Empty;


            string country = (Request.QueryString["country"].IsNullOrEmpty() ? "(All)" : Request.QueryString["country"]);

            department = country;

            if (Request.QueryString["new"] == "true")
            {
                Session["searchrequest"] = null;
                masterpage.SearchRequest = null;
            }

            if (this.SearchType.IsNullOrEmpty() == false)
            {
                searchtype = this.SearchType;
            }

            //else if (Request.Form["searchtype"] != null)
            //{
            //    searchtype = Request.Form["searchtype"];
            //}

            if (Request.QueryString["searchfor"].IsNullOrEmpty() == false)
            {
                searchfor = Request.QueryString["searchfor"];
            }

            if (Request.Form["txtSearchFor"].IsNullOrEmpty() == false)
            {
                searchfor = Request.Form["txtSearchFor"];
            }

            if (Request.QueryString["lname"].IsNullOrEmpty() == false)
            {
                lname = Request.QueryString["lname"];
            }

            if (Request.QueryString["institution"].IsNullOrEmpty() == false)
            {
                institution = Request.QueryString["institution"];
            }

            if (Request.QueryString["division"].IsNullOrEmpty() == false)
            {
                division = Request.QueryString["division"];
            }

            if (Request.QueryString["fname"].IsNullOrEmpty() == false)
            {
                fname = Request.QueryString["fname"];
            }

            if (Request.QueryString["classgroupuri"].IsNullOrEmpty() == false)
            {
                classgroupuri = HttpUtility.UrlDecode(Request.QueryString["classgroupuri"]);
            }
            else
            {
                classgroupuri = HttpUtility.UrlDecode(Request.Form["classgroupuri"]);
            }

            if (classgroupuri != null)
            {
                if (classgroupuri.Contains("!"))
                {
                    classgroupuri = classgroupuri.Replace('!', '#');
                }
            }

            if (Request.QueryString["classuri"].IsNullOrEmpty() == false)
            {
                classuri = HttpUtility.UrlDecode(Request.QueryString["classuri"]);
            }
            else
            {
                classuri = HttpUtility.UrlDecode(Request.Form["classuri"]);
            }

            if (classuri != null)
            {
                if (classuri.Contains("!"))
                {
                    classuri = classuri.Replace('!', '#');
                }
            }
            else
            {
                classuri = "";
            }

            if (Request.QueryString["perpage"].IsNullOrEmpty() == false)
            {
                perpage = Request.QueryString["perpage"];
            }
            else
            {
                perpage = Request.Form["perpage"];
            }

            //if (perpage == string.Empty || perpage == null)
            //{
            //    perpage = Request.QueryString["perpage"];
            //}

            if (perpage.IsNullOrEmpty())
            {
                perpage = "15";
            }

            if (Request.QueryString["offset"].IsNullOrEmpty() == false)
            {
                offset = Request.QueryString["offset"];
            }
            else
            {
                offset = Request.Form["offset"];
            }

            if (offset.IsNullOrEmpty())
            {
                offset = "0";
            }



            if (Request.QueryString["otherfilters"].IsNullOrEmpty() == false)
            {
                otherfilters = Request.QueryString["otherfilters"];
            }

            if (Request.QueryString["institutionallexcept"].IsNullOrEmpty() == false)
            {
                institutionallexcept = Request.QueryString["institutionallexcept"];
            }

            if (Request.QueryString["departmentallexcept"].IsNullOrEmpty() == false)
            {
                departmentallexcept = Request.QueryString["departmentallexcept"];
            }

            if (Request.QueryString["divisionallexcept"].IsNullOrEmpty() == false)
            {
                divisionallexcept = Request.QueryString["divisionallexcept"];
            }

            if (Request.QueryString["exactphrase"].IsNullOrEmpty() == false)
            {
                exactphrase = Request.QueryString["exactphrase"];
            }

            if (Request.QueryString["nodeuri"].IsNullOrEmpty() == false)
            {
                nodeuri = Request.QueryString["nodeuri"];
                nodeid  = nodeuri.Substring(nodeuri.LastIndexOf("/") + 1);
            }



            string keywordOrPerson = "keyword";

            //added this test for search type so we could split the person keyword search into a split to remove the why col for person
            keywordOrPerson = data.SearchType(searchfor);



            if (keywordOrPerson == "person")
            {
                xml = data.CovidPersonSearchRequest(searchfor, offset, perpage, country);
            }
            else
            {
                xml = data.SearchRequest(searchfor, exactphrase, fname, lname, institution, institutionallexcept, department, departmentallexcept, division, divisionallexcept, "http://xmlns.com/foaf/0.1/Person", perpage, offset, otherfilters, "", true, ref searchrequest);
            }

            searchrequest            = xml.OuterXml;
            Session["SearchRequest"] = searchrequest;

            if (nodeuri != string.Empty && nodeid != string.Empty)
            {
                masterpage.RDFData = data.WhySearch(xml, nodeuri, Convert.ToInt64(nodeid));
            }
            else
            {
                masterpage.RDFData = data.Search(xml, false, false);
            }

            Framework.Utilities.DebugLogging.Log(masterpage.RDFData.OuterXml);
            masterpage.RDFNamespaces = rdfnamespaces.LoadNamespaces(masterpage.RDFData);
            masterpage.SearchRequest = searchrequest;
        }
コード例 #2
0
        private void DrawProfilesModule()
        {
            XsltArgumentList args               = new XsltArgumentList();
            long             offset             = 0;
            long             perpage            = 0;
            long             totalcount         = 0;
            long             totalpageremainder = 0;
            long             totalpages         = 0;
            long             startrecord        = 0;
            long             page               = 0;
            string           searchfor          = "";
            string           classgroupuri      = "";
            string           classuri           = "";

            string      fname         = "";
            string      lname         = "";
            string      institution   = "";
            string      department    = "";
            string      division      = "";
            string      searchrequest = "";
            XmlDocument xmlsearchrequest;

            xmlsearchrequest = new XmlDocument();


            string otherfilters         = "";
            string institutionallexcept = string.Empty;
            string departmentallexcept  = "0";
            string divisionallexcept    = string.Empty;
            string exactphrase          = "false"; // UCSF default value to allow old Mini Search to work


            string country = (Request.QueryString["country"].IsNullOrEmpty() ? "(All)" : Request.QueryString["country"]);

            department = country;
            string keywordOrPerson = "keyword";



            string searchtype = "";

            Search.Utilities.DataIO data = new Profiles.Search.Utilities.DataIO();


            if (String.IsNullOrEmpty(Request.QueryString["searchtype"]) == false)
            {
                searchtype = Request.QueryString["searchtype"];
            }
            else if (String.IsNullOrEmpty(Request.Form["searchtype"]) == false)
            {
                searchtype = Request.Form["searchtype"];
            }


            if (String.IsNullOrEmpty(Request.QueryString["searchfor"]) == false)
            {
                searchfor = Request.QueryString["searchfor"];
                //exactphrase = Request.QueryString["exactphrase"];  This is causing a bug. We test and set this if present later in this block anyway
            }
            else if (String.IsNullOrEmpty(Request.Form["txtSearchFor"]) == false)
            {
                searchfor = Request.Form["txtSearchFor"];
            }


            if (searchfor == null)
            {
                searchfor = string.Empty;
            }

            if (String.IsNullOrEmpty(Request.QueryString["lname"]) == false)
            {
                lname = Request.QueryString["lname"];
            }
            else
            {
                lname = Request.Form["txtLname"];
            }

            if (lname == null)
            {
                lname = string.Empty;
            }

            if (String.IsNullOrEmpty(Request.QueryString["fname"]) == false)
            {
                fname = Request.QueryString["fname"];
            }
            else
            {
                fname = Request.Form["txtFname"];
            }

            if (fname == null)
            {
                fname = string.Empty;
            }



            if (String.IsNullOrEmpty(Request.QueryString["perpage"]) == false)
            {
                perpage = Convert.ToInt64(Request.QueryString["perpage"]);
                if (!(perpage > 0))
                {
                    perpage = 15;
                }
            }
            else
            {
                perpage = 15; //default
            }

            if (String.IsNullOrEmpty(Request.QueryString["offset"]) == false)
            {
                offset = Convert.ToInt64(Request.QueryString["offset"]);
            }
            else
            {
                offset = 0;
            }

            if (String.IsNullOrEmpty(Request.QueryString["page"]) == false)
            {
                page = Convert.ToInt64(Request.QueryString["page"]);
                if (!(page > 0))
                {
                    page = 1;
                }
            }
            else
            {
                page = 1;
            }


            if (String.IsNullOrEmpty(Request.QueryString["classgroupuri"]) == false)
            {
                classgroupuri = HttpUtility.UrlDecode(Request.QueryString["classgroupuri"]);
            }
            else
            {
                classgroupuri = HttpUtility.UrlDecode(Request.Form["classgroupuri"]);
            }

            if (classgroupuri != null)
            {
                if (classgroupuri.Contains("!"))
                {
                    classgroupuri = classgroupuri.Replace('!', '#');
                }
            }
            else
            {
                classgroupuri = string.Empty;
            }

            if (String.IsNullOrEmpty(Request.QueryString["classuri"]) == false)
            {
                classuri = HttpUtility.UrlDecode(Request.QueryString["classuri"]);
            }
            else
            {
                classuri = HttpUtility.UrlDecode(Request.Form["classuri"]);
            }

            if (classuri != null)
            {
                if (classuri.Contains("!"))
                {
                    classuri = classuri.Replace('!', '#');
                }
            }
            else
            {
                classuri = string.Empty;
            }


            if (String.IsNullOrEmpty(Request.QueryString["otherfilters"]) == false)
            {
                otherfilters = Request.QueryString["otherfilters"];
            }


            try
            {
                totalcount = data.GetTotalSearchConnections(this.SearchData, base.Namespaces);

                if (page < 0)
                {
                    page = 1;
                }


                totalpages = Math.DivRem(totalcount, Convert.ToInt64(perpage), out totalpageremainder);

                if (totalpageremainder > 0)
                {
                    totalpages = totalpages + 1;
                }

                if (page > totalpages)
                {
                    page = totalpages;
                }

                startrecord = ((Convert.ToInt32(page) * Convert.ToInt32(perpage)) + 1) - Convert.ToInt32(perpage);

                if (startrecord < 0)
                {
                    startrecord = 1;
                }

                List <GenericListItem> g = new List <GenericListItem>();
                g = data.GetListOfFilters();

                if (otherfilters.IsNullOrEmpty() && base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description/vivo:overview/SearchOptions/MatchOptions/SearchFiltersList/SearchFilter[@Property='http://profiles.catalyst.harvard.edu/ontology/prns#hasPersonFilter']", base.Namespaces) != null)
                {
                    string s = string.Empty;

                    foreach (XmlNode x in base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description/vivo:overview/SearchOptions/MatchOptions/SearchFiltersList/SearchFilter[@Property='http://profiles.catalyst.harvard.edu/ontology/prns#hasPersonFilter']", base.Namespaces))
                    {
                        s             = data.GetConvertedURIListItem(g, x.InnerText);
                        otherfilters += "," + s;
                    }
                }



                //added this test for search type so we could split the person keyword search into a split to remove the why col for person
                keywordOrPerson = data.SearchType(searchfor);


                if (keywordOrPerson == "person")
                {
                    xmlsearchrequest = data.CovidPersonSearchRequest(searchfor, (startrecord - 1).ToString(), perpage.ToString(), country);
                }
                else
                {
                    xmlsearchrequest = data.SearchRequest(searchfor, exactphrase, fname, lname, institution, institutionallexcept, department, departmentallexcept, division, divisionallexcept, "http://xmlns.com/foaf/0.1/Person", perpage.ToString(), (startrecord - 1).ToString(), otherfilters, "", true, ref searchrequest);
                    HttpContext.Current.Session["PERSON-SEARCH-ADD"] = "true";
                }

                this.SearchData               = data.Search(xmlsearchrequest, false, false);
                this.SearchRequest            = xmlsearchrequest.OuterXml;
                base.MasterPage.SearchRequest = this.SearchRequest;
                base.MasterPage.RDFData       = this.SearchData;
                base.MasterPage.RDFNamespaces = this.Namespaces;
            }
            catch (DisallowedSearchException se)
            {
                litEverythingResults.Text = se.Message;
                return;
            }
            catch (Exception ex)
            {
                ex = ex;
                DebugLogging.Log("ERROR " + ex.Message);
                //for now just flip it back to the defaults. This is if someone keys some funky divide by zero stuff in the URL
                // to try and break the system.
                startrecord = 1;
                perpage     = 15;
            }

            args.AddParam("root", "", Root.Domain);
            args.AddParam("perpage", "", perpage);
            args.AddParam("offset", "", offset);
            args.AddParam("totalpages", "", totalpages);
            args.AddParam("page", "", page);
            args.AddParam("searchfor", "", searchfor);
            args.AddParam("exactphrase", "", exactphrase);
            args.AddParam("classGrpURIpassedin", "", classgroupuri);
            args.AddParam("classURIpassedin", "", classuri);

            switch (searchtype.ToLower())
            {
            case "everything":
                litEverythingResults.Text = XslHelper.TransformInMemory(Server.MapPath("~/Search/Modules/SearchResults/EverythingResults.xslt"), args, this.SearchData.OuterXml);
                break;

            case "people":


                args.AddParam("country", "", country);


                if (keywordOrPerson == "keyword")
                {
                    args.AddParam("why", "", true);
                }
                else
                {
                    args.AddParam("why", "", false);
                }

                litEverythingResults.Text = HttpUtility.HtmlDecode(XslHelper.TransformInMemory(Server.MapPath("~/Search/Modules/SearchResults/PeopleResults.xslt"), args, this.SearchData.OuterXml));
                break;
            }
        }