예제 #1
0
        /// <summary>
        /// 获取1,2,4 将其转 list
        /// </summary>
        /// <param name="strName"></param>
        /// <param name="splitChar">分割标识符</param>
        /// <param name="filtSame">是否过滤重复</param>
        /// <returns></returns>
        public static List <int> GetFormInts(string strName, string splitChar, bool filtSame)
        {
            List <int> list = new List <int>();

            if (HttpContext.Current.Request.Form[strName] == null)
            {
                return(list);
            }
            var arr  = StringTool.SplitString(GetFormString(strName), splitChar);
            int temp = 0;

            foreach (var i in arr)
            {
                temp = TypeParseHelper.StrToInt(i, int.MinValue);
                if (temp != int.MinValue)
                {
                    if (filtSame && list.Contains(temp))
                    {
                        continue;
                    }
                    list.Add(temp);
                }
            }
            return(list);
        }
예제 #2
0
 public static string GetGoodString(string strSource, int maxLength)
 {
     if (StringTool.GetLength(strSource) > maxLength)
     {
         return(StringTool.GetSubString(strSource, maxLength, ""));
     }
     return(strSource);
 }
예제 #3
0
        /// <summary>
        /// 给前台编辑器使用
        /// </summary>
        /// <param name="nKey"></param>
        /// <param name="def"></param>
        /// <returns></returns>
        public static string RequestStringForUserEditor(string nKey, string def)
        {
            string temp = RequestString(nKey, def);

            if (temp == "")
            {
                return(def);
            }
            return(StringTool.FilterScript(temp));
        }
예제 #4
0
        public static string RequestString(string nKey, string def)
        {
            var ojb = HttpContext.Current.Request.QueryString[nKey];

            if (ojb != null)
            {
                return(StringTool.InjectFiltrate(ojb.Trim()));
            }
            ojb = HttpContext.Current.Request.Form[nKey];
            if (ojb != null)
            {
                return(StringTool.InjectFiltrate(ojb.Trim()));
            }
            return(def);
        }
예제 #5
0
        /// <summary>
        /// 客户机使用IP 地址
        /// </summary>
        /// <returns></returns>
        public static string GetIP()
        {
            try
            {
                string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                if (null == result || result == String.Empty)
                {
                    result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
                }

                if (null == result || result == String.Empty)
                {
                    result = HttpContext.Current.Request.UserHostAddress;
                }
                result = StringTool.HtmlFiltrate(result);
                return(result);
            }
            catch
            {
                return("");
            }
        }
예제 #6
0
 public static string GetGoodStringByOther(string strScoure, string strOther, int maxTotal)
 {
     return(GetGoodString(strScoure, maxTotal - StringTool.GetLength(strOther)));
 }