private void DrawProfilesModule() { XsltArgumentList args = new XsltArgumentList(); XslCompiledTransform xslt = new XslCompiledTransform(); SessionManagement sm = new SessionManagement(); Utilities.DataIO data = new Profiles.Profile.Utilities.DataIO(); string email = string.Empty; string imageemailurl = string.Empty; if (this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/prns:emailEncrypted", this.Namespaces) != null && this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/vivo:email", this.Namespaces) == null) { email = this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/prns:emailEncrypted", this.Namespaces).InnerText; imageemailurl = string.Format(Root.Domain + "/profile/modules/CustomViewPersonGeneralInfo/" + "EmailHandler.ashx?msg={0}", HttpUtility.UrlEncode(email)); } args.AddParam("root", "", Root.Domain); if (email != string.Empty) { args.AddParam("email", "", imageemailurl); } args.AddParam("imgguid", "", Guid.NewGuid().ToString()); // Check for an ORCID string internalUsername = new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.Profile.Data.Person().GetInternalUsername(Convert.ToInt64(Request.QueryString["Subject"])); Profiles.ORCID.Utilities.ProfilesRNSDLL.BO.ORCID.Person orcidPerson = new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.ORCID.Person().GetByInternalUsername(internalUsername); if (orcidPerson.Exists && !orcidPerson.ORCIDIsNull) { args.AddParam("orcid", "", orcidPerson.ORCID); args.AddParam("orcidurl", "", Profiles.ORCID.Utilities.config.ORCID_URL + "/" + orcidPerson.ORCID); args.AddParam("orcidinfosite", "", Profiles.ORCID.Utilities.config.InfoSite); args.AddParam("orcidimage", "", Root.Domain + "/Framework/Images/orcid_16x16(1).gif"); args.AddParam("orcidimageguid", "", Guid.NewGuid().ToString()); } else if (Profiles.ORCID.Utilities.config.ShowNoORCIDMessage && Profiles.ORCID.Utilities.config.Enabled) { //args.AddParam("orcid", "", "No ORCID id has been created for this user"); args.AddParam("orcid", "", "Login to create your ORCID iD"); args.AddParam("orcidinfosite", "", Profiles.ORCID.Utilities.config.InfoSite); string qs = HttpUtility.UrlEncode("predicateuri=http%3a%2f%2fvivoweb.org%2fontology%2fcore!orcidId&module=DisplayItemToEdit&ObjectType=Literal"); args.AddParam("orcidurl", "", Root.Domain + "/login/default.aspx?method=login&edit=true&editparams=" + qs); args.AddParam("orcidimage", "", Root.Domain + "/Framework/Images/orcid_16x16(1).gif"); args.AddParam("orcidimageguid", "", Guid.NewGuid().ToString()); } litPersonalInfo.Text = XslHelper.TransformInMemory(Server.MapPath("~/Profile/Modules/CustomViewPersonGeneralInfo/CustomViewPersonGeneralInfo.xslt"), args, base.BaseData.OuterXml); if (base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[1]/prns:mainImage/@rdf:resource", base.Namespaces) != null) { string imageurl = base.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description[1]/prns:mainImage/@rdf:resource", base.Namespaces).Value; imgPhoto.ImageUrl = imageurl + "&cachekey=" + Guid.NewGuid().ToString(); } else { imgPhoto.Visible = false; } }
private static Message GenerateInvoicMessageWithCompiledXsltMap(CustomInvoic customInvoic) { // Map the custom EDI into ediFabric EDI (the instance of the class that represents the transaction set & version) var serializedCustomInvoic = XslHelper.Serialize(customInvoic, "customedifact"); // This uses a precompiled xslt, therefore needs to serialize to XML first // You can generate an xsd for the custom object using xsd.exe or xsd2code var ediFabricInvoic = serializedCustomInvoic.Map(); // Create ediFabric message (this serializes the instance and passes the xml + context (transaction set, version, format)) var msg = new Message(ediFabricInvoic); // Set the UNT segment count SetSegmentsCount(ref msg); // Validate to ensure it's a valid EDI message var brokenRules = msg.Validate().ToList(); if (brokenRules.Any()) { // Do something if the message is invalid foreach (var br in brokenRules) { Debug.WriteLine(br); } } return(msg); }
private void DrawProfilesModule() { XsltArgumentList args = new XsltArgumentList(); XslCompiledTransform xslt = new XslCompiledTransform(); SessionManagement sm = new SessionManagement(); Utilities.DataIO data = new Profiles.Profile.Utilities.DataIO(); string email = string.Empty; string imageemailurl = string.Empty; if (this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/prns:emailEncrypted", this.Namespaces) != null && this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/vivo:email", this.Namespaces) == null) { email = this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/prns:emailEncrypted", this.Namespaces).InnerText; imageemailurl = string.Format(Root.Domain + "/profile/modules/CustomViewPersonGeneralInfo/" + "EmailHandler.ashx?msg={0}", HttpUtility.UrlEncode(email)); } args.AddParam("root", "", Root.Domain); if (email != string.Empty) { args.AddParam("email", "", imageemailurl); } args.AddParam("imgguid", "", Guid.NewGuid().ToString()); litPersonalInfo.Text = XslHelper.TransformInMemory(Server.MapPath("~/Profile/Modules/CustomViewPersonGeneralInfo/CustomViewPersonGeneralInfo.xslt"), args, base.BaseData.OuterXml); if (base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[1]/prns:mainImage/@rdf:resource", base.Namespaces) != null) { string imageurl = base.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description[1]/prns:mainImage/@rdf:resource", base.Namespaces).Value; imgPhoto.ImageUrl = imageurl + "&cachekey=" + Guid.NewGuid().ToString(); } else { imgPhoto.Visible = false; } }
internal static Custom810 CreateSampleCustom810() { // Create a sample instance of a custom type // This will be your message(s) that have to be converted into EDI const string sampleEdi = "EdiFabric.Sdk.ObjectToEdi.ConsoleApplication.TestFiles.CustomX12.xml"; var xEl = XElement.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream(sampleEdi)); return(XslHelper.Deserialize <Custom810>(xEl, "customx12")); }
public void DrawProfilesCloud() { XmlDocument document = new XmlDocument(); string xml = string.Empty; Profiles.Profile.Utilities.DataIO pdata = new Profiles.Profile.Utilities.DataIO(); RDFTriple request = new RDFTriple(Convert.ToInt64(Request.QueryString["subject"])); document.LoadXml(pdata.GetNetworkCloud(request).ToString().Replace("&", "&")); XslCompiledTransform xslt = new XslCompiledTransform(); XsltArgumentList args = new XsltArgumentList(); args.AddParam("root", "", Root.Domain); litListView.Text = XslHelper.TransformInMemory(Server.MapPath("~/Profile/Modules/NetworkList/NetworkList.xslt"), args, document.OuterXml); }
/// <summary> /// Renders the control to the specified HTML writer. /// </summary> /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter"></see> object that receives the control content.</param> protected override void Render(HtmlTextWriter writer) { // get XSLT stylesheet XslCompiledTransform xslDoc = new XslCompiledTransform(); try { string myFilePath = HttpContext.Current.Server.MapPath( string.Concat(Path.ApplicationRoot, "/app_support/ZenNavigation/", XsltFile, ".xslt")); xslDoc.Load(myFilePath); } catch (Exception e) { throw new ApplicationException("Cannot load specified XsltFile: " + e.Message); } try { // build parameter list to pass to stylesheet XsltArgumentList xslArg = new XsltArgumentList(); xslArg.AddParam("ActivePageId", "", portalSettings.ActivePage.PageID); xslArg.AddParam("ContainerCssClass", "", ContainerCssClass); xslArg.AddParam("UsePageNameInUrl", "", UsePageNameInUrl.ToString().ToLower()); xslArg.AddParam("UsePathTraceInUrl", "", UsePathTraceInUrl.ToString().ToLower()); // add the helper object XslHelper xslHelper = new XslHelper(); xslArg.AddExtensionObject("urn:rainbow", xslHelper); // do the transform StringWriter result = new StringWriter(); xslDoc.Transform(PortalPagesXml, xslArg, result); string myResult = result.ToString(); writer.Write(myResult); } catch (Exception ex) { HttpContext.Current.Trace.Warn("ZenNavigation :: Failed to transform menu:" + ex.Message); writer.Write("ZenNavigation :: Failed to transform menu:" + ex.Message); } }
/// <summary> /// The Page_Load event handler on this User Control uses /// the Portal configuration system to obtain an xml document /// and xsl/t transform file location. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Page_Load(object sender, System.EventArgs e) { XslTransform xs; XPathDocument xd; XsltArgumentList xa = new XsltArgumentList(); XslHelper xh = new XslHelper(); StringBuilder sb = new StringBuilder(); TextWriter tw = new StringWriter(sb); PortalUrlDataType pt; pt = new PortalUrlDataType(); pt.Value = Settings["XMLsrc"].ToString(); string xmlsrc = Server.MapPath(pt.FullPath); pt = new PortalUrlDataType(); pt.Value = Settings["XSLsrc"].ToString(); string xslsrc = Server.MapPath(pt.FullPath); if ((xmlsrc != null) && (xmlsrc != string.Empty) && (xslsrc != null) && (xslsrc != string.Empty) && File.Exists(xmlsrc) && File.Exists(xslsrc)) { xd = new XPathDocument(xmlsrc); xs = new XslTransform(); xs.Load(xslsrc); xa.AddParam("Lang", string.Empty, this.portalSettings.PortalContentLanguage.Name.ToLower()); xa.AddExtensionObject("urn:rainbow", xh); #if FW11 xs.Transform(xd, xa, tw, new XmlUrlResolver()); #else xs.Transform(xd, xa, tw); #endif this.Content = sb.ToString(); this.ContentHolder.Controls.Add(new LiteralControl(this.Content.ToString())); this.ModuleConfiguration.CacheDependency.Add(xslsrc); this.ModuleConfiguration.CacheDependency.Add(xmlsrc); } }
private static void Main(string[] args) { // This sample will parse an EDI message to a custom entity. The steps are: // 1. Converts an EDI message into XML. // 2. Validates the Message object to ensure it adheres to the EDI rules for this transaction and version // 3. Transform each XML into a custom object // For simplicity the custom object bears the same structure as the ediFabric object. The only difference being the root element and the namespace // The default locations for the transaction set classes and validation XSD are set in the app.config // This sample is for Edifact and uses a compiled XSLT map to convert to custom object from ediFabric object const string sampleEdifact = "EdiFabric.Sdk.EdiToObject.ConsoleApplication.TestFiles.Edifact_INVOIC_D00A.txt"; List <CustomInvoic> edifactInvoices = Helpers.ConvertEdifactToObjectsWithCompiledXsltMap( Assembly.GetExecutingAssembly().GetManifestResourceStream(sampleEdifact)).ToList(); var b = XslHelper.Serialize(edifactInvoices[0], "customedifact"); // This sample is for X12 and uses a code map (I used Automapper, but could be any custom code\mapper) to convert to custom object from ediFabric object const string sampleX12 = "EdiFabric.Sdk.EdiToObject.ConsoleApplication.TestFiles.X12_810_00204.txt"; List <Custom810> x12Invoices = Helpers.ConvertX12ToObjectsWithCodeMap( Assembly.GetExecutingAssembly().GetManifestResourceStream(sampleX12)).ToList(); }
private void DrawProfilesModule() { XsltArgumentList args = new XsltArgumentList(); XslCompiledTransform xslt = new XslCompiledTransform(); SessionManagement sm = new SessionManagement(); Profiles.Profile.Modules.CustomViewPersonGeneralInfo.DataIO data = new Profiles.Profile.Modules.CustomViewPersonGeneralInfo.DataIO(); string email = string.Empty; string imageemailurl = string.Empty; string audioemailurl = string.Empty; if (this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/prns:emailEncrypted", this.Namespaces) != null && this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/vivo:email", this.Namespaces) == null) { email = this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/prns:emailEncrypted", this.Namespaces).InnerText; imageemailurl = string.Format(Root.Domain + "/profile/modules/CustomViewPersonGeneralInfo/" + "EmailHandler.ashx?msg={0}", HttpUtility.UrlEncode(email)); audioemailurl = string.Format(Root.Domain + "/profile/modules/CustomViewPersonGeneralInfo/" + "EmailAudioHandler.ashx?msg={0}", HttpUtility.UrlEncode(email)); } args.AddParam("root", "", Root.Domain); if (email != string.Empty) { args.AddParam("email", "", imageemailurl); args.AddParam("emailAudio", "", audioemailurl); args.AddParam("emailAudioImg", "", Root.Domain + "/Framework/Images/listen.jpg"); } args.AddParam("imgguid", "", Guid.NewGuid().ToString()); if (base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[1]/vivo:orcidId", base.Namespaces) != null) // Only show ORCID if security settings allow it { args.AddParam("orcid", "", base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[1]/vivo:orcidId", base.Namespaces).InnerText); args.AddParam("orcidurl", "", Profiles.ORCID.Utilities.config.ORCID_URL + "/" + base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[1]/vivo:orcidId", base.Namespaces).InnerText); string infosite; if (Profiles.ORCID.Utilities.config.InfoSite == null) { infosite = Root.Domain + "/about/default.aspx?tab=orcid"; } else if (Profiles.ORCID.Utilities.config.InfoSite.Equals("")) { infosite = Root.Domain + "/about/default.aspx?tab=orcid"; } else { infosite = Profiles.ORCID.Utilities.config.InfoSite; } args.AddParam("orcidinfosite", "", infosite); args.AddParam("orcidimage", "", Root.Domain + "/Framework/Images/orcid_16x16(1).gif"); args.AddParam("orcidimageguid", "", Guid.NewGuid().ToString()); } else if (Profiles.ORCID.Utilities.config.ShowNoORCIDMessage && Profiles.ORCID.Utilities.config.Enabled) { // Check for an ORCID string internalUsername = new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.Profile.Data.Person().GetInternalUsername(Convert.ToInt64(Request.QueryString["Subject"])); Profiles.ORCID.Utilities.ProfilesRNSDLL.BO.ORCID.Person orcidPerson = new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.ORCID.Person().GetByInternalUsername(internalUsername); if (!orcidPerson.Exists || orcidPerson.ORCIDIsNull) { //args.AddParam("orcid", "", "No ORCID id has been created for this user"); args.AddParam("orcid", "", "Login to create your ORCID iD"); args.AddParam("orcidinfosite", "", Profiles.ORCID.Utilities.config.InfoSite); string qs = HttpUtility.UrlEncode("predicateuri=http%3a%2f%2fvivoweb.org%2fontology%2fcore!orcidId&module=DisplayItemToEdit&ObjectType=Literal"); args.AddParam("orcidurl", "", Root.Domain + "/login/default.aspx?method=login&edit=true&editparams=" + qs); args.AddParam("orcidimage", "", Root.Domain + "/Framework/Images/orcid_16x16(1).gif"); args.AddParam("orcidimageguid", "", Guid.NewGuid().ToString()); } } args.AddParam("nodeid", "", Request.QueryString["Subject"]); litPersonalInfo.Text = XslHelper.TransformInMemory(Server.MapPath("~/Profile/Modules/CustomViewPersonGeneralInfo/CustomViewPersonGeneralInfo.xslt"), args, base.BaseData.OuterXml); try { string addressURI = base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[1]/vivo:mailingAddress", base.Namespaces).Attributes["rdf:resource"].Value; mapCountry = base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about=\"" + addressURI + "\"]/vivo:address3", base.Namespaces).InnerText; string mr = data.GetMapData(mapCountry); if (mr != "-1") { mapRegion = "region: '" + mr + "',"; } } catch (Exception) { } /* * if (base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[1]/prns:mainImage/@rdf:resource", base.Namespaces) != null) * { * string imageurl = base.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description[1]/prns:mainImage/@rdf:resource", base.Namespaces).Value; * imgPhoto.ImageUrl = imageurl;// + "&cachekey=" + Guid.NewGuid().ToString(); * } * else * { * imgPhoto.Visible = false; * } */ // OpenSocial. Allows gadget developers to show test gadgets if you have them installed /* string uri = this.BaseData.SelectSingleNode("rdf:RDF/rdf:Description/@rdf:about", base.Namespaces).Value; * OpenSocialManager om = OpenSocialManager.GetOpenSocialManager(uri, Page); * if (om.IsVisible() && om.GetUnrecognizedGadgets().Count > 0) * { * pnlSandboxGadgets.Visible = true; * litSandboxGadgets.Visible = true; * string sandboxDivs = "" ; * foreach (PreparedGadget gadget in om.GetUnrecognizedGadgets()) * { * sandboxDivs += "<div id='" + gadget.GetChromeId() + "' class='gadgets-gadget-parent'></div>"; * } * litSandboxGadgets.Text = sandboxDivs; * om.LoadAssets(); * // Add this just in case it is needed. * new ORNGProfileRPCService(Page, this.BaseData.SelectSingleNode("rdf:RDF/rdf:Description/foaf:firstName", base.Namespaces).InnerText, uri); * } */ }
public void DrawProfilesModule() { DateTime d = DateTime.Now; //If your module performs a data request, based on the DataURI parameter then call ReLoadBaseData base.GetDataByURI(); List <CloudItem> weights = new List <CloudItem>(); double firsttwenty = 0.0; double lasttwenty = 0.0; string cloudweightnode = string.Empty; string networklistnode = string.Empty; string itemurl = string.Empty; string itemurltext = string.Empty; string itemtext = string.Empty; cloudweightnode = base.GetModuleParamString("CloudWeightNode"); networklistnode = base.GetModuleParamString("NetworkListNode"); itemurl = base.GetModuleParamString("ItemURL"); itemurltext = base.GetModuleParamString("ItemURLText"); itemtext = base.GetModuleParamString("ItemText"); if (base.BaseData.SelectNodes(networklistnode, base.Namespaces) != null && cloudweightnode != string.Empty) { if (cloudweightnode != string.Empty) { var items = from XmlNode networknode in base.BaseData.SelectNodes(networklistnode, base.Namespaces) select new { weight = Convert.ToDouble(networknode.SelectSingleNode(cloudweightnode, base.Namespaces).InnerText), value = networknode.SelectSingleNode("./rdf:object/@rdf:resource", this.Namespaces).Value }; foreach (var i in items) { weights.Add(new CloudItem(i.weight, i.value)); } //foreach (XmlNode networknode in base.BaseData.SelectNodes(networklistnode, base.Namespaces)) //{ // weight = Convert.ToDouble(networknode.SelectSingleNode(cloudweightnode, base.Namespaces).InnerText); // weights.Add(new CloudItem(weight, networknode.SelectSingleNode("./rdf:object/@rdf:resource", this.Namespaces).Value)); //} } weights = weights.OrderByDescending(clouditem => clouditem.Weight).ToList(); firsttwenty = weights.Count * .2; lasttwenty = weights.Count * .8; int cnt = 0; foreach (CloudItem ci in weights) { if (cnt > firsttwenty && cnt < lasttwenty) { ci.Rank = "med"; } if (cnt < firsttwenty) { ci.Rank = "big"; } if (cnt > lasttwenty) { ci.Rank = "small"; } cnt++; } } XmlDocument document = new XmlDocument(); System.Text.StringBuilder documentdata = new System.Text.StringBuilder(); documentdata.Append("<ListView"); documentdata.Append(" Columns=\""); documentdata.Append(base.GetModuleParamString("Columns")); documentdata.Append("\""); if (base.GetModuleParamString("BulletType") != string.Empty) { documentdata.Append(" Bullet=\""); documentdata.Append(base.GetModuleParamString("BulletType")); documentdata.Append("\""); } documentdata.Append(" InfoCaption=\""); documentdata.Append(base.GetModuleParamString("InfoCaption")); documentdata.Append("\""); documentdata.Append(" Description=\""); documentdata.Append(base.GetModuleParamString("Description")); documentdata.Append("\">"); string item = string.Empty; if (base.BaseData.SelectNodes(networklistnode, base.Namespaces) != null) { var items = from XmlNode networknode in base.BaseData.SelectNodes(networklistnode, base.Namespaces) select new { itemurl = CustomParse.Parse(itemurl, networknode, base.Namespaces), item = CustomParse.Parse(itemtext, networknode, base.Namespaces), weight = GetCloudRank(networknode.SelectSingleNode("./rdf:object/@rdf:resource", base.Namespaces).InnerText, weights), connectiondetails = networknode.SelectSingleNode("prns:hasConnectionDetails/@rdf:resource", base.Namespaces), sortorder = networknode.SelectSingleNode("prns:sortOrder", base.Namespaces), itemxpath = CustomParse.Parse(itemurltext, networknode, base.Namespaces) }; foreach (var i in items) { //foreach (XmlNode networknode in base.BaseData.SelectNodes(networklistnode, base.Namespaces)) //{ documentdata.Append("<Item"); if (itemurl != string.Empty) { documentdata.Append(" ItemURL=\""); documentdata.Append(i.itemurl); documentdata.Append("\""); if (cloudweightnode != string.Empty) { documentdata.Append(" Weight=\""); documentdata.Append(i.weight); documentdata.Append("\""); } if (i.connectiondetails != null) { if (base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + i.connectiondetails.InnerText + "']/prns:isAlsoCoAuthor", base.Namespaces) != null) { documentdata.Append(" CoAuthor=\""); documentdata.Append(base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + i.connectiondetails.InnerText + "']/prns:isAlsoCoAuthor", base.Namespaces).InnerText); documentdata.Append("\""); } if (i.sortorder != null) { documentdata.Append(" sortOrder=\""); documentdata.Append(i.sortorder.InnerText); documentdata.Append("\""); } } string itemxpath = i.itemxpath; if (itemxpath != string.Empty) { item = base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about= '" + itemxpath + "']/rdfs:label", base.Namespaces).InnerText; } documentdata.Append(" ItemURLText=\""); documentdata.Append(item); documentdata.Append("\""); } documentdata.Append(">"); documentdata.Append(i.item); documentdata.Append("</Item>"); } } documentdata.Append("</ListView>"); document.LoadXml(documentdata.ToString().Replace("&", "&")); XsltArgumentList args = new XsltArgumentList(); string xmlbuffer; if (base.GetModuleParamString("SortBy").Equals("Weight")) { xmlbuffer = XslHelper.TransformInMemory(Server.MapPath("~/Profile/Modules/NetworkList/SortIntermediateByWeight.xslt"), args, document.OuterXml); } else { xmlbuffer = XslHelper.TransformInMemory(Server.MapPath("~/Profile/Modules/NetworkList/SortIntermediate.xslt"), args, document.OuterXml); } litListView.Text = XslHelper.TransformInMemory(Server.MapPath("~/Profile/Modules/NetworkList/NetworkList.xslt"), args, xmlbuffer); Framework.Utilities.DebugLogging.Log("Network List MODULE end Milliseconds:" + (DateTime.Now - d).TotalSeconds); }
private void Page_Load(object sender, System.EventArgs e) { // set current directory so paths are relative to this page location Environment.CurrentDirectory = this.Server.MapPath(this.TemplateSourceDirectory); // set localized Page Title this.TabTitle = Esperantus.Localize.GetString("TAB_TITLE_RAINBOW_HELP", "Rainbow Help", this); // add the Help css this.ClearCssFileList(); this.RegisterCssFile("help", "css/help.css"); this.RegisterCssFile("menu", "css/mainmenu.css"); if (!this.IsAdditionalMetaElementRegistered("ie7")) { string _ie7 = string.Empty; string _ie7Part = string.Empty; foreach (string _script in Ie7Script.Split(new char[] { ';' })) { _ie7Part = Rainbow.Settings.Path.WebPathCombine(Rainbow.Settings.Path.ApplicationRoot, _script); _ie7Part = string.Format("<!--[if lt IE 7]><script src=\"{0}\" type=\"text/javascript\"></script><![endif]-->", _ie7Part); _ie7 += _ie7Part + "\n"; } this.RegisterAdditionalMetaElement("ie7", _ie7); } string loc = string.Empty; string src = string.Empty; string xslt = string.Empty; CultureInfo lang = this.portalSettings.PortalContentLanguage; CultureInfo defaultLang = this.portalSettings.PortalContentLanguage; CultureInfo fallbackLang = new CultureInfo(ConfigurationSettings.AppSettings["DefaultLanguage"]); XslTransform xt; // grab the QueryString NameValueCollection qs = Request.QueryString; // Read Location if (qs["loc"] != null && qs["loc"] != string.Empty) { loc = qs["loc"]; } else { loc = defaultLocation; } // Read Source if (qs["src"] != null && qs["src"] != string.Empty) { src = qs["src"]; } else { src = defaultSource; } // Read Culture if (qs["lang"] != null && qs["lang"] != string.Empty) { try{ lang = new CultureInfo(qs["lang"], false); } catch {} } // Read XSLT Stylesheet if (qs["xslt"] != null && qs["xslt"] != string.Empty && File.Exists(qs["xslt"]) ) { xslt = qs["xslt"]; } else { xslt = defaultXslt; } // create language sequence ArrayList langSequence = new ArrayList(7); langSequence.Add(lang); if (!lang.Equals(defaultLang)) { langSequence.Add(defaultLang); } if (!defaultLang.Equals(fallbackLang)) { langSequence.Add(fallbackLang); } langSequence.Add(new CultureInfo(string.Empty)); // create file sequence ArrayList fileSequence = new ArrayList(2); fileSequence.Add(Rainbow.Settings.Path.WebPathCombine(loc, src)); fileSequence.Add(Rainbow.Settings.Path.WebPathCombine(defaultLocation, defaultSource)); string filePath = string.Empty; bool found = false; bool asRequested = true; string languageReturned = string.Empty; // find a file foreach (string _file in fileSequence) { foreach (CultureInfo _language in langSequence) { filePath = string.Concat(_file, ".", _language.Name, sourceExtension); filePath = filePath.Replace("..", "."); if (File.Exists(filePath)) { languageReturned = _language.Name; found = true; break; } if (_language.TwoLetterISOLanguageName.ToLower().Equals("en")) { filePath = string.Concat(_file, sourceExtension); } else { filePath = string.Concat(_file, ".", _language.TwoLetterISOLanguageName, sourceExtension); } filePath = filePath.Replace("..", "."); if (File.Exists(filePath)) { languageReturned = _language.TwoLetterISOLanguageName; found = true; break; } } if (found) { break; } else { asRequested = false; } } // if we found something to display if (found) { // get the Transformer string transformerCacheKey = string.Concat(cacheKeyRoot, "_", xslt); if (Context.Cache[transformerCacheKey] == null) { try { xt = new XslTransform(); xslt = this.Server.MapPath(xslt); XmlUrlResolver xr = new XmlUrlResolver(); xt.Load(xslt, xr); Context.Cache.Insert(transformerCacheKey, xt, new CacheDependency(xslt)); } catch (Exception ex) { Helpers.LogHelper.Logger.Log(Rainbow.Configuration.LogLevel.Error, "Failed in Help Transformer load - message was: " + ex.Message); throw new Exception("Failed in Help Transformer load - message was: " + ex.Message); } } else { xt = (XslTransform)Context.Cache[transformerCacheKey]; } // create the ArgList XsltArgumentList xa = new XsltArgumentList(); XslHelper xh = new XslHelper(); xa.AddExtensionObject("urn:rainbow", xh); xa.AddParam("LanguageRequested", string.Empty, lang.Name); xa.AddParam("LanguageReturned", string.Empty, languageReturned); xa.AddParam("AsRequested", string.Empty, asRequested.ToString()); //string rootFolder = Rainbow.Settings.Path.ApplicationRoot + "/rb_documentation/"; //xa.AddParam("Location",string.Empty,rootFolder + loc); xa.AddParam("Location", string.Empty, loc); xa.AddParam("Title", string.Empty, this.TabTitle); string tocFile = string.Concat(loc.Substring(0, loc.IndexOf("/")), "/map.", languageReturned, sourceExtension); tocFile = tocFile.Replace("..", "."); tocFile = string.Concat("../", tocFile); xa.AddParam("TOCfile", string.Empty, tocFile); xa.AddParam("Viewer", string.Empty, this.Request.Url.AbsolutePath); xa.AddParam("myRoot", string.Empty, loc.Substring(0, loc.IndexOf("/"))); // load up the Xml control myXml.DocumentSource = filePath; myXml.Transform = xt; myXml.TransformArgumentList = xa; } else { using (Esperantus.WebControls.Literal errorMsg = new Esperantus.WebControls.Literal()) { errorMsg.TextKey = "HELP_VIEWER_ERROR"; errorMsg.Text = "Sorry - no help available"; using (HtmlGenericControl container = new HtmlGenericControl("div")) { container.Attributes.Add("style", "padding:3em;font-size:1.2em;text-align:center"); container.Controls.Add(errorMsg); this.ContentHolder.Controls.Add(container); } } } }
public void DrawProfilesModule() { DateTime d = DateTime.Now; //If your module performs a data request, based on the DataURI parameter then call ReLoadBaseData base.GetDataByURI(); XmlDocument document = new XmlDocument(); XsltArgumentList args = new XsltArgumentList(); bool networkexists = false; System.Text.StringBuilder documentdata = new System.Text.StringBuilder(); documentdata.Append("<PassiveList"); documentdata.Append(" InfoCaption=\""); documentdata.Append(base.GetModuleParamString("InfoCaption")); documentdata.Append("\""); documentdata.Append(" Description=\""); documentdata.Append(base.GetModuleParamString("Description")); documentdata.Append("\""); documentdata.Append(" ID=\""); documentdata.Append(Guid.NewGuid().ToString()); documentdata.Append("\""); documentdata.Append(" MoreText=\""); documentdata.Append(CustomParse.Parse(base.GetModuleParamString("MoreText"), base.BaseData, base.Namespaces)); documentdata.Append("\""); documentdata.Append(" MoreURL=\""); if (base.GetModuleParamString("MoreURL").Contains("&")) { documentdata.Append(Root.Domain + CustomParse.Parse(base.GetModuleParamString("MoreURL"), base.BaseData, base.Namespaces).Replace("&", "&")); } else { documentdata.Append(CustomParse.Parse(base.GetModuleParamString("MoreURL"), base.BaseData, base.Namespaces)); } documentdata.Append("\""); documentdata.Append(">"); documentdata.Append("<ItemList>"); try { var items = from XmlNode networknode in this.BaseData.SelectNodes(base.GetModuleParamString("ListNode") + "[position() < " + Math.BigMul((Convert.ToInt16(base.GetModuleParamString("MaxDisplay")) + 1), 1).ToString() + "]", this.Namespaces) select new { itemurl = CustomParse.Parse(base.GetModuleParamString("ItemURL"), networknode, this.Namespaces), itemurltext = CustomParse.Parse(base.GetModuleParamString("ItemURLText"), networknode, this.Namespaces), item = CustomParse.Parse(base.GetModuleParamString("ItemText"), networknode, this.Namespaces), personid = CustomParse.Parse("{{{rdf:Description/prns:personId}}}", networknode, this.Namespaces) }; foreach (var i in items) { networkexists = true; documentdata.Append("<Item"); if (base.GetModuleParamString("ItemURL") != string.Empty) { documentdata.Append(" ItemURL=\"" + i.itemurl); documentdata.Append("\""); documentdata.Append(" ItemURLText=\"" + i.itemurltext); documentdata.Append("\""); if (i.personid != string.Empty) { documentdata.Append(" PersonID=\"" + i.personid); documentdata.Append("\""); } } documentdata.Append(">"); documentdata.Append(i.item); documentdata.Append("</Item>"); } } catch (Exception ex) { Framework.Utilities.DebugLogging.Log(ex.Message + " ++ " + ex.StackTrace); } documentdata.Append("</ItemList>"); documentdata.Append("</PassiveList>"); if (networkexists) { document.LoadXml(documentdata.ToString()); args.AddParam("root", "", Root.Domain); args.AddParam("ListNode", "", base.GetModuleParamString("ListNode")); args.AddParam("InfoCaption", "", base.GetModuleParamString("InfoCaption")); args.AddParam("Description", "", base.GetModuleParamString("Description")); args.AddParam("MoreUrl", "", base.GetModuleParamString("ListNode")); litPassiveNetworkList.Text = XslHelper.TransformInMemory(Server.MapPath("~/Profile/Modules/PassiveList/PassiveList.xslt"), args, document.OuterXml); Framework.Utilities.DebugLogging.Log("PASSIVE MODULE end Milliseconds:" + (DateTime.Now - d).TotalSeconds); } }
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 sort = ""; string sortdirection = ""; string searchrequest = ""; XmlDocument xmlsearchrequest; xmlsearchrequest = new XmlDocument(); Int16 showcolumns = 0; string otherfilters = ""; string institutionallexcept = string.Empty; string departmentallexcept = string.Empty; string divisionallexcept = string.Empty; string exactphrase = "false"; // UCSF default value to allow old Mini Search to work string searchtype = ""; Search.Utilities.DataIO data = new Profiles.Search.Utilities.DataIO(); if (String.IsNullOrEmpty(Request.QueryString["searchrequest"]) == false) { searchrequest = data.DecryptRequest(Request.QueryString["searchrequest"]); xmlsearchrequest.LoadXml(searchrequest); } else if (Session["searchrequest"] != null) { searchrequest = Session["searchrequest"].ToString(); xmlsearchrequest.LoadXml(searchrequest); } else if (string.IsNullOrEmpty(base.MasterPage.SearchRequest) == false) { searchrequest = data.DecryptRequest(base.MasterPage.SearchRequest); xmlsearchrequest.LoadXml(searchrequest); } 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"]; } else if (xmlsearchrequest.ChildNodes.Count > 0) { try { searchfor = xmlsearchrequest.SelectSingleNode("SearchOptions/MatchOptions/SearchString").InnerText; } catch (Exception) { // Do nothing, leave searchfor = null } } 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["institution"]) == false) { institution = Request.QueryString["institution"]; } if (String.IsNullOrEmpty(Request.QueryString["department"]) == false) { department = Request.QueryString["department"]; } if (String.IsNullOrEmpty(Request.QueryString["division"]) == false) { division = Request.QueryString["division"]; } if (String.IsNullOrEmpty(Request.QueryString["perpage"]) == false) { perpage = Convert.ToInt64(Request.QueryString["perpage"]); if (!(perpage > 0)) { perpage = 15; } //if (String.IsNullOrEmpty(Request.QueryString["perpage"])==false) // perpage = Convert.ToInt64(Request.QueryString["perpage"]); //else // perpage = 15; } else { perpage = 15; //default } if (String.IsNullOrEmpty(Request.QueryString["offset"]) == false) { offset = Convert.ToInt64(Request.QueryString["offset"]); //if (Request.QueryString["offset"] != string.Empty) // offset = Convert.ToInt64(Request.QueryString["offset"]); //else // offset = 0; } else { offset = 0; } if (String.IsNullOrEmpty(Request.QueryString["page"]) == false) { page = Convert.ToInt64(Request.QueryString["page"]); if (!(page > 0)) { page = 1; } //if (Request.QueryString["page"] != string.Empty) // page = Convert.ToInt64(Request.QueryString["page"]); //else // 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["sortby"]) == false) { sort = Request.QueryString["sortby"]; } if (String.IsNullOrEmpty(Request.QueryString["sortdirection"]) == false) { sortdirection = Request.QueryString["sortdirection"]; } if (String.IsNullOrEmpty(Request.QueryString["showcolumns"]) == false) { showcolumns = Convert.ToInt16(Request.QueryString["showcolumns"]); } else { showcolumns = 1; } if (String.IsNullOrEmpty(Request.QueryString["otherfilters"]) == false) { otherfilters = Request.QueryString["otherfilters"]; } if (String.IsNullOrEmpty(Request.QueryString["institutionallexcept"]) == false) { institutionallexcept = Request.QueryString["institutionallexcept"]; } if (String.IsNullOrEmpty(Request.QueryString["departmentallexcept"]) == false) { departmentallexcept = Request.QueryString["departmentallexcept"]; } if (String.IsNullOrEmpty(Request.QueryString["divisionallexcept"]) == false) { divisionallexcept = Request.QueryString["divisionallexcept"]; } if (String.IsNullOrEmpty(Request.QueryString["exactphrase"]) == false) { exactphrase = Request.QueryString["exactphrase"]; } 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; } if (searchrequest.Trim() != string.Empty) { searchrequest = data.EncryptRequest(searchrequest); } 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; } } switch (searchtype.ToLower()) { case "everything": xmlsearchrequest = data.SearchRequest(searchfor, exactphrase, classgroupuri, classuri, perpage.ToString(), (startrecord - 1).ToString()); break; default: 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(), sort, sortdirection, otherfilters, "", true, ref searchrequest); HttpContext.Current.Session["PERSON-SEARCH-ADD"] = "true"; break; } this.SearchData = data.Search(xmlsearchrequest, false); this.SearchRequest = data.EncryptRequest(xmlsearchrequest.OuterXml); base.MasterPage.SearchRequest = this.SearchRequest; base.MasterPage.RDFData = this.SearchData; base.MasterPage.RDFNamespaces = this.Namespaces; // only shows these if we are not doing an everything search, or we are looking at people in the everything search if (!"everything".Equals(searchtype.ToLower()) || "http://profiles.catalyst.harvard.edu/ontology/prns#ClassGroupPeople".Equals(classgroupuri)) { new ORNGSearchRPCService(Page, this.SearchData, xmlsearchrequest, 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); args.AddParam("searchrequest", "", this.SearchRequest); 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("showcolumns", "", showcolumns.ToString()); if ((showcolumns & 1) == 1) { args.AddParam("institution", "", "true"); } else { args.AddParam("institution", "", "false"); } if ((showcolumns & 2) == 2) { args.AddParam("department", "", "true"); } else { args.AddParam("department", "", "false"); } if ((showcolumns & 8) == 8) { args.AddParam("facrank", "", "true"); } else { args.AddParam("facrank", "", "false"); } //Profiles.Search.Utilities.DataIO dropdowns = new Profiles.Search.Utilities.DataIO(); if (Convert.ToBoolean(ConfigurationSettings.AppSettings["ShowInstitutions"]) == true) { args.AddParam("ShowInstitutions", "", "true"); } else { args.AddParam("ShowInstitutions", "", "false"); } if (Convert.ToBoolean(ConfigurationSettings.AppSettings["ShowDepartments"]) == true) { args.AddParam("ShowDepartments", "", "true"); } else { args.AddParam("ShowDepartments", "", "false"); } //Faculty Rank always shows args.AddParam("ShowFacRank", "", "true"); args.AddParam("currentsort", "", sort); args.AddParam("currentsortdirection", "", sortdirection); if (base.BaseData.SelectNodes("rdf:RDF/rdf:Description/vivo:overview/SearchDetails/SearchPhraseList", base.Namespaces).Count > 0) { 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; } }
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; } }
private void DrawProfilesModule() { XsltArgumentList args = new XsltArgumentList(); string searchfor = string.Empty; string classgroupuri = string.Empty; string classuri = string.Empty; string searchrequest = string.Empty; string exactphrase = string.Empty; XmlDocument xmlsearchrequest; if (Request.QueryString["searchfor"] != null) { searchfor = Request.QueryString["searchfor"]; } else { searchfor = Request.Form["txtSearchFor"]; } if (Request.QueryString["classgroupuri"] != null) { 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 (Request.QueryString["classuri"] != null) { 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; } Search.Utilities.DataIO data = new Profiles.Search.Utilities.DataIO(); if (Request.QueryString["searchrequest"] != null) { searchrequest = Request.QueryString["searchrequest"]; if (searchfor == null) { xmlsearchrequest = new XmlDocument(); xmlsearchrequest.LoadXml(data.DecryptRequest(searchrequest)); searchfor = xmlsearchrequest.SelectSingleNode("SearchOptions/MatchOptions/SearchString").InnerText; } } if (Request.QueryString["exactphrase"] != null) { exactphrase = Request.QueryString["exactphrase"]; } else { exactphrase = "false"; } //Grab the full results so I can get the counts, this comes from the cache cloud. this.SearchResults = data.Search(data.SearchRequest(searchfor, exactphrase, "", "", "0", "100"), false); Int64 total = 0; foreach (XmlNode x in this.SearchResults.SelectNodes("rdf:RDF/rdf:Description/vivo:overview/prns:matchesClassGroupsList/prns:matchesClassGroup", this.Namespaces)) { total += Convert.ToInt64(x.SelectSingleNode("prns:numberOfConnections", this.Namespaces).InnerText); } args.AddParam("total", "", total); args.AddParam("searchfor", "", searchfor); args.AddParam("exactphrase", "", exactphrase); args.AddParam("root", "", Root.Domain); args.AddParam("classGrpURIpassedin", "", classgroupuri); args.AddParam("classURIpassedin", "", classuri); XslCompiledTransform xslt = new XslCompiledTransform(); litEverythingPassiveResults.Text = XslHelper.TransformInMemory(Server.MapPath("~/Search/Modules/SearchEverythingFacets/SearchEverythingFacets.xslt"), args, this.SearchResults.OuterXml); }
public void DrawProfilesModule() { DateTime d = DateTime.Now; //If your module performs a data request, based on the DataURI parameter then call ReLoadBaseData base.GetDataByURI(); XmlDocument document = new XmlDocument(); XsltArgumentList args = new XsltArgumentList(); bool networkexists = false; System.Text.StringBuilder documentdata = new System.Text.StringBuilder(); documentdata.Append("<PassiveList"); documentdata.Append(" InfoCaption=\""); documentdata.Append(base.GetModuleParamString("InfoCaption")); documentdata.Append("\""); documentdata.Append(" Description=\""); documentdata.Append(base.GetModuleParamString("Description")); documentdata.Append("\""); documentdata.Append(" ID=\""); documentdata.Append(Guid.NewGuid().ToString()); documentdata.Append("\""); documentdata.Append(" MoreText=\""); documentdata.Append(CustomParse.Parse(base.GetModuleParamString("MoreText"), base.BaseData, base.Namespaces)); documentdata.Append("\""); documentdata.Append(" MoreURL=\""); if (base.GetModuleParamString("MoreURL").Contains("&")) { documentdata.Append(Root.Domain + CustomParse.Parse(base.GetModuleParamString("MoreURL"), base.BaseData, base.Namespaces).Replace("&", "&")); } else { documentdata.Append(CustomParse.Parse(base.GetModuleParamString("MoreURL"), base.BaseData, base.Namespaces)); } documentdata.Append("\""); documentdata.Append(">"); documentdata.Append("<ItemList>"); string path = base.GetModuleParamString("ListNode"); //path = path.Substring(path.LastIndexOf("@rdf:about=") + 12); //path = path.Substring(0, path.Length - 1); try { XmlNodeList items = this.BaseData.SelectNodes(path, this.Namespaces); int remainingItems = Convert.ToInt16(base.GetModuleParamString("MaxDisplay")); foreach (XmlNode i in items) { if (remainingItems == 0) { break; } remainingItems--; XmlNode networknode = this.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about=\"" + i.Value + "\"]", this.Namespaces); string itemurl = CustomParse.Parse(base.GetModuleParamString("ItemURL"), networknode, this.Namespaces); string itemurltext = CustomParse.Parse(base.GetModuleParamString("ItemURLText"), networknode, this.Namespaces); string item = CustomParse.Parse(base.GetModuleParamString("ItemText"), networknode, this.Namespaces); networkexists = true; documentdata.Append("<Item"); if (base.GetModuleParamString("ItemURL") != string.Empty) { documentdata.Append(" ItemURL=\"" + itemurl); documentdata.Append("\""); if (!itemurltext.Equals("")) { documentdata.Append(" ItemURLText=\"" + itemurltext); } else { documentdata.Append(" ItemURLText=\"" + CustomParse.Parse("{{{//rdf:Description[@rdf:about='" + itemurl + "']/rdfs:label}}}", this.BaseData, this.Namespaces)); } documentdata.Append("\""); } documentdata.Append(">"); documentdata.Append(item); documentdata.Append("</Item>"); } } catch (Exception ex) { Framework.Utilities.DebugLogging.Log(ex.Message + " ++ " + ex.StackTrace); } /* * try * { * var items = from XmlNode networknode in this.BaseData.SelectNodes(base.GetModuleParamString("ListNode") + "[position() < " + Math.BigMul((Convert.ToInt16(base.GetModuleParamString("MaxDisplay")) + 1), 1).ToString() + "]", this.Namespaces) * select new * { * itemurl = CustomParse.Parse(base.GetModuleParamString("ItemURL"), networknode, this.Namespaces), * itemurltext = CustomParse.Parse(base.GetModuleParamString("ItemURLText"), networknode, this.Namespaces), * item = CustomParse.Parse(base.GetModuleParamString("ItemText"), networknode, this.Namespaces) * }; * * foreach (var i in items) * { * networkexists = true; * * documentdata.Append("<Item"); * * if (base.GetModuleParamString("ItemURL") != string.Empty) * { * documentdata.Append(" ItemURL=\"" + i.itemurl); * documentdata.Append("\""); * if (!i.itemurltext.Equals("")) documentdata.Append(" ItemURLText=\"" + i.itemurltext); * else documentdata.Append(" ItemURLText=\"" + CustomParse.Parse("{{{//rdf:Description[@rdf:about='"+ i.itemurl + "']/rdfs:label}}}", this.BaseData, this.Namespaces)); * documentdata.Append("\""); * } * documentdata.Append(">"); * documentdata.Append(i.item); * documentdata.Append("</Item>"); * } * * } * catch (Exception ex) { Framework.Utilities.DebugLogging.Log(ex.Message + " ++ " + ex.StackTrace); } */ documentdata.Append("</ItemList>"); documentdata.Append("</PassiveList>"); if (networkexists) { document.LoadXml(documentdata.ToString()); args.AddParam("root", "", Root.Domain); args.AddParam("ListNode", "", base.GetModuleParamString("ListNode")); args.AddParam("InfoCaption", "", base.GetModuleParamString("InfoCaption")); args.AddParam("Description", "", base.GetModuleParamString("Description")); args.AddParam("MoreUrl", "", base.GetModuleParamString("ListNode")); litPassiveNetworkList.Text = XslHelper.TransformInMemory(Server.MapPath("~/Profile/Modules/PassiveList/PassiveList.xslt"), args, document.OuterXml); Framework.Utilities.DebugLogging.Log("PASSIVE MODULE end Milliseconds:" + (DateTime.Now - d).TotalSeconds); } }