#27 Prepared a migration from timestmaps to message ids in the jobs and relocated the Core.cs classfile.
This commit is contained in:
parent
4fdb226a21
commit
7a90260207
10 changed files with 136 additions and 68 deletions
|
@ -13,16 +13,16 @@
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using Discord;
|
||||||
|
using Discord.WebSocket;
|
||||||
|
using DML.Application.Classes;
|
||||||
|
using DML.Application.Core;
|
||||||
|
using DML.Client;
|
||||||
|
using SweetLib.Utils.Extensions;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
using DML.Application.Classes;
|
|
||||||
using DML.Client;
|
|
||||||
using SweetLib.Utils;
|
|
||||||
using SweetLib.Utils.Extensions;
|
|
||||||
using static SweetLib.Utils.Logger.Logger;
|
using static SweetLib.Utils.Logger.Logger;
|
||||||
|
|
||||||
namespace DML.AppCore.Classes
|
namespace DML.AppCore.Classes
|
||||||
|
@ -49,7 +49,7 @@ namespace DML.AppCore.Classes
|
||||||
{
|
{
|
||||||
Debug("Storing job to database...");
|
Debug("Storing job to database...");
|
||||||
Trace("Getting jobs collection...");
|
Trace("Getting jobs collection...");
|
||||||
var jobDb = Core.Database.GetCollection<Job>("jobs");
|
var jobDb = Application.Core.Core.Database.GetCollection<Job>("jobs");
|
||||||
|
|
||||||
Trace("Adding new value...");
|
Trace("Adding new value...");
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ namespace DML.AppCore.Classes
|
||||||
{
|
{
|
||||||
Debug("Deleting job from database...");
|
Debug("Deleting job from database...");
|
||||||
Trace("Getting jobs collection...");
|
Trace("Getting jobs collection...");
|
||||||
var jobDb = Core.Database.GetCollection<Job>("jobs");
|
var jobDb = Application.Core.Core.Database.GetCollection<Job>("jobs");
|
||||||
|
|
||||||
Trace("Deleting value...");
|
Trace("Deleting value...");
|
||||||
jobDb.Delete(Id);
|
jobDb.Delete(Id);
|
||||||
|
@ -111,7 +111,10 @@ namespace DML.AppCore.Classes
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.Abs(StopTimestamp) < 0.4)
|
if (Math.Abs(StopTimestamp) < 0.4)
|
||||||
|
{
|
||||||
StopTimestamp = KnownTimestamp;
|
StopTimestamp = KnownTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
Trace("Initialized scanning parameters.");
|
Trace("Initialized scanning parameters.");
|
||||||
|
|
||||||
while (!finished)
|
while (!finished)
|
||||||
|
@ -139,9 +142,11 @@ namespace DML.AppCore.Classes
|
||||||
foreach (var m in messages)
|
foreach (var m in messages)
|
||||||
{
|
{
|
||||||
if (!IsValid)
|
if (!IsValid)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Core.Scheduler.MessagesScanned++;
|
Application.Core.Core.Scheduler.MessagesScanned++;
|
||||||
|
|
||||||
Debug($"Processing message {m.Id}");
|
Debug($"Processing message {m.Id}");
|
||||||
if (m.Id < lastId)
|
if (m.Id < lastId)
|
||||||
|
@ -161,7 +166,7 @@ namespace DML.AppCore.Classes
|
||||||
if (m.Attachments.Count > 0)
|
if (m.Attachments.Count > 0)
|
||||||
{
|
{
|
||||||
result.Add(m);
|
result.Add(m);
|
||||||
Core.Scheduler.TotalAttachments += (ulong)m.Attachments.Count;
|
Application.Core.Core.Scheduler.TotalAttachments += (ulong)m.Attachments.Count;
|
||||||
Trace($"Added message {m.Id}");
|
Trace($"Added message {m.Id}");
|
||||||
}
|
}
|
||||||
Debug($"Finished message {m.Id}");
|
Debug($"Finished message {m.Id}");
|
||||||
|
@ -226,7 +231,7 @@ namespace DML.AppCore.Classes
|
||||||
{
|
{
|
||||||
Debug("Restoring jobs...");
|
Debug("Restoring jobs...");
|
||||||
Trace("Getting jobs collection...");
|
Trace("Getting jobs collection...");
|
||||||
var jobDb = Core.Database.GetCollection<Job>("jobs");
|
var jobDb = Application.Core.Core.Database.GetCollection<Job>("jobs");
|
||||||
|
|
||||||
Trace("Creating new empty job list");
|
Trace("Creating new empty job list");
|
||||||
return jobDb.FindAll();
|
return jobDb.FindAll();
|
||||||
|
|
|
@ -13,22 +13,12 @@
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Discord;
|
using Discord;
|
||||||
using DML.AppCore.Classes;
|
using DML.AppCore.Classes;
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using Discord;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
using DML.Application.Classes;
|
|
||||||
using SweetLib.Utils;
|
|
||||||
using SweetLib.Utils.Extensions;
|
|
||||||
using SweetLib.Utils.Logger;
|
using SweetLib.Utils.Logger;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DML.Application.Classes
|
namespace DML.Application.Classes
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,13 +13,13 @@
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using DML.Client;
|
||||||
|
using SweetLib.Utils.Logger;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DML.Client;
|
|
||||||
using SweetLib.Utils.Logger;
|
|
||||||
using static SweetLib.Utils.Logger.Logger;
|
using static SweetLib.Utils.Logger.Logger;
|
||||||
|
|
||||||
namespace DML.Application.Classes
|
namespace DML.Application.Classes
|
||||||
|
@ -38,7 +38,7 @@ namespace DML.Application.Classes
|
||||||
{
|
{
|
||||||
Debug("Storing job to database...");
|
Debug("Storing job to database...");
|
||||||
Trace("Getting jobs collection...");
|
Trace("Getting jobs collection...");
|
||||||
var db = Core.Database.GetCollection<MediaData>("media");
|
var db = Core.Core.Database.GetCollection<MediaData>("media");
|
||||||
|
|
||||||
Trace("Adding new value...");
|
Trace("Adding new value...");
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ namespace DML.Application.Classes
|
||||||
{
|
{
|
||||||
Debug("Deleting job from database...");
|
Debug("Deleting job from database...");
|
||||||
Trace("Getting jobs collection...");
|
Trace("Getting jobs collection...");
|
||||||
var db = Core.Database.GetCollection<MediaData>("media");
|
var db = Core.Core.Database.GetCollection<MediaData>("media");
|
||||||
|
|
||||||
Trace("Deleting value...");
|
Trace("Deleting value...");
|
||||||
db.Delete(Id);
|
db.Delete(Id);
|
||||||
|
@ -67,7 +67,7 @@ namespace DML.Application.Classes
|
||||||
Trace("Beginning attachment download...");
|
Trace("Beginning attachment download...");
|
||||||
|
|
||||||
Debug("Building filename...");
|
Debug("Building filename...");
|
||||||
var fileName = Path.Combine(Core.Settings.OperatingFolder, Core.Settings.FileNameScheme);
|
var fileName = Path.Combine(Core.Core.Settings.OperatingFolder, Core.Core.Settings.FileNameScheme);
|
||||||
|
|
||||||
Debug($"Base filename: {fileName}");
|
Debug($"Base filename: {fileName}");
|
||||||
|
|
||||||
|
@ -88,7 +88,9 @@ namespace DML.Application.Classes
|
||||||
|
|
||||||
Trace("Adding extension if required");
|
Trace("Adding extension if required");
|
||||||
if (extensionRequired)
|
if (extensionRequired)
|
||||||
|
{
|
||||||
fileName += Path.GetExtension(Filename);
|
fileName += Path.GetExtension(Filename);
|
||||||
|
}
|
||||||
|
|
||||||
Debug($"Final filename: {fileName}");
|
Debug($"Final filename: {fileName}");
|
||||||
|
|
||||||
|
@ -104,7 +106,7 @@ namespace DML.Application.Classes
|
||||||
Logger.Debug($"Downloaded attachment {Id}.");
|
Logger.Debug($"Downloaded attachment {Id}.");
|
||||||
|
|
||||||
|
|
||||||
Core.Scheduler.AttachmentsDownloaded++;
|
Core.Core.Scheduler.AttachmentsDownloaded++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace DML.Application.Classes
|
||||||
public void Store()
|
public void Store()
|
||||||
{
|
{
|
||||||
Logger.Trace("Getting settings collection...");
|
Logger.Trace("Getting settings collection...");
|
||||||
var settingsDB = Core.Database.GetCollection<Settings>("settings");
|
var settingsDB = Core.Core.Database.GetCollection<Settings>("settings");
|
||||||
|
|
||||||
Logger.Debug("Storing settings to database...");
|
Logger.Debug("Storing settings to database...");
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ using Discord;
|
||||||
using Discord.Net;
|
using Discord.Net;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using DML.AppCore.Classes;
|
using DML.AppCore.Classes;
|
||||||
|
using DML.Application.Classes;
|
||||||
using DML.Application.Classes.RPC;
|
using DML.Application.Classes.RPC;
|
||||||
using DML.Application.Dialogs;
|
using DML.Application.Dialogs;
|
||||||
using DML.Client;
|
using DML.Client;
|
||||||
|
@ -35,7 +36,7 @@ using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Logger = SweetLib.Utils.Logger.Logger;
|
using Logger = SweetLib.Utils.Logger.Logger;
|
||||||
|
|
||||||
namespace DML.Application.Classes
|
namespace DML.Application.Core
|
||||||
{
|
{
|
||||||
public static class Core
|
public static class Core
|
||||||
{
|
{
|
||||||
|
@ -118,6 +119,8 @@ namespace DML.Application.Classes
|
||||||
Database = new LiteDatabase(databasePath);
|
Database = new LiteDatabase(databasePath);
|
||||||
Database.Log.Logging += (message) => Logger.Trace($"LiteDB: {message}");
|
Database.Log.Logging += (message) => Logger.Trace($"LiteDB: {message}");
|
||||||
|
|
||||||
|
Migrator.CheckMigrations();
|
||||||
|
|
||||||
Logger.Debug("Loading settings collection out of database...");
|
Logger.Debug("Loading settings collection out of database...");
|
||||||
var settingsDB = Database.GetCollection<Settings>("settings");
|
var settingsDB = Database.GetCollection<Settings>("settings");
|
||||||
if (settingsDB.Count() > 1)
|
if (settingsDB.Count() > 1)
|
67
src/Discord Media Loader.Application/Core/Migrator.cs
Normal file
67
src/Discord Media Loader.Application/Core/Migrator.cs
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#region LICENSE
|
||||||
|
/**********************************************************************************************
|
||||||
|
* Copyright (C) 2017-2019 - All Rights Reserved
|
||||||
|
*
|
||||||
|
* This file is part of "DML.Application".
|
||||||
|
* The official repository is hosted at https://github.com/Serraniel/DiscordMediaLoader
|
||||||
|
*
|
||||||
|
* "DML.Application" is licensed under Apache 2.0.
|
||||||
|
* Full license is included in the project repository.
|
||||||
|
*
|
||||||
|
* Users who edited Migrator.cs under the condition of the used license:
|
||||||
|
* - Serraniel (https://github.com/Serraniel)
|
||||||
|
**********************************************************************************************/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
using LiteDB;
|
||||||
|
using SweetLib.Utils.Extensions;
|
||||||
|
|
||||||
|
namespace DML.Application.Core
|
||||||
|
{
|
||||||
|
internal static class Migrator
|
||||||
|
{
|
||||||
|
internal static ushort Version => 1;
|
||||||
|
|
||||||
|
internal static void CheckMigrations()
|
||||||
|
{
|
||||||
|
var baseVersion = Core.Database.Engine.UserVersion;
|
||||||
|
|
||||||
|
for (var step = baseVersion; step <= Version; step++)
|
||||||
|
{
|
||||||
|
Migrate(step);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Migrate(ushort step)
|
||||||
|
{
|
||||||
|
switch (step)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
// base database
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
foreach (var jobDoc in Core.Database.Engine.Find("jobs", Query.All()))
|
||||||
|
{
|
||||||
|
// pseudo datetime snowflake conversion https://discordapp.com/developers/docs/reference#convert-snowflake-to-datetime
|
||||||
|
var pseudoId = 0UL;
|
||||||
|
var timestamp = (ulong)jobDoc["KnownTimestamp"].AsDouble * 1000; // milliseconds have not been stored
|
||||||
|
|
||||||
|
if (timestamp > 0)
|
||||||
|
{
|
||||||
|
pseudoId = timestamp - 1420070400000 << 22;
|
||||||
|
pseudoId -= (1000 * 60 * 60 * 24) << 22; // substract one random day of pseudo id just in case the timestamp has errors
|
||||||
|
}
|
||||||
|
|
||||||
|
jobDoc["LastMessageId"] = pseudoId;
|
||||||
|
|
||||||
|
Core.Database.Engine.Update("jobs", jobDoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core.Database.Engine.UserVersion = step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -164,13 +164,14 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Classes\Core.cs" />
|
<Compile Include="Core\Core.cs" />
|
||||||
<Compile Include="Classes\Job.cs" />
|
<Compile Include="Classes\Job.cs" />
|
||||||
<Compile Include="Classes\JobScheduler.cs" />
|
<Compile Include="Classes\JobScheduler.cs" />
|
||||||
<Compile Include="Classes\RPC\DiscordRpc.cs" />
|
<Compile Include="Classes\RPC\DiscordRpc.cs" />
|
||||||
<Compile Include="Classes\RPC\DiscordRpcHelper.cs" />
|
<Compile Include="Classes\RPC\DiscordRpcHelper.cs" />
|
||||||
<Compile Include="Classes\RPC\RpcWrapper.cs" />
|
<Compile Include="Classes\RPC\RpcWrapper.cs" />
|
||||||
<Compile Include="Classes\MediaData.cs" />
|
<Compile Include="Classes\MediaData.cs" />
|
||||||
|
<Compile Include="Core\Migrator.cs" />
|
||||||
<Compile Include="Dialogs\LoginDialog.cs">
|
<Compile Include="Dialogs\LoginDialog.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace DML.Application.Dialogs
|
||||||
private void LoginDialog_Shown(object sender, EventArgs e)
|
private void LoginDialog_Shown(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Trace("Login dialog shown.");
|
Trace("Login dialog shown.");
|
||||||
edToken.Text = Core.Settings.LoginToken;
|
edToken.Text = Core.Core.Settings.LoginToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoginDialog_FormClosing(object sender, FormClosingEventArgs e)
|
private void LoginDialog_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
@ -40,9 +40,9 @@ namespace DML.Application.Dialogs
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Debug("Adjusting login settings...");
|
Debug("Adjusting login settings...");
|
||||||
Core.Settings.LoginToken = edToken.Text;
|
Core.Core.Settings.LoginToken = edToken.Text;
|
||||||
|
|
||||||
Core.Settings.Store();
|
Core.Core.Settings.Store();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnOk_Click(object sender, EventArgs e)
|
private void btnOk_Click(object sender, EventArgs e)
|
||||||
|
|
|
@ -64,16 +64,16 @@ namespace DML.Application
|
||||||
lbVersion.Text = $"v{Assembly.GetExecutingAssembly().GetName().Version} Copyright © by Serraniel";
|
lbVersion.Text = $"v{Assembly.GetExecutingAssembly().GetName().Version} Copyright © by Serraniel";
|
||||||
|
|
||||||
Trace("Refreshing operating folder component...");
|
Trace("Refreshing operating folder component...");
|
||||||
edOperatingFolder.Text = Core.Settings.OperatingFolder;
|
edOperatingFolder.Text = Core.Core.Settings.OperatingFolder;
|
||||||
|
|
||||||
Trace("Refreshing name scheme component...");
|
Trace("Refreshing name scheme component...");
|
||||||
edNameScheme.Text = Core.Settings.FileNameScheme;
|
edNameScheme.Text = Core.Core.Settings.FileNameScheme;
|
||||||
|
|
||||||
Trace("Refreshing skip existing files component...");
|
Trace("Refreshing skip existing files component...");
|
||||||
cbSkipExisting.Checked = Core.Settings.SkipExistingFiles;
|
cbSkipExisting.Checked = Core.Core.Settings.SkipExistingFiles;
|
||||||
|
|
||||||
Trace("Refreshing thread limit component...");
|
Trace("Refreshing thread limit component...");
|
||||||
edThreadLimit.Value = Core.Settings.ThreadLimit;
|
edThreadLimit.Value = Core.Core.Settings.ThreadLimit;
|
||||||
|
|
||||||
if (cbGuild.Items.Count == 0)
|
if (cbGuild.Items.Count == 0)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +88,7 @@ namespace DML.Application
|
||||||
Trace("Refreshing job list component...");
|
Trace("Refreshing job list component...");
|
||||||
var oldIndex = lbxJobs.SelectedIndex;
|
var oldIndex = lbxJobs.SelectedIndex;
|
||||||
lbxJobs.Items.Clear();
|
lbxJobs.Items.Clear();
|
||||||
foreach (var job in Core.Scheduler.JobList)
|
foreach (var job in Core.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(new IdentifiedString<int>(job.Id, $"{FindServerById(job.GuildId)?.Name}:{FindChannelById(FindServerById(job.GuildId), job.ChannelId)?.Name}"));
|
||||||
}
|
}
|
||||||
|
@ -107,19 +107,19 @@ namespace DML.Application
|
||||||
}
|
}
|
||||||
|
|
||||||
Trace("Updating operating folder...");
|
Trace("Updating operating folder...");
|
||||||
Core.Settings.OperatingFolder = edOperatingFolder.Text;
|
Core.Core.Settings.OperatingFolder = edOperatingFolder.Text;
|
||||||
|
|
||||||
Trace("Updating name scheme...");
|
Trace("Updating name scheme...");
|
||||||
Core.Settings.FileNameScheme = edNameScheme.Text;
|
Core.Core.Settings.FileNameScheme = edNameScheme.Text;
|
||||||
|
|
||||||
Trace("Updating skip existing files...");
|
Trace("Updating skip existing files...");
|
||||||
Core.Settings.SkipExistingFiles = cbSkipExisting.Checked;
|
Core.Core.Settings.SkipExistingFiles = cbSkipExisting.Checked;
|
||||||
|
|
||||||
Trace("Updating thread limit...");
|
Trace("Updating thread limit...");
|
||||||
Core.Settings.ThreadLimit = (int)edThreadLimit.Value;
|
Core.Core.Settings.ThreadLimit = (int)edThreadLimit.Value;
|
||||||
|
|
||||||
Trace("Storing new settings...");
|
Trace("Storing new settings...");
|
||||||
Core.Settings.Store();
|
Core.Core.Settings.Store();
|
||||||
|
|
||||||
Info("New settings have been saved.");
|
Info("New settings have been saved.");
|
||||||
}
|
}
|
||||||
|
@ -211,12 +211,12 @@ namespace DML.Application
|
||||||
ChannelId = ((IdentifiedString<ulong>)cbChannel.SelectedItem).Id
|
ChannelId = ((IdentifiedString<ulong>)cbChannel.SelectedItem).Id
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!(from j in Core.Scheduler.JobList
|
if (!(from j in Core.Core.Scheduler.JobList
|
||||||
where j.GuildId == job.GuildId && j.ChannelId == job.ChannelId
|
where j.GuildId == job.GuildId && j.ChannelId == job.ChannelId
|
||||||
select j).Any())
|
select j).Any())
|
||||||
{
|
{
|
||||||
job.Store();
|
job.Store();
|
||||||
Core.Scheduler.JobList.Add(job);
|
Core.Core.Scheduler.JobList.Add(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshComponents();
|
RefreshComponents();
|
||||||
|
@ -234,11 +234,11 @@ namespace DML.Application
|
||||||
|
|
||||||
var jobId = ((IdentifiedString<int>)lbxJobs.SelectedItem).Id;
|
var jobId = ((IdentifiedString<int>)lbxJobs.SelectedItem).Id;
|
||||||
|
|
||||||
var job = Core.Scheduler.JobList.FirstOrDefault(j => j.Id == jobId);
|
var job = Core.Core.Scheduler.JobList.FirstOrDefault(j => j.Id == jobId);
|
||||||
if (job != null)
|
if (job != null)
|
||||||
{
|
{
|
||||||
Core.Scheduler.JobList.Remove(job);
|
Core.Core.Scheduler.JobList.Remove(job);
|
||||||
Core.Scheduler.RunningJobs.Remove(job.Id);
|
Core.Core.Scheduler.RunningJobs.Remove(job.Id);
|
||||||
job.Stop();
|
job.Stop();
|
||||||
job.Delete();
|
job.Delete();
|
||||||
}
|
}
|
||||||
|
@ -249,9 +249,9 @@ namespace DML.Application
|
||||||
|
|
||||||
private void tmrRefreshProgress_Tick(object sender, System.EventArgs e)
|
private void tmrRefreshProgress_Tick(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
var scanned = Core.Scheduler.MessagesScanned;
|
var scanned = Core.Core.Scheduler.MessagesScanned;
|
||||||
var totalAttachments = Core.Scheduler.TotalAttachments;
|
var totalAttachments = Core.Core.Scheduler.TotalAttachments;
|
||||||
var done = Core.Scheduler.AttachmentsDownloaded;
|
var done = Core.Core.Scheduler.AttachmentsDownloaded;
|
||||||
|
|
||||||
var progress = totalAttachments > 0 ? (int)(100 * done / totalAttachments) : 0;
|
var progress = totalAttachments > 0 ? (int)(100 * done / totalAttachments) : 0;
|
||||||
progress = Math.Min(Math.Max(0, progress), 100);
|
progress = Math.Min(Math.Max(0, progress), 100);
|
||||||
|
@ -260,16 +260,16 @@ namespace DML.Application
|
||||||
|
|
||||||
lbProgress.Text = $"Scanned: {scanned} Downloaded: {done} Open: {totalAttachments - done}";
|
lbProgress.Text = $"Scanned: {scanned} Downloaded: {done} Open: {totalAttachments - done}";
|
||||||
|
|
||||||
if (Core.Settings.UseRPC)
|
if (Core.Core.Settings.UseRPC)
|
||||||
{
|
{
|
||||||
Core.RpcPresence.details = "Downloading media files";
|
Core.Core.RpcPresence.details = "Downloading media files";
|
||||||
Core.RpcPresence.state = $"{done} / {totalAttachments} ({pgbProgress.Value}%)";
|
Core.Core.RpcPresence.state = $"{done} / {totalAttachments} ({pgbProgress.Value}%)";
|
||||||
Core.RpcPresence.largeImageKey = "main";
|
Core.Core.RpcPresence.largeImageKey = "main";
|
||||||
Core.RpcPresence.largeImageText = "Visit discordmedialoader.net";
|
Core.Core.RpcPresence.largeImageText = "Visit discordmedialoader.net";
|
||||||
Core.RpcPresence.smallImageKey = "author";
|
Core.Core.RpcPresence.smallImageKey = "author";
|
||||||
Core.RpcPresence.smallImageText = "Made by Serraniel";
|
Core.Core.RpcPresence.smallImageText = "Made by Serraniel";
|
||||||
|
|
||||||
Core.RpcUpdatePresence();
|
Core.Core.RpcUpdatePresence();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ namespace DML.Application
|
||||||
|
|
||||||
private void showTokenToolStripMenuItem_Click(object sender, EventArgs e)
|
private void showTokenToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Clipboard.SetText(Core.Settings.LoginToken);
|
Clipboard.SetText(Core.Core.Settings.LoginToken);
|
||||||
MessageBox.Show(this, "Your login token has been copied to your clipboard.", "Discord Media Loader",
|
MessageBox.Show(this, "Your login token has been copied to your clipboard.", "Discord Media Loader",
|
||||||
MessageBoxButtons.OK);
|
MessageBoxButtons.OK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using DML.Application.Core;
|
||||||
|
using Nito.AsyncEx;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using DML.Application.Classes;
|
|
||||||
using Nito.AsyncEx;
|
|
||||||
|
|
||||||
namespace Discord_Media_Loader
|
namespace Discord_Media_Loader
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue