public void saveResource(SimpleSQLManager dbManager, ResourceResp response) { ConfigRow configRow = LoadConfig(dbManager); if (response.latestVersion > configRow.ResourceVersion) { dbManager.BeginTransaction(); dbManager.Execute("UPDATE ConfigRow SET ResourceVersion = ? WHERE Id = ?", response.latestVersion, 1); Resource r; Resource[] list = response.list; for (int i = 0; i < list.Length; i++) { r = list[i]; dbManager.Execute("DELETE FROM ResourceRow WHERE Code = ? AND Lan = ?", r.code, r.lan); dbManager.Insert(new ResourceRow { Code = r.code, Lan = r.lan, Desc = r.desc }); } dbManager.Commit(); Debug.Log(list.Length + " ResourceRow records updated."); } }
private static int DbContainsCollumns(string dbName, string collumn, SimpleSQLManager db) { int result; try { bool flag = false; string query = "pragma table_info(\"" + dbName + "\")"; List <DatabaseValidator.TableInfo> list = db.Query <DatabaseValidator.TableInfo>(query, new object[0]); foreach (DatabaseValidator.TableInfo tableInfo in list) { if (tableInfo.name.Equals(collumn)) { flag = true; break; } } result = ((!flag) ? 0 : 1); } catch (Exception ex) { UnityEngine.Debug.Log(" " + ex.Message); result = -1; } return(result); }
public void CreateTables(SimpleSQLManager dbManager) { SimpleDataTable dtConfigRow = dbManager.QueryGeneric("SELECT COUNT(*) CT FROM sqlite_master where type='table' and name='ConfigRow'"); List <SimpleDataRow> simpleDataConfigRowRows = dtConfigRow.rows; if (int.Parse(simpleDataConfigRowRows[0]["CT"].ToString()) == 0) { dbManager.CreateTable <ConfigRow>(); Debug.Log("create table ConfigRow."); } SimpleDataTable dtResourceRow = dbManager.QueryGeneric("SELECT COUNT(*) CT FROM sqlite_master where type='table' and name='ResourceRow'"); List <SimpleDataRow> simpleDataResourceRowRows = dtResourceRow.rows; if (int.Parse(simpleDataResourceRowRows[0]["CT"].ToString()) == 0) { dbManager.CreateTable <ResourceRow>(); Debug.Log("create table ResourceRow."); } SimpleDataTable dtSessionRow = dbManager.QueryGeneric("SELECT COUNT(*) CT FROM sqlite_master where type='table' and name='SessionRow'"); List <SimpleDataRow> simpleDataSessionRowRows = dtSessionRow.rows; if (int.Parse(simpleDataSessionRowRows[0]["CT"].ToString()) == 0) { dbManager.CreateTable <SessionRow>(); Debug.Log("create table SessionRow."); } }
public void loadWords() { dbManager = this.gameObject.GetComponentInChildren <SimpleSQLManager>(); int activeListID = PlayerPrefs.GetInt("ActiveWordList"); words = getWords(activeListID); words.Shuffle(); Messenger.Broadcast <string>("show new word", getNextWord()); }
public SessionRow LoadSession(SimpleSQLManager dbManager) { List <SessionRow> sessionRows = dbManager.Query <SessionRow>("SELECT * FROM SessionRow WHERE Id = 1"); if (sessionRows == null || sessionRows.Count == 0) { return(null); } return(sessionRows[0]); }
//private TextAsset m_CacheBytes; private void Awake() { Debug.Log(Application.persistentDataPath); //m_CacheBytes = Resources.Load<TextAsset>("DataBases/Cache"); GameObject dbPrefab = Resources.Load <GameObject>("DBManager"); m_DbManager = Instantiate(dbPrefab, transform).GetComponent <SimpleSQLManager>(); createTable(); }
private void Awake() { if (Instance) { Destroy(gameObject); } Instance = this; dbManager = GetComponent <SimpleSQLManager>(); DontDestroyOnLoad(gameObject); }
public string GetDescByCode(SimpleSQLManager dbManager, string code, string lan) { SimpleDataTable dt = dbManager.QueryGeneric(string.Format("SELECT Desc FROM ResourceRow WHERE Code = '{0}' AND Lan = '{1}'", code, lan)); List <SimpleDataRow> simpleDataRows = dt.rows; if (dt == null || simpleDataRows == null || simpleDataRows.Count == 0) { return("-"); } return(simpleDataRows[0]["Desc"].ToString()); }
public string LoadToken(SimpleSQLManager dbManager) { SimpleDataTable dt = dbManager.QueryGeneric("SELECT Token FROM SessionRow WHERE Id = 1"); List <SimpleDataRow> simpleDataRows = dt.rows; if (dt == null || simpleDataRows == null || simpleDataRows.Count == 0) { return("-"); } return(simpleDataRows[0]["Token"].ToString()); }
public ConfigRow SaveDefaultConfig(SimpleSQLManager dbManager) { ConfigRow configRow = new ConfigRow(); configRow.Id = 1; configRow.ResourceVersion = 0; //SystemLanguage systemLanguage = Application.systemLanguage; //configRow.Lan = systemLanguage.ToString(); configRow.Lan = "Chinese"; dbManager.Insert(configRow); return(configRow); }
private new void Awake() { base.Awake(); databaseManager = GetComponentInChildren <SimpleSQLManager>(); emotionsDict = new Dictionary <RNGesus.Tools.Emotions, Emotion>(); foreach (Emotion emotion in emotions) { emotionsDict.Add(emotion.emotion, emotion); } }
public string LoadLan(SimpleSQLManager dbManager) { SimpleDataTable dt = dbManager.QueryGeneric("SELECT Lan FROM ConfigRow WHERE Id = 1"); List <SimpleDataRow> simpleDataRows = dt.rows; if (dt == null || simpleDataRows == null || simpleDataRows.Count == 0) { SaveDefaultConfig(dbManager); return("Chinese"); } return(simpleDataRows[0]["Lan"].ToString()); }
public void SaveProfile(SimpleSQLManager dbManager, LoginResp response) { dbManager.BeginTransaction(); dbManager.Execute("DELETE FROM SessionRow WHERE Id = 1"); SessionRow row = new SessionRow(); row.Id = 1; row.Token = response.token; row.Mobile = response.mobile; row.Status = response.status; row.NickName = response.nickName; dbManager.Insert(row); dbManager.Commit(); }
public ConfigRow LoadConfig(SimpleSQLManager dbManager) { ConfigRow configRow; List <ConfigRow> configRows = dbManager.Query <ConfigRow>("SELECT * FROM ConfigRow WHERE Id = 1"); if (configRows == null || configRows.Count == 0) { configRow = SaveDefaultConfig(dbManager); } else { configRow = configRows[0]; } return(configRow); }
public static void Init(SimpleSQLManager database, PicturePack pack = null, List <PictureSaveData> saves = null) { DatabaseManager.db = database; bool flag = false; if (DatabaseManager.Version == 0) { int num = DatabaseManager.CreatePicDb(); int num2 = DatabaseManager.CreateSaveDb(); if (num != -1 && num2 != -1) { DatabaseManager.Version = 1; UnityEngine.Debug.Log("initial db creation successful"); } else { UnityEngine.Debug.Log(string.Concat(new object[] { "db error picDb:", num, " saveDb:", num2 })); } flag = true; } if (DatabaseManager.Version == 1) { DatabaseManager.DbUpdateOne(); DatabaseManager.Version = 2; } if (DatabaseManager.Version == 2) { DatabaseManager.CreateGiftDb(false); DatabaseManager.Version = 3; } if (DatabaseManager.Version == 3) { DatabaseManager.CreateNewsDb(false); DatabaseManager.Version = 4; } DatabaseValidator.Validate(DatabaseManager.db); if (flag && pack != null && pack.Pictures != null) { DatabaseManager.InitialDbFill(pack, saves); } }
private static bool DbExists(string dbName, SimpleSQLManager db) { bool result; try { //string query = "SELECT * FROM " + dbName + " LIMIT 1"; //List<object> list = db.Query<object>(query, new object[0]); result = true; } catch (Exception ex) { UnityEngine.Debug.Log(dbName + " DOES NOT exist. " + ex.Message); result = false; } return(result); }
private void OnEnable() { //CASCFiles = new List<CASCFile>(); CASCFiles = new List <CASCFile>(); dbManager = GetComponent <SimpleSQLManager>(); }
protected void AddDBManager() { dbManager = GameObject.FindGameObjectWithTag("appdbmanager").GetComponent <SimpleSQLManager>(); }
public static void Validate(SimpleSQLManager db) { string text = string.Empty; if (DatabaseValidator.DbExists("PictureDb", db)) { int num = DatabaseValidator.DbContainsCollumns("PictureDb", "PicClass", db); if (num == -1) { text += "picDbUpd:-1"; UnityEngine.Debug.Log("picDb upd check error"); } else if (num == 0) { text += "picDbUpd:0"; UnityEngine.Debug.Log("picDb NOT up to date"); } } else { text += "pic:NULL|"; UnityEngine.Debug.Log("PictureDb doest not exist"); int num2 = DatabaseManager.FallbackCreatePicDb(); if (num2 == 1) { AnalyticsManager.DbRecovery("pic"); } } if (DatabaseValidator.DbExists("SaveDb", db)) { int num3 = DatabaseValidator.DbContainsCollumns("SaveDb", "HintsUsed", db); if (num3 == -1) { text += "saveDbUpd:-1"; UnityEngine.Debug.Log("saveDb upd check error"); } else if (num3 == 0) { text += "saveDbUpd:0"; UnityEngine.Debug.Log("saveDb NOT up to date"); } } else { text += "saves:NULL|"; UnityEngine.Debug.Log("SaveDb doest not exist"); int num4 = DatabaseManager.FallbackCreateSaveDb(); if (num4 == 1) { AnalyticsManager.DbRecovery("save"); } } if (!DatabaseValidator.DbExists("NewsDb", db)) { UnityEngine.Debug.Log("NewsDb doest not exist"); text += "news:NULL|"; int num5 = DatabaseManager.CreateNewsDb(true); if (num5 == 1) { AnalyticsManager.DbRecovery("news"); } } if (!DatabaseValidator.DbExists("GiftDb", db)) { UnityEngine.Debug.Log("GiftDb doest not exist"); text += "gifts:NULL|"; int num6 = DatabaseManager.CreateGiftDb(true); if (num6 == 1) { AnalyticsManager.DbRecovery("gift"); } } if (!string.IsNullOrEmpty(text)) { AnalyticsManager.DbValidationError(text); } }
public void CleanProfile(SimpleSQLManager dbManager) { dbManager.Execute("DELETE FROM SessionRow WHERE Id = 1"); SceneManager.LoadScene("login"); }