コード例 #1
0
        /// <summary>
        /// The Render method is called when the ASP.NET Page Framework
        /// determines that it is time to render content into the page output stream.
        /// This method and captures the output generated by the portal module user control
        /// It then adds this content into the ASP.NET Cache for future requests.
        /// </summary>
        /// <remarks>
        /// </remarks>
        protected override void Render(HtmlTextWriter output)
        {
            if (_moduleConfiguration != null)
            {
                // If no caching is specified or in admin mode, render the child tree and return
                if (_moduleConfiguration.CacheTime == 0 | PortalSecurity.HasEditPermissions(_moduleConfiguration.ModulePermissions))
                {
                    base.Render(output);
                }
                else //output caching enabled
                {
                    // If no cached output was found from a previous request, render
                    // child controls into a TextWriter, and then cache the results
                    if (_cachedOutput == "")
                    {
                        StringWriter tempWriter = new StringWriter();
                        base.Render(new HtmlTextWriter(tempWriter));
                        _cachedOutput = tempWriter.ToString();

                        if (CacheMethod != "D")
                        {
                            DataCache.SetCache(CacheKey, _cachedOutput, DateTime.Now.AddSeconds(_moduleConfiguration.CacheTime));
                        }
                        else // cache to disk
                        {
                            try
                            {
                                if (!Directory.Exists(CacheDirectory))
                                {
                                    Directory.CreateDirectory(CacheDirectory);
                                }

                                StreamWriter objStream;
                                objStream = File.CreateText(CacheFileName);
                                objStream.WriteLine(_cachedOutput);
                                objStream.Close();
                            }
                            catch
                            {
                                // error writing to disk
                            }
                        }
                    }

                    // Output the user control's content
                    output.Write(_cachedOutput);
                }
            }
            else
            {
                base.Render(output);
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the properties
        /// </summary>
        /// <history>
        ///     [cnurse]	02/23/2006	created
        /// </history>
        private ProfilePropertyDefinitionCollection GetProperties()
        {
            string strKey = ProfileController.PROPERTIES_CACHEKEY + "." + UsersPortalId;

            if (m_objProperties == null)
            {
                m_objProperties = (ProfilePropertyDefinitionCollection)DataCache.GetCache(strKey);
                if (m_objProperties == null)
                {
                    m_objProperties = ProfileController.GetPropertyDefinitionsByPortal(UsersPortalId);
                    DataCache.SetCache(strKey, m_objProperties);
                }
            }
            return(m_objProperties);
        }
コード例 #3
0
        private void ManageFavicon()
        {
            string strFavicon = Convert.ToString(DataCache.GetCache("FAVICON" + PortalSettings.PortalId));

            if (strFavicon == "")
            {
                if (File.Exists(PortalSettings.HomeDirectoryMapPath + "favicon.ico"))
                {
                    strFavicon = PortalSettings.HomeDirectory + "favicon.ico";
                    if (Globals.PerformanceSetting != Globals.PerformanceSettings.NoCaching)
                    {
                        DataCache.SetCache("FAVICON" + PortalSettings.PortalId, strFavicon);
                    }
                }
            }
            if (!String.IsNullOrEmpty(strFavicon))
            {
                HtmlLink objLink = new HtmlLink();
                objLink.Attributes["rel"]  = "SHORTCUT ICON";
                objLink.Attributes["href"] = strFavicon;

                Page.Header.Controls.Add(objLink);
            }
        }
コード例 #4
0
        private void ManageStyleSheets(bool PortalCSS)
        {
            // initialize reference paths to load the cascading style sheets
            string id;

            Hashtable objCSSCache = (Hashtable)DataCache.GetCache("CSS");

            if (objCSSCache == null)
            {
                objCSSCache = new Hashtable();
            }

            if (PortalCSS == false)
            {
                // default style sheet ( required )
                id = Globals.CreateValidID(Globals.HostPath);
                AddStyleSheet(id, Globals.HostPath + "default.css");

                // skin package style sheet
                id = Globals.CreateValidID(PortalSettings.ActiveTab.SkinPath);
                if (objCSSCache.ContainsKey(id) == false)
                {
                    if (File.Exists(Server.MapPath(PortalSettings.ActiveTab.SkinPath) + "skin.css"))
                    {
                        objCSSCache[id] = PortalSettings.ActiveTab.SkinPath + "skin.css";
                    }
                    else
                    {
                        objCSSCache[id] = "";
                    }
                    if (Globals.PerformanceSetting != Globals.PerformanceSettings.NoCaching)
                    {
                        DataCache.SetCache("CSS", objCSSCache);
                    }
                }
                if (objCSSCache[id].ToString() != "")
                {
                    AddStyleSheet(id, objCSSCache[id].ToString());
                }

                // skin file style sheet
                id = Globals.CreateValidID(PortalSettings.ActiveTab.SkinSrc.Replace(".ascx", ".css"));
                if (objCSSCache.ContainsKey(id) == false)
                {
                    if (File.Exists(Server.MapPath(PortalSettings.ActiveTab.SkinSrc.Replace(".ascx", ".css"))))
                    {
                        objCSSCache[id] = PortalSettings.ActiveTab.SkinSrc.Replace(".ascx", ".css");
                    }
                    else
                    {
                        objCSSCache[id] = "";
                    }
                    if (Globals.PerformanceSetting != Globals.PerformanceSettings.NoCaching)
                    {
                        DataCache.SetCache("CSS", objCSSCache);
                    }
                }
                if (objCSSCache[id].ToString() != "")
                {
                    AddStyleSheet(id, objCSSCache[id].ToString());
                }
            }
            else
            {
                // portal style sheet
                id = Globals.CreateValidID(PortalSettings.HomeDirectory);
                AddStyleSheet(id, PortalSettings.HomeDirectory + "portal.css");
            }
        }