Some UI stuff and adjustments....Seriously...I am lost to the changes I did
This commit is contained in:
parent
fe4a4769f8
commit
8484a5e04c
7 changed files with 273 additions and 47 deletions
|
@ -36,6 +36,16 @@ namespace DML.Application.Classes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void Delete()
|
||||||
|
{
|
||||||
|
Debug("Deleting job from database...");
|
||||||
|
Trace("Getting jobs collection...");
|
||||||
|
var jobDb = Core.Database.GetCollection<Job>("jobs");
|
||||||
|
|
||||||
|
Trace("Deleting value...");
|
||||||
|
jobDb.Delete(Id);
|
||||||
|
}
|
||||||
|
|
||||||
private Server FindServerById(ulong id)
|
private Server FindServerById(ulong id)
|
||||||
{
|
{
|
||||||
Trace($"Trying to find server by Id: {id}");
|
Trace($"Trying to find server by Id: {id}");
|
||||||
|
@ -103,9 +113,12 @@ namespace DML.Application.Classes
|
||||||
if (m.Attachments.Length > 0)
|
if (m.Attachments.Length > 0)
|
||||||
{
|
{
|
||||||
result.Add(m);
|
result.Add(m);
|
||||||
|
Core.Scheduler.TotalAttachments++;
|
||||||
Trace($"Added message {m.Id}");
|
Trace($"Added message {m.Id}");
|
||||||
}
|
}
|
||||||
Debug($"Finished message {m.Id}");
|
Debug($"Finished message {m.Id}");
|
||||||
|
|
||||||
|
Core.Scheduler.MessagesScanned++;
|
||||||
}
|
}
|
||||||
|
|
||||||
finished = finished || messages.Length < limit;
|
finished = finished || messages.Length < limit;
|
||||||
|
|
|
@ -15,11 +15,71 @@ namespace DML.Application.Classes
|
||||||
{
|
{
|
||||||
internal class JobScheduler
|
internal class JobScheduler
|
||||||
{
|
{
|
||||||
|
private ulong messageScanned = 0;
|
||||||
|
private ulong totalAttachments = 0;
|
||||||
|
private ulong attachmentsDownloaded = 0;
|
||||||
|
|
||||||
private bool Run { get; set; } = false;
|
private bool Run { get; set; } = false;
|
||||||
internal List<Job> JobList { get; set; } = new List<Job>();
|
internal List<Job> JobList { get; set; } = new List<Job>();
|
||||||
internal Dictionary<int, Queue<Message>> RunningJobs = new Dictionary<int, Queue<Message>>();
|
internal Dictionary<int, Queue<Message>> RunningJobs = new Dictionary<int, Queue<Message>>();
|
||||||
internal int RunningThreads { get; set; } = 0;
|
internal int RunningThreads { get; set; } = 0;
|
||||||
|
|
||||||
|
internal ulong MessagesScanned
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
return messageScanned;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
messageScanned = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal ulong TotalAttachments
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
return totalAttachments;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
totalAttachments = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal ulong AttachmentsDownloaded
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
return attachmentsDownloaded;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
attachmentsDownloaded = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal ulong AttachmentsToDownload => TotalAttachments - AttachmentsDownloaded;
|
||||||
|
|
||||||
internal void Stop()
|
internal void Stop()
|
||||||
{
|
{
|
||||||
Run = false;
|
Run = false;
|
||||||
|
@ -28,7 +88,7 @@ namespace DML.Application.Classes
|
||||||
internal void Start()
|
internal void Start()
|
||||||
{
|
{
|
||||||
Run = true;
|
Run = true;
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
Info("Started JobScheduler...");
|
Info("Started JobScheduler...");
|
||||||
|
@ -71,7 +131,7 @@ namespace DML.Application.Classes
|
||||||
}
|
}
|
||||||
Trace($"Added {queue.Count} messages to queue.");
|
Trace($"Added {queue.Count} messages to queue.");
|
||||||
|
|
||||||
if(messages.Count!= queue.Count)
|
if (messages.Count != queue.Count)
|
||||||
Warn("Not all messages have been added into the queue.");
|
Warn("Not all messages have been added into the queue.");
|
||||||
|
|
||||||
var startedDownload = false;
|
var startedDownload = false;
|
||||||
|
@ -128,50 +188,70 @@ namespace DML.Application.Classes
|
||||||
Trace("Queue found.");
|
Trace("Queue found.");
|
||||||
}
|
}
|
||||||
Trace("Unlocked scheduler.");
|
Trace("Unlocked scheduler.");
|
||||||
|
|
||||||
Debug($"Messages to process for job {jobId}: {queue.Count}");
|
Debug($"Messages to process for job {jobId}: {queue.Count}");
|
||||||
while (queue.Count > 0)
|
while (queue.Count > 0)
|
||||||
{
|
{
|
||||||
|
Trace("Locking scheduler...");
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
Trace("Checking if still a job...");
|
||||||
|
if (!RunningJobs.ContainsKey(jobId))
|
||||||
|
{
|
||||||
|
Warn($"Queue for job {jobId} not found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Trace("Continue working...");
|
||||||
|
}
|
||||||
|
Trace("Unlocked scheduler.");
|
||||||
|
|
||||||
Trace("Dequeueing message...");
|
Trace("Dequeueing message...");
|
||||||
var message = queue.Dequeue();
|
var message = queue.Dequeue();
|
||||||
|
|
||||||
Debug($"Attachments for message {message.Id}: {message.Attachments.Length}");
|
Debug($"Attachments for message {message.Id}: {message.Attachments.Length}");
|
||||||
foreach (var a in message.Attachments)
|
foreach (var a in message.Attachments)
|
||||||
{
|
{
|
||||||
var fileName = Path.Combine(Core.Settings.OperatingFolder, Core.Settings.FileNameScheme);
|
try
|
||||||
|
|
||||||
Trace("Replacing filename placeholders...");
|
|
||||||
fileName =
|
|
||||||
fileName.Replace("%guild%", message.Server.Name)
|
|
||||||
.Replace("%channel%", message.Channel.Name)
|
|
||||||
.Replace("%timestamp%", SweetUtils.DateTimeToUnixTimeStamp(message.Timestamp).ToString())
|
|
||||||
.Replace("%name%", a.Filename);
|
|
||||||
Trace($"Detemined file name: {fileName}.");
|
|
||||||
|
|
||||||
if (File.Exists(fileName) && new FileInfo(fileName).Length == a.Size)
|
|
||||||
{
|
{
|
||||||
Debug($"{fileName} already existing with its estimated size. Skipping...");
|
var fileName = Path.Combine(Core.Settings.OperatingFolder, Core.Settings.FileNameScheme);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Trace("Determining directory...");
|
|
||||||
var fileDirectory = Path.GetDirectoryName(fileName);
|
|
||||||
|
|
||||||
if (!Directory.Exists(fileDirectory))
|
Trace("Replacing filename placeholders...");
|
||||||
|
fileName =
|
||||||
|
fileName.Replace("%guild%", message.Server.Name)
|
||||||
|
.Replace("%channel%", message.Channel.Name)
|
||||||
|
.Replace("%timestamp%", SweetUtils.DateTimeToUnixTimeStamp(message.Timestamp).ToString())
|
||||||
|
.Replace("%name%", a.Filename);
|
||||||
|
Trace($"Detemined file name: {fileName}.");
|
||||||
|
|
||||||
|
if (File.Exists(fileName) && new FileInfo(fileName).Length == a.Size)
|
||||||
|
{
|
||||||
|
Debug($"{fileName} already existing with its estimated size. Skipping...");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Trace("Determining directory...");
|
||||||
|
var fileDirectory = Path.GetDirectoryName(fileName);
|
||||||
|
|
||||||
|
if (!Directory.Exists(fileDirectory))
|
||||||
|
{
|
||||||
|
Info($"Directory {fileDirectory} does not exist. Creating directory...");
|
||||||
|
Directory.CreateDirectory(fileDirectory);
|
||||||
|
Debug("Created directory.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var wc = new WebClient();
|
||||||
|
Debug($"Starting downloading of attachment {a.Id}...");
|
||||||
|
wc.DownloadFile(new Uri(a.Url), fileName);
|
||||||
|
Debug($"Downloaded attachment {a.Id}.");
|
||||||
|
|
||||||
|
Trace("Updating known timestamp for job...");
|
||||||
|
job.KnownTimestamp = SweetUtils.DateTimeToUnixTimeStamp(message.Timestamp);
|
||||||
|
job.Store();
|
||||||
|
}
|
||||||
|
finally
|
||||||
{
|
{
|
||||||
Info($"Directory {fileDirectory} does not exist. Creating directory...");
|
AttachmentsDownloaded++;
|
||||||
Directory.CreateDirectory(fileDirectory);
|
|
||||||
Debug("Created directory.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var wc = new WebClient();
|
|
||||||
Debug($"Starting downloading of attachment {a.Id}...");
|
|
||||||
wc.DownloadFile(new Uri(a.Url), fileName);
|
|
||||||
Debug($"Downloaded attachment {a.Id}.");
|
|
||||||
|
|
||||||
Trace("Updating known timestamp for job...");
|
|
||||||
job.KnownTimestamp = SweetUtils.DateTimeToUnixTimeStamp(message.Timestamp);
|
|
||||||
job.Store();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||||
this.pnlSettings = new System.Windows.Forms.GroupBox();
|
this.pnlSettings = new System.Windows.Forms.GroupBox();
|
||||||
this.lbThreadLimit = new System.Windows.Forms.Label();
|
this.lbThreadLimit = new System.Windows.Forms.Label();
|
||||||
|
@ -44,11 +45,18 @@
|
||||||
this.lbChannel = new System.Windows.Forms.Label();
|
this.lbChannel = new System.Windows.Forms.Label();
|
||||||
this.cbGuild = new System.Windows.Forms.ComboBox();
|
this.cbGuild = new System.Windows.Forms.ComboBox();
|
||||||
this.lbGuild = new System.Windows.Forms.Label();
|
this.lbGuild = new System.Windows.Forms.Label();
|
||||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
this.statusStrip = new System.Windows.Forms.StatusStrip();
|
||||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.lbxJobs = new System.Windows.Forms.ListBox();
|
||||||
|
this.btnDelete = new System.Windows.Forms.Button();
|
||||||
|
this.lbProgress = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
|
this.pgbProgress = new System.Windows.Forms.ToolStripProgressBar();
|
||||||
|
this.tmrRefreshProgress = new System.Windows.Forms.Timer(this.components);
|
||||||
this.pnlSettings.SuspendLayout();
|
this.pnlSettings.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.edThreadLimit)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.edThreadLimit)).BeginInit();
|
||||||
this.groupBox1.SuspendLayout();
|
this.groupBox1.SuspendLayout();
|
||||||
|
this.statusStrip.SuspendLayout();
|
||||||
|
this.groupBox2.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// pnlSettings
|
// pnlSettings
|
||||||
|
@ -220,16 +228,21 @@
|
||||||
this.lbGuild.TabIndex = 0;
|
this.lbGuild.TabIndex = 0;
|
||||||
this.lbGuild.Text = "Guild:";
|
this.lbGuild.Text = "Guild:";
|
||||||
//
|
//
|
||||||
// statusStrip1
|
// statusStrip
|
||||||
//
|
//
|
||||||
this.statusStrip1.Location = new System.Drawing.Point(0, 311);
|
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.statusStrip1.Name = "statusStrip1";
|
this.pgbProgress,
|
||||||
this.statusStrip1.Size = new System.Drawing.Size(553, 22);
|
this.lbProgress});
|
||||||
this.statusStrip1.TabIndex = 2;
|
this.statusStrip.Location = new System.Drawing.Point(0, 311);
|
||||||
this.statusStrip1.Text = "statusStrip1";
|
this.statusStrip.Name = "statusStrip";
|
||||||
|
this.statusStrip.Size = new System.Drawing.Size(553, 22);
|
||||||
|
this.statusStrip.TabIndex = 2;
|
||||||
|
this.statusStrip.Text = "statusStrip1";
|
||||||
//
|
//
|
||||||
// groupBox2
|
// groupBox2
|
||||||
//
|
//
|
||||||
|
this.groupBox2.Controls.Add(this.btnDelete);
|
||||||
|
this.groupBox2.Controls.Add(this.lbxJobs);
|
||||||
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.groupBox2.Location = new System.Drawing.Point(0, 150);
|
this.groupBox2.Location = new System.Drawing.Point(0, 150);
|
||||||
this.groupBox2.Name = "groupBox2";
|
this.groupBox2.Name = "groupBox2";
|
||||||
|
@ -238,13 +251,51 @@
|
||||||
this.groupBox2.TabStop = false;
|
this.groupBox2.TabStop = false;
|
||||||
this.groupBox2.Text = "Jobs";
|
this.groupBox2.Text = "Jobs";
|
||||||
//
|
//
|
||||||
|
// lbxJobs
|
||||||
|
//
|
||||||
|
this.lbxJobs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.lbxJobs.FormattingEnabled = true;
|
||||||
|
this.lbxJobs.Location = new System.Drawing.Point(6, 19);
|
||||||
|
this.lbxJobs.Name = "lbxJobs";
|
||||||
|
this.lbxJobs.Size = new System.Drawing.Size(541, 108);
|
||||||
|
this.lbxJobs.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// btnDelete
|
||||||
|
//
|
||||||
|
this.btnDelete.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
|
this.btnDelete.Location = new System.Drawing.Point(3, 135);
|
||||||
|
this.btnDelete.Name = "btnDelete";
|
||||||
|
this.btnDelete.Size = new System.Drawing.Size(547, 23);
|
||||||
|
this.btnDelete.TabIndex = 1;
|
||||||
|
this.btnDelete.Text = "Delete selected";
|
||||||
|
this.btnDelete.UseVisualStyleBackColor = true;
|
||||||
|
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
|
||||||
|
//
|
||||||
|
// lbProgress
|
||||||
|
//
|
||||||
|
this.lbProgress.Name = "lbProgress";
|
||||||
|
this.lbProgress.Size = new System.Drawing.Size(0, 17);
|
||||||
|
//
|
||||||
|
// pgbProgress
|
||||||
|
//
|
||||||
|
this.pgbProgress.Name = "pgbProgress";
|
||||||
|
this.pgbProgress.Size = new System.Drawing.Size(100, 16);
|
||||||
|
//
|
||||||
|
// tmrRefreshProgress
|
||||||
|
//
|
||||||
|
this.tmrRefreshProgress.Enabled = true;
|
||||||
|
this.tmrRefreshProgress.Interval = 500;
|
||||||
|
this.tmrRefreshProgress.Tick += new System.EventHandler(this.tmrRefreshProgress_Tick);
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(553, 333);
|
this.ClientSize = new System.Drawing.Size(553, 333);
|
||||||
this.Controls.Add(this.groupBox2);
|
this.Controls.Add(this.groupBox2);
|
||||||
this.Controls.Add(this.statusStrip1);
|
this.Controls.Add(this.statusStrip);
|
||||||
this.Controls.Add(this.groupBox1);
|
this.Controls.Add(this.groupBox1);
|
||||||
this.Controls.Add(this.pnlSettings);
|
this.Controls.Add(this.pnlSettings);
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
@ -258,6 +309,9 @@
|
||||||
((System.ComponentModel.ISupportInitialize)(this.edThreadLimit)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.edThreadLimit)).EndInit();
|
||||||
this.groupBox1.ResumeLayout(false);
|
this.groupBox1.ResumeLayout(false);
|
||||||
this.groupBox1.PerformLayout();
|
this.groupBox1.PerformLayout();
|
||||||
|
this.statusStrip.ResumeLayout(false);
|
||||||
|
this.statusStrip.PerformLayout();
|
||||||
|
this.groupBox2.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
@ -267,7 +321,7 @@
|
||||||
|
|
||||||
private System.Windows.Forms.GroupBox pnlSettings;
|
private System.Windows.Forms.GroupBox pnlSettings;
|
||||||
private System.Windows.Forms.GroupBox groupBox1;
|
private System.Windows.Forms.GroupBox groupBox1;
|
||||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
private System.Windows.Forms.StatusStrip statusStrip;
|
||||||
private System.Windows.Forms.GroupBox groupBox2;
|
private System.Windows.Forms.GroupBox groupBox2;
|
||||||
private System.Windows.Forms.Label lbThreadLimit;
|
private System.Windows.Forms.Label lbThreadLimit;
|
||||||
private System.Windows.Forms.NumericUpDown edThreadLimit;
|
private System.Windows.Forms.NumericUpDown edThreadLimit;
|
||||||
|
@ -282,5 +336,10 @@
|
||||||
private System.Windows.Forms.Label lbChannel;
|
private System.Windows.Forms.Label lbChannel;
|
||||||
private System.Windows.Forms.ComboBox cbGuild;
|
private System.Windows.Forms.ComboBox cbGuild;
|
||||||
private System.Windows.Forms.Label lbGuild;
|
private System.Windows.Forms.Label lbGuild;
|
||||||
|
private System.Windows.Forms.Button btnDelete;
|
||||||
|
private System.Windows.Forms.ListBox lbxJobs;
|
||||||
|
private System.Windows.Forms.ToolStripProgressBar pgbProgress;
|
||||||
|
private System.Windows.Forms.ToolStripStatusLabel lbProgress;
|
||||||
|
private System.Windows.Forms.Timer tmrRefreshProgress;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -42,6 +42,16 @@ namespace DML.Application
|
||||||
cbGuild.Items.AddRange(Core.Client.Servers.OrderBy(g => g.Name).Select(g => g.Name).ToArray());
|
cbGuild.Items.AddRange(Core.Client.Servers.OrderBy(g => g.Name).Select(g => g.Name).ToArray());
|
||||||
cbGuild.SelectedIndex = 0;
|
cbGuild.SelectedIndex = 0;
|
||||||
Trace("Guild component initialized.");
|
Trace("Guild component initialized.");
|
||||||
|
|
||||||
|
Trace("Refreshing job list component...");
|
||||||
|
var oldIndex = lbxJobs.SelectedIndex;
|
||||||
|
lbxJobs.Items.Clear();
|
||||||
|
foreach (var job in Core.Scheduler.JobList)
|
||||||
|
{
|
||||||
|
lbxJobs.Items.Add(
|
||||||
|
$"{FindServerById(job.GuildId).Name}:{FindChannelById(FindServerById(job.GuildId), job.ChannelId).Name}");
|
||||||
|
}
|
||||||
|
lbxJobs.SelectedIndex = oldIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoSomethingChanged(object sender, System.EventArgs e)
|
private void DoSomethingChanged(object sender, System.EventArgs e)
|
||||||
|
@ -102,6 +112,18 @@ namespace DML.Application
|
||||||
return (from c in server.TextChannels where c.Name == name select c).FirstOrDefault();
|
return (from c in server.TextChannels where c.Name == name select c).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Server FindServerById(ulong id)
|
||||||
|
{
|
||||||
|
Trace($"Trying to find server by Id: {id}");
|
||||||
|
return (from s in Core.Client.Servers where s.Id == id select s).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Channel FindChannelById(Server server, ulong id)
|
||||||
|
{
|
||||||
|
Trace($"Trying to find channel in {server} by id: {id}");
|
||||||
|
return (from c in server.TextChannels where c.Id == id select c).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
private void cbGuild_SelectedIndexChanged(object sender, System.EventArgs e)
|
private void cbGuild_SelectedIndexChanged(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
Trace("Guild index changed.");
|
Trace("Guild index changed.");
|
||||||
|
@ -152,5 +174,54 @@ namespace DML.Application
|
||||||
job.Store();
|
job.Store();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnDelete_Click(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
Trace("Deleting job pressed.");
|
||||||
|
|
||||||
|
if (lbxJobs.SelectedIndex < 0)
|
||||||
|
{
|
||||||
|
Warn("No job selected.");
|
||||||
|
MessageBox.Show("No job has been seleted.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
var jobNameData = lbxJobs.SelectedItem.ToString().Split(':');
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (job.GuildId == guild.Id && job.ChannelId == channel.Id)
|
||||||
|
{
|
||||||
|
Core.Scheduler.JobList.Remove(job);
|
||||||
|
Core.Scheduler.RunningJobs.Remove(job.Id);
|
||||||
|
job.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lbxJobs.SelectedIndex = -1;
|
||||||
|
RefreshComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tmrRefreshProgress_Tick(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
var scanned = Core.Scheduler.MessagesScanned;
|
||||||
|
var totalAttachments = Core.Scheduler.TotalAttachments;
|
||||||
|
var done = Core.Scheduler.AttachmentsDownloaded;
|
||||||
|
|
||||||
|
var progress = totalAttachments > 0 ? (int)(100 * done / totalAttachments) : 0;
|
||||||
|
pgbProgress.Maximum = 100;
|
||||||
|
pgbProgress.Value = progress;
|
||||||
|
|
||||||
|
lbProgress.Text = $"Scanned: {scanned} Downloaded: {done} Open: {totalAttachments - done}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,9 +117,12 @@
|
||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="tmrRefreshProgress.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>126, 17</value>
|
||||||
|
</metadata>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.2.142.0")]
|
[assembly: AssemblyVersion("0.2.148.0")]
|
||||||
[assembly: AssemblyFileVersion("0.2.142.0")]
|
[assembly: AssemblyFileVersion("0.2.148.0")]
|
||||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.99.70.0")]
|
[assembly: AssemblyVersion("0.99.75.0")]
|
||||||
[assembly: AssemblyFileVersion("0.99.70.0")]
|
[assembly: AssemblyFileVersion("0.99.75.0")]
|
||||||
|
|
Loading…
Add table
Reference in a new issue