Some fixes so it does compile again
This commit is contained in:
parent
b52b6b4189
commit
3eb8750df7
|
@ -12,6 +12,13 @@ using static SweetLib.Utils.Logger.Logger;
|
|||
|
||||
namespace DML.AppCore.Classes
|
||||
{
|
||||
internal enum JobState
|
||||
{
|
||||
Idle,
|
||||
Scanning,
|
||||
Listening
|
||||
}
|
||||
|
||||
public class Job
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
@ -20,6 +27,8 @@ namespace DML.AppCore.Classes
|
|||
public double KnownTimestamp { get; set; } = 0;
|
||||
private double StopTimestamp { get; set; } = 0;
|
||||
private bool IsValid { get; set; } = true;
|
||||
internal JobState State { get; set; } = JobState.Idle;
|
||||
|
||||
|
||||
internal void Store()
|
||||
{
|
||||
|
@ -61,6 +70,10 @@ namespace DML.AppCore.Classes
|
|||
return (from c in server.TextChannels where c.Id == id select c).FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs scanning task of the job.
|
||||
/// </summary>
|
||||
/// <returns>Returns true if the newest messages have been scanned.</returns>
|
||||
internal async Task<bool> Scan()
|
||||
{
|
||||
Debug($"Starting scan of guild {GuildId} channel {ChannelId}...");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using DML.AppCore.Classes;
|
||||
|
@ -7,7 +8,6 @@ using System.Globalization;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using DML.Application.Classes;
|
||||
|
@ -95,21 +95,29 @@ namespace DML.Application.Classes
|
|||
//foreach (var job in JobList)
|
||||
for (var i = JobList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
try
|
||||
if (JobList[i].State == JobState.Idle)
|
||||
{
|
||||
var job = JobList[i];
|
||||
Logger.Debug($"Checking job {job}");
|
||||
|
||||
Task.Run(async () =>
|
||||
try
|
||||
{
|
||||
var foundCount = await job.Scan();
|
||||
while (foundCount > 0)
|
||||
foundCount = await job.Scan();
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex.Message);
|
||||
var job = JobList[i];
|
||||
Logger.Debug($"Checking job {job.Id}");
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var scanFinished = await job.Scan();
|
||||
Logger.Trace($"Scan result of {job.Id}: {scanFinished}");
|
||||
|
||||
while (!scanFinished)
|
||||
{
|
||||
scanFinished = await job.Scan();
|
||||
Logger.Trace($"Scan result of {job.Id}: {scanFinished}");
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue