Exemple #1
0
        /// <summary>
        /// FormCollection转到Hashtable
        /// </summary>
        /// <param name="collection">界面传过来的FormCollection</param>
        /// <returns>转换后的Hashtable</returns>
        public static Hashtable FormCollectionToHashtable(FormCollection collection)
        {
            Hashtable ht = new Hashtable();

            for (int i = 0; i < collection.Count; i++)
            {
                ht.Add(collection.GetKey(i), CharacterUtil.SQLEncode(collection.GetValue(collection.GetKey(i)).AttemptedValue));
            }
            return(ht);
        }
Exemple #2
0
        public static Hashtable HtFromPage(IIdentity _identity)
        {
            var request = HttpContext.Current.Request;

            //request.ContentEncoding("UTF-8");
            request.InputStream.Position = 0; //核心代码
                                              //  byte[] byteArray = System.Text.Encoding.Default.GetBytes(aaa);
                                              // string aaa2 = System.Text.Encoding.Default.GetString(byteArray);

            byte[] byts = new byte[request.InputStream.Length];
            request.InputStream.Read(byts, 0, byts.Length);
            string    data = Encoding.UTF8.GetString(byts);
            Hashtable ht   = new Hashtable();

            if (!string.IsNullOrEmpty(data))
            {
                JObject oData = JObject.Parse(data);

                if (!string.IsNullOrEmpty(data))
                {
                    foreach (JProperty item in oData.Children())
                    {
                        var value = item.Value.ToString().Replace("\"", "");
                        ht.Add(item.Name, CharacterUtil.SQLEncode(value));
                        ht.Add(item.Name + "_Off", ParamUtil.ReplaceHyphenOrEmpty(value));
                    }
                }
            }
            ht.Remove("CompanyCode");
            var orgId = ExtendIdentity.GetOrganizationId(_identity);

            ht.Add("CompanyCode", CharacterUtil.SQLEncode(orgId));
            ht.Remove("RenYuanId");
            var userId = ExtendIdentity.GetUserId(_identity);

            ht.Add("RenYuanId", CharacterUtil.SQLEncode(userId));

            ht.Remove("RenYuanID");
            ht.Add("RenYuanID", CharacterUtil.SQLEncode(userId));
            ht.Remove("Renyuanid");
            ht.Add("Renyuanid", CharacterUtil.SQLEncode(userId));
            ht.Remove("RenYuanid");
            ht.Add("RenYuanid", CharacterUtil.SQLEncode(userId));

            ht.Remove("CreateUser");
            ht.Add("CreateUser", CharacterUtil.SQLEncode(userId));
            ht.Remove("UseCompanySSPC");
            ht.Add("UseCompanySSPC", CharacterUtil.SQLEncode(ConfigurationManager.AppSettings["UseCompanySSPC"].ToString()));


            return(ht);
        }
Exemple #3
0
        public static Hashtable HtFromUrl()
        {
            var       request = HttpContext.Current.Request;
            Hashtable ht      = new Hashtable();

            foreach (string key in request.QueryString.Keys)
            {
                string value = request.QueryString[key];
                ht.Add(key, CharacterUtil.SQLEncode(value));
                ht.Add(key + "_Off", ParamUtil.ReplaceHyphenOrEmpty(value));
            }
            return(ht);
        }
Exemple #4
0
        public static object ParamReplace(object inParam, object outParam, bool toUpperFlag = true, string[] trimArray = null)
        {
            string       expression   = null;
            MethodInfo   getMethod    = null;
            Hashtable    hashtable    = null;
            object       objectValue  = null;
            PropertyInfo info2        = null;
            Hashtable    propertyInfo = null;

            System.Type  propertyType = null;
            Hashtable    hashtable3   = null;
            string       str2         = null;
            PropertyInfo info3        = null;
            Hashtable    hashtable4   = null;

            System.Type type2      = null;
            object[]    parameters = null;
            object      obj3;
            MethodInfo  setMethod = null;

            try
            {
                IEnumerator enumerator = null;
                propertyInfo = GetPropertyInfo(RuntimeHelpers.GetObjectValue(inParam));
                hashtable4   = GetPropertyInfo(RuntimeHelpers.GetObjectValue(outParam));
                hashtable    = GetPropertyAliasName(RuntimeHelpers.GetObjectValue(inParam), toUpperFlag, trimArray);
                hashtable3   = GetPropertyAliasName(RuntimeHelpers.GetObjectValue(outParam), toUpperFlag, trimArray);
                try
                {
                    enumerator = hashtable4.Keys.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        str2 = enumerator.Current.ToString();
                        if (str2 != null)
                        {
                            expression = str2;
                        }
                        else
                        {
                            expression = "";
                        }
                        if (toUpperFlag)
                        {
                            expression = expression.ToUpper();
                        }
                        if ((trimArray != null) && (trimArray.Length > 0))
                        {
                            int num2 = trimArray.Length - 1;
                            for (int i = 0; i <= num2; i++)
                            {
                                if (trimArray[i] != null)
                                {
                                    //expression = Strings.Replace(expression, trimArray[i], "", 1, -1, CompareMethod.Binary);
                                    expression = expression.Replace(trimArray[i], "");
                                }
                            }
                        }
                        info2 = (PropertyInfo)propertyInfo[CharacterUtil.ReplaceNothing(hashtable[expression].ToString(), "")];
                        info3 = (PropertyInfo)hashtable4[CharacterUtil.ReplaceNothing(hashtable3[expression].ToString(), "")];
                        if (info3.CanWrite && !((info2 == null) | (info3 == null)))
                        {
                            propertyType = info2.PropertyType;
                            type2        = info3.PropertyType;
                            if (propertyType.FullName == type2.FullName)
                            {
                                getMethod = info2.GetGetMethod();
                                setMethod = info3.GetSetMethod();
                                if (!((getMethod == null) | (setMethod == null)))
                                {
                                    objectValue = RuntimeHelpers.GetObjectValue(getMethod.Invoke(RuntimeHelpers.GetObjectValue(inParam), null));
                                    parameters  = new object[] { RuntimeHelpers.GetObjectValue(objectValue) };
                                    setMethod.Invoke(RuntimeHelpers.GetObjectValue(outParam), parameters);
                                }
                            }
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                obj3 = outParam;
            }
            catch (Exception)
            {
                obj3 = null;
            }
            return(obj3);
        }