Switched joblist to IdentifiedString objects
This commit is contained in:
parent
5e940c09bd
commit
5c93684164
1 changed files with 8 additions and 22 deletions
|
@ -72,8 +72,7 @@ namespace DML.Application
|
||||||
lbxJobs.Items.Clear();
|
lbxJobs.Items.Clear();
|
||||||
foreach (var job in Core.Scheduler.JobList)
|
foreach (var job in Core.Scheduler.JobList)
|
||||||
{
|
{
|
||||||
lbxJobs.Items.Add(
|
lbxJobs.Items.Add(new IdentifiedString<int>(job.Id, $"{FindServerById(job.GuildId)?.Name}:{FindChannelById(FindServerById(job.GuildId), job.ChannelId)?.Name}"));
|
||||||
$"{FindServerById(job.GuildId)?.Name}:{FindChannelById(FindServerById(job.GuildId), job.ChannelId)?.Name}");
|
|
||||||
}
|
}
|
||||||
lbxJobs.SelectedIndex = oldIndex;
|
lbxJobs.SelectedIndex = oldIndex;
|
||||||
|
|
||||||
|
@ -215,28 +214,15 @@ namespace DML.Application
|
||||||
MessageBox.Show("No job has been seleted.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show("No job has been seleted.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
var jobNameData = lbxJobs.SelectedItem.ToString().Split(':');
|
var jobId = ((IdentifiedString<int>)lbxJobs.SelectedItem).Id;
|
||||||
|
|
||||||
var guildName = "";
|
var job = Core.Scheduler.JobList.FirstOrDefault(j => j.Id == jobId);
|
||||||
for (var i = 0; i < jobNameData.Length - 1; i++)
|
if (job != null)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
if (job.GuildId == guild.Id && job.ChannelId == channel.Id)
|
Core.Scheduler.JobList.Remove(job);
|
||||||
{
|
Core.Scheduler.RunningJobs.Remove(job.Id);
|
||||||
Core.Scheduler.JobList.Remove(job);
|
job.Stop();
|
||||||
Core.Scheduler.RunningJobs.Remove(job.Id);
|
job.Delete();
|
||||||
job.Stop();
|
|
||||||
job.Delete();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lbxJobs.SelectedIndex = -1;
|
lbxJobs.SelectedIndex = -1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue