コード例 #1
0
        private string GetJsonDataByLitJson()
        {
            JsonData result      = new JsonData();
            var      data        = itemsApp.GetList();
            var      detailsData = itemsDetailApp.GetList();//获取所有数据
            JsonData resultArr   = new JsonData();

            //遍历分组
            foreach (var item in data)
            {
                JsonData itemJd = new JsonData();
                itemJd["key"] = item.F_EnCode;
                //在所有数据中查找f_itemid==item.key的数据
                JsonData itemAddJd = new JsonData();
                itemAddJd.Add(null);
                itemAddJd.Clear();
                foreach (var details in detailsData.Where(d => d.F_ItemId == item.F_Id))
                {
                    JsonData itemDetailJD = new JsonData();
                    itemDetailJD["Id"]   = details.F_Id;
                    itemDetailJD["Code"] = details.F_ItemCode;
                    itemDetailJD["Name"] = details.F_ItemName;
                    itemAddJd.Add(itemDetailJD);
                }
                itemJd["value"] = itemAddJd;
                resultArr.Add(itemJd);
            }
            result["DictionaryJsonV1"] = resultArr;
            return(JsonMapper.ToJson(result));
        }
コード例 #2
0
    //This method is run first in the Procedural Engine initial setup
    public CrewMember ChooseCulprit()
    {
        // For the vertical slice of our game there can only be two possible Culprits (First Mate or Pilot). So we limit the choices to those
        // two here in this function. The values passed in here is the ID value that corresponds to each crew member in the JSON File crew.json
        // For culprit, the ID's are 3 and 5


        JsonData culpritData = JsonMapper.ToObject(crewFinal.text);
        //int randomID = Random.Range (0, 6);
        int randomID = ChooseID(3, 5);

        CrewMember void_Culprit = new CrewMember();

        // Assign the randomID to _culpritID to ensure that we have an ID to check against
        void_Culprit.ID = randomID;

        // Assign the Title property of void_Culprit by drilling into the JsonData Object and extracting the "Title" entry for our random crew member
        void_Culprit.Title = culpritData["Crew"][randomID]["Title"].ToString();
        // This is the Culprit so we set it's bool of isCulprit to true
        void_Culprit.IsCulprit = true;

        // Clear the JsonData object
        culpritData.Clear();

        // Remove the culprit from the _crewMembers List
        _crewMembers.Remove(void_Culprit.Title);

        // Return the CrewMember object that holds the culprit's data
        return(void_Culprit);
    }
コード例 #3
0
        //
        /// <summary>
        /// 通过版本进行实例化。
        /// </summary>
        /// <param name="version"></param>
        public MinecraftStartHelper(string version)
        {
            verList = new List <MinecraftVersion>();
            libs    = new List <Library>();

            var              version2 = version;
            var              jsonText = new StreamReader(NativePath + "\\versions\\" + version2 + "\\" + version2 + ".json").ReadToEnd();
            JsonData         json     = JsonMapper.ToObject(jsonText);
            MinecraftVersion mv       = JsonMapper.ToObject <MinecraftVersion>(jsonText);

            this.mainClass = json["mainClass"].ToString();
            verList.Add(mv);
            if (json.Keys.Contains("inheritsFrom"))
            {
                this.isOriginal = true;
            }
            while (json.Keys.Contains("inheritsFrom"))
            {
                version2 = json["inheritsFrom"].ToString();
                jsonText = new StreamReader(NativePath + "\\versions\\" + version2 + "\\" + version2 + ".json").ReadToEnd();
                json.Clear();
                json = JsonMapper.ToObject(jsonText);
                mv   = JsonMapper.ToObject <MinecraftVersion>(jsonText);
                verList.Add(mv);
            }//把所有层次版本搞出来

            foreach (MinecraftVersion item in verList)
            {
                libs.AddRange(item.libraries);
            }

            this.getLatestLibFromLibList();
        }
コード例 #4
0
    public CrewMember ChooseVictim()
    {
        // For the vertical slice of our game there can only be two possible Victims (Engineer and Cook). So we limit the choices to those
        // two here in this function. The values passed in here is the ID value that corresponds to each crew member in the JSON File crew.json
        // The ID's are 1 and 2

        JsonData victimData = JsonMapper.ToObject(crewFinal.text);
        // int randomID = Random.Range (0, 6);
        int randomID = ChooseID(1, 2);
        // We would need to include a check here if we were to open the game up to randomly choose a victim from the
        // entire crew list. The check would ensure that the same ID as _culpritID is not assigned

        CrewMember void_Victim = new CrewMember();

        void_Victim.Title = victimData["Crew"][randomID]["Title"].ToString();

        // Assign the chosen Victim's Title to _victimTitle. This will be used to find the appropriate Location in the json file.
        //void_Victim.title = _victimTitle;

        // Clear the JsonData Object
        victimData.Clear();

        // Remove the Victim from the _crewMembers List
        _crewMembers.Remove(void_Victim.Title);

        // Return the CrewMember object that holds the victim's data
        return(void_Victim);
    }
コード例 #5
0
 /// <summary>
 /// 清理数据文件
 /// </summary>
 internal void ClearData()
 {
     ExcelData.Clear();
     JsonData.Clear();
     TemplateData.Clear();
     MultipleJsonData.Clear();
     MultipleTemplateData.Clear();
     ErrorLog.Clear();
 }
コード例 #6
0
 public override void save(string path)
 {
     if (m_PreRoot.Count > 0)
     {
         throw new Exception(m_PreRoot.Count.ToString());
     }
     File.WriteAllText(path, JsonMapper.ToJson(m_Root), Encoding.UTF8);
     m_Root.Clear();
     this.clear();
 }
コード例 #7
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="key"></param>
 /// <param name="data"></param>
 public static void UpdateData(string key, List <string> data)
 {
     if (data != null && data.Count > 0)
     {
         JsonData jsonData = Config[key];
         jsonData.Clear();
         foreach (var item in data)
         {
             jsonData.Add(item);
         }
     }
 }
コード例 #8
0
    void SpawnClues(string cName, int rating)
    {
        // There are 3 possible entries right now for each clue owner.
        int NUMBER_OF_OWNERS = 3;
        // Select the index we will use to select the first possible clue owner of this clue
        int firstClueOwnerIndex = Random.Range(0, NUMBER_OF_OWNERS);
        int secondClueOwnerIndex;

        // Choose the second index to use for selecting the second clue Owner of this clue
        do
        {
            secondClueOwnerIndex = Random.Range(0, NUMBER_OF_OWNERS);
        } while (secondClueOwnerIndex == firstClueOwnerIndex);


        // Create the JSON object to hold the clues Descriptions
        JsonData descriptionData = JsonMapper.ToObject(clueDescriptionsFinal.text);
        JsonData clueOwnerData   = JsonMapper.ToObject(cluePossibleOwnersFinal.text);

        int spawnIndex = Random.Range(0, spawnPoints.Count);

        GameObject tGO = Instantiate(Resources.Load(cName, typeof(GameObject)) as GameObject, spawnPoints[spawnIndex].position, Quaternion.identity);

        tGO.name = cName;
        tGO.AddComponent <ClueItem>();
        tGO.GetComponent <ClueItem>().Rating      = rating;
        tGO.GetComponent <ClueItem>().ItemName    = cName;
        tGO.GetComponent <ClueItem>().Description = descriptionData["Clues"][cName][0].ToString();
        tGO.GetComponent <ClueItem>().ClueOwner1  = clueOwnerData["Clues"][MurderLocation][MurderMethod][cName][firstClueOwnerIndex].ToString();
        tGO.GetComponent <ClueItem>().ClueOwner2  = clueOwnerData["Clues"][MurderLocation][MurderMethod][cName][secondClueOwnerIndex].ToString();
        tGO.GetComponent <ClueItem>().Location    = spawnPoints[spawnIndex].GetComponent <SpawnPoint>().Location;
        // Position this clue to it's correct Position
        PositionClue(tGO);

        // Make the clue a child of the Ship Object
        tGO.transform.SetParent(shipTransform);

        // Check if the spawnPoint chosen has a ClueHolder script
        if (IsClueHolderObject(spawnPoints[spawnIndex]))
        {
            // Assign the ClueHolder clue field to match this specific clue Item
            spawnPoints[spawnIndex].parent.GetComponent <ClueHolder>().clue = tGO.GetComponent <ClueItem>();
        }

        // Remove the spawnPoint used from the List of usable spawnPoints
        spawnPoints.RemoveAt(spawnIndex);

        // Clear the JSONData Object
        descriptionData.Clear();
        clueOwnerData.Clear();
    }
コード例 #9
0
    JsonData returnFeiji(int count)
    {
        if (handCardsJson.Count < lastCardsCount || lastCardsCount < 6)
        {
            return(null);
        }
        int seqLen = lastCardsCount / 3;
        //起始点为lastMinLev+1
        int len = 0;
        int i   = 0;

        if (this.seqStartLev > lastMinLev)
        {
            i = seqStartLev + count;
        }
        else
        {
            i = lastMinLev + 1 + count;
        }
        JsonData result = new JsonData();

        for (; i < 12; i++)
        {
            if (levelCardsDic.ContainsKey(i) && levelCardsDic[i].Count >= 3)
            {
                if (len == 0)
                {
                    seqStartLev = i;
                }
                len++;
                //取最小3张牌
                for (int j = levelCardsDic [i].Count - 1; j >= levelCardsDic [i].Count - 3; j--)
                {
                    JsonData data = levelCardsDic [i] [j];
                    result.Add(data);
                }
                if (len >= seqLen)
                {
                    return(sortJsonData(result));
                }
            }
            else
            {
                len = 0;
                result.Clear();
            }
        }
        seqStartLev = 0;
        return(null);
    }
コード例 #10
0
    //ChooseMethod chooses the Murder method based on what the location is.
    public string ChooseMethod(string location)
    {
        JsonData methodData = JsonMapper.ToObject(methodsFinal.text);

        // Pick a random number between 0 an 1 because right now each room only has two possible methods
        int index = ChooseID(0, 1);
        // TODO Review this. Is this a modular approach to picking methods based off of the location room chosen?
        string method = methodData["Location"][_murderLocation][0].ToString();

        // Clear the JsonData Object
        methodData.Clear();

        return(method);
    }
コード例 #11
0
        public virtual void OnDestroy()
        {
            _shopReady = false;

            if (_JsonProductInfo != null)
            {
                _JsonProductInfo.Clear();
            }

            if (_DicProduct != null)
            {
                _DicProduct.Clear();
            }
        }
コード例 #12
0
        public void PropertiesOrderTest()
        {
            JsonData data = new JsonData();
            string   json = "{\"first\":\"one\",\"second\":\"two\",\"third\":\"three\",\"fourth\":\"four\"}";

            for (int i = 0; i < 10; i++)
            {
                data.Clear();
                data["first"]  = "one";
                data["second"] = "two";
                data["third"]  = "three";
                data["fourth"] = "four";
                Assert.AreEqual(json, data.ToJson());
            }
        }
コード例 #13
0
    //返回顺子
    JsonData returnShunzi(int count)
    {
        if (handCardsJson.Count < lastCardsCount && lastCardsCount < 5)
        {
            return(null);
        }

        //起始点为lastMinLev+1

        JsonData result = new JsonData();
        int      len    = 0;
        int      i      = 0;

        if (this.seqStartLev > lastMinLev)
        {
            i = seqStartLev + count;
        }
        else
        {
            i = lastMinLev + 1 + count;
        }
        for (; i < 12; i++)
        {
            if (levelCardsDic.ContainsKey(i))
            {
                if (len == 0)
                {
                    seqStartLev = i;
                }
                len++;
                //取最小牌
                JsonData data = levelCardsDic [i] [levelCardsDic [i].Count - 1];
                result.Add(data);
                if (len >= lastCardsCount)
                {
                    return(sortJsonData(result));
                }
            }
            else
            {
                len = 0;
                result.Clear();
            }
        }
        seqStartLev = 0;
        return(null);
    }
コード例 #14
0
    public string ChooseLocation()
    {
        JsonData locationData = JsonMapper.ToObject(locationsFinal.text);

        // For now only two rooms are available and they are the only entry located on either the Cook or the Engineer in the json file.
        // so randomRoomID will equal 0
        int randomRoomID = 0;

        // Return the location found according to the value stored in _victimTitle;
        //string location = locationData ["Victim"] [0] ["Engineer"] [0].ToString();
        string location = locationData["Victim"][_victim.Title][randomRoomID].ToString();

        // Clear the JsonData Object
        locationData.Clear();

        return(location);
    }
コード例 #15
0
ファイル: AreaController.cs プロジェクト: yidabash1/YiDaBus
        private JsonData GetChild(List <AreaEntity> data, string F_Id)
        {
            var      childData = data.Where(t => t.F_ParentId == F_Id);
            JsonData arrChild  = new JsonData();

            arrChild.Add(null);
            arrChild.Clear();
            foreach (var citem in childData)
            {
                JsonData Child = new JsonData();
                Child["id"]       = citem.F_Id;
                Child["text"]     = citem.F_FullName;
                Child["layer"]    = citem.F_Layers;
                Child["children"] = GetChild(data, citem.F_Id);
                arrChild.Add(Child);
            }
            return(arrChild);
        }
コード例 #16
0
        public ActionResult GetTreeSelectJson(string enCode)
        {
            JsonData r = new JsonData();

            r.Add(null);
            r.Clear();
            var data = itemsDetailApp.GetItemList(enCode);

            foreach (ItemsDetailEntity item in data)
            {
                JsonData boot = new JsonData();
                boot["id"]     = item.F_ItemName;
                boot["text"]   = item.F_ItemName;
                boot["elment"] = item.F_ItemName;
                r.Add(boot);
            }
            return(Content(JsonMapper.ToJson(r)));
        }
コード例 #17
0
        private void button2_Click(object sender, EventArgs e)
        {
            JsonData data = new JsonData();

            string json = "{\"first\":\"one\",\"second\":\"two\"," +
                          "\"third\":\"three\",\"fourth\":\"four\"}";

            for (int i = 0; i < 10; i++)
            {
                data.Clear();

                data["first"]  = "one";
                data["second"] = "two";
                data["third"]  = "three";
                data["fourth"] = "four";

                json += data.ToJson();
            }
        }
コード例 #18
0
    public void LoadNoteData(string filePath)
    {
        TextAsset  textAsset  = Resources.Load("Data/Notes/" + filePath) as TextAsset;
        TextReader textReader = new StringReader(textAsset.text);

        //FileStream file = new FileStream("./note.json", FileMode.Open);
        //StreamReader reader = new StreamReader(file);

        if (m_noteData != null)
        {
            m_noteData.Clear();
        }
        m_noteData = JsonMapper.ToObject(textAsset.text);
        //m_noteData = JsonMapper.ToObject(reader.ReadToEnd());

        m_bpm       = (int)m_noteData["BPM"];
        m_maxBeat   = (int)m_noteData["MaxBeat"];
        m_noteCount = (int)m_noteData["NoteCount"];
    }
コード例 #19
0
ファイル: AreaController.cs プロジェクト: yidabash1/YiDaBus
        public ActionResult GetTreeSelectJson3()
        {
            OperatorModel     op   = OperatorProvider.Provider.GetCurrent();
            List <AreaEntity> data = areaApp.GetList();
            var treeList           = new List <TreeSelectModel>();

            if (string.IsNullOrEmpty(op.F_Area) || op.F_Area.Contains("上海市"))
            {
                foreach (AreaEntity item in data)
                {
                    TreeSelectModel treeModel = new TreeSelectModel();
                    treeModel.id       = item.F_Id;
                    treeModel.text     = item.F_FullName;
                    treeModel.parentId = item.F_ParentId;
                    treeList.Add(treeModel);
                }
                return(Content(treeList.TreeSelectJson2()));
            }
            else
            {
                JsonData r = new JsonData();
                r.Add(null);
                r.Clear();
                foreach (AreaEntity item in data)
                {
                    if (op.F_Area.Contains(item.F_FullName))
                    {
                        JsonData boot = new JsonData();
                        boot["id"]     = item.F_FullName;
                        boot["text"]   = item.F_FullName;
                        boot["elment"] = item.F_FullName;
                        r.Add(boot);
                    }
                }
                return(Content(JsonMapper.ToJson(r)));
            }
        }
コード例 #20
0
ファイル: AreaController.cs プロジェクト: yidabash1/YiDaBus
        public ActionResult GetTreeSelectJson1()
        {
            JsonData r = new JsonData();

            r.Add(null);
            r.Clear();
            var data     = areaApp.GetList();
            var treeList = new List <TreeSelectModel>();

            var BootData = data.Where(t => t.F_ParentId == "0");

            foreach (AreaEntity item in BootData)
            {
                JsonData boot = new JsonData();
                boot["id"]     = item.F_FullName;
                boot["text"]   = item.F_FullName;
                boot["elment"] = item.F_FullName;

                var      childData = data.Where(t => t.F_ParentId == item.F_Id);
                JsonData arrChild  = new JsonData();
                arrChild.Add(null);
                arrChild.Clear();
                foreach (var citem in childData)
                {
                    JsonData Child = new JsonData();
                    Child["id"]     = citem.F_FullName;
                    Child["text"]   = citem.F_FullName;
                    Child["elment"] = citem.F_FullName;
                    arrChild.Add(Child);
                }
                boot["children"] = arrChild;
                r.Add(boot);
            }

            return(Content(JsonMapper.ToJson(r)));
        }
コード例 #21
0
ファイル: Events.cs プロジェクト: mansuiki/ListenAround
        void Start()
        {
            socket = Socket.Connect(serverUrl);

            socket.On("getq", (string data) => {
                //Debug.Log(data);
                quart = JsonMapper.ToObject(data);
                player.GetComponent <CapsuleManager>().rotate(float.Parse(quart["roll"].ToString()),
                                                              float.Parse(quart["pitch"].ToString()),
                                                              float.Parse(quart["yaw"].ToString()));
                //player.GetComponent<CapsuleManager>().walk(float.Parse(quart[1]["x"].ToString()), float.Parse(quart[1]["y"].ToString()), float.Parse(quart[1]["z"].ToString()));
                quart.Clear();
            });

            socket.On("walk", (string data) =>
            {
                Debug.Log(data);
                player.transform.Translate(120, 0, 0);
                //walks = data;
            });

            socket.On("navigate", (string data) =>
            {
                Debug.Log(data);
                player.GetComponent <pathFind>().root = int.Parse(data);
                //walks = data;
            });

            /*socket.On("geto", (string data) => {
             *  Debug.Log(data);
             *  accer = JsonMapper.ToObject(data);
             * float x = float.Parse(accer[0]["vx"].ToString());
             * float y = float.Parse(accer[0]["vy"].ToString());
             *  player.GetComponent<CapsuleManager>().LocSet(x, y);
             * });*/
        }
コード例 #22
0
 private void CopyJsonData()
 {
     //重新绑定引用(更换attachment之后顶点动画引用丢失的情况)
     //1.把当前装备所替换的attachment保存起来,再分别找到各个attachment在当前装备json中的顶点动画数据。
     //2.把各个attachment的顶点动画数据复制到roleJson中。
     //3.利用新的roleJson生成新的动画并和新的attachment进行绑定。(可以用litjson插件替换json里面的数据)
     while (true)
     {
         lock (lockd) {
             isFinshedThread = false;
             Dictionary <string, JsonData> dic = new Dictionary <string, JsonData> ();
             JsonData allDataFromEquipment     = JsonMapper.ToObject(equipmentJson);
             JsonData animDataFromEquipment    = allDataFromEquipment.TryGetData("animations");
             string[] animNamesFromEquipment   = new string[animDataFromEquipment.Count];
             animDataFromEquipment.Keys.CopyTo(animNamesFromEquipment, 0);
             //1.先从当前装备的json中拿出来
             for (int i = 0; i < slotAttachmentNameList.Count; i++)
             {
                 for (int j = 0; j < animDataFromEquipment.Count; j++)
                 {
                     JsonData deformData = animDataFromEquipment[j].TryGetData("deform");
                     if (null != deformData)
                     {
                         JsonData slotData = deformData.TryGetData(SpineConstValue.defaultSkinName).TryGetData(slotAttachmentNameList[i].Split('$') [0]);
                         if (null != slotData)
                         {
                             JsonData attachmentData = slotData.TryGetData(slotAttachmentNameList[i].Split('$') [1]);
                             dic.Add(animNamesFromEquipment[j] + "$deform$" + SpineConstValue.defaultSkinName + "$" + slotAttachmentNameList[i].Split('$') [0] + "$" + slotAttachmentNameList[i].Split('$') [1], attachmentData);
                         }
                     }
                 }
             }
             //2.重新组装到roleJson中
             JsonData allDataFromRoleJson = JsonMapper.ToObject(animationData.roleJsonStr);
             foreach (KeyValuePair <string, JsonData> keyValue in dic)
             {
                 JsonData animsData = allDataFromRoleJson.TryGetData("animations");
                 string[] keys      = keyValue.Key.Split('$');
                 int      length    = keys.Length;
                 if (null != animsData)
                 {
                     for (int i = 0; i < length; i++)
                     {
                         animsData = animsData.TryGetData(keys[i]);
                         if (null != animsData)
                         {
                             if (i >= length - 1)
                             {
                                 //string newJsonStr = keyValue.Value.ToJson ().Substring (1, keyValue.Value.ToJson ().Length - 2);
                                 animsData.Clear();
                                 for (int j = 0; j < keyValue.Value.Count; j++)
                                 {
                                     animsData.Add(keyValue.Value[j]);
                                 }
                                 //animsData.Add (keyValue.Value.TryGetData());
                             }
                             continue;
                         }
                         else
                         {
                             break;
                         }
                     }
                 }
             }
             //3.刷新json
             animationData.roleJsonStr = allDataFromRoleJson.ToJson();
             isFinshedThread           = true;
             break;
         }
     }
 }
コード例 #23
0
ファイル: SettingJson.cs プロジェクト: zhoulk/ETBrainSecond
 /// <summary>
 /// 清空所有配置项。
 /// </summary>
 public void RemoveAllSettings()
 {
     m_PlayerPrefs.Clear();
 }
コード例 #24
0
ファイル: JsonDataWrapper.cs プロジェクト: zjljxsc/cshotfix
 public static void Clear(JsonData m_JsonData)
 {
     m_JsonData.Clear();
 }
コード例 #25
0
 public ChartManager ClearChartListCache()
 {
     chartListJsonData.Clear();
     return(this);
 }
コード例 #26
0
 public void Clear()
 {
     mJsonData.Clear();
 }
コード例 #27
0
    //返回飞机带对子
    JsonData returnFeijiTakeDuizi(int count)
    {
        if (handCardsJson.Count < lastCardsCount || lastCardsCount < 10)
        {
            return(null);
        }
        //连续长度
        int seqLen = lastCardsCount / 5;
        //copy对象
        Dictionary <int, JsonData> cardsLevDic = new Dictionary <int, JsonData> (this.levelCardsDic);
        int len = 0;
        int ii  = 0;

        if (this.seqStartLev > lastMinLev)
        {
            ii = seqStartLev + count;
        }
        else
        {
            ii = lastMinLev + 1 + count;
        }
        JsonData result = new JsonData();

        result.SetJsonType(JsonType.Array);
        JsonData keyResult = new JsonData();

        for (; ii < 12; ii++)
        {
            if (cardsLevDic.ContainsKey(ii) && cardsLevDic[ii].Count >= 3)
            {
                if (len == 0)
                {
                    seqStartLev = ii;
                }
                len++;
                //取最小3张牌
                for (int j = cardsLevDic [ii].Count - 1; j >= cardsLevDic [ii].Count - 3; j--)
                {
                    JsonData data = cardsLevDic [ii] [j];
                    result.Add(data);
                }
                keyResult.Add(ii);
                if (len >= seqLen)
                {
                    sortJsonData(result);
                    //删除取出的牌
                    for (int k = 0; k < keyResult.Count; k++)
                    {
                        cardsLevDic.Remove((int)keyResult [k]);
                    }
                    break;
                }
            }
            else
            {
                len = 0;
                result.Clear();
                keyResult.Clear();
            }
        }
        if (len < seqLen)
        {
            len         = 0;
            seqStartLev = 0;
            result.Clear();
            keyResult.Clear();
        }
        //从剩下的牌里抽取N张最小的牌
        if (result.Count > 0)
        {
            //检查对子
            if (typeLevelsDic.ContainsKey(CardsType.Duizi) && seqLen > 0)
            {
                for (int i = typeLevelsDic[CardsType.Duizi].Count - 1; i >= 0; i--)
                {
                    int lev = typeLevelsDic [CardsType.Duizi] [i];

                    JsonData duizi = cardsLevDic [lev];
                    for (int k = 0; k < duizi.Count; k++)
                    {
                        result.Add(duizi [k]);
                    }
                    seqLen--;
                    if (seqLen <= 0)
                    {
                        return(sortJsonData(result));
                    }
                }
            }
            //检查三张
            if (typeLevelsDic.ContainsKey(CardsType.Three) && seqLen > 0)
            {
                for (int i = typeLevelsDic[CardsType.Three].Count - 1; i >= 0; i--)
                {
                    int lev = typeLevelsDic [CardsType.Three] [i];

                    JsonData three = cardsLevDic [lev];
                    for (int k = three.Count - 1; k >= 1; k--)
                    {
                        result.Add(three [k]);
                    }
                    seqLen--;
                    if (seqLen <= 0)
                    {
                        return(sortJsonData(result));
                    }
                }
            }
        }
        return(null);
    }
コード例 #28
0
    /// <summary>
    /// 获取微信用户基本信息
    /// API参考:https://mp.weixin.qq.com/wiki/14/bb5031008f1494a59c6f71fa0f319c66.html
    /// </summary>
    /// <param name="wxUsers"></param>
    public static void RefreshWxUserInfo(List <WeChatUser> wxUsers)
    {
        string   wxUserInfoAPI = string.Format(@"https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token={0}", WxJSAPI.GetAccessToken());
        string   recvMsg;
        JsonData jUserList = new JsonData(), jUserInfoList = new JsonData(), jUser;

        jUserList["user_list"] = new JsonData();
        for (int i = 0; i < wxUsers.Count; i++)
        {
            jUser           = new JsonData();
            jUser["openid"] = wxUsers[i].OpenID;
            jUserList["user_list"].Add(jUser);

            //一次最多拉取100个用户的微信信息
            if (jUserList["user_list"].Count == 100 || i == (wxUsers.Count - 1))
            {
                recvMsg       = HttpService.Post(jUserList.ToJson(), wxUserInfoAPI, false, Config.WeChatAPITimeout);
                jUserInfoList = JsonMapper.ToObject(recvMsg);

                //用获取的信息刷新形参
                if (jUserInfoList != null && jUserInfoList.Keys.Contains("user_info_list") && jUserInfoList["user_info_list"].IsArray)
                {
                    //遍历拉取的微信用户JSON消息包,并刷新形参
                    for (int j = 0; j < jUserInfoList["user_info_list"].Count; j++)
                    {
                        if (jUserInfoList["user_info_list"][j].Keys.Contains("subscribe") && jUserInfoList["user_info_list"][j].Keys.Contains("openid"))
                        {
                            WeChatUser user = wxUsers.Find(wxUser =>
                            {
                                if (wxUser.OpenID == jUserInfoList["user_info_list"][j]["openid"].ToString())
                                {
                                    return(true);
                                }
                                return(false);
                            });

                            if (user != default(WeChatUser))
                            {
                                //此用户关注公众号,则返回详细信息
                                if (jUserInfoList["user_info_list"][j]["subscribe"].ToString() == "1")
                                {
                                    user.IsSubscribe = true;
                                    user.NickName    = jUserInfoList["user_info_list"][j].Keys.Contains("nickname") ? jUserInfoList["user_info_list"][j]["nickname"].ToString() : user.NickName;
                                    user.Sex         = jUserInfoList["user_info_list"][j].Keys.Contains("sex") ? (jUserInfoList["user_info_list"][j]["sex"].ToString() == "1" ? true : false) : user.Sex;
                                    user.Country     = jUserInfoList["user_info_list"][j].Keys.Contains("country") ? jUserInfoList["user_info_list"][j]["country"].ToString() : user.Country;
                                    user.Province    = jUserInfoList["user_info_list"][j].Keys.Contains("province") ? jUserInfoList["user_info_list"][j]["province"].ToString() : user.Province;
                                    user.City        = jUserInfoList["user_info_list"][j].Keys.Contains("city") ? jUserInfoList["user_info_list"][j]["city"].ToString() : user.City;
                                    user.HeadImgUrl  = jUserInfoList["user_info_list"][j].Keys.Contains("headimgurl") ? jUserInfoList["user_info_list"][j]["headimgurl"].ToString() : user.HeadImgUrl;
                                    user.UnionID     = jUserInfoList["user_info_list"][j].Keys.Contains("unionid") ? jUserInfoList["user_info_list"][j]["unionid"].ToString() : user.UnionID;
                                }
                                else
                                {
                                    user.IsSubscribe = false;
                                    user.UnionID     = jUserInfoList["user_info_list"][j].Keys.Contains("unionid") ? jUserInfoList["user_info_list"][j]["unionid"].ToString() : user.UnionID;
                                }
                            }
                        }
                    }
                }

                jUserList.Clear();
            }
        }
    }
コード例 #29
0
 public void CleanJson()
 {
     jsonData.Clear();
     Debug.Log("清空存档文件");
 }