private void unreadChangelogEventsToolStripMenuItem_Click(object sender, EventArgs e) { FormChangelogNotification changelogNotification = new FormChangelogNotification(); changelogNotification.Text = "All unread changelog events"; DataTable historyEvents = sqliteDatabase.GetDataTable("SELECT * FROM changelogEvents WHERE read = 0 ORDER BY date DESC;"); changelogNotification.listViewChangeLog.Items.Clear(); foreach (DataRow changeEvent in historyEvents.Rows) { ListViewItem lviHistory = changelogNotification.listViewChangeLog.Items.Add(changeEvent["id"].ToString()); lviHistory.SubItems.Add(GetCharacterNameById(changeEvent["character_id"].ToString())); lviHistory.SubItems.Add(changeEvent["message"].ToString()); } changelogNotification.ShowDialog(this); }
private void PerformUpdate() { int totalChangeEvents = 0; int failedUpdates = 0; for (int i = 0; i < listViewTrackedCharacters.Items.Count; i++) { string userCharacterName = listViewTrackedCharacters.Items[i].SubItems[1].Text; string userCharacterRealm = listViewTrackedCharacters.Items[i].SubItems[2].Text; string userCharacterRegion = listViewTrackedCharacters.Items[i].SubItems[3].Text; this.Text = appName + " - Updating " + userCharacterName; try { int trackedCharacterId = Int32.Parse(listViewTrackedCharacters.Items[i].SubItems[0].Text); int currentChangeEvents = UpdateCharacter(trackedCharacterId, userCharacterName, userCharacterRealm, userCharacterRegion); if (currentChangeEvents < 0) { errorLog.Add(new ErrorEvent("Failed to update " + userCharacterName + " (" + userCharacterRegion + "-" + userCharacterRealm + ") ", "No character data returned.")); this.Text = appName + " - Failed to update " + userCharacterName; failedUpdates++; } else { totalChangeEvents += currentChangeEvents; } } catch (Exception ex) { errorLog.Add(new ErrorEvent("Failed to update " + userCharacterName + " (" + userCharacterRegion + "-" + userCharacterRealm + ") ", ex.ToString())); this.Text = appName + " - Failed to update " + userCharacterName; failedUpdates++; } } this.Text = appName; UpdateTrackedCharactersUI(); if (notifyIconTray.Visible == true && failedUpdates > 0) { notifyIconTray.BalloonTipText = failedUpdates.ToString() + " character could not be updated. Open the application and check the error log."; notifyIconTray.BalloonTipIcon = ToolTipIcon.Error; notifyIconTray.BalloonTipTitle = "Pelz Character Tracker"; notifyIconTray.ShowBalloonTip(2000); } if (notifyIconTray.Visible == true && totalChangeEvents > 0) { notifyIconTray.BalloonTipIcon = ToolTipIcon.Info; notifyIconTray.BalloonTipText = totalChangeEvents.ToString() + " new changelog event(s) have been recorded after updating all tracked characters."; notifyIconTray.BalloonTipTitle = "Pelz Character Tracker"; notifyIconTray.ShowBalloonTip(1000); } if (totalChangeEvents > 0 && notifyIconTray.Visible == false) { FormChangelogNotification changelogNotification = new FormChangelogNotification(); changelogNotification.Text = "Notification: " + totalChangeEvents.ToString() + " new changelog event(s)"; DataTable historyEvents = sqliteDatabase.GetDataTable("SELECT * FROM changelogEvents WHERE read = 0 ORDER BY date DESC;"); changelogNotification.listViewChangeLog.Items.Clear(); foreach (DataRow changeEvent in historyEvents.Rows) { ListViewItem lviHistory = changelogNotification.listViewChangeLog.Items.Add(changeEvent["id"].ToString()); lviHistory.SubItems.Add(GetCharacterNameById(changeEvent["character_id"].ToString())); lviHistory.SubItems.Add(changeEvent["message"].ToString()); } changelogNotification.ShowDialog(this); } }