// Use this for initialization void Awake() { //container.SetListItemTest(10); //TutorialManager.Instance.SetTutorialStep (process.step); test.ClientDataLoader.readClientData(); StreamReader sr = new StreamReader(Application.dataPath + teamDataPath); json = sr.ReadToEnd(); MyUserLargeData userData = JsonConversionExtensions.ConvertJson <MyUserLargeData>(json); MyUserData.UpdataUserdata(userData); //Debug.Log (largeData.TeamListData.team); /*StreamReader sr = new StreamReader (Application.dataPath + path); * string js = sr.ReadToEnd ();*/ //reciever.ResolveReq (js); //int[] nia = new int[5]; //Array.Copy (ia, 1, nia, 0, 5); //Debug.Log ("Length : "+nia.Length); /*foreach (int i in nia) { * Debug.Log (i); * }*/ }
public void SetParams(Dictionary <string, object> _params) { SaveParams(_params); if (isCombine) { SetElement((object)_params, requestElementList[0]); } else { foreach (MethodElement element in requestElementList) { if (element.target == null || string.IsNullOrEmpty(_params [element.methodKey].ToString())) { Debug.Log(_params [element.methodKey]); continue; } ParameterReciever reciever = element.target.GetComponent <ParameterReciever> (); if (element.paramFunc != ParamFuncEnum.Defaut) { SetElement(JsonConversionExtensions.ConvertType(_params [element.methodKey], element._methodType), element); } else { if (reciever != null) { reciever.ResolveReq(_params [element.methodKey].ToString()); } } } } }
public void GetData(object param) { foreach (var v in (List <object>)param) { var data = JsonConversionExtensions.readJson(v.ToString()); SetData(data); } }
//Movie movie = JsonConvert.DeserializeObject<Movie>(json, new MovieConverter()); static public void readClientData() { StreamReader sr = new StreamReader(Application.dataPath + "/ClientData/ClientData.txt"); json = sr.ReadToEnd(); ClientLargeData largeData = JsonConversionExtensions.ConvertJson <ClientLargeData>(json); MasterDataManager.UpdataMasterdata(largeData); }
public void ResolveReq(object param) { if (param == null) { return; } if (requestElementList.Length > 0) { SetParams(JsonConversionExtensions.readJson(param.ToString())); } }
void SaveParams(Dictionary <string, object> _params) { Dictionary <string, object> _savedParams = new Dictionary <string, object> (); foreach (MethodElement element in requestElementList) { if (element.isParam == true) { _savedParams.Add(element.methodKey, _params [element.methodKey]); } } savedParams = JsonConversionExtensions.ConvertJson(_savedParams); }
public IActionResult syncOrg([FromBody] JObject[] value) { //List<Dictionary<string, object>> f = new List<Dictionary<string, object>>(); //foreach (JObject item in value) //{ // var d = UTILITY.JsonConversionExtensions.ToDictionary(item); // f.Add((Dictionary<string, object>)d); //} if (cm.getConfig()) { try { var t = JsonConversionExtensions.ToDictionary(value); var res = mm.syncOrg((List <Dictionary <string, object> >)t); if (res == "2000") { Dictionary <string, object> d = new Dictionary <string, object>(); d["SEND_URL"] = Extension.GetClientUserIp(Request.HttpContext); d["RECEIVE_URL"] = Request.HttpContext.Connection.LocalIpAddress.MapToIPv4().ToString(); d["SYNC_CONTENT"] = "云组织同步接收成功"; d["SYNC_RESULT"] = 0; d["ERROR_INFO"] = ""; d["FAIL_CONTENT"] = ""; d["REMARK"] = ""; srm.createSyncResult(d); } else { Dictionary <string, object> d = new Dictionary <string, object>(); d["SEND_URL"] = Extension.GetClientUserIp(Request.HttpContext); d["RECEIVE_URL"] = Request.HttpContext.Connection.LocalIpAddress.MapToIPv4().ToString(); d["SYNC_CONTENT"] = "云组织同步接收失败!" + res; d["SYNC_RESULT"] = 0; d["ERROR_INFO"] = ""; d["FAIL_CONTENT"] = ""; d["REMARK"] = ""; srm.createSyncResult(d); } return(Content(res)); } catch (Exception ex) { return(Content(ex.ToString())); } } return(Content("5000")); }
static object readContent(object content) { //Console.WriteLine(content.GetType().Name); switch (Type.GetTypeCode(content.GetType())) { case TypeCode.Int64: case TypeCode.String: case TypeCode.Boolean: return(content); default: if (content.GetType() == typeof(JArray)) { Console.WriteLine("IS JARRAY"); JArray ja = (JArray)content; var reader = JsonConversionExtensions.ToArray(ja); //string abList = ""; for (int i = 0; i < reader.Length; i++) { //readContent(reader[i]); Console.WriteLine(reader[i]); } return(reader); } else if (content.GetType() == typeof(JObject)) { Console.WriteLine("IS JOBJECT"); JObject jo = (JObject)content; var reader = ToDictionary(jo); //JObject jo = (JObject)content; //Console.WriteLine (jo.SelectToken("Hp")); foreach (var kv in reader) { Console.WriteLine(kv.Key); } //CharaData data = new CharaData(); return(reader); } else { return(null); } } }
public string syncOrg(List <Dictionary <string, object> > f) { try { DataTable dt = JsonConversionExtensions.CreateTable(f); BatchImport import = new BatchImport(); return(import.ImportInfo(dt, "ts_uidp_org")); } catch (Exception ex) { return(ex.ToString()); } //string fengefu = ""; //StringBuilder sb = new StringBuilder(); //try //{ // db.clearOrg(); // sb.Append(" insert into ts_uidp_org (ORG_ID,ORG_CODE,ORG_NAME,ORG_SHORT_NAME,ORG_CODE_UPPER,ISINVALID,ISDELETE,REMARK) values "); // foreach (var row in f) // { // sb.Append(fengefu + "('" + getString(row["ORG_ID"]) + "',"); // sb.Append("'" + getString(row["ORG_CODE"]) + "',"); // sb.Append("'" + getString(row["ORG_NAME"]) + "',"); // sb.Append("'" + getString(row["ORG_SHORT_NAME"]) + "',"); // sb.Append("'" + getString(row["ORG_CODE_UPPER"]) + "',"); // sb.Append("'" + getString(row["ISINVALID"]) + "',"); // sb.Append("'1',"); // sb.Append("'" + getString(row["REMARK"]) + "')"); // fengefu = ","; // } //} //catch (Exception ex) //{ // throw ex; //} //return db.UploadOrgFile(sb.ToString()); }
private static object ToFlutterObject(object value) { if (value == null) { return(null); } Type type = value.GetType(); Type properType = Nullable.GetUnderlyingType(type) ?? type; if (properType.IsPrimitive || properType == typeof(string)) { return(value); } if (properType.IsArray && properType.IsGenericType == false) { Type elementType = properType.GetElementType(); Type properElementType = Nullable.GetUnderlyingType(elementType) ?? elementType; if (properElementType == typeof(byte)) { // for performance reasons, we adopt Newtonsoft approach // and convert byte[] to a base-64 encoded string return(JsonConversionExtensions.ConvertByteArrayToBase64String(value)); } JavaList list = new JavaList(); foreach (object item in (IList)value) { list.Add(properElementType.IsPrimitive ? item : ToFlutterObject(item)); } return(list); } if (properType.IsGenericType) { Type[] interfaces = properType.IsInterface ? new[] { properType } : properType.GetInterfaces(); bool implementsDictionary = interfaces.Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IDictionary <,>)); if (implementsDictionary) { Type[] types = properType.GetGenericArguments(); Type valueType = Nullable.GetUnderlyingType(types[1]) ?? types[1]; JavaDictionary map = new JavaDictionary(); foreach (dynamic kvp in (IEnumerable)value) { map.Add(kvp.Key, valueType.IsPrimitive ? kvp.Value : ToFlutterObject(kvp.Value)); } return(map); } bool implementsEnumerable = interfaces.Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IEnumerable <>)); if (implementsEnumerable) { Type[] types = properType.GetGenericArguments(); Type itemType = Nullable.GetUnderlyingType(types[0]) ?? types[0]; JavaList list = new JavaList(); foreach (object item in (IEnumerable)value) { list.Add(itemType.IsPrimitive ? item : ToFlutterObject(item)); } return(list); } throw new InvalidOperationException(); } if (properType.GetCustomAttributes(typeof(PlatformDataAttribute), false).Length > 0) { return(JObject.FromObject(value).ToJavaDictionary()); } throw new InvalidOperationException(); }