/// <summary> /// Executes the non query. /// </summary> /// <param name="query">Query.</param> public void ExecuteNonQuery(string query) { if (!canQuery) { HDebug.LogWarning("Can't execute the query, verify DB origin file"); return; } if (!isConnectionOpen) { Open(pathDB); } #if !UNITY_WEBPLAYER if ((ConnectionState)dbconn.State != ConnectionState.Open) { HDebug.LogWarning("Sqlite DB is not open"); return; } dbcmd.CommandText = query; try { dbcmd.ExecuteNonQuery(); } catch (Exception e) { HDebug.Log("Query : " + query); HDebug.LogError(e.Message); return; } #endif if (!isConnectionOpen) { Close(); } }
/// <summary> /// Debug the specified data and www. /// </summary> /// <param name="data">Data.</param> /// <param name="www">Www.</param> protected void LogDownload(AssetBundleData data, object obj) { if (obj == null) { return; } time = Time.time - time; if (!debug) { return; } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.AppendFormat("[Download time] {0}\n[URL] {1}\n[Version] {2}\n", time, data.url, data.version); #if UNITY_5_4_OR_NEWER UnityEngine.Networking.UnityWebRequest www = obj as UnityEngine.Networking.UnityWebRequest; #else WWW www = obj as WWW; #endif if (www.error != null) { stringBuilder.AppendFormat("[WWW.error]\n{0}\n", www.error); HDebug.LogError(stringBuilder.ToString()); } else { HDebug.Log(stringBuilder.ToString()); } }
/// <summary> /// Downloads the asset bundle. /// </summary> /// <param name="json">Json.</param> protected void DownloadAssetBundle(string json) { assetBundleData = JsonUtil.FromJson <AssetBundleInitialData> (json); if (assetBundleData._Resource.Major != Register.GetInt(assetBundleData._Resource.Name + AssetBundleInitialData.major)) { #if UNITY_EDITOR HDebug.Log("Major : " + assetBundleData._Resource.Major); #endif downloads = assetBundleData._AssetBundle; // Delete all AssetBundle. assetBundleManager.CleanCache(); } else if (assetBundleData._Resource.Minor != Register.GetInt(assetBundleData._Resource.Name + AssetBundleInitialData.minor)) { #if UNITY_EDITOR HDebug.Log("Minor : " + assetBundleData._Resource.Minor); #endif downloads = new List <AssetBundleInitialData.AssetBundle> (); for (int i = 0; i < assetBundleData._AssetBundle.Count; i++) { if (assetBundleData._AssetBundle [i]._Version != Register.GetInt(assetBundleData._AssetBundle [i].Name)) { downloads.Add(assetBundleData._AssetBundle [i]); } } } else { if (aEvent != null) { aEvent(AssetBundleInitalStatus.Over); } return; } if (aEvent != null) { aEvent(AssetBundleInitalStatus.Start); } if (downloads.Count > 0) { index = 0; DownloadAssetBundle(); } else { HDebug.LogWarning("None of this has changed assetbundle version."); Register.SetInt(assetBundleData._Resource.Name + AssetBundleInitialData.major, assetBundleData._Resource.Major); Register.SetInt(assetBundleData._Resource.Name + AssetBundleInitialData.minor, assetBundleData._Resource.Minor); if (aEvent != null) { aEvent(AssetBundleInitalStatus.Over); } } }
/// <summary> /// Executes the query. /// </summary> /// <returns>The query.</returns> /// <param name="query">Query.</param> public DataTable ExecuteQuery(string query) { if (!canQuery) { HDebug.LogWarning("Can't execute the query, verify DB origin file"); return(null); } if (!isConnectionOpen) { Open(pathDB); } #if !UNITY_WEBPLAYER if ((ConnectionState)dbconn.State != ConnectionState.Open) { HDebug.LogWarning("Sqlite DB is not open"); return(null); } dbcmd.CommandText = query; try { reader = dbcmd.ExecuteReader(); } catch (Exception e) { HDebug.Log("Query : " + query); HDebug.LogError(e.Message); return(null); } #endif DataTable dataTable = new DataTable(); #if !UNITY_WEBPLAYER for (int i = 0; i < reader.FieldCount; i++) { dataTable.Columns.Add(reader.GetName(i)); } while (reader.Read()) { DataRow row = new DataRow(); for (int i = 0; i < reader.FieldCount; i++) { row.Add(reader.GetName(i), reader.GetValue(i)); } dataTable.Rows.Add(row); } #endif if (!isConnectionOpen) { Close(); } return(dataTable); }
/// <summary> /// Debug the specified data and www. /// warring is timeover /// </summary> /// <param name="data">Data.</param> /// <param name="www">Www.</param> protected void Log() { time = Time.time - time; if (!debug) { return; } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.AppendFormat("[Request time] {0}\n[URL] {1}\n", time, data.url); if (data.headers != null) { stringBuilder.Append("[WWWForm.headers]\n"); foreach (KeyValuePair <string, string> pair in data.headers) { stringBuilder.AppendFormat("{0} : {1}\n", pair.Key, pair.Value); } stringBuilder.Append("\n"); } if (data.headers != null) { stringBuilder.Append("[WWWForm.data]\n"); foreach (KeyValuePair <string, string> pair in data.datas) { stringBuilder.AppendFormat("{0} : {1}\n", pair.Key, pair.Value); } stringBuilder.Append("\n"); } if (www == null) { HDebug.LogWarning(stringBuilder.ToString()); } else if (www.error != null) { stringBuilder.AppendFormat("[WWW.error]\n{0}\n", www.error); HDebug.LogError(stringBuilder.ToString()); } else { HDebug.Log(stringBuilder.ToString()); } }