public async void Build() { try { StorageFile jsonFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/AllSets.txt")); string jsonStr = await FileIO.ReadTextAsync(jsonFile); JsonData jsonData = JsonConvert.DeserializeObject <JsonData>(jsonStr); ProcessSet(jsonData.BFZ, Set.BattleForZendikar); ProcessSet(jsonData.DTK, Set.DragonsOfTarkir); ProcessSet(jsonData.OGW, Set.OathOfTheGatewatch); ProcessSet(jsonData.ORI, Set.MagicOrigins); ProcessSet(jsonData.SOI, Set.ShadowsOverInnistrad); ProcessSet(jsonData.EMN, Set.EldritchMoon); ProcessSet(jsonData.FRF, Set.FateReforged); ProcessSet(jsonData.KTK, Set.KhansOfTarkir); ProcessSet(jsonData.M15, Set.Magic2015); await BuildHunspellDictionary(); Debug.WriteLine("Finished processing card data"); } catch (Exception e) { Debug.WriteLine("Exception while building card database : " + e.Message); } this.Ready = true; OnDatabaseUpdated?.Invoke(1f); }
/* * This method executes the Sql request in the parameters and returns the results in a MySqlDataReader object. If specified in the parameters, triggers a DatabaseUpdated event */ public MySqlDataReader SqlRequest(string Request, bool TriggerUpdateEvent) { if (Request == null) { throw new ArgumentNullException(nameof(Request)); } try { MySqlConnection dbConnexion = Connexion(); // Connecting to the database MySqlCommand cmd = new MySqlCommand(Request, dbConnexion); // Initializes the command using the connection and the request in the parameters. MySqlDataReader reader = cmd.ExecuteReader(); // Executes the command and puts the results in a MySqlDataReader. //If the DatabaseUpdated EventHandler has been assigned from FormMain and the trigger event parameter is true, invokes DatabaseUpdated EventHandler if (TriggerUpdateEvent) { DatabaseUpdated?.Invoke(this, new EventArgs()); } // Returns the results return(reader); } catch (Exception e) { ExceptionManager.NewException(e, "Requête incorrecte", false); return(null); } }
public void SqlRequestNonQuery(string Request, bool TriggerUpdateEvent) { if (Request == null) { throw new ArgumentNullException(nameof(Request)); } // Initialise la commande dans une nouvelle instance de l'objet SQLiteCommand //SQLiteCommand command = new SQLiteCommand(Request, Connexion()); try { MySqlConnection dbConnexion = Connexion(); // Connecting to the database MySqlCommand cmd = new MySqlCommand(Request, dbConnexion); // Initializes the command using the connection and the request in the parameters. cmd.ExecuteNonQuery(); // Executes the command. //If the DatabaseUpdated EventHandler has been assigned from FormMain and the trigger event parameter is true, invokes DatabaseUpdated EventHandler if (TriggerUpdateEvent) { DatabaseUpdated?.Invoke(this, new EventArgs()); } cmd.Dispose(); } catch (Exception e) { ExceptionManager.NewException(e, "Requête incorrecte", false); } }
public static async Task UpdateItem(ServiceItem serviceitem) { await CurrentService.UpdateUserItem(serviceitem.UserItem); var oldItem = CurrentItems.FindIndex(x => x.ServiceID == serviceitem.ServiceID); CurrentItems.RemoveAt(oldItem); CurrentItems.Insert(oldItem, serviceitem); DatabaseUpdated.Invoke(serviceitem, null); }
private bool onEvent(KodiEventMessage e) { switch (e.Sender) { case "onAbortRequested": AbortRequested?.Invoke(e.Sender, new EventArgs()); break; case "onCleanStarted": CleanStarted?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0])); break; case "onCleanFinished": CleanFinished?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0])); break; case "onDPMSActivated": DPMSActivated?.Invoke(e.Sender, new EventArgs()); break; case "onDPMSDeactivated": DPMSDeactivated?.Invoke(e.Sender, new EventArgs()); break; case "onDatabaseScanStarted": DatabaseScanStarted?.Invoke(e.Sender, new DatabaseEventArgs(e.EventArgs[0])); break; case "onDatabaseUpdated": DatabaseUpdated?.Invoke(e.Sender, new DatabaseEventArgs(e.EventArgs[0])); break; case "onNotification": Notification?.Invoke(e.Sender, new NotificationEventArgs( e.EventArgs[0], e.EventArgs[1], e.EventArgs[2] )); break; case "onScanStarted": ScanStarted?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0])); break; case "onScanFinished": ScanFinished?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0])); break; case "onScreensaverActivated": ScreensaverActivated?.Invoke(e.Sender, new EventArgs()); break; case "onScreensaverDeactivated": ScreensaverDeactivated?.Invoke(e.Sender, new EventArgs()); break; case "onSettingsChanged": SettingsChanged?.Invoke(e.Sender, new EventArgs()); break; default: PyConsole.WriteLine(string.Format("Unknown event '{0}' not handled", e.Sender)); return(false); } return(true); }