/// <summary> /// Geeft aan of het pad Door NetWriter uit de database opgehaald kan worden. /// </summary> /// <param name="virtualPath"></param> /// <returns></returns> private bool isPathVirtual(string virtualPath) { // om de performance te verbeteren wordt maar ייn keer in de database gekeken of een pad van ons is. // statische of andere bestanden belemmeren de performance zo niet. bool pathIsVirtual = false; // standaard van iemand anders if (oUrls.ContainsKey(virtualPath)) { // al een keertje gecheckt blijkbaar pathIsVirtual = (bool)oUrls[virtualPath]; } else { try { //is het een afbeelding uit de binary tabel?? string[] sBinFolders = ConfigurationManager.AppSettings["ObjectBinaryFolder"].ToString().Split(','); foreach (string sBinFolder in sBinFolders) { if (virtualPath.Contains(sBinFolder)) { //ja, kijken of we hem kunnen vinden, zo ja toevoegen aan hashtable NwPublishedObjectBinary oBinary = new NwPublishedObjectBinary("MSSql", this.ConnectionString); string sBinaryURL = sBinFolder + virtualPath.Substring(virtualPath.IndexOf(sBinFolder) - 1 + sBinFolder.Length + 1); oBinary.GetNwPublishedObjectBinaryByNwPublishedObjectBinaryUrlItemOnline(sBinaryURL, true); oUrls.Add(virtualPath, true); pathIsVirtual = true; break; } } if (pathIsVirtual == false) // nog niet gevonden als binary folder { //is het een gepubliceerde pagina? NwPublishedContent oContent = new NwPublishedContent("MSSql", this.ConnectionString); //string sUrl = virtualPath.Replace(ConfigurationManager.AppSettings["TranslatePathFrom"].ToString(), ConfigurationManager.AppSettings["TranslatePathTo"].ToString()); string sUrl = virtualPath.ToLower(); if (ConfigurationManager.AppSettings["TranslatePathFrom"].ToString() == "/") { sUrl = ConfigurationManager.AppSettings["TranslatePathTo"].ToString() + sUrl.Replace("/default.aspx", ""); } else { sUrl = sUrl.Replace(ConfigurationManager.AppSettings["TranslatePathFrom"].ToString(), ConfigurationManager.AppSettings["TranslatePathTo"].ToString()).Replace("/default.aspx", ""); } if (sUrl.Substring(sUrl.Length - 1, 1) == "/") { sUrl = sUrl.Substring(0, sUrl.Length - 1); } if (sUrl.EndsWith("generated_css_site_xml.css")) { sUrl = sUrl.Substring(0, sUrl.LastIndexOf("generated_css_site_xml.css") - 1); // to string mag binnenkort weg oContent.GetNwPublishedContentByNwPublishedContentIsPageNwPublishedContentUrlNwPublishedXsltIdItemOnline(true, sUrl, this.CssXsltId.ToString(), true); } else { if (sUrl.EndsWith("mapindex.aspx")) { sUrl = sUrl.Substring(0, sUrl.LastIndexOf("mapindex.aspx") - 1); // to string mag binnenkort weg oContent.GetNwPublishedContentByNwPublishedContentIsPageNwPublishedContentUrlNwPublishedXsltIdItemOnline(true, sUrl, this.MapXsltId.ToString(), true); } else { // to string mag binnenkort weg oContent.GetNwPublishedContentByNwPublishedContentIsPageNwPublishedContentUrlNwPublishedXsltIdItemOnline(true, sUrl, this.XsltId.ToString(), true); } } oUrls.Add(virtualPath, true); pathIsVirtual = true; } } catch (Exception ex) { //ai, we kennen hem niet, dan snel markeren als zijnde van iemand anders. //dat scheelt weer een aantal maal fouten afvangen.... oUrls.Add(virtualPath, false); } } return pathIsVirtual; }
public override System.IO.Stream Open() { string sContent = ""; try { string[] sBinFolders = ConfigurationManager.AppSettings["ObjectBinaryFolder"].ToString().Split(','); // binary folders doorlopen foreach (string sBinFolder in sBinFolders) { if (_virtualPath.Contains(sBinFolder)) { //binary ophalen en terug geven NwPublishedObjectBinary oBinary = new NwPublishedObjectBinary("MSSql", this._sConn); string sBinaryURL = sBinFolder + _virtualPath.Substring(_virtualPath.IndexOf(sBinFolder) - 1 + sBinFolder.Length + 1); oBinary.GetNwPublishedObjectBinaryByNwPublishedObjectBinaryUrlItemOnline(sBinaryURL, true); return new System.IO.MemoryStream(oBinary.NwPublishedObjectBinary); } } //is het een pagina? Content ophalen en terug geven. NwPublishedContent oContent = new NwPublishedContent("MSSql", _sConn); //string sUrl = _virtualPath.ToLower().Replace(ConfigurationManager.AppSettings["TranslatePathFrom"].ToString(), ConfigurationManager.AppSettings["TranslatePathTo"].ToString()).Replace("/default.aspx", ""); string sUrl = _virtualPath.ToLower(); if (ConfigurationManager.AppSettings["TranslatePathFrom"].ToString() == "/") { sUrl = ConfigurationManager.AppSettings["TranslatePathTo"].ToString() + sUrl.Replace("/default.aspx", ""); } else { sUrl = sUrl.Replace(ConfigurationManager.AppSettings["TranslatePathFrom"].ToString(), ConfigurationManager.AppSettings["TranslatePathTo"].ToString()).Replace("/default.aspx", ""); } if (sUrl.Substring(sUrl.Length - 1, 1) == "/") { sUrl = sUrl.Substring(0, sUrl.Length - 1); } // to string mag binnenkort weg if (sUrl.EndsWith("mapindex.aspx")) { sUrl = sUrl.Substring(0, sUrl.LastIndexOf("mapindex.aspx") - 1); // to string mag binnenkort weg oContent.GetNwPublishedContentByNwPublishedContentIsPageNwPublishedContentUrlNwPublishedXsltIdItemOnline(true, sUrl, _MapXsltId.ToString(), true); } else { // to string mag binnenkort weg oContent.GetNwPublishedContentByNwPublishedContentIsPageNwPublishedContentUrlNwPublishedXsltIdItemOnline(true, sUrl, _XsltId.ToString(), true); } sContent = oContent.NwPublishedContent; return new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(sContent)); } catch (Exception ex) { // fout, dan maar fout teruggeven return new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(ex.Message)); } }
private DataTable UpdateUrlsAndTitles(DataTable dat) { // dit stuk mag er uit is overbodig er staat gewoon een label in de database!!!! foreach (DataRow row in dat.Rows) { string url = row["content_url"].ToString(); string Label="Titel onbekend"; try { NwPublishedContent oContent = new NwPublishedContent("MSSql", ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString); oContent.GetNwPublishedContentByNwPublishedContentIsPageNwPublishedContentUrlNwPublishedXsltIdItemOnline(true, url, XsltId.ToString(), true); Label = oContent.NwPublishedContent.Substring(oContent.NwPublishedContent.IndexOf("Title=\"") + 7, oContent.NwPublishedContent.IndexOf("\"", oContent.NwPublishedContent.IndexOf("Title=\"") + 9) - oContent.NwPublishedContent.IndexOf("Title=\"") - 7).Replace(RootTitle, ""); ; } catch { } row["naam"] = Label; if (Request.QueryString.ToString().ToLower().IndexOf("netwritergui") > -1) { url = String.Format("/NetwriterGui/publication/cms.aspx?ObjectId={0}&ObjectTypeId={1}", 0, 0); } else { //add "/" so the helicon can put default.aspx behind the url if (ConfigurationManager.AppSettings["TranslatePathFrom"].ToString() != "/") { url = url.Replace(ConfigurationManager.AppSettings["TranslatePathTo"].ToString(), ConfigurationManager.AppSettings["TranslatePathFrom"].ToString()) + "/"; } else { url = url.Replace(ConfigurationManager.AppSettings["TranslatePathTo"].ToString(), "") + "/"; } } row["content_url"] = url; row.AcceptChanges(); } return dat; }