I’m trying to find all possible values of property LastJobState under RecurringJobDto…
I read docs and browse over sources but it is defined as string so I do not have idea what all possible values are…
- Do you have info what are possible values of LastJobState
- Why we do not use Enum hire? is it by dev reason?
Last what I found, is that some states can be readed from state definition…
Dto sources:
For all who are interested i do this for now:
public enum ScheduleState {
Enqueued,
Scheduled,
Processing,
Succeeded,
Failed,
Deleted,
Awaiting
}
try {
if (string.IsNullOrWhiteSpace(schedule_guid)) {
return null;
}
Dictionary<string, string> result;
// todo Revrite this hangfire connection t ouse connection
using (var connection = JobStorage.Current.GetConnection()) {
result = connection.GetAllEntriesFromHash($"recurring-job:{schedule_guid}");
if (result.ContainsKey("LastJobId") && !string.IsNullOrWhiteSpace(result["LastJobId"])) {
string last_id = result["LastJobId"];
var stateData = connection.GetStateData(last_id);
if (stateData != null) {
return stateData.Name.ToEnum<ScheduleState>();
}
}
}
} catch { }
return null;
public static class StringExtensions {
public static T ToEnum<T>(this string value, bool ignoreCase = true) {
return (T)Enum.Parse(typeof(T), value, ignoreCase);
}
}