public void AddTransaction(int AccountId, int AccountSortCodeId, int ProductId, bool IsActive) { try { int id; if (TableBinary.Rows.Count == 0) { id = 0; } else { id = Convert.ToInt32(TableBinary.Compute("MAX([Id])", "")); } id = id + 1; using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Append))) { writer.Write(GetTransactionBytes(id, AccountId, AccountSortCodeId, ProductId, IsActive), 0, Size_Block); TableBinary.Rows.Add(id, AccountId, AccountSortCodeId, ProductId, IsActive); } } catch (Exception e) { MessageBox.Show(e.ToString()); } }
private void AddTransaction(int AccountId, int AccountSortCodeId, int ProductId, bool IsActive) { try { if (TableBinary.Rows.Count == 0) { Id = 0; } else { Id = Convert.ToInt32(TableBinary.Compute("MAX([Id])", "")); } Id = Id + 1; Chunk = GetTransactionBytes(Id, AccountId, AccountSortCodeId, ProductId, IsActive); using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Append))) { writer.Write(Chunk, 0, Size_Chunk); TableBinary.Rows.Add(Id, AccountId, AccountSortCodeId, ProductId, IsActive); } } catch (Exception e) { MessageBox.Show(e.ToString()); } }
public new static CharacterSO ConvertRow(TableRow row, CharacterSO scriptableObject) { CharacterSO character = scriptableObject ? scriptableObject : CreateInstance <CharacterSO>(); if (row.Fields.Count == 0) { return(character); } DatabaseConfig config = TableBinary.Fetch(); if (config != null) { character.ID = row.RowId; var entryId = (character.ID + 1).ToString(); if (!character.characterName.IsEmpty) { character.characterName.TableEntryReference = entryId; } } foreach (var field in row.Fields) { if (field.Key.Equals("id")) { character.ID = uint.Parse(field.Value.Data); } } return(character); }
private void Add_Products(int AccountId, int AccountSortCodeId, string paraStringProductId) { string[] strings = paraStringProductId.Trim().Split(','); DataRow[] drs; if (AccountId > 0) { foreach (string str in strings) { drs = TableBinary.Select(string.Format("AccountId = {0} AND AccountSortCodeId = 0 AND ProductId = {1} AND IsActive = 1", AccountId, Convert.ToInt32(str))); if (drs.Length == 0) { AddTransaction(AccountId, 0, Convert.ToInt32(str), true); } } } if (AccountSortCodeId > 0) { foreach (string str in strings) { drs = TableBinary.Select(string.Format("AccountId = 0 AND AccountSortCodeId = {0} AND ProductId = {1} AND IsActive = 1", AccountSortCodeId, Convert.ToInt32(str))); if (drs.Length == 0) { AddTransaction(0, AccountSortCodeId, Convert.ToInt32(str), true); } } } }
public void Inactivate_AccountId(int AccountId, int AccountSortCodeId) { DataRow[] drs = TableBinary.Select(string.Format("AccountId = {0} AND AccountSortCodeId = {1} AND IsActive = 1", AccountId, AccountSortCodeId)); foreach (DataRow dr in drs) { InactivateTransaction(dr.Field <int>("Id")); } }
public new static StorySO ConvertRow(TableRow row, StorySO scriptableObject = null) { StorySO story = scriptableObject ? scriptableObject : CreateInstance <StorySO>(); if (row.Fields.Count == 0) { return(story); } DatabaseConfig config = TableBinary.Fetch(); if (config != null) { story.ID = row.RowId; var entryId = (story.ID + 1).ToString(); if (!story.title.IsEmpty) { story.title.TableEntryReference = entryId; } if (!story.Description.IsEmpty) { story.Description.TableEntryReference = entryId; } } foreach (var field in row.Fields) { if (field.Key.Equals("id")) { uint data = (uint)field.Value.Data; story.ID = data == uint.MaxValue - 1 ? uint.MaxValue : data; } // Fetch the first dialogue we should start if (field.Key.Equals("childId")) { // retrieve the necessary items uint data = (uint)field.Value.Data; story.childId = data == uint.MaxValue - 1 ? uint.MaxValue : data; } if (field.Key.Equals("parentId")) { // retrieve the necessary items uint data = (uint)field.Value.Data; story.parentId = data == uint.MaxValue - 1 ? uint.MaxValue : data; } if (field.Key.Equals("typeId")) { story.typeId = (StoryType)field.Value.Data; } } return(story); }
public TableBinary GetBinary(string tableName) { if (!_Binaries.ContainsKey(tableName)) { TableBinary bin = new TableBinary(tableName); _Binaries.Add(tableName, bin); } return(_Binaries[tableName]); }
public Table GetTable(string tableName) { if (!Data.ContainsKey(tableName)) { Data.Add(tableName, TableBinary.GetTable(tableName)); return(Data[tableName]); } return(Data[tableName]); }
public static T ConvertRow <T>(TableRow row, T scriptableObject = null) where T : ItemSO { T item = scriptableObject ? scriptableObject : CreateInstance <T>(); if (row.Fields.Count == 0) { return(item); } DatabaseConfig config = TableBinary.Fetch(); if (config != null) { item.ID = row.RowId; var entryId = (item.ID + 1).ToString(); if (!item.ItemName.IsEmpty) { item.ItemName.TableEntryReference = entryId; } if (!item.Description.IsEmpty) { item.Description.TableEntryReference = entryId; } } // public ItemType ItemType => itemType; foreach (var field in row.Fields) { if (item is ItemRecipeSO so && field.Key.Equals("childId")) { so.ChildId = (uint)field.Value.Data; } if (field.Key.Equals("sellValue")) { item.SellValue = (double)field.Value.Data; } if (field.Key.Equals("sellable")) { item.Sellable = (bool)field.Value.Data; } // TODO keep reference // if (field.Key.Equals("itemType")) // { // item.ItemType = (uint) field.Value.Data // } } return(item); }
/*Dictionary<uint, TableRow> GetRows(string tableName) * { * return GetTable(tableName).Rows; * }*/ /// <summary> /// /// </summary> /// <param name="tableName"></param> /// <param name="entityID"></param> /// <returns></returns> public TableRow GetRow(string tableName, uint entityID) { Table table = GetTable(tableName); if (!table.Rows.ContainsKey(entityID)) { TableRow r = TableBinary.GetRow(tableName, entityID); table.Rows.Add(entityID, r); return(table.Rows[entityID]); } return(table.Rows[entityID]); }
private TableDatabase() { // locate the data folder var config = TableBinary.Fetch(); if (config == null) { return; } Reload(config); // Get database version // UpdateTime(); }
protected override void Awake() { base.Awake(); m_Config = TableBinary.FetchDialogueSetting(); if (m_Config != null && useConfig) { font = m_Config.Font; enableAutoSizing = m_Config.AutoResize; if (enableAutoSizing) { // fontSizeMin = m_Config.minFontSize; // fontSizeMin = m_Config.maxFontSize; } fontSize = m_Config.DialogueFontSize; } }
public string GetProductIdString(int AccountId, int AccountSortCodeId) { DataRow[] drs; string str = ""; drs = TableBinary.Select(string.Format("AccountId = {0} AND AccountSortCodeId = {1} AND IsActive = 1", AccountId, AccountSortCodeId)); foreach (DataRow dr in drs) { str = str + dr.Field <int>("ProductId").ToString() + ", "; } if (str.Length > 0) { str = str.Substring(0, str.Length - 2); } else { str = ""; } return(str); }
private void OnResponseReceived(UnityWebRequest request, string tableID = "") { // FetchNotification->SetCompletionState(bWasSuccessful? SNotificationItem::CS_Success : SNotificationItem::CS_Fail); // FetchNotification->ExpireAndFadeout(); if (request.result == UnityWebRequest.Result.ConnectionError || request.responseCode == 401 || request.responseCode == 500) { Debug.Log("Error: " + request.error); Debug.Log("Error: " + request.downloadHandler.text); _canFetch = true; return; } // Debug.Log("Received: " + request.downloadHandler.text); // Handle result string str = request.downloadHandler.text; bool hasTable = tableID != ""; // Create a pointer to hold the json serialized data if (hasTable) { var jsonToken = JToken.Parse(str); Table tableData = jsonToken.ToObject <Table>() ?? throw new ArgumentException($"Can't make Table from JSON file"); // Get table name and store it as individual data TableBinary bin = TableDatabase.Get.GetBinary(tableData.metadata.title); bin.Import(jsonToken); } else { var jsonArray = JArray.Parse(str); // now we can get the values from json of any attribute. foreach (var item in jsonArray.Children()) { Table tableData = item.ToObject <Table>(); if (tableData == null || tableData.metadata == null || tableData.metadata.title == "") { throw new ArgumentException("Can't make Table from JSON file"); } // Get table name and store it as individual data TableBinary bin = TableDatabase.Get.GetBinary(tableData.metadata.title); bin.Import(item); } } #if UNITY_EDITOR // TODO see if unity has notify system // Update editor // auto& PropertyModule = FModuleManager::LoadModuleChecked< FPropertyEditorModule >("PropertyEditor"); // PropertyModule.NotifyCustomizationModuleChanged(); #endif DatabaseConfig config = Fetch(); if (config && !string.IsNullOrEmpty(config.dataPath)) { // Update timestamp _lastTimeStamp = DateTime.Now.Ticks; string destination = $"{config.dataPath}/uptime.txt"; File.WriteAllText(destination, _lastTimeStamp.ToString()); } Debug.Log("Invoking fetch"); onFetchCompleted?.Invoke(this, EventArgs.Empty); Debug.Log("Fetching complete"); _canFetch = true; }