Пример #1
0
        public void Search()
        {
            target(Search);

            String addr = ctx.Post("webAddress");

            if (strUtil.IsNullOrEmpty(addr) || addr.StartsWith("http:") == false)
            {
                set("dirAndFiles", "");
                return;
            }

            IWebContext webContext = MockWebContext.New(ctx.viewer.Id, addr, new StringWriter());

            AdminSecurityUtils.SetSession(webContext);
            try {
                new CoreHandler().ProcessRequest(webContext);
            }
            catch (Exception ex) {
                set("dirAndFiles", "<div class=\"warning\">" + lang("exSearchViews") + "</div><div style=\"border:1px #f2f2f2 solid; margin-top:10px; padding:10px;display:none;\">" + ex.ToString().Replace(Environment.NewLine, "<br/>") + "</div>");
                return;
            }

            List <string> list = CurrentRequest.getItem(Template.loadedTemplates) as List <string>;

            bindResults(list);
        }
Пример #2
0
        /// <summary>
        /// 将所有日志即可写入磁盘
        /// </summary>
        internal static void Flush()
        {
            StringBuilder sb = CurrentRequest.getItem("currentLogList") as StringBuilder;

            if (sb != null)
            {
                writeContentToFile(sb.ToString());
            }
        }
Пример #3
0
        private static bool shouldTransaction()
        {
            Object trans = CurrentRequest.getItem(_beginTransactionAll);

            if (trans == null)
            {
                return(false);
            }
            return((Boolean)trans);
        }
Пример #4
0
        /// <summary>
        /// 将所有日志即可写入磁盘
        /// </summary>
        internal static void Flush()
        {
            StringBuilder sb = CurrentRequest.getItem(_contextLogItem) as StringBuilder;

            if (sb != null)
            {
                writeContentToFile(sb.ToString());
                CurrentRequest.setItem(_contextLogItem, null);
            }
        }
Пример #5
0
        /// <summary>
        /// 获取存储在上下文中的 sql 执行次数
        /// </summary>
        /// <returns></returns>
        public static int getSqlCount()
        {
            Object count = CurrentRequest.getItem(SqlCountLabel);

            if (count == null)
            {
                return(0);
            }
            return(cvt.ToInt(count));
        }
Пример #6
0
        internal static IDictionary getContextCache()
        {
            Object dic = CurrentRequest.getItem(_contextCacheKey);

            if (dic == null)
            {
                dic = new Hashtable();
                CurrentRequest.setItem(_contextCacheKey, dic);
            }
            return(dic as IDictionary);
        }
Пример #7
0
 /// <summary>
 /// 在 web 系统中,记录 sql 执行的次数
 /// </summary>
 public static void LogSqlCount()
 {
     if (CurrentRequest.getItem("sqlcount") == null)
     {
         CurrentRequest.setItem("sqlcount", 1);
     }
     else
     {
         CurrentRequest.setItem("sqlcount", ((int)CurrentRequest.getItem("sqlcount")) + 1);
     }
 }
Пример #8
0
        private static IEntity getNullUser( int realUserId ) {

            IUserFactory userFactory = CurrentRequest.getItem( "_user_factory" ) as IUserFactory;
            if (userFactory == null) return null;
            IEntity user = userFactory.NullUser() as IEntity;
            if (user != null) {
                user.set( "RealId", realUserId );
            }
            return user;

        }
Пример #9
0
            private bool isCollapse(Page x)
            {
                Object obj = CurrentRequest.getItem("__currentPageParentId");

                if (obj != null && (int)obj == x.Id)
                {
                    return(false);
                }

                return(x.IsCollapse == 1);
            }
Пример #10
0
        private static void clearTransactionAll()
        {
            Dictionary <String, IDbTransaction> dic = CurrentRequest.getItem(_transactionKey) as Dictionary <String, IDbTransaction>;

            if (dic == null)
            {
                return;
            }
            dic.Clear();
            CurrentRequest.setItem(_transactionKey, dic);
        }
Пример #11
0
 /// <summary>
 /// 在 web 系统中,记录 sql 执行的次数
 /// </summary>
 public static void LogSqlCount()
 {
     if (CurrentRequest.getItem(getSqlCountLabel()) == null)
     {
         CurrentRequest.setItem(getSqlCountLabel(), 1);
     }
     else
     {
         CurrentRequest.setItem(getSqlCountLabel(), ((int)CurrentRequest.getItem(getSqlCountLabel())) + 1);
     }
 }
Пример #12
0
        private static Dictionary <String, IDbTransaction> getTransactionAll()
        {
            Dictionary <String, IDbTransaction> dic;

            dic = CurrentRequest.getItem(_transactionKey) as Dictionary <String, IDbTransaction>;
            if (dic == null)
            {
                dic = new Dictionary <String, IDbTransaction>();
                CurrentRequest.setItem(_transactionKey, dic);
            }
            return(dic);
        }
Пример #13
0
        //------------------------------------------------------------------------------

        /// <summary>
        /// 获取所有的数据库连接
        /// </summary>
        /// <returns></returns>
        public static Dictionary <String, IDbConnection> getConnectionAll()
        {
            Dictionary <String, IDbConnection> dic;

            dic = CurrentRequest.getItem(_connectionKey) as Dictionary <String, IDbConnection>;
            if (dic == null)
            {
                dic = new Dictionary <String, IDbConnection>();
                CurrentRequest.setItem(_connectionKey, dic);
            }
            return(dic);
        }
Пример #14
0
        // 避免同一页面的多个验证码冲突
        private int getCount()
        {
            String CaptchaCountKey = "CaptchaCount";
            object objCount        = CurrentRequest.getItem(CaptchaCountKey);

            if (objCount == null)
            {
                objCount = 1;
                CurrentRequest.setItem(CaptchaCountKey, objCount);
                return(1);
            }

            return((int)objCount + 1);
        }
Пример #15
0
        //--------------------------------------------------------------------

        /// <summary>
        /// 获取当前语言字符(比如 zh-cn,或 en-us)
        /// </summary>
        /// <returns></returns>
        public static String getLangString()
        {
            Object ret = CurrentRequest.getItem("__lang_name");

            if (ret == null)
            {
                String langCookie = CurrentRequest.getLangCookie();
                logger.Info("lang cookie: " + ret);
                ret = getLangNamePrivate(langCookie);
                CurrentRequest.setItem("__lang_name", ret);
            }

            return(ret.ToString());
        }
Пример #16
0
        /// <summary>
        /// 将日志写入磁盘
        /// </summary>
        /// <param name="msg"></param>
        public static void WriteFile(ILogMsg msg)
        {
            if (!SystemInfo.IsWeb || LogConfig.Instance.InRealTime)
            {
                writeFilePrivate(msg);
                return;
            }
            StringBuilder sb = CurrentRequest.getItem("currentLogList") as StringBuilder;

            if (sb == null)
            {
                sb = new StringBuilder();
                CurrentRequest.setItem("currentLogList", sb);
            }
            sb.AppendFormat("{0} {1} {2} - {3} \r\n", msg.LogTime, msg.LogLevel, msg.TypeName, msg.Message);
        }
Пример #17
0
        /// <summary>
        /// 将日志写入磁盘
        /// </summary>
        /// <param name="msg"></param>
        public static void WriteFile(ILogMsg msg)
        {
            if (SystemInfo.IsWeb == false)
            {
                writeFilePrivate(msg);
                return;
            }

            StringBuilder sb = CurrentRequest.getItem(_contextLogItem) as StringBuilder;

            if (sb == null)
            {
                sb = new StringBuilder();
                CurrentRequest.setItem(_contextLogItem, sb);
            }

            sb.AppendFormat("{0} {1} {2} - {3} \r\n", msg.LogTime, msg.LogLevel, msg.TypeName, msg.Message);
        }
Пример #18
0
        private static void setConnection(String key, IDbConnection cn)
        {
            Dictionary <String, IDbConnection> dic;

            dic = CurrentRequest.getItem(_connectionKey) as Dictionary <String, IDbConnection>;
            if (dic == null)
            {
                dic = new Dictionary <String, IDbConnection>();
            }
            if (dic.ContainsKey(key))
            {
                dic[key] = cn;
            }
            else
            {
                dic.Add(key, cn);
            }
            CurrentRequest.setItem(_connectionKey, dic);
        }
Пример #19
0
        private static void setTransaction(String key, IDbTransaction trans)
        {
            Dictionary <String, IDbTransaction> dic;

            dic = CurrentRequest.getItem(_transactionKey) as Dictionary <String, IDbTransaction>;
            if (dic == null)
            {
                dic = new Dictionary <String, IDbTransaction>();
            }
            if (dic.ContainsKey(key))
            {
                dic[key] = trans;
            }
            else
            {
                dic.Add(key, trans);
            }
            CurrentRequest.setItem(_transactionKey, dic);
        }
Пример #20
0
        private static String getString(String key)
        {
            Object result = CurrentRequest.getItem(key);

            return(result == null ? null : result.ToString());
        }
Пример #21
0
 public object GetItem(string key)
 {
     return(CurrentRequest.getItem(key));
 }