/// <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); }
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); }
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); }