Ejemplo n.º 1
0
    protected IEnumerator CoLoadDataFromServer <T>(string hID, string strPHPName, System.Action <bool, T> OnFinishLoad, params StringPair[] arrParameter)
    {
        bool   bSuccess    = true;
        T      pData       = default(T);
        string strTypeName = typeof(T).ToString();
        WWW    www         = GetWWW(hID, strPHPName, strTypeName, arrParameter);

        yield return(www);

        //Debug.Log(strPHPName + " result : " + www.text);

        List <T> listOutData = new List <T>();

        bSuccess = www.error == null;
        try
        {
            bSuccess = SCManagerParserJson.DoReadJsonArray <T>(www, ref listOutData);
            if (listOutData.Count > 0)
            {
                pData = listOutData[0];
            }
        }
        catch
        {
            bSuccess = false;
        }

        if (bSuccess == false)
        {
            Debug.Log("DBParser Error " + www.text + " php : " + strPHPName + " TableName : " + strTypeName);
        }

        if (OnFinishLoad != null)
        {
            OnFinishLoad(bSuccess, pData);
        }

        yield break;
    }
Ejemplo n.º 2
0
    public IEnumerator CoLoadDataListFrom_Array <T>(string hID, string strPHPName, System.Action <bool, T[]> OnFinishLoad, params StringPair[] arrParameter)
    {
        bool   bSuccess    = true;
        string strTypeName = typeof(T).ToString();
        WWW    www         = GetWWW(hID, strPHPName, strTypeName, arrParameter);

        yield return(www);

        T[] arrOutData = null;
        bSuccess = www.error == null;
        try
        {
            bSuccess = SCManagerParserJson.DoReadJsonArray <T>(www, out arrOutData);
        }
        catch
        {
            bSuccess = false;
        }

        if (bSuccess == false)
        {
            Debug.Log("DBParser Warning " + www.text + " php : " + strPHPName + " TableName : " + strTypeName, null);
        }

        if (arrOutData == null)
        {
            arrOutData = new T[0];
        }

        if (OnFinishLoad != null)
        {
            OnFinishLoad(bSuccess, arrOutData);
        }

        yield break;
    }
Ejemplo n.º 3
0
    public IEnumerator CoLoadDataListFrom_Array <T>(string hID, string strPHPName, delDBRequest_GenericArray <T> OnFinishLoad, params StringPair[] arrParameter)
    {
        string strTableName = typeof(T).Name;

        if (p_Event_DB_OnRequest_Start != null)
        {
            p_Event_DB_OnRequest_Start(strTableName, arrParameter);
        }

        //UnityEngine.Networking.UnityWebRequest www;
        WWW  www;
        int  iRequestCount = 0;
        bool bSuccess;

        while (true)
        {
            bSuccess = true;
            www      = GetWWW(hID, strPHPName, strTableName, arrParameter);
            yield return(www);

            //www = GetWWWNew( hID, strPHPName, strTableName, arrParameter );
            //yield return www.SendWebRequest();

            T[] arrOutData = null;
            bSuccess = www.error == null;
            try
            {
                bSuccess = SCManagerParserJson.DoReadJsonArray <T>(www, out arrOutData);
            }
            catch
            {
                bSuccess = false;
            }

            if (OnFinishLoad == null)
            {
                break;
            }
            else if (OnFinishLoad(bSuccess, ++iRequestCount, arrOutData))
            {
                break;
            }
        }

        if (bSuccess == false)
        {
            Debug.Log("DBParser Warning " + www.text + " php : " + strPHPName + " TableName : " + strTableName + " iRequestCount : " + iRequestCount, null);
            //Debug.Log( "DBParser Warning " + www.downloadHandler.text + " php : " + strPHPName + " TableName : " + strTableName + " iRequestCount : " + iRequestCount, null );
            for (int i = 0; i < arrParameter.Length; i++)
            {
                Debug.LogWarning(string.Format("Key{0} : {1}, Value{2} : {3} ", i, arrParameter[i].strKey, i, arrParameter[i].strValue));
            }
        }

        if (p_Event_DB_OnRequest_Finish != null)
        {
            p_Event_DB_OnRequest_Finish(strTableName, arrParameter);
        }

        yield break;
    }
Ejemplo n.º 4
0
    protected IEnumerator CoLoadDataFromServer <T>(string hID, string strPHPName, delDBRequest_Generic <T> OnFinishLoad, params StringPair[] arrParameter)
    {
        T      pData        = default(T);
        string strTableName = typeof(T).ToString();

        if (p_Event_DB_OnRequest_Start != null)
        {
            p_Event_DB_OnRequest_Start(strTableName, arrParameter);
        }

        int  iRequestCount = 0;
        WWW  www;
        bool bSuccess = true;

        while (true)
        {
            bSuccess = true;
            www      = GetWWW(hID, strPHPName, strTableName, arrParameter);
            yield return(www);

            //Debug.Log(strPHPName + " result : " + www.text);

            List <T> listOutData = new List <T>();
            bSuccess = www.error == null;
            try
            {
                bSuccess = SCManagerParserJson.DoReadJsonArray <T>(www, ref listOutData);
                pData    = listOutData[0];
            }
            catch
            {
                bSuccess = false;
            }


            if (OnFinishLoad == null)
            {
                break;
            }
            else if (OnFinishLoad(bSuccess, ++iRequestCount, pData))
            {
                break;
            }
        }

        if (bSuccess == false)
        {
            Debug.LogWarning("[DBParser Error] RequestCount : " + iRequestCount + " php : " + strPHPName + " TableName : " + strTableName + " Error : " + www.text);
            for (int i = 0; i < arrParameter.Length; i++)
            {
                Debug.LogWarning(string.Format("Key{0} : {1}, Value{2} : {3} ", i, arrParameter[i].strKey, i, arrParameter[i].strValue));
            }
        }

        if (p_Event_DB_OnRequest_Finish != null)
        {
            p_Event_DB_OnRequest_Finish(strTableName, arrParameter);
        }

        yield break;
    }