Example #1
0
 /**/
 /*CsContextS���ݴ���ָ���������ݲ���*/
 private static void SaveContextToStore(CSContext context)
 {
     if(context.IsWebRequest)
     {
         context.Context.Items[dataKey] = context;
     }
     else
     {
         Thread.SetData(GetSlot(), context);
     }
 }
Example #2
0
 private static void SaveContextToStore(LocalDataStoreSlot storeSlot, CSContext context)
 {
     Thread.SetData(storeSlot, context);
 }
Example #3
0
 /// <summary>
 /// Creates a Context instance based. If the HttpContext is available it will be used.
 /// Generally this method should be used when working with CS outside of a valid Web Request
 /// </summary>
 public static CSContext Create(Uri uri, string appName)
 {
     CSContext csContext = new CSContext(uri,appName);
     SaveContextToStore(GetSlot(),csContext);
     return csContext;
 }
Example #4
0
        /// <summary>
        /// Creates a Context instance based on HttpContext. Generally, this
        /// method should be called via Begin_Request in an HttpModule
        /// </summary>
        public static CSContext Create(HttpContext context, bool isReWritten)
        {
            CSContext csContext = new CSContext(context);
            csContext.IsUrlReWritten = isReWritten;
            SaveContextToStore(GetSlot(),csContext);

            return csContext;
        }
Example #5
0
File: Roles.cs Project: pcstx/OA
        public static Hashtable GetRoles(CSContext csContext, int userID, bool cacheable, bool flush)
        {
            Hashtable roles;
            string cacheKey = string.Format("Roles:User:{0}:Site:{1}", userID, CSContext.Current.SiteSettings.SettingsID);

            #if DEBUG_NOCACHE
            cacheable = false;
            #endif

            if(flush)
            {
                CSCache.Remove(cacheKey);
                csContext.Items.Remove(cacheKey);
            }

            // See if this has already been requested
            roles = csContext.Items[cacheKey] as Hashtable;
            if(roles != null)
                return roles;

            // Ensure it's not in the cache
            if(!cacheable)
                CSCache.Remove(cacheKey);

            // Have we already fetched for this request?
            roles = CSCache.Get(cacheKey) as Hashtable;

            // Get the roles if it is not in the cache
            if(roles == null)
            {
                roles = CommonDataProvider.Instance().GetRoles(userID);

                // Cache if we can
                if (cacheable) {
                    CSCache.Insert(cacheKey, roles, 30 * CSCache.MinuteFactor, CacheItemPriority.Normal);
                }
            }

            // Insert into request cache
            csContext.Items.Add(cacheKey, roles);

            return roles;
        }
Example #6
0
        private void ValidateApplicationStatus(CSContext cntx)
        {
            if (!cntx.User.IsAdministrator)
            {
                string disablePath = null;
                switch (cntx.Config.AppLocation.CurrentApplicationType)
                {
                    case ApplicationType.Forum:
                        if (cntx.SiteSettings.ForumsDisabled)
                            disablePath = "ForumsDisabled.htm";
                        break;
                    case ApplicationType.Weblog:
                        if (cntx.SiteSettings.BlogsDisabled)
                            disablePath = "BlogsDisabled.htm";
                        break;
                    case ApplicationType.Gallery:
                        if (cntx.SiteSettings.GalleriesDisabled)
                            disablePath = "GalleriesDisabled.htm";
                        break;
                    case ApplicationType.GuestBook:
                        if (cntx.SiteSettings.GuestBookDisabled)
                            disablePath = "GuestBookDisabled.htm";
                        break;
                }

                if (disablePath != null)
                {

                    string errorpath = cntx.Context.Server.MapPath(string.Format("~/Languages/{0}/errors/{1}", cntx.Config.DefaultLanguage, disablePath));
                    using (StreamReader reader = new StreamReader(errorpath))
                    {
                        string html = reader.ReadToEnd();
                        reader.Close();

                        cntx.Context.Response.Write(html);
                        cntx.Context.Response.End();
                    }
                }
            }
        }