예제 #1
0
        public static void Main()
        {
            JsonData config = ProjectSettingsConfig.LoadJsonData(_configName);

            if (config != null && config.Count > 0)
            {
                List <JsonData> datas = new List <JsonData>();
                for (int i = 0; i < config.Count; i++)
                {
                    datas.Add(config[i]);
                }
                bool update  = false;
                var  folders = Directory.GetDirectories("Assets/Game/MiniGames");
                for (int i = 0; i < folders.Length; i++)
                {
                    EditorUtility.DisplayProgressBar("MiniGames To AssetBundleEditor", folders[i], i / (folders.Length - 1.0f));
                    string   abName  = Path.GetFileNameWithoutExtension(folders[i]);
                    JsonData getData = datas.Find(x => (abName.Equals((string)x["AssetBundleName"])));
                    if (getData == null)
                    {
                        getData = new JsonData();
                        getData["AssetBundleName"] = abName;
                        getData["Variant"]         = "";
                        getData["Filter"]          = 17410;
                        getData["Split"]           = false;
                        getData["SplitCount"]      = 1;
                        getData["ForceUpdate"]     = false;
                        getData["Preload"]         = false;
                        getData["SearchInFolders"] = new JsonData();
                        getData["SearchInFolders"].SetJsonType(JsonType.Array);
                        getData["SearchInFolders"].Add(folders[i].Replace("\\", "/"));
                        datas.Add(getData);
                        config.Add(getData);
                        update = true;
                    }
                }
                EditorUtility.ClearProgressBar();
                if (update)
                {
                    ProjectSettingsConfig.SaveJsonData(_configName, config);
                    EditorUtility.DisplayDialog("数据保存成功", _configName, "ok");
                }
            }
        }
예제 #2
0
    private void LoadResToMemory()
    {
        if (m_qResPaths.Count > 0)
        {
            string strPath = m_qResPaths.Dequeue() as string;

            ResManager.Instance.OnLoadLocalRes(strPath, (res) =>
            {
                JsonData jd = new JsonData();
                jd["Path"]  = strPath;
                jd["Name"]  = res.GetName();
                jd["Crc"]   = res.GetCrc();
                m_jdFbx.Add(jd);

                m_pMemeryRes.Add(res);

                PopWaiting();

                string strFileName = res.GetName();
                strFileName        = Utils.GetFilePrefix(strFileName);
                if (resName_Crc.ContainsKey(strFileName))
                {
                    Debug.LogWarning("-------------模型文件重名:" + strFileName);
                }
                resName_Crc.AddOrReplace(strFileName.ToLower(), jd);
                LoadResToMemory();
            });
        }
        else
        {
            string strJd = m_jdFbx.ToJson();
            Utils.SaveInfo(strJd, "本地新组件AB信息");
            Debug.LogWarning("加载本地文件完成");

            // 上传资源到服务器
            UpdateRes(() => {
                Debug.Log("---------资源上传完成!-------");
            });

            // 加载服务器组件配置
            LoadCompConfig(ReadCompDataForUpdate);
        }
    }
        static string CreateInvokeRequest(string id, params string[] invokeArgs)
        {
            JsonData req = new JsonData();

            req.Add("invoke");
            JsonData parameters = new JsonData();

            parameters["id"] = id;
            JsonData args = new JsonData();

            args.SetJsonType(JsonType.Array); // To avoid invalid json if it is empty
            foreach (var arg in invokeArgs)
            {
                args.Add(arg);
            }
            parameters["args"] = args;
            req.Add(parameters);
            return(JsonMapper.ToJson(req));
        }
예제 #4
0
        public string GetAllJson()
        {
            List <RoadFlow.Data.Model.AppLibraryButtons> all = this.GetAll();
            JsonData jsonData = new JsonData();

            foreach (RoadFlow.Data.Model.AppLibraryButtons appLibraryButtons in all)
            {
                jsonData.Add((object)new JsonData()
                {
                    ["id"]     = (JsonData)appLibraryButtons.ID.ToString(),
                    ["name"]   = (JsonData)appLibraryButtons.Name,
                    ["events"] = (JsonData)appLibraryButtons.Events,
                    ["ico"]    = (JsonData)appLibraryButtons.Ico,
                    ["sort"]   = (JsonData)appLibraryButtons.Sort
                });
            }
            //return jsonData.ToJson(true);
            return(jsonData.ToJson());
        }
예제 #5
0
        public string GetUserDirectoryJson(Guid userID, string path = "", bool isFirst = false)
        {
            path = path.IsNullOrEmpty() ? this.GetUserRootPath(userID) : path;
            string[] directories = Directory.GetDirectories(path);
            JsonData jsonData1   = new JsonData();

            if (isFirst)
            {
                jsonData1["id"]        = (JsonData)path.DesEncrypt();
                jsonData1["parentID"]  = (JsonData)"0";
                jsonData1["title"]     = (JsonData)"我的文件";
                jsonData1["type"]      = (JsonData)0;
                jsonData1["ico"]       = (JsonData)"";
                jsonData1["hasChilds"] = (JsonData)(directories.Length != 0 ? "1" : "0");
                if (directories.Length != 0)
                {
                    jsonData1["childs"] = new JsonData();
                }
            }
            foreach (string str in directories)
            {
                bool     flag      = (uint)Directory.GetDirectories(str).Length > 0U;
                string   fileName  = Path.GetFileName(str);
                JsonData jsonData2 = new JsonData();
                jsonData2["id"]        = (JsonData)str.DesEncrypt();
                jsonData2["parentID"]  = (JsonData)path.DesEncrypt();
                jsonData2["title"]     = (JsonData)fileName;
                jsonData2["type"]      = (JsonData)1;
                jsonData2["hasChilds"] = (JsonData)(flag ? "1" : "0");
                jsonData2["ico"]       = (JsonData)(flag ? "" : "fa-folder");
                if (isFirst)
                {
                    jsonData1["childs"].Add((object)jsonData2);
                }
                else
                {
                    jsonData1.Add((object)jsonData2);
                }
            }
            //return jsonData1.ToJson(true);
            return(jsonData1.ToJson());
        }
예제 #6
0
    static void RecordABList(BuildTarget target)
    {
        DirectoryInfo path          = new DirectoryInfo(Application.dataPath + "/StreamingAssets/data");
        JsonData      assetNameJson = new JsonData();

        foreach (FileInfo file in path.GetFiles("*.*", SearchOption.AllDirectories))
        {
            string name = file.Name;
            if (name.EndsWith(".meta") || name.EndsWith(".manifest"))
            {
                continue;
            }

            ToolUtil.WriteFile(path + "/" + name, GetEncryptBytes(file.FullName));
            JsonData resJson = new JsonData();
            resJson["name"] = name;
            resJson["md5"]  = ToolUtil.GetMD5(path + "/" + name);
            resJson["size"] = ToolUtil.GetFileSize(path + "/" + name);
            assetNameJson.Add(resJson);
        }

        JsonData verJson = new JsonData();

        verJson["ver"] = Convert.ToInt32(_version);
        if (target == BuildTarget.iOS)
        {
            verJson["target"] = "IOS";
            verJson["down"]   = _updateurl + _version + "/ios/";
        }
        else if (target == BuildTarget.Android)
        {
            verJson["target"] = "Android";
            verJson["down"]   = _updateurl + _version + "/android/";
        }
        verJson["entryres"]    = ToolUtil.EntryRes;
        verJson["entryscript"] = ToolUtil.EntryScript;
        verJson["list"]        = assetNameJson;
        ToolUtil.SaveAndEncryptFile(path + "/assets.dat", verJson.ToJson());

        ToolUtil.SaveFile(Application.dataPath + "/StreamingAssets/assetlist.txt", verJson.ToJson());
        Debug.Log("version -------->" + verJson.ToJson());
    }
예제 #7
0
        public string SendMPNews(List <Tuple <string, string, string, string, string, string, string> > articleList, string userids = "", string depts = "", string groups = "", int agentid = 0, bool async = false)
        {
            JsonData jsonData1 = new JsonData();

            jsonData1["touser"]        = (JsonData)userids;
            jsonData1["toparty"]       = (JsonData)depts;
            jsonData1["totag"]         = (JsonData)groups;
            jsonData1["msgtype"]       = (JsonData)"mpnews";
            jsonData1[nameof(agentid)] = (JsonData)agentid;
            JsonData jsonData2 = new JsonData();
            JsonData jsonData3 = new JsonData();

            foreach (Tuple <string, string, string, string, string, string, string> article in articleList)
            {
                JsonData jsonData4 = new JsonData();
                jsonData4["title"] = (JsonData)article.Item1;
                string str = article.Item2;
                if (File.Exists(article.Item2))
                {
                    str = new Media(agentid).UploadFormal(article.Item2, "image");
                }
                jsonData4["thumb_media_id"]     = (JsonData)str;
                jsonData4["author"]             = (JsonData)article.Item3;
                jsonData4["content_source_url"] = (JsonData)article.Item4;
                jsonData4["content"]            = (JsonData)article.Item5;
                jsonData4["digest"]             = (JsonData)article.Item6;
                jsonData4["show_cover_pic"]     = (JsonData)article.Item7;
                jsonData3.Add((object)jsonData4);
            }
            jsonData2["articles"] = jsonData3;
            jsonData1["mpnews"]   = jsonData2;
            this.agentId          = agentid;
            //string json = jsonData1.ToJson(false);
            string json = jsonData1.ToJson();

            if (!async)
            {
                return(this.send(json));
            }
            this.sendAsync(json);
            return("");
        }
예제 #8
0
        public string GetUserDirectoryJson(Guid userID, string path = "", bool isFirst = false)
        {
            path = (path.IsNullOrEmpty() ? GetUserRootPath(userID) : path);
            string[] directories = Directory.GetDirectories(path);
            JsonData jsonData    = new JsonData();

            if (isFirst)
            {
                jsonData["id"]        = path.DesEncrypt();
                jsonData["parentID"]  = "0";
                jsonData["title"]     = "我的文件";
                jsonData["type"]      = 0;
                jsonData["ico"]       = "";
                jsonData["hasChilds"] = ((directories.Length != 0) ? "1" : "0");
                if (directories.Length != 0)
                {
                    jsonData["childs"] = new JsonData();
                }
            }
            string[] array = directories;
            foreach (string text in array)
            {
                bool     flag      = Directory.GetDirectories(text).Length != 0;
                string   fileName  = Path.GetFileName(text);
                JsonData jsonData2 = new JsonData();
                jsonData2["id"]        = text.DesEncrypt();
                jsonData2["parentID"]  = path.DesEncrypt();
                jsonData2["title"]     = fileName;
                jsonData2["type"]      = 1;
                jsonData2["hasChilds"] = (flag ? "1" : "0");
                jsonData2["ico"]       = (flag ? "" : "fa-folder");
                if (isFirst)
                {
                    jsonData["childs"].Add(jsonData2);
                }
                else
                {
                    jsonData.Add(jsonData2);
                }
            }
            return(jsonData.ToJson());
        }
예제 #9
0
        /// <summary>
        /// 获取酒店门店信息
        /// </summary>
        /// <param name="context"></param>
        private void GetHotelInfo(HttpContext context)
        {
            string   adminhotelid = context.Request["adminhotelid"];
            JsonData jsondata     = new JsonData();
            string   sql          = string.Format(@"select AdminHotelid,Name from Hotel_Admin where adminhotelid=@adminhotelid and DeleteMark=1 ");

            SqlParam[] parmAdd = new SqlParam[] {
                new SqlParam("@AdminHotelid", adminhotelid)
            };
            DataTable ds = DataFactory.SqlDataBase().GetDataTableBySQL(new StringBuilder(sql), parmAdd);

            if (ds != null && ds.Rows.Count > 0)
            {
                for (int i = 0; i < ds.Rows.Count; i++)
                {
                    JsonData json1 = new JsonData();
                    json1["ID"]   = ds.Rows[i]["AdminHotelid"].ToString();
                    json1["NAME"] = ds.Rows[i]["Name"].ToString();
                    sql           = string.Format(@"select id,name from Hotel where AdminHotelid=@AdminHotelid  and DeleteMark=1 order by sort desc");
                    SqlParam[] pmadd = new SqlParam[] {
                        new SqlParam("@AdminHotelid", ds.Rows[i]["AdminHotelid"])
                    };
                    DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(new StringBuilder(sql), pmadd);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        json1["hotel"] = new JsonData();
                        for (int s = 0; s < dt.Rows.Count; s++)
                        {
                            JsonData json2 = new JsonData();
                            json2["id"]   = dt.Rows[s]["id"].ToString();
                            json2["name"] = dt.Rows[s]["name"].ToString();
                            json1["hotel"].Add(json2);
                        }
                    }
                    jsondata.Add(json1);
                }
            }
            string json = "";

            json = jsondata.ToJson();
            context.Response.Write(json);
        }
예제 #10
0
        private JsonData ToJsonObjectRecurse(object in_object)
        {
            if (IsBasicType(in_object))
            {
                return(new JsonData(in_object));
            }
            else if (in_object is IList)
            {
                JsonData listJson   = new JsonData();
                IList    objectList = (IList)in_object;
                for (int i = 0; i < objectList.Count; ++i)
                {
                    listJson.Add(ToJsonObjectRecurse((object)objectList[i]));
                }
                return(listJson);
            }

            /*
             * else if (in_object is IDictionary<string, object>)
             * {
             *  JsonData dictJson = new JsonData();
             *  foreach (KeyValuePair<string, object> kv in (IDictionary<string, object>) in_object)
             *  {
             *      dictJson[kv.Key] = ToJsonObjectRecurse(kv.Value);
             *  }
             *  return dictJson;
             * }
             */
            else if (in_object is IDictionary)
            {
                JsonData dictJson = new JsonData();
                foreach (DictionaryEntry de in (IDictionary)in_object)
                {
                    dictJson[(string)de.Key] = ToJsonObjectRecurse(de.Value);
                }
                return(dictJson);
            }
            else
            {
                throw new ArgumentException("Found unknown type, can't serialize to json!");
            }
        }
예제 #11
0
파일: NodeGraph.cs 프로젝트: dudu502/AiFa
    public static JsonData CreateNodeJsonData(NodeGraph data)
    {
        var jd = new JsonData();

        jd["name"]       = data.Name;
        jd["type"]       = (int)data.Type;
        jd["scriptName"] = data.ScriptName;
        jd["weight"]     = data.Weight;
        jd["x"]          = data.NodeRect.x;
        jd["y"]          = data.NodeRect.y;
        var arr = new JsonData();

        arr.SetJsonType(JsonType.Array);
        jd["children"] = arr;
        for (int i = 0; i < data.Nodes.Count; ++i)
        {
            arr.Add(CreateNodeJsonData(data.Nodes[i]));
        }
        return(jd);
    }
예제 #12
0
        public bool Save(JsonData json_root)
        {
            string lowName = name.ToLower();

            json_root["name"] = lowName;
            JsonData effect_nodes = new JsonData();

            effect_nodes.SetJsonType(JsonType.Array);
            json_root["effects"] = effect_nodes;

            foreach (KeyValuePair <string, SkillEffectProp> pair in m_effectDict)
            {
                JsonData effect_node = new JsonData();
                effect_nodes.Add(effect_node);

                pair.Value.Save(effect_node);
            }

            return(true);
        }
예제 #13
0
        public override void ProcessStruct(JsonData jsonData)
        {
            int      maskIndex = FindIndexByName(jsonData, MaskNode.MASK);
            JsonData mask      = jsonData[NodeField.CHILDREN][maskIndex];
            JsonData jArray    = new JsonData();

            for (int i = 0; i < jsonData[NodeField.CHILDREN].Count; i++)
            {
                JsonData child = jsonData[NodeField.CHILDREN][i];
                if (i != maskIndex)
                {
                    jArray.Add(child);
                }
            }
            mask[NodeField.CHILDREN] = jArray;
            mask[NodeField.TYPE]     = MaskNode.MASK;

            jsonData[NodeField.CHILDREN].Clear();
            jsonData[NodeField.CHILDREN].Add(mask);
        }
예제 #14
0
        protected override void ToJson(ref JsonData json)
        {
            json["beginPosition"] = JTweenUtils.Vector3Json(m_beginPosition);
            if (m_toPath == null || m_toPath.Length <= 0)
            {
                return;
            }
            JsonData pathJson = new JsonData();

            for (int i = 0; i < m_toPath.Length; ++i)
            {
                pathJson.Add(JTweenUtils.Vector3Json(m_toPath[i]));
            } // end for
            json["path"]       = pathJson;
            json["type"]       = (int)m_pathType;
            json["mode"]       = (int)m_pathMode;
            json["resolution"] = (int)m_resolution;
            json["gizmoColor"] = JTweenUtils.ColorJson(m_gizmoColor);
            json["showGizmo"]  = m_showGizmo;
        }
예제 #15
0
        public void Save(string strPath)
        {
            //filePath = strPath;
            var animsJsonData = new JsonData();

            for (int i = 0; i < animations.Count; i++)
            {
                MyAnimation anim            = animations[i];
                var         oneAnimJsonData = new JsonData();
                animsJsonData.Add(oneAnimJsonData);
                oneAnimJsonData["name"]       = anim.name;
                oneAnimJsonData["loop"]       = anim.loop;
                oneAnimJsonData["oneStage"]   = anim.oneStage;
                oneAnimJsonData["spritePath"] = anim.spritePath;

                if (animations[i].oneStage)
                {
                    oneAnimJsonData["spriteStart"]    = anim.spriteStart;
                    oneAnimJsonData["spriteNum"]      = anim.spriteNum;
                    oneAnimJsonData["frameLenth"]     = anim.frameLenth;
                    oneAnimJsonData["framePerSprite"] = anim.framePerSprite;
                }
                else
                {
                    var stagesJsonData = new JsonData();
                    oneAnimJsonData["stages"] = stagesJsonData;

                    for (int j = 0; j < 3; j++)
                    {
                        var oneStageJsonData = new JsonData();
                        stagesJsonData.Add(oneStageJsonData);

                        oneStageJsonData["startSprite"] = anim.stageData[j].x;
                        oneStageJsonData["spriteNum"]   = anim.stageData[j].y;
                        oneStageJsonData["frameNum"]    = anim.stageData[j].z;
                    }
                }
            }

            FilePathHelp.SaveStringToFile(strPath, animsJsonData.ToJson());
        }
예제 #16
0
        public string SendMPNews(List <Tuple <string, string, string, string, string, string, string> > articleList, string userids = "", string depts = "", string groups = "", int agentid = 0, bool async = false)
        {
            JsonData jsonData = new JsonData();

            jsonData["touser"]  = userids;
            jsonData["toparty"] = depts;
            jsonData["totag"]   = groups;
            jsonData["msgtype"] = "mpnews";
            jsonData["agentid"] = agentid;
            JsonData jsonData2 = new JsonData();
            JsonData jsonData3 = new JsonData();

            foreach (Tuple <string, string, string, string, string, string, string> article in articleList)
            {
                JsonData jsonData4 = new JsonData();
                jsonData4["title"] = article.Item1;
                string data = article.Item2;
                if (File.Exists(article.Item2))
                {
                    data = new Media(agentid).UploadFormal(article.Item2, "image");
                }
                jsonData4["thumb_media_id"]     = data;
                jsonData4["author"]             = article.Item3;
                jsonData4["content_source_url"] = article.Item4;
                jsonData4["content"]            = article.Item5;
                jsonData4["digest"]             = article.Item6;
                jsonData4["show_cover_pic"]     = article.Item7;
                jsonData3.Add(jsonData4);
            }
            jsonData2["articles"] = jsonData3;
            jsonData["mpnews"]    = jsonData2;
            agentId = agentid;
            string data2 = jsonData.ToJson(false);

            if (async)
            {
                sendAsync(data2);
                return("");
            }
            return(send(data2));
        }
예제 #17
0
        /// <summary>
        ///  同种结构转为Array
        /// </summary>
        /// <returns></returns>
        public JsonData ConvertListTableToJson(ListTable list)
        {
            JsonData resJsonDatas = new JsonData();

            resJsonDatas.SetJsonType(JsonType.Array);

            foreach (List <object> objects in list.Rows)
            {
                Queue <object> queueVal = new Queue <object>(objects);
                JsonData       jsonData = new JsonData();
                foreach (string o in list.Columns)
                {
                    var val = queueVal.Dequeue();
                    jsonData[o] = (val is JsonData) ? (JsonData)val : new JsonData(val);
                }

                resJsonDatas.Add(jsonData);
            }

            return(resJsonDatas);
        }
예제 #18
0
        public override JsonData GetJsonData()
        {
            JsonData ret = new JsonData()
            {
                [IdleRewardDataKey.START_TIME]       = startTimestamp,
                [IdleRewardDataKey.SETTLEMENT_TIME]  = settlementTimestamp,
                [IdleRewardDataKey.QUICK_IDLE_INDEX] = quickIdleIndex,
            };

            if (settlementList.Count > 0)
            {
                JsonData settlementListJson = new JsonData();
                settlementListJson.SetJsonType(JsonType.Array);
                for (int i = 0; i < settlementList.Count; i++)
                {
                    settlementListJson.Add(settlementList[i].GetJsonData());
                }
                ret[IdleRewardDataKey.SETTLEMENT_DATAS] = settlementListJson;
            }
            return(ret);
        }
예제 #19
0
    // 请求自定义牌型
    public static void reqCustomPoker(string uid, List <TLJCommon.PokerInfo> pokerList)
    {
        JsonData data = new JsonData();

        data["tag"] = TLJCommon.Consts.Tag_DebugSetPoker;
        data["uid"] = uid;

        {
            JsonData jarray = new JsonData();
            for (int i = 0; i < pokerList.Count; i++)
            {
                JsonData jd = new JsonData();
                jd["num"]       = pokerList[i].m_num;
                jd["pokerType"] = (int)pokerList[i].m_pokerType;
                jarray.Add(jd);
            }
            data["pokerList"] = jarray;
        }

        PlayServiceSocket.s_instance.sendMessage(data.ToJson());
    }
예제 #20
0
    // 인터페이스 : 리소스 리스트를 Json형태로 쓰기
    public static void SaveToResourcesInfo(Dictionary <string, SHResourcesInfo> dicTable, string strSaveFilePath)
    {
        if (0 == dicTable.Count)
        {
            return;
        }

        var pResourcesJsonData = new JsonData();

        foreach (var kvp in dicTable)
        {
            pResourcesJsonData.Add(MakeResourceJsonData(kvp.Value));
        }

        var pJsonWriter = new JsonWriter();

        pJsonWriter.PrettyPrint = true;
        JsonMapper.ToJson(pResourcesJsonData, pJsonWriter);

        SHUtils.SaveFile(pJsonWriter.ToString(), strSaveFilePath);
    }
예제 #21
0
        /// <summary>
        ///获取营业点图片
        /// </summary>
        /// <param name="context"></param>
        private void GetBusinessPicList(HttpContext context)
        {
            string   HotelId  = context.Request["HotelId"];
            JsonData jsondata = new JsonData();
            string   sql      = string.Format(@"select ID,TypeName,BusinessName,AdminHotelid from Bookings where HotelId=@HotelId  order by sort desc");

            SqlParam[] parmAdd = new SqlParam[] {
                new SqlParam("@HotelId", HotelId)
            };
            DataTable ds = DataFactory.SqlDataBase().GetDataTableBySQL(new StringBuilder(sql), parmAdd);

            if (ds != null && ds.Rows.Count > 0)
            {
                for (int i = 0; i < ds.Rows.Count; i++)
                {
                    JsonData json1 = new JsonData();
                    json1["ID"]           = ds.Rows[i]["ID"].ToString();
                    json1["TYPENAME"]     = ds.Rows[i]["TypeName"].ToString();
                    json1["BUSINESSNAME"] = ds.Rows[i]["BusinessName"].ToString();
                    sql = string.Format(@"select ID, ImgFile from Photo where PID='{0}' and [type]='{1}' and AdminHotelid='{2}' order by ID asc", ds.Rows[i]["id"], (int)DefaultFilePath.SystemType.Business, ds.Rows[i]["AdminHotelid"]);
                    DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(new StringBuilder(sql));
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        json1["pic"] = new JsonData();
                        for (int s = 0; s < dt.Rows.Count; s++)
                        {
                            JsonData json2 = new JsonData();
                            json2["ID"]      = dt.Rows[s]["ID"].ToString();
                            json2["IMGFILE"] = dt.Rows[s]["ImgFile"].ToString();
                            json1["pic"].Add(json2);
                        }
                    }
                    jsondata.Add(json1);
                }
            }
            string json = "";

            json = jsondata.ToJson();
            context.Response.Write(json);
        }
예제 #22
0
    /// <summary>
    /// DataTable - JsonData
    /// </summary>
    /// <param name="dt"></param>
    /// <returns></returns>
    public static JsonData DataTableToJsonData(DataTable dt)
    {
        JsonData jdData = new JsonData();//DataTable值

        foreach (DataRow dr in dt.Rows)
        {
            JsonData jdList = new JsonData();
            foreach (DataColumn dc in dr.Table.Columns)
            {
                if (dr[dc] != null && dr[dc] != DBNull.Value && dr[dc].ToString() != "")
                {
                    jdList[dc.ColumnName] = dr[dc].ToString();//
                }
                else
                {
                    jdList[dc.ColumnName] = "";//
                }
            }
            jdData.Add(jdList);
        }
        return(jdData);
    }
예제 #23
0
        public static string SaveTree(JsonData jsondata, ChildNode cn)
        {
            JsonData jd = new JsonData();

            jd["Keys"]      = new JsonData();
            jd["NextNodes"] = new JsonData();
            for (int i = 0; i < cn.Keys.Count; i++)
            {
                jd["Keys"].Add(cn.Keys[i]);
            }
            if (jsondata.Keys.Contains("NextNodes"))
            {
                jsondata["NextNodes"].Add(jd);
            }
            else
            {
                jsondata = new JsonData();
                jsondata.Add(jd);
            }
            for (int i = 0; i < cn.Nodes.Count; i++)
            {
                if (cn.Nodes[i] is ChildNode)
                {
                    SaveTree(jd, (cn.Nodes[i] as ChildNode));
                }
                else
                {
                    JsonData jd2 = new JsonData();
                    jd2["Keys"]      = new JsonData();
                    jd2["NextNodes"] = new JsonData();
                    for (int j = 0; j < (cn.Nodes[i] as LeafNode).Records.Count; j++)
                    {
                        jd2["Keys"].Add((cn.Nodes[i] as LeafNode).Records[j].Key);
                    }
                    jd["NextNodes"].Add(jd2);
                }
            }
            return(jsondata.ToJson());
        }
예제 #24
0
    static void CreateArrangement()
    {
        Debug.Log("" + Selection.activeGameObject.name);
        if (Selection.activeGameObject != null)
        {
            JsonData jd  = new JsonData();
            JsonData jd1 = new JsonData();

            jd["Arrangement"] = "1.0.0.0";
            foreach (Transform item in Selection.activeGameObject.transform)
            {
                JsonData tmp  = new JsonData();
                JsonData tmp1 = new JsonData();
                JsonData tmp2 = new JsonData();
                JsonData tmp3 = new JsonData();
                JsonData tmp4 = new JsonData();
                tmp2["x"] = item.transform.localPosition.x;
                tmp2["y"] = item.transform.localPosition.y;
                tmp2["z"] = item.transform.localPosition.z;

                tmp3["x"] = item.transform.localRotation.eulerAngles.x;
                tmp3["y"] = item.transform.localRotation.eulerAngles.y;
                tmp3["z"] = item.transform.localRotation.eulerAngles.z;

                tmp4["x"] = item.transform.localScale.x;
                tmp4["y"] = item.transform.localScale.y;
                tmp4["z"] = item.transform.localScale.z;

                tmp1["pos"]      = tmp2;
                tmp1["pot"]      = tmp3;
                tmp1["scale"]    = tmp4;
                tmp["Transform"] = tmp1;
                jd1.Add(tmp);
            }
            jd["Array"] = jd1;
            My_UIEditorToos.CreateFile("Assets/Resources", "Arrangement", jd);
            Debug.Log("" + jd.ToJson());
        }
    }
예제 #25
0
        public static JsonData AnimationCurveJson(AnimationCurve arg)
        {
            JsonData ret      = new JsonData();
            JsonData jsonKeys = new JsonData();

            Keyframe[] keys = arg.keys;
            for (int i = 0, imax = keys.Length; i < imax; ++i)
            {
                Keyframe k      = keys[i];
                JsonData oneKey = new JsonData();
                oneKey["T"] = System.Math.Round(k.time, 4);
                oneKey["V"] = System.Math.Round(k.value, 4);
                oneKey["I"] = System.Math.Round(k.inTangent, 4);
                oneKey["O"] = System.Math.Round(k.outTangent, 4);
                oneKey["M"] = k.tangentMode;
                jsonKeys.Add(oneKey);
            }
            ret["keys"] = jsonKeys;
            ret["pre"]  = (int)arg.preWrapMode;
            ret["post"] = (int)arg.postWrapMode;
            return(ret);
        }
예제 #26
0
    public string GetJson()
    {
        JsonData data = new JsonData();

        data["clickAccuracy"] = clickAccuracy;
        data["clickScore"]    = clickScore;
        data["clickNumber"]   = clickNumber;
        data["rightNumber"]   = rightNumber;
        data["wrongNumber"]   = wrongNumber;
        data["wholeScore"]    = wholeScore;

        JsonData readingData = new JsonData();

        for (int i = 0; i < m_ReadingData.Count; i++)
        {
            readingData.Add(m_ReadingData[i].GetJsonData());
        }

        data["readingData"] = readingData;

        return(data.ToJson());
    }
예제 #27
0
        public override JsonData GetJsonData()
        {
            JsonData ret = new JsonData()
            {
                [CampsiteDataKey.ID] = id,
                [CampsiteDataKey.TOTAL_REWARD_VAL]   = totalRewardVal,
                [CampsiteDataKey.LAST_RECORD_TIME]   = PTUtil.DateTime2Timestamp(lastRecordTime),
                [CampsiteDataKey.HAS_OFFLINE_REWARD] = hasOfflineReward,
            };

            JsonData pointsJsonArr = new JsonData();

            pointsJsonArr.SetJsonType(JsonType.Array);
            for (int i = 0; i < points.Length; i++)
            {
                pointsJsonArr.Add(points[i].GetJsonData());
            }

            ret[CampsiteDataKey.POINTS] = pointsJsonArr;

            return(ret);
        }
예제 #28
0
        public static bool SetFile(Dictionary <string, string> saveInfo, string path)
        {
            Dictionary <int, KeyValuesItem> configMsg = new Dictionary <int, KeyValuesItem>();

            //item.Key = saveInfo["Tip"];
            // configMsg.Add(0, item);

            JsonData _saveData = new JsonData();
            int      conut     = 0;

            _saveData["ConfigInfo"] = new JsonData();
            JsonData arrayData = new JsonData();

            arrayData.SetJsonType(JsonType.Array);
            foreach (var temp in saveInfo)
            {
                JsonData _data = new JsonData();
                Debug.Log(temp.Key + "  " + temp.Value);
                _data["Key"]   = temp.Key;
                _data["Value"] = temp.Value;
                arrayData.Add(_data);
            }
            _saveData["ConfigInfo"] = arrayData;
            string values = JsonMapper.ToJson(_saveData);

            //找到当前路径
            Debug.Log("保存的Json: " + values);
            FileInfo file = new FileInfo(path);
            //判断有没有文件,有则打开文件,,没有创建后打开文件
            StreamWriter sw = file.CreateText();

            //将转换好的字符串存进文件,
            sw.WriteLine(values);
            //注意释放资源
            sw.Close();
            sw.Dispose();

            return(true);
        }
예제 #29
0
    void OnGUI()
    {
        GUI.skin.button.fontSize = 64;

        if (GUILayout.Button("QDataUpdate"))
        {
            JsonData updateData = new JsonData();
            updateData["photo"]       = "www.baidu.com";
            updateData["player_name"] = "szn";
            JsonData friendsArray = new JsonData();
            friendsArray.Add(new JsonData());
            updateData["friends"] = friendsArray;

            NetDispatcher.Instance.RegisterNetEvent(NetProtocolEnum.QDataUpdate,
                                                    (result, data) =>
            {
                Debug.LogError("Resp QDataUpdate msg = " + result + "\n" + data.ToJson());
            });
            NetManager.Instance.Request(NetProtocolEnum.QDataUpdate, updateData);
        }

        if (GUILayout.Button("QCustomsDataPut"))
        {
            JsonData cusData = new JsonData();
            cusData["gold"]      = 10000;
            cusData["score"]     = 10001;
            cusData["world"]     = 10002;
            cusData["sub_world"] = 10003;
            cusData["level"]     = 10004;

            NetDispatcher.Instance.RegisterNetEvent(NetProtocolEnum.QCustomsDataPut,
                                                    (result, data) =>
            {
                Debug.LogError("Resp QCustomsDataPut msg = " + result + "\n" + data.ToJson());
            });
            NetManager.Instance.Request(NetProtocolEnum.QCustomsDataPut, cusData);
        }
    }
예제 #30
0
        public string SendNews(List <Tuple <string, string, string, string> > articleList, string userids = "", string depts = "", string groups = "", int agentid = 0, bool async = false)
        {
            JsonData jsonData1 = new JsonData();

            jsonData1["touser"]        = (JsonData)userids;
            jsonData1["toparty"]       = (JsonData)depts;
            jsonData1["totag"]         = (JsonData)groups;
            jsonData1["msgtype"]       = (JsonData)"news";
            jsonData1[nameof(agentid)] = (JsonData)agentid;
            JsonData jsonData2 = new JsonData();
            JsonData jsonData3 = new JsonData();

            foreach (Tuple <string, string, string, string> article in articleList)
            {
                JsonData jsonData4 = new JsonData();
                jsonData4["title"]       = (JsonData)article.Item1;
                jsonData4["description"] = (JsonData)article.Item2;
                jsonData4["url"]         = (JsonData)article.Item3;
                string str = article.Item4;
                if (!str.IsNullOrEmpty())
                {
                    jsonData4["picurl"] = (JsonData)str;
                    jsonData3.Add((object)jsonData4);
                }
            }
            jsonData2["articles"] = jsonData3;
            jsonData1["news"]     = jsonData2;
            this.agentId          = agentid;
            //string json = jsonData1.ToJson(false);
            string json = jsonData1.ToJson();

            if (!async)
            {
                return(this.send(json));
            }
            this.sendAsync(json);
            return("");
        }