Пример #1
0
        /// <summary>
        /// Creates the portal path.
        /// </summary>
        /// <param name="portalPath">
        /// The portal path.
        /// </param>
        public void CreatePortalPath(string portalPath)
        {
            portalPath = portalPath.Replace("/", string.Empty);
            portalPath = portalPath.Replace("\\", string.Empty);
            portalPath = portalPath.Replace(".", string.Empty);

            if (!portalPath.StartsWith("_"))
            {
                portalPath = "_" + portalPath;
            }

            // jes1111
            // string pd = ConfigurationSettings.AppSettings[strPortalsDirectory];
            // if(pd!=null)
            // {
            // if (portalPath.IndexOf (pd) > -1)
            // portalPath = portalPath.Substring(portalPath.IndexOf (pd) + pd.Length);
            // }
            var pd = Config.PortalsDirectory;

            if (portalPath.IndexOf(pd) > -1)
            {
                portalPath = portalPath.Substring(portalPath.IndexOf(pd) + pd.Length);
            }

            // jes1111 - string portalPhisicalDir = HttpContext.Current.Server.MapPath(Path.ApplicationRoot + "/" + ConfigurationSettings.AppSettings[strPortalsDirectory] + "/" + portalPath);
            var portalPhisicalDir =
                HttpContext.Current.Server.MapPath(
                    Path.WebPathCombine(Path.ApplicationRoot, Config.PortalsDirectory, portalPath));

            if (!Directory.Exists(portalPhisicalDir))
            {
                Directory.CreateDirectory(portalPhisicalDir);
            }

            // Subdirs
            string[] subdirs = { "images", "polls", "documents", "xml" };

            for (var i = 0; i <= subdirs.GetUpperBound(0); i++)
            {
                if (!Directory.Exists(portalPhisicalDir + "\\" + subdirs[i]))
                {
                    Directory.CreateDirectory(portalPhisicalDir + "\\" + subdirs[i]);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the image menu.
        /// </summary>
        /// <returns>
        /// A System.Collections.Hashtable value...
        /// </returns>
        private Hashtable GetImageMenu()
        {
            Hashtable imageMenuFiles;

            if (!CurrentCache.Exists(Key.ImageMenuList(this.PortalSettings.CurrentLayout)))
            {
                imageMenuFiles = new Hashtable {
                    { General.GetString("PAGESETTINGS_SITEDEFAULT", "(Site Default)"), string.Empty }
                };
                var layoutManager = new LayoutManager(this.PortalPath);

                var menuDirectory = Path.WebPathCombine(
                    layoutManager.PortalLayoutPath, this.PortalSettings.CurrentLayout);
                if (Directory.Exists(menuDirectory))
                {
                    menuDirectory = Path.WebPathCombine(menuDirectory, "menuimages");
                }
                else
                {
                    menuDirectory = Path.WebPathCombine(
                        LayoutManager.Path, this.PortalSettings.CurrentLayout, "menuimages");
                }

                if (Directory.Exists(menuDirectory))
                {
                    var menuImages = (new DirectoryInfo(menuDirectory)).GetFiles("*.gif");

                    foreach (var fi in menuImages.Where(fi => fi.Name != "spacer.gif" && fi.Name != "icon_arrow.gif"))
                    {
                        imageMenuFiles.Add(fi.Name, fi.Name);
                    }
                }

                CurrentCache.Insert(Key.ImageMenuList(this.PortalSettings.CurrentLayout), imageMenuFiles, null);
            }
            else
            {
                imageMenuFiles = (Hashtable)CurrentCache.Get(Key.ImageMenuList(this.PortalSettings.CurrentLayout));
            }

            return(imageMenuFiles);
        }
Пример #3
0
        /// <summary>
        /// Gets the magic URL list.
        /// </summary>
        /// <param name="portalId">
        /// The portal ID.
        /// </param>
        /// <returns>
        /// </returns>
        /// <remarks>
        /// </remarks>
        private Hashtable GetMagicUrlList(string portalId)
        {
            var result = new Hashtable();

            if (this.Cache["Appleseed_MagicUrlList_" + Portal.UniqueID] == null)
            {
                var myPath =
                    this.Server.MapPath(
                        Path.WebPathCombine(this.PortalSettings.PortalFullPath, "MagicUrl/MagicUrlList.xml"));
                if (File.Exists(myPath))
                {
                    var xmlDoc = new XmlDocument();
                    if (myPath != null)
                    {
                        xmlDoc.Load(myPath);
                    }
                    var xnl = xmlDoc.SelectNodes("/MagicUrlList/MagicUrl");
                    if (xnl != null)
                    {
                        foreach (XmlNode node in xnl)
                        {
                            try
                            {
                                result.Add(
                                    node.Attributes["key"].Value, HttpUtility.HtmlDecode(node.Attributes["value"].Value));
                            }
                            catch
                            {
                            }
                        }
                    }

                    this.Cache.Insert("Appleseed_MagicUrlList_" + Portal.UniqueID, result, new CacheDependency(myPath));
                }
            }
            else
            {
                result = (Hashtable)this.Cache["Appleseed_MagicUrlList_" + Portal.UniqueID];
            }

            return(result);
        }
Пример #4
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">
        /// The <see cref="T:System.EventArgs"/> object that contains the event data.
        /// </param>
        /// <remarks>
        /// The Page_Load event handler on this User Control obtains
        ///   an xml document and xsl/t transform file location.
        ///   It then sets these properties on an &lt;asp:Xml&gt; server control.
        ///   Patch 11/11/2003 by Manu: Errors are logged.
        /// </remarks>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            var xmlsrcType = this.Settings["XML Type"].ToString();
            var xmlsrc     = xmlsrcType == "File"
                             ? this.Settings["XML File"].ToString()
                             : this.Settings["XML URL"].ToString();

            var xslsrcType = this.Settings["XSL Type"].ToString();
            var xslsrc     = xslsrcType == "File"
                             ? this.Settings["XSL File"].ToString()
                             : this.Settings["XSL Predefined"].ToString();

            // Timeout
            var timeout = int.Parse(this.Settings["Timeout"].ToString());

            if (xmlsrc.Length != 0)
            {
                if (xmlsrcType == "File")
                {
                    var pathXml = new PortalUrlDataType {
                        Value = xmlsrc
                    };
                    xmlsrc = pathXml.FullPath;

                    if (File.Exists(this.Server.MapPath(xmlsrc)))
                    {
                        this.xml1.DocumentSource = xmlsrc;
                    }
                    else
                    {
                        this.Controls.Add(
                            new LiteralControl(
                                string.Format("<br /><div class='error'>File {0} not found.<br /></div>", xmlsrc)));
                    }
                }
                else
                {
                    try
                    {
                        ErrorHandler.Publish(
                            LogLevel.Warn,
                            string.Format("XMLFeed - This should not done more than once in 30 minutes: '{0}'", xmlsrc));

                        // handle on the remote resource
                        var wr = (HttpWebRequest)WebRequest.Create(xmlsrc);

                        // jes1111 - not needed: global proxy is set in Global class Application Start
                        // if (ConfigurationSettings.AppSettings.Get("UseProxyServerForServerWebRequests") == "true")
                        // wr.Proxy = PortalSettings.GetProxy();

                        // set the HTTP properties
                        wr.Timeout = timeout * 1000; // milliseconds to seconds

                        // Read the response
                        var resp = wr.GetResponse();

                        // Stream read the response
                        var stream = resp.GetResponseStream();
                        if (stream != null)
                        {
                            // Read XML data from the stream
                            // ignore the DTD (resolver null)
                            var reader = new XmlTextReader(stream)
                            {
                                XmlResolver = null
                            };

                            // Create a new document object
                            var doc = new XmlDocument();

                            // Create the content of the XML Document from the XML data stream
                            doc.Load(reader);

                            // the XML control to hold the generated XML document
                            this.xml1.Document = doc;
                        }
                    }
                    catch (Exception ex)
                    {
                        // connectivity issues
                        this.Controls.Add(
                            new LiteralControl(
                                string.Format(
                                    "<br /><div class='error'>Error loading: {0}.<br />{1}</div>", xmlsrc, ex.Message)));
                        ErrorHandler.Publish(LogLevel.Error, string.Format("Error loading: {0}.", xmlsrc), ex);
                    }
                }
            }

            if (xslsrcType == "File")
            {
                var pathXsl = new PortalUrlDataType {
                    Value = xslsrc
                };
                xslsrc = pathXsl.FullPath;
            }
            else
            {
                // if (ConfigurationSettings.AppSettings.Get("XMLFeedXSLFolder") != null)
                // {
                // if (ConfigurationSettings.AppSettings.Get("XMLFeedXSLFolder").ToString().Length > 0)
                //     xslsrc = ConfigurationSettings.AppSettings.Get("XMLFeedXSLFolder").ToString() + xslsrc;
                // else
                //     xslsrc = "~/DesktopModules/CommunityModules/XmlFeed/" + xslsrc;
                // }
                // else
                // {
                //     xslsrc = "~/DesktopModules/CommunityModules/XmlFeed/" + xslsrc;
                // }
                xslsrc =
                    Path.WebPathCombine(
                        Config.XMLFeedXSLFolder.Length == 0 ? this.TemplateSourceDirectory : Config.XMLFeedXSLFolder,
                        xslsrc);

                if (!xslsrc.EndsWith(".xslt"))
                {
                    xslsrc += ".xslt";
                }
            }

            if (!string.IsNullOrEmpty(xslsrc))
            {
                if (File.Exists(this.Server.MapPath(xslsrc)))
                {
                    this.xml1.TransformSource = xslsrc;
                }
                else
                {
                    this.Controls.Add(
                        new LiteralControl(
                            string.Format("<br /><div class='error'>File {0} not found.<br /></div>", xslsrc)));
                }
            }
        }