private async void NextButton_Click(object sender, System.Windows.RoutedEventArgs e) { await this.RunAsyncOperation(async() => { if (this.IntroPageGrid.Visibility == System.Windows.Visibility.Visible) { this.BackButton.IsEnabled = true; this.IntroPageGrid.Visibility = System.Windows.Visibility.Collapsed; this.ExternalServicesPageGrid.Visibility = System.Windows.Visibility.Visible; } else if (this.ExternalServicesPageGrid.Visibility == System.Windows.Visibility.Visible) { this.ExternalServicesPageGrid.Visibility = System.Windows.Visibility.Collapsed; this.ImportScorpBotSettingsPageGrid.Visibility = System.Windows.Visibility.Visible; } else if (this.ImportScorpBotSettingsPageGrid.Visibility == System.Windows.Visibility.Visible) { this.StatusMessageTextBlock.Text = "Gathering ScorpBot Data..."; if (!string.IsNullOrEmpty(this.ScorpBotDirectoryTextBox.Text)) { this.scorpBotData = await this.GatherScorpBotData(this.ScorpBotDirectoryTextBox.Text); if (this.scorpBotData == null) { await MessageBoxHelper.ShowMessageDialog("Failed to import ScorpBot settings, please ensure that you have selected the correct directory. If this continues to fail, please contact Mix it Up support for assitance."); return; } } this.ImportScorpBotSettingsPageGrid.Visibility = System.Windows.Visibility.Collapsed; if (this.soundwaveData != null) { this.ImportSoundwaveInteractiveSettingsGrid.Visibility = System.Windows.Visibility.Visible; } else { this.SetupCompletePageGrid.Visibility = System.Windows.Visibility.Visible; } } else if (this.ImportSoundwaveInteractiveSettingsGrid.Visibility == System.Windows.Visibility.Visible) { this.ImportSoundwaveInteractiveSettingsGrid.Visibility = System.Windows.Visibility.Collapsed; this.SetupCompletePageGrid.Visibility = System.Windows.Visibility.Visible; } else if (this.SetupCompletePageGrid.Visibility == System.Windows.Visibility.Visible) { await this.RunAsyncOperation(async() => { this.StatusMessageTextBlock.Text = "Importing data, this may take a few moments..."; await this.FinalizeNewUser(); this.Close(); }); } }); this.StatusMessageTextBlock.Text = string.Empty; }
private async Task <ScorpBotData> GatherScorpBotData(string folderPath) { try { ScorpBotData scorpBotData = new ScorpBotData(); string dataPath = Path.Combine(folderPath, "Data"); string settingsFilePath = Path.Combine(dataPath, "settings.ini"); if (Directory.Exists(dataPath) && File.Exists(settingsFilePath)) { IEnumerable <string> lines = File.ReadAllLines(settingsFilePath); string currentGroup = null; foreach (var line in lines) { if (line.Contains("=")) { string[] splits = line.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries); if (splits.Count() == 2) { scorpBotData.Settings[currentGroup][splits[0]] = splits[1]; } } else { currentGroup = line.Replace("[", "").Replace("]", "").ToLower(); scorpBotData.Settings[currentGroup] = new Dictionary <string, string>(); } } string databasePath = Path.Combine(dataPath, "Database"); if (Directory.Exists(databasePath)) { SQLiteDatabaseWrapper databaseWrapper = new SQLiteDatabaseWrapper(databasePath); databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "CommandsDB.sqlite"); await databaseWrapper.RunReadCommand("SELECT * FROM RegCommand", (reader) => { scorpBotData.Commands.Add(new ScorpBotCommand(reader)); }); databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "Timers2DB.sqlite"); await databaseWrapper.RunReadCommand("SELECT * FROM TimeCommand", (reader) => { scorpBotData.Timers.Add(new ScorpBotTimer(reader)); }); databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "FilteredWordsDB.sqlite"); await databaseWrapper.RunReadCommand("SELECT * FROM Word", (reader) => { scorpBotData.FilteredWords.Add(((string)reader["word"]).ToLower()); }); databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "QuotesDB.sqlite"); await databaseWrapper.RunReadCommand("SELECT * FROM Quotes", (reader) => { scorpBotData.Quotes.Add((string)reader["quote_text"]); }); databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "RankDB.sqlite"); await databaseWrapper.RunReadCommand("SELECT * FROM Rank", (reader) => { scorpBotData.Ranks.Add(new ScorpBotRank(reader)); }); databaseWrapper.DatabaseFilePath = Path.Combine(databasePath, "Viewers3DB.sqlite"); await databaseWrapper.RunReadCommand("SELECT * FROM Viewer", (reader) => { if (reader["BeamID"] != null && int.TryParse((string)reader["BeamID"], out int id)) { scorpBotData.Viewers.Add(new ScorpBotViewer(reader)); } }); } } return(scorpBotData); } catch (Exception ex) { Logger.Log(ex); } return(null); }