private async void ButtonSessionStarter_Click(object sender, EventArgs e) { if (SessionRunning || sessionPaused) { buttonSessionStarter.Text = "Start a log session"; buttonUnPauseSession.Text = "Pause session"; buttonUnPauseSession.Enabled = false; SessionRunning = false; sessionPaused = false; stopWatch.Stop(); var elapsedTime = stopWatch.Elapsed.ParseHMS(); var elapsedTimeSpan = stopWatch.Elapsed; stopWatch.Reset(); var sortBy = radioButtonSortByUpload.Checked ? 1 : 0; var logSessionSettings = new LogSessionSettings() { Name = textBoxSessionName.Text, ContentText = textBoxSessionContent.Text, ShowSuccess = !checkBoxOnlySuccess.Checked, ElapsedTime = elapsedTime, ElapsedTimeSpan = elapsedTimeSpan, SortBy = (LogSessionSortBy)sortBy, MakeWvWSummaryEmbed = checkBoxMakeWvWSummary.Checked, UseSelectedWebhooksInstead = radioButtonOnlySelectedWebhooks.Checked, SelectedWebhooks = ConvertCheckboxListToList() }; var sessionNameFormatted = textBoxSessionName.Text.ToLower().Replace(" ", string.Empty); var invalidCharacters = Path.GetInvalidFileNameChars().Where(x => !x.Equals('/')).ToList(); invalidCharacters.ForEach(x => sessionNameFormatted = sessionNameFormatted.Replace(x.ToString(), "")); sessionNameFormatted = sessionNameFormatted.Replace(@"/", "-out-of-"); var fileName = $"{((!string.IsNullOrWhiteSpace(sessionNameFormatted)) ? $"{sessionNameFormatted} " : "")}{sessionTimeStarted.Year}-{sessionTimeStarted.Month}-{sessionTimeStarted.Day} {sessionTimeStarted.Hour}-{sessionTimeStarted.Minute}-{sessionTimeStarted.Second}"; File.AppendAllText($"{ApplicationSettings.LocalDir}{fileName}.csv", "Boss;BossId;Success;Duration;RecordedBy;EliteInsightsVersion;arcdpsVersion;Permalink\n"); foreach (var reportJSON in mainLink.SessionLogs) { var success = (reportJSON.Encounter.Success ?? false) ? "true" : "false"; File.AppendAllText($"{ApplicationSettings.LocalDir}{fileName}.csv", $"{reportJSON.ExtraJSON?.FightName ?? reportJSON.Encounter.Boss};{reportJSON.Encounter.BossId};{success};{reportJSON.ExtraJSON?.Duration ?? string.Empty};{reportJSON.ExtraJSON?.RecordedBy ?? string.Empty};{reportJSON.ExtraJSON?.EliteInsightsVersion ?? string.Empty};{reportJSON.EVTC.Type}{reportJSON.EVTC.Version};{reportJSON.Permalink}\n"); } await mainLink.ExecuteSessionLogWebhooksAsync(logSessionSettings); mainLink.SessionLogs.Clear(); } else { buttonSessionStarter.Text = "Stop the log session"; buttonUnPauseSession.Text = "Pause session"; buttonUnPauseSession.Enabled = true; SessionRunning = true; sessionPaused = false; stopWatch.Start(); sessionTimeStarted = DateTime.Now; } }
private async void ButtonSessionStarter_Click(object sender, EventArgs e) { if (SessionRunning || sessionPaused) { buttonSessionStarter.Text = "Start a log session"; buttonUnPauseSession.Text = "Pause session"; buttonUnPauseSession.Enabled = false; SessionRunning = false; sessionPaused = false; stopWatch.Stop(); string elapsedTime = NiceTime.ParseTimeSpanHMS(stopWatch.Elapsed); stopWatch.Reset(); int sortBy = radioButtonSortByUpload.Checked ? 1 : 0; LogSessionSettings logSessionSettings = new LogSessionSettings() { Name = textBoxSessionName.Text, ContentText = textBoxSessionContent.Text, ShowSuccess = !checkBoxOnlySuccess.Checked, ElapsedTime = elapsedTime, SortBy = (LogSessionSortBy)sortBy, UseSelectedWebhooksInstead = radioButtonOnlySelectedWebhooks.Checked, SelectedWebhooks = ConvertCheckboxListToList() }; string fileName = $"{textBoxSessionName.Text.ToLower().Replace(" ", "")} {sessionTimeStarted.Year}-{sessionTimeStarted.Month}-{sessionTimeStarted.Day} {sessionTimeStarted.Hour}-{sessionTimeStarted.Minute}-{sessionTimeStarted.Second}"; File.AppendAllText($"{mainLink.LocalDir}{fileName}.csv", "Boss;BossId;Success;Duration;RecordedBy;EliteInsightsVersion;arcdpsVersion;Permalink\n"); foreach (DPSReport.DPSReportJSON reportJSON in mainLink.SessionLogs) { string success = (reportJSON.Encounter.Success ?? false) ? "true" : "false"; File.AppendAllText($"{mainLink.LocalDir}{fileName}.csv", $"{reportJSON.ExtraJSON?.FightName ?? reportJSON.Encounter.Boss};{reportJSON.Encounter.BossId};{success};{reportJSON.ExtraJSON?.Duration ?? ""};{reportJSON.ExtraJSON?.RecordedBy ?? ""};{reportJSON.ExtraJSON?.EliteInsightsVersion ?? ""};{reportJSON.EVTC.Type}{reportJSON.EVTC.Version};{reportJSON.Permalink}\n"); } await mainLink.ExecuteSessionLogWebhooksAsync(logSessionSettings); mainLink.SessionLogs.Clear(); } else { buttonSessionStarter.Text = "Stop the log session"; buttonUnPauseSession.Text = "Pause session"; buttonUnPauseSession.Enabled = true; SessionRunning = true; sessionPaused = false; stopWatch.Start(); sessionTimeStarted = DateTime.Now; } }