Example #1
0
    IEnumerator GetMessageTYB()
    {
        string url = Static.Instance.URL + Data.URL;

        if (Data.SendData.Length > 0)
        {
            //message += "?";
            foreach (SendMessage child in Data.SendData)
            {
                message += "&" + child.Name + "=" + child.SetValue();
            }
        }
        message = EncryptDecipherTool.GetListOld(message, IsLock);
        url     = url + message;
        Debug.Log(url);

        WWW www = new WWW(url);

        yield return(www);

        Data.ShowMessage = www.text;
        if (www.error != null)
        {
            Data.ShowMessage = "error code = " + www.error;
            ShowError.transform.localScale = new Vector3(1, 1, 1);
        }
        else
        {
            string jsondata = System.Text.Encoding.UTF8.GetString(www.bytes, 3, www.bytes.Length - 3);
            jsondata = jsondata.Remove(0, Data.CutCount);
            int a = 0;
            Static.Instance.DeleteFile(Application.persistentDataPath, "json.txt");
            Static.Instance.CreateFile(Application.persistentDataPath, "json.txt", jsondata);
            ArrayList infoall = Static.Instance.LoadFile(Application.persistentDataPath, "json.txt");
            String    sr      = null;
            foreach (string str in infoall)
            {
                sr += str;
            }
            JsonData jd = JsonMapper.ToObject(sr);
            Data.ShowMessage = jsondata;
            Debug.Log(jsondata);
            Data.GetBase.code   = jd.Keys.Contains("code") ? jd["code"].ToString() : "";
            Data.GetBase.result = jd.Keys.Contains("result") ? jd["result"].ToString() : "";
            Data.GetBase.msg    = jd.Keys.Contains("msg") ? jd["msg"].ToString() : "";
            if (Data.GetBase.codetext != null)
            {
                Data.GetBase.codetext.text = Data.GetBase.code;
            }
            if (Data.GetBase.resulttext != null)
            {
                Data.GetBase.resulttext.text = Data.GetBase.result;
            }
            if (Data.GetBase.msgtext != null)
            {
                Data.GetBase.msgtext.text = Data.GetBase.msg;
            }

            if (Data.GetBase.code == "1")
            {
                List <string> Savename = new List <string>();
                Dictionary <string, string> SaveMessage = new Dictionary <string, string>();

                foreach (string child in jd[Data.DataName].Keys)
                {
                    Savename.Add(child);
                }

                for (int i = 0; i < jd[Data.DataName].Count; i++)
                {
                    if (jd [Data.DataName] [i] == null)
                    {
                        Data.BackData.Add("null");
                    }
                    else
                    {
                        Data.BackData.Add(jd [Data.DataName] [i].ToString());
                    }

                    SaveMessage.Add(Savename[i], Data.BackData[i]);
                    Data.GetData(Savename[i], Data.BackData[i]);
                }
                if (Data.Action)
                {
                    foreach (GetData child in Data.BackDataGet)
                    {
                        string obj = null;
                        SaveMessage.TryGetValue(child.ShowData, out obj);

                        if (child.IsSave)
                        {
                            Static.Instance.AddValue(child.ShowData, obj);
                        }
                        if (child.GetDataObj != null)
                        {
                            child.GetDataObj.text = obj;
                        }
                    }
                }
            }

            if (Data.GetBase.code == "2")
            {
                GameObject.Find("ErrorRestart").SendMessage("Restart", Data.GetBase.msg);
            }
            if (Data.GetBase.code == "1")
            {
                Suc.Invoke();
            }
            else
            {
                Fal.Invoke();
            }
        }
        if (BusinessInfoHelper.Instance != null)
        {
            BusinessInfoHelper.Instance.isDone = true;
        }
        ShowLoad.transform.localScale = new Vector3(0, 0, 0);
    }