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;
            }
        }
Beispiel #3
0
 public async Task ExecuteSessionWebhooksAsync(List <DPSReportJSON> reportsJSON, LogSessionSettings logSessionSettings)
 {
     SessionTextConstructor.DiscordEmbeds discordEmbeds = SessionTextConstructor.ConstructSessionEmbeds(reportsJSON, logSessionSettings);
     if (logSessionSettings.UseSelectedWebhooksInstead)
     {
         await SendDiscordMessageToSelectedWebhooksAsync(logSessionSettings.SelectedWebhooks, discordEmbeds, logSessionSettings.ContentText);
     }
     else
     {
         await SendDiscordMessageToAllActiveWebhooksAsync(discordEmbeds, logSessionSettings.ContentText);
     }
     if (logSessionSettings.UseSelectedWebhooksInstead && logSessionSettings.SelectedWebhooks.Count > 0)
     {
         mainLink.AddToText(">:> All selected webhooks successfully executed with finished log session.");
     }
     else if (allWebhooks.Count > 0)
     {
         mainLink.AddToText(">:> All active webhooks successfully executed with finished log session.");
     }
 }
Beispiel #4
0
 public async Task ExecuteSessionWebhooksAsync(List <DPSReportJSON> reportsJSON, LogSessionSettings logSessionSettings)
 {
     if (logSessionSettings.UseSelectedWebhooksInstead)
     {
         foreach (var webhook in logSessionSettings.SelectedWebhooks)
         {
             var discordEmbeds = SessionTextConstructor.ConstructSessionEmbeds(reportsJSON.Where(x => webhook.Team.IsSatisfied(x.ExtraJSON)).ToList(), logSessionSettings);
             await SendDiscordMessageWebhooksAsync(webhook, discordEmbeds, logSessionSettings.ContentText);
         }
     }
     else
     {
         foreach (var webhook in allWebhooks.Values.Where(x => x.Active))
         {
             var discordEmbeds = SessionTextConstructor.ConstructSessionEmbeds(reportsJSON.Where(x => webhook.Team.IsSatisfied(x.ExtraJSON)).ToList(), logSessionSettings);
             await SendDiscordMessageWebhooksAsync(webhook, discordEmbeds, logSessionSettings.ContentText);
         }
     }
     if (logSessionSettings.UseSelectedWebhooksInstead && logSessionSettings.SelectedWebhooks.Count > 0)
     {
         mainLink.AddToText(">:> All selected webhooks successfully executed with finished log session.");
     }
     else if (allWebhooks.Count > 0)
     {
         mainLink.AddToText(">:> All active webhooks successfully executed with finished log session.");
     }
 }