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."); } }
public override void Callback(byte[] data) { ResourceResp response = null; try { response = Serializer.Deserialize <ResourceResp>(new MemoryStream(data)); } catch (Exception) { Debug.LogError("ResourceResp parse error"); ShowMessage(ErrorCode.EC_PARSE_DATA_ERROR); } if (response != null) { switch (response.code) { case "0": { DataHelper.GetInstance().saveResource(dbManager, response); SceneManager.LoadScene("home"); break; } default: { ShowMessage(response.code); break; } } } }