Files
Disco/Disco.Services/Tasks/ScheduledTaskMockStatus.cs
T
Gary Sharp 27c21175d7 Certificate/wireless plugins; major refactoring
Migrate much of BI to Services.
Added Wireless Profile Provider plugin feature.
Added Certificate Authority Provider plugin feature.
Modified Certificate Provider plugin feature.
Database migration v17, for Device Profiles.
Enrolment Client Updated to support CA Certificates, Wireless Profiles
and Hardware Info.
New Client Enrolment Protocol to support new features.
Plugin Manifest Generator added to main solution.
Improved AD search performance.
2016-09-28 20:17:55 +10:00

118 lines
3.8 KiB
C#

using System;
namespace Disco.Services.Tasks
{
public class ScheduledTaskMockStatus : IScheduledTaskStatus
{
public string TaskName { get; private set; }
public byte Progress { get; set; }
public string CurrentProcess { get; set; }
public string CurrentDescription { get; set; }
public bool IgnoreCurrentProcessChanges { get; set; }
public bool IgnoreCurrentDescription { get; set; }
public double ProgressMultiplier { get; set; }
public byte ProgressOffset { get; set; }
public string FinishedMessage { get; set; }
public string FinishedUrl { get; set; }
public Exception TaskException { get; set; }
public ScheduledTaskMockStatus(string TaskName)
{
this.TaskName = TaskName;
}
private byte CalculateProgressValue(byte Progress)
{
return (byte)((Progress * this.ProgressMultiplier) + this.ProgressOffset);
}
public void UpdateStatus(byte Progress)
{
this.Progress = CalculateProgressValue(Progress);
}
public void UpdateStatus(double Progress)
{
UpdateStatus((byte)Progress);
}
public void UpdateStatus(string CurrentDescription)
{
if (!IgnoreCurrentDescription)
this.CurrentDescription = CurrentDescription;
}
public void UpdateStatus(byte Progress, string CurrentDescription)
{
this.Progress = CalculateProgressValue(Progress);
if (!IgnoreCurrentDescription)
this.CurrentDescription = CurrentDescription;
}
public void UpdateStatus(double Progress, string CurrentDescription)
{
UpdateStatus((byte)Progress, CurrentDescription);
}
public void UpdateStatus(byte Progress, string CurrentProcess, string CurrentDescription)
{
this.Progress = CalculateProgressValue(Progress);
if (!IgnoreCurrentProcessChanges)
this.CurrentProcess = CurrentProcess;
if (!IgnoreCurrentDescription)
this.CurrentDescription = CurrentDescription;
}
public void UpdateStatus(double Progress, string CurrentProcess, string CurrentDescription)
{
UpdateStatus((byte)Progress, CurrentProcess, CurrentDescription);
}
public void SetFinishedUrl(string FinishedUrl)
{
this.FinishedUrl = FinishedUrl;
}
public void SetFinishedMessage(string FinishedMessage)
{
this.FinishedMessage = FinishedMessage;
}
public void Finished()
{
Finished(this.FinishedMessage, this.FinishedUrl);
}
public void Finished(string FinishedMessage)
{
Finished(FinishedMessage, this.FinishedUrl);
}
public void Finished(string FinishedMessage, string FinishedUrl)
{
this.FinishedMessage = FinishedMessage;
this.FinishedUrl = FinishedUrl;
}
public void SetTaskException(Exception TaskException)
{
this.TaskException = TaskException;
}
public void LogWarning(string Message)
{
ScheduledTasksLog.LogScheduledTaskWarning(TaskName, null, Message);
}
public void LogInformation(string Message)
{
ScheduledTasksLog.LogScheduledTaskInformation(TaskName, null, Message);
}
[Obsolete("Use the constructor which requires a TaskName instead")]
public static ScheduledTaskMockStatus Create()
{
return new ScheduledTaskMockStatus("Unknown Task");
}
public static ScheduledTaskMockStatus Create(string TaskName)
{
return new ScheduledTaskMockStatus(TaskName);
}
}
}