/// <summary> /// Updates the word entry data in the data base and the word list dictionary as well. /// Additionally, it also saves any changes made to the audio or picture files. /// Returns true if the entry in the data base was updated successfully. /// </summary> /// <param name="word"></param> /// <returns></returns> public bool EditDbEntry(string word, string wordTags) { WordDO dataObject = wordList[word]; bool audioSuccess = true, photoSuccess = true; // Check if the audio file path and photo file paths are active if (CurrentClip != null) { dataObject.WordSound = word + ".wav"; //TODO: Fix false positive when overwriting existing files if (!SaveAudioClip()) { //TODO: Add some error handling audioSuccess = false; } } if (CurrentTexture != null) { dataObject.WordImage = word + ".png"; //TODO: Fix false positive when overwriting existing files if (SaveTextures(word) <= 0) { //TODO: add error message photoSuccess = false; } } // Adjust all the data object values to the new values dataObject.WordTags = wordTags; if (audioSuccess && photoSuccess) { if (dataService.EditWordEntry(dataObject) == 1) { wordList[word] = dataObject; return(true); } else { //TODO: error handling } } else { Debug.Log("EDITDB: AUDIO OR PHOTO SUCCESS NOT SUCCESS"); } return(false); }
/// <summary> /// Loads the word list from the data base into the class word list. /// </summary> private void LoadWordList() { WordDO tempObject; IEnumerable <Words> words = dataService.GetWordsTable(); foreach (var row in words) { tempObject = new WordDO( row.word_id, row.word_name, row.stock_custom, row.word_tags, row.word_sound, row.word_image ); wordList.Add(row.word_name, tempObject); } }
//public void DLCButton() //{ // HTTPRequest request = new HTTPRequest(new System.Uri("https://matthewriddett.com/static/mludlc/test.png"), OnRequestFinished); // request.Send(); //} //void OnRequestFinished(HTTPRequest request, HTTPResponse response) //{ // Debug.Log("Request Finished! Text received: " + response.DataAsText); // controller.SetCurrentTexture(response.DataAsTexture2D); // galleryCameraModal.SetActive(false); // saveButton.interactable = true; // CleanUpScroll(); // DisplayGallery(); //} private void SetUpWordTags() { string word = controller.GetTargetWord(); if (word == "" || word == null) { Debug.Log("no word tags found"); wordTags = ""; wordTagsText.text = wordTags; } else { WordDO dataObject = controller.GetWordDO(word); wordTags = dataObject.WordTags; Debug.Log("GetTargetWordTags = " + wordTags); wordTagsText.text = wordTags; Debug.Log("word tags = " + wordTagsText.text); } }
private void AddEditValues(string key, WordDO value) { wordList[key] = value; }
/// <summary> /// Creates a new word list entry and saves it to the database and the word list dictionary. /// Additionally, it saves any new audio or picture files. /// Returns true if saving data to the data base is successful. /// </summary> /// <param name="word"></param> /// <returns>bool</returns> public bool CreateNewDbEntry(string word, string wordTags) { string img; string sound; string tags; int rowsInserted; bool audioSuccess = true; bool photoSuccess = true; // Check if the audio file path and photo file paths are active if (CurrentClip != null) { //TODO: Fix false positive when overwriting existing files // Maybe a check between the files date metadata and the current time? audioSuccess = FileAccessUtil.SaveWordAudio(CurrentClip, word); if (!audioSuccess) { //TODO: add error checking } } if (CurrentTexture != null) { //TODO: Fix false positive when overwriting existing files // Maybe a check between the files date metadata and the current time? /* * photoSuccess = FileAccessUtil.SaveWordPic(CurrentTexture, word); * * if (!photoSuccess) * { * //TODO: add error checking * } */ SaveTextures(word); } //Save word to DB string category = "custom"; //int diff = (int)Math.Round(difficultySlider.value); //Preset Image and sound entries - This will need to be changed when adding features for an image/audio path img = word + ".png"; sound = word + ".wav"; tags = wordTags; if (audioSuccess && photoSuccess) { //Call to DB to insert the word rowsInserted = dataService.CreateWord(word, category, tags, sound, img); if (rowsInserted == 1) { // Get the newly created id of the word entry from the data base IEnumerable <Words> rows = dataService.GetLastById(); int id = 0; string check = ""; foreach (var row in rows) { id = row.word_id; check = row.word_name; } if (check.Equals(word)) { // Create a new word data object and add a new entry into the static word/WordDO dictionary WordDO dataObject = new WordDO(id, word, category, tags, sound, img); wordList[word] = dataObject; return(true); } else { //TODO: THROW AN ERROR } } } return(false); }
public int AddWordEntry(string word, WordDO wordData) { string query = "INSERT INTO Words (word_name, stock_custom, word_tags) VALUES(?, ?, ?)"; return(_connection.Execute(query, word, wordData.StockCustom, wordData.WordTags)); }
// Edits the data in a database word entry public int EditWordEntry(WordDO wordData) { string query = "UPDATE words SET stock_custom = ?, word_tags = ? WHERE word_id = ?"; return(_connection.Execute(query, wordData.StockCustom, wordData.WordTags, wordData.IdNum)); }
private void EditOrAdd() { if (controller.IsEditSettings) { Debug.Log("VW: In Edit"); // Enable wordText and disable word field wordText.SetActive(true); wordField.SetActive(false); if (!(controller.IsTextureSet() || controller.IsClipSet())) { Debug.Log("No pic or audio clip change yet"); saveButton.interactable = false; CleanUpScroll(); } if (controller.IsTextureSet() || controller.IsClipSet()) { Debug.Log("Change made to pic and/or audio clip. Save is now allowed."); saveButton.interactable = true; CleanUpScroll(); } string word = controller.GetTargetWord(); Debug.Log("Inside edit. word is = " + word); Debug.Log("Inside edit. word tags are: " + wordTags); if (word != null || word != "") { Debug.Log("attempting to load Word_DO for Word Name"); WordDO dataObject = controller.GetWordDO(word); Debug.Log("Got the Word_DO, now attempting to get the text component"); wordText.GetComponent <Text>().text = TidyCase(word); titleLabel.text = TITLE_EDIT; } else { //TODO: THROW AN ERROR Debug.Log("Error, word is null or blank. Word = " + word); } if (wordTags != null || wordTags != "") { Debug.Log("attempting to load Word_DO for Word Tags"); WordDO dataObject = controller.GetWordDO(word); Debug.Log("Got the Word_DO, now attempting to get the text component"); wordTagsText.text = wordTags; } else { //TODO: THROW AN ERROR Debug.Log("Error, wordtags is null or blank. Wordtags = " + wordTags); } } else { Debug.Log("VW: In ADD"); titleLabel.text = TITLE_ADD; string word = controller.GetTargetWord(); string wordTags = controller.GetTargetWordTags(); // Enable word field and disable word text wordField.SetActive(true); wordText.SetActive(false); wordTagsText.text = wordTags; if (controller.GetTargetWord() == null || !controller.IsTextureSet()) { saveButton.interactable = false; CleanUpScroll(); } else { saveButton.interactable = true; CleanUpScroll(); } if (word != null) { Debug.Log("VW: Setting text to " + controller.GetTargetWord()); wordFieldText.text = word; placeHolderText.text = word; } } }
/// <summary> /// Takes the word as a string and returns true if that word is in use. /// </summary> /// <param name="word"></param> /// <returns>bool</returns> public bool WordInUse(string word) { WordDO temp = model.GetListValue(word); return(model.inUseWordIds.Contains(temp.IdNum)); }