Compare commits

..

No commits in common. "support/1.1" and "v1.1.1.0" have entirely different histories.

4 changed files with 29 additions and 45 deletions

View file

@ -179,7 +179,6 @@
<Compile Include="FrmInternalSplash.Designer.cs">
<DependentUpon>FrmInternalSplash.cs</DependentUpon>
</Compile>
<Compile Include="Helper\IdentifiedString.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>

View file

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DML.Application.Helper
{
internal class IdentifiedString<T>
{
internal T Id { get; set; }
internal string Caption { get; set; }
internal IdentifiedString(T id, string caption)
{
Id = id;
Caption = caption;
}
public override string ToString() => Caption;
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
@ -9,9 +8,7 @@ using Discord;
using Discord.WebSocket;
using DML.AppCore.Classes;
using DML.Application.Classes;
using DML.Application.Helper;
using DML.Client;
using static DML.Client.DMLClient;
using static SweetLib.Utils.Logger.Logger;
namespace DML.Application
@ -60,9 +57,7 @@ namespace DML.Application
if (cbGuild.Items.Count == 0)
{
Trace("Adding guilds to component...");
cbGuild.Items.AddRange(DMLClient.Client.Guilds.Where(g => g.Name != null).OrderBy(g => g.Name).Select(g => new IdentifiedString<ulong>(g.Id, g.Name)).ToArray());
cbGuild.Items.AddRange(DMLClient.Client.Guilds.Where(g => g.Name != null).OrderBy(g => g.Name).Select(g => g.Name).ToArray());
cbGuild.SelectedIndex = 0;
Trace("Guild component initialized.");
}
@ -72,7 +67,8 @@ namespace DML.Application
lbxJobs.Items.Clear();
foreach (var job in Core.Scheduler.JobList)
{
lbxJobs.Items.Add(new IdentifiedString<int>(job.Id, $"{FindServerById(job.GuildId)?.Name}:{FindChannelById(FindServerById(job.GuildId), job.ChannelId)?.Name}"));
lbxJobs.Items.Add(
$"{FindServerById(job.GuildId)?.Name}:{FindChannelById(FindServerById(job.GuildId), job.ChannelId)?.Name}");
}
lbxJobs.SelectedIndex = oldIndex;
@ -157,7 +153,7 @@ namespace DML.Application
UseWaitCursor = true;
try
{
var guild = FindServerById(((IdentifiedString<ulong>)cbGuild.SelectedItem).Id);
var guild = FindServerByName(cbGuild.Text);
if (guild != null)
{
@ -165,9 +161,7 @@ namespace DML.Application
cbChannel.Items.Clear();
Trace("Adding new channels...");
cbChannel.Items.AddRange(guild.TextChannels.OrderBy(c => c.Position).Select(c => new IdentifiedString<ulong>(c.Id, c.Name)).ToArray());
cbChannel.Items.AddRange(guild.TextChannels.OrderBy(c => c.Position).Select(c => c.Name).ToArray());
Trace($"Added {cbChannel.Items.Count} channels.");
cbChannel.SelectedIndex = 0;
@ -189,8 +183,8 @@ namespace DML.Application
{
var job = new Job
{
GuildId = ((IdentifiedString<ulong>)cbGuild.SelectedItem).Id,
ChannelId = ((IdentifiedString<ulong>)cbChannel.SelectedItem).Id
GuildId = FindServerByName(cbGuild.Text).Id,
ChannelId = FindChannelByName(FindServerByName(cbGuild.Text), cbChannel.Text).Id
};
if (!(from j in Core.Scheduler.JobList
@ -214,15 +208,28 @@ namespace DML.Application
MessageBox.Show("No job has been seleted.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
var jobId = ((IdentifiedString<int>)lbxJobs.SelectedItem).Id;
var jobNameData = lbxJobs.SelectedItem.ToString().Split(':');
var job = Core.Scheduler.JobList.FirstOrDefault(j => j.Id == jobId);
if (job != null)
var guildName = "";
for (var i = 0; i < jobNameData.Length - 1; i++)
guildName += jobNameData[i] + ":";
guildName = guildName.Substring(0, guildName.Length - 1);
var channelName = jobNameData[jobNameData.Length - 1];
var guild = FindServerByName(guildName);
var channel = FindChannelByName(guild, channelName);
foreach (var job in Core.Scheduler.JobList)
{
Core.Scheduler.JobList.Remove(job);
Core.Scheduler.RunningJobs.Remove(job.Id);
job.Stop();
job.Delete();
if (job.GuildId == guild.Id && job.ChannelId == channel.Id)
{
Core.Scheduler.JobList.Remove(job);
Core.Scheduler.RunningJobs.Remove(job.Id);
job.Stop();
job.Delete();
break;
}
}
lbxJobs.SelectedIndex = -1;

View file

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.2.0")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]