public static object PostWithDict( string dllName, string className, string methodName, Hashtable dict, out int errCode, out string errText) { if (!dict.ContainsKey("DllName")) { dict.Add("DllName", dllName); } if (!dict.ContainsKey("ClassName")) { dict.Add("ClassName", className); } if (!dict.ContainsKey("MethodName")) { dict.Add("MethodName", methodName); } Dictionary <string, object> trueDict = new Dictionary <string, object>(); foreach (DictionaryEntry item in dict) { trueDict.Add(item.Key.ToString(), item.Value); } IRAPJsonResult res = HttpClientUtil.doPostWidthDict <IRAPJsonResult>("RESTful", trueDict); errCode = res.ErrCode; errText = res.ErrText; return(IRAPJsonSerializer.Deserializer(res.Json, res.TypeName)); }
/// <summary> /// WCF 通用接口 /// </summary> public object Exchange(string assemblyName, string className, string methodName, Hashtable paramDict, out int errCode, out string errText) { ServiceIRAPGlobalClient client = new ServiceIRAPGlobalClient(); if (_wcfAddress != "") { client.Endpoint.Address = new EndpointAddress(_wcfAddress); } string backTypeName = ""; string jsonContent = ""; List <IRAPJsonTable> jsonTableList = new List <IRAPJsonTable>(); #region 把 Hashtable 转换成 IRAPJsonTable 传输 foreach (DictionaryEntry item in paramDict) { if (item.Value != null) { IRAPJsonTable jsonTable = new IRAPJsonTable() { FullName = item.Value.GetType().FullName, Key = item.Key.ToString(), }; jsonTable.JsonContent = IRAPJsonSerializer.Serializer( item.Value, jsonTable.FullName); jsonTableList.Add(jsonTable); } else { errCode = 99998; errText = string.Format("字典属性:[{0}]值不能为空,请检查!", item.Key.ToString()); return(errText); } } #endregion try { errCode = client.ExChange( assemblyName, className, methodName, jsonTableList, ref jsonContent, out backTypeName, out errText); } finally { client.Close(); } object d1 = IRAPJsonSerializer.Deserializer(jsonContent, backTypeName); return(d1); }
public static object PostWithClass( string dllName, string className, string methodName, object anonymousClass, out int errCode, out string errText) { Dictionary <string, object> dict = new Dictionary <string, object>(); foreach (PropertyInfo pi in anonymousClass.GetType().GetProperties()) { bool isClass = false; if (pi.PropertyType.Equals(typeof(string)) || pi.PropertyType.IsInterface && pi.PropertyType.IsClass) { isClass = false; } else if (pi.PropertyType.IsClass) { isClass = true; } if (isClass) { object obj = pi.GetValue(anonymousClass, null); string json = IRAPJsonSerializer.Serializer(obj); dict.Add(pi.Name, json); } else { dict.Add(pi.Name, pi.GetValue(anonymousClass, null)); } } if (!dict.ContainsKey("DllName")) { dict.Add("DllName", dllName); } if (!dict.ContainsKey("ClassName")) { dict.Add("ClassName", className); } if (!dict.ContainsKey("MethodName")) { dict.Add("MethodName", methodName); } IRAPJsonResult res = HttpClientUtil.doPostWidthDict <IRAPJsonResult>("RESTful", dict); errCode = res.ErrCode; errText = res.ErrText; return(IRAPJsonSerializer.Deserializer(res.Json, res.TypeName)); }