Beispiel #1
0
        /// <summary>
        /// 初始化注册要显示Tab项模型
        /// </summary>
        /// <param name="context"></param>
        private void Initialize(HttpContext context)
        {
            try
            {
                showdialog = new ShowdialogModel(context);
                ModelID = showdialog.ID;
                if (ShowdialogModelStore.Instance.TryAdd(showdialog, context))
                {
                    //注册Configuration
                    // ConfigurationModel config = new ConfigurationModel(ConfigurationKey, "Configuration", 2);
                    // showdialog.Models.Add(ConfigurationKey, config);

                    ////注册Trace
                    //TraceModel trace = new TraceModel(TraceKey, "Trace", 0);
                    //showdialog.Models.Add(TraceKey, trace);

                    //注册Cache
                    //  CacheModel cache = new CacheModel(CacheKey, "Cache", 3);
                    //showdialog.Models.Add(CacheKey, cache);

                    //注册Environment
                    //EnvironmentModel env = new EnvironmentModel(EnvironmentKey, "Environment", 1);
                    //showdialog.Models.Add(EnvironmentKey, env);

                    //注册Session
                    // SessionModel session = new SessionModel(SessionKey, "Session", context, 5);
                    //  showdialog.Models.Add(SessionKey, session);

                    //注册SQL
                    // SQLModel sql = new SQLModel(SQLKey, "SQL", 6);
                    // showdialog.Models.Add(SQLKey, sql);

                    //注册Request
                    // RequestModel rquestModel = new RequestModel(RequestKey, "Request", context, 4);
                    // showdialog.Models.Add(RequestKey, rquestModel);

                    //注册Navigation
                    NavigationModel navigationModel = new NavigationModel(NavigationKey, "Navigation", 7);
                    showdialog.Models.Add(NavigationKey, navigationModel);
                    string applicationPath = context.Request.ApplicationPath.TrimEnd('/');
                  //  context.Response.Filter = new PreBodyTagFilter(string.Format(outPutString, applicationPath, showdialog.RequestId, DateTime.Now.Ticks), context.Response.Filter, context.Response.ContentEncoding, context);

                    context.Response.Filter = new ResposeFilter(string.Format(outPutString, applicationPath, showdialog.RequestId, DateTime.Now.Ticks), context.Response.Filter,  context);
                
                }
            }
            catch
            { }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public bool TryAdd(ShowdialogModel mode, HttpContext context)
        {
            bool result = false;
            if (models.Count < capacity)
            {
                try
                {
                    lock (synObject)
                    {
                        if (models.Keys.Contains(mode.RequestId))
                        {
                            models[mode.RequestId] = mode;
                        }
                        else
                        {
                            models.Add(mode.RequestId, mode);
                        }
                        context.Items.Add(requestKey, mode.RequestId);
                        result = true;
                    }
                }
                catch
                { }
            }

            if (DateTime.Now.Subtract(clearTime).TotalSeconds < 2)
            {
                new Action(() =>
                {
                    Clear();
                }).BeginInvoke(null, null);

                clearTime = DateTime.Now;
            }

            return result;
        }
        public bool TryGet(string requestid, out ShowdialogModel mode)
        {
            bool result = false;
            lock (synObject)
            {
                result = models.TryGetValue(requestid, out mode);
            }

            return result;
        }
 public bool TryGet(out ShowdialogModel mode, HttpContext context)
 {
     string key = GetRequestID(context);
     return models.TryGetValue(key, out mode);
 }