Exemplo n.º 1
0
        /// <summary>
        /// 获取当前请求中的表单数据,如果没有该表单项,将返回传入的默认值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">表单名</param>
        /// <param name="method">数据提交方法</param>
        /// <param name="defaultValue">默认值</param>
        /// <returns></returns>
        public T[] GetList <T>(string key, Method method, T[] defaultValue) where T : struct
        {
            string value = GetValue(key, method);

            if (string.IsNullOrEmpty(value))
            {
                return(defaultValue);
            }

            using (ErrorScope es = new ErrorScope())
            {
                string[] strings = value.Split(',');
                T[]      results = new T[strings.Length];

                for (int i = 0; i < strings.Length; i++)
                {
                    string tempValue = strings[i];
                    if (tempValue == string.Empty)
                    {
                        continue;
                    }
                    T result;
                    if (StringUtil.TryParse <T>(tempValue, out result))
                    {
                        results[i] = result;
                    }
                    else
                    {
                        es.IgnoreError <ErrorInfo>();
                        return(new T[0]);
                    }
                }
                return(results);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取当前请求中的表单数据,如果没有该表单项,将返回传入的默认值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">表单名</param>
        /// <param name="method">数据提交方法</param>
        /// <param name="defaultValue">默认值</param>
        /// <returns></returns>
        public T Get <T>(string key, Method method, T defaultValue) where T : struct
        {
            string value = GetValue(key, method);

            if (value == null)
            {
                return(defaultValue);
            }

            using (ErrorScope es = new ErrorScope())
            {
                T result;

                if (StringUtil.TryParse <T>(value, out result))
                {
                    /*用户时间转数据库服务器时间*/
                    if (typeof(T) == typeof(DateTime))
                    {
                        DateTime dateTime = (DateTime)(object)result;
                        dateTime.AddHours(-UserBO.Instance.GetUserTimeDiffrence(User.Current));
                        return((T)(object)dateTime);
                    }
                    /*  */
                    return(result);
                }
                else
                {
                    es.IgnoreError <ErrorInfo>();
                    return(defaultValue);
                }
            }
        }
Exemplo n.º 3
0
        public void Dispose()
        {
            if (m_Disposed == false)
            {
                m_Disposed = true;

                s_Current = m_Previous;

                Thread.EndThreadAffinity();
            }
        }
Exemplo n.º 4
0
        public static T TryParse <T>(string value)
        {
            using (ErrorScope es = new ErrorScope())
            {
                T result = StringUtil.TryParse <T>(value);

                es.IgnoreError <ErrorInfo>();

                return(result);
            }
        }
Exemplo n.º 5
0
        public ErrorScope()
        {
            if (Context.Current != null)
            {
                m_ErrorStartIndex = Context.Current.Errors.Count;
            }

            Thread.BeginThreadAffinity();

            m_Previous = s_Current;
            s_Current  = this;
        }
Exemplo n.º 6
0
        private const string FASTASPX_FAIL = "";//"?v=" + Globals.InternalVersion;


        protected override void OnLoad(EventArgs e)
        {
            if (m_IsOnload == false)
            {
                m_IsOnload = true;

                m_PageErrorScope = new ErrorScope();

                Root = Globals.AppRoot;

                Dialog = Globals.GetVirtualPath(SystemDirecotry.Dialogs);

                Admin = Globals.GetVirtualPath(SystemDirecotry.Admin);

                if (Globals.UseStaticCompress)
                {
                    _FastAspx = FASTASPX;
                }
                else
                {
                    _FastAspx = FASTASPX_FAIL;
                }

                switch (AllSettings.Current.FriendlyUrlSettings.UrlFormat)
                {
                case UrlFormat.Folder:
                    _Url_Before = Globals.AppRoot + "/";
                    _Url_After  = string.Empty;
                    break;

                case UrlFormat.Aspx:
                    _Url_Before = Globals.AppRoot + "/";
                    _Url_After  = ".aspx";
                    break;

                case UrlFormat.Html:
                    _Url_Before = Globals.AppRoot + "/";
                    _Url_After  = ".html";
                    break;

                default:
                    _Url_Before = Globals.AppRoot + "/?";
                    _Url_After  = string.Empty;
                    break;
                }

                base.OnLoad(e);

                //ProcessActionRequest();
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取当前请求中的表单数据,如果没有该表单项,将返回null
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">表单名</param>
        /// <param name="method">数据提交方法</param>
        /// <returns></returns>
        public Nullable <T> Get <T>(string key, Method method) where T : struct
        {
            string value = null;

            if (method == Method.Post || method == Method.All)
            {
                value = GetForm(key);
            }

            if (method == Method.Get || (method == Method.All && value == null))
            {
                value = GetQueryString(key);
            }

            if (value == null)
            {
                return(null);
            }


            using (ErrorScope es = new ErrorScope())
            {
                T result;

                if (StringUtil.TryParse <T>(value, out result))
                {
                    //用户时间转数据库服务器时间
                    if (typeof(T) == typeof(DateTime))
                    {
                        DateTime dateTime = (DateTime)(object)result;
                        dateTime.AddHours(0 - UserBO.Instance.GetUserTimeDiffrence(User.Current));
                        return((T)(object)dateTime);
                    }

                    return(result);
                }
                else
                {
                    es.IgnoreError <ErrorInfo>();
                    return(null);
                }
            }
        }