Пример #1
0
        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;
            }
        }
Пример #2
0
        public override void WriteJson(JsonWriter writer,
                                       object untypedValue,
                                       JsonSerializer serializer)
        {
            if (untypedValue == null)
            {
                serializer.Serialize(writer,
                                     null);

                return;
            }

            NiceTime value = (NiceTime)untypedValue;

            switch (value)
            {
            case NiceTime.Day:
                serializer.Serialize(writer,
                                     "day");

                return;

            case NiceTime.Hour:
                serializer.Serialize(writer,
                                     "hour");

                return;

            case NiceTime.Minute:
                serializer.Serialize(writer,
                                     "minute");

                return;

            case NiceTime.Month:
                serializer.Serialize(writer,
                                     "month");

                return;

            case NiceTime.Second:
                serializer.Serialize(writer,
                                     "second");

                return;

            case NiceTime.Week:
                serializer.Serialize(writer,
                                     "week");

                return;

            case NiceTime.Year:
                serializer.Serialize(writer,
                                     "year");

                return;
            }

            throw new Exception("Cannot marshal type NiceTime");
        }