Getting all the tasks scheduled in the Quartz.NET scheduler - quartz.net

How I can get all the tasks that has been scheduled to the Quartz scheduler to display in a web page?

Should be something like this:
string[] groups = myScheduler.JobGroupNames;
for (int i = 0; i < groups.Length; i++)
{
string[] names = myScheduler.GetJobNames(groups[i]);
for (int j = 0; j < names.Length; j++)
{
// groups[i]
// names[j]
}
}

Related

Question about Future execution order in Dart [duplicate]

This question already has answers here:
Dart - make long running synchronous function asynchronous
(3 answers)
Closed 10 months ago.
Here is my code,
Future<int> test() {
print('Start test()');
for (var i = 1; i < 100000; i++) {
for (var j = 1; j < 100000; j++) {
var k = i * j;
}
}
print('After a long running task in test()');
return Future<int>.value(1);
}
void main() {
test().then((result) => print('Done with test()'));
print('Done with main().');
}
and here is the output,
Start test()
After a long running task in test()
Done with main().
Done with test()
my question is, shouldn't 'Done with main()' be printed before 'After a long running task in test()'?
Use Future.microtask() if you want skip task.
Example:
Future<int> test() {
print('Start test()');
for (var i = 1; i < 100000; i++) {
for (var j = 1; j < 100000; j++) {
var k = i * j;
}
}
print('After a long running task in test()');
return Future<int>.value(1);
}
void main() {
Future.microtask(test);
print('Done with main().');
}
Output:
Done with main().
Start test()
After a long runnin task in test()

c++ builder: dynamically remove all TPanel's from TFramedVertScrollBox

In my C++ Builder Project i have a TFramedVertScrollBox (pnl_art_box) which dynamically gets TPanel's. I want to clear out all existing TPanel's before adding the "new" ones.
for(int i = 0; i < this->pnl_art_box->ComponentCount; i++)
{
// this here is where i dont find any solution ...
this->pnl_art_box->Components[i]->DestroyComponents();
}
for(int i = 0; i < i_article_amount;i++)
{
this->articlelistpanels[i] = new TPanel(this->pnl_art_box);
this->articlelistlabels[i] = new TLabel(this);
this->articlelistlabels[i]->Text = this->articlelist[i].get_name();
this->articlelistpanels[i]->Align = Fmx::Types::TAlignLayout::MostTop;
this->articlelistpanels[i]->AddObject(this->articlelistlabels[i]);
this->pnl_art_box->AddObject(this->articlelistpanels[i]);
}
At Google i only found very less help and none of them is in C++;
Would be nice, if someone could tell me, when i do wrong.
Sincerely Timo Treichel
I finally found it by myself.
The correct command had been:
for(int i = 1; i < this->pnl_art_box->ComponentCount; i++)
{
this->pnl_art_box->Components[i]->DisposeOf();
}

MVC Survey and capturing data

Im kinda new to MVC and have built a site with a risk calculator.
This all works fine the site works for users logging in and the form calculates the form then sends the user to the correct page.
When a user signs in with account and fills out the survey i want to capture the score on the database but cannot work out how/where to do this. Should i be writing the code in the behind file for the survey form?
here is the script
<script type="text/javascript">
function test_it(entry) {
if (entry.value != null && entry.value.length != 0) {
entry.value = "" + eval(entry.value);
}
computeForm(entry.form);
}
function computeForm(form) {
var total = 0
for (var count = 0; count < 5; count++) {
if (form.a[count].checked) {
var total = total + parseInt(form.a[count].value);
}
}
for (var count = 0; count < 5; count++) {
if (form.b[count].checked) {
var total = total + parseInt(form.b[count].value);
}
}
for (var count = 0; count < 5; count++) {
if (form.c[count].checked) {
var total = total + parseInt(form.c[count].value);
}
}
for (var count = 0; count < 5; count++) {
if (form.d[count].checked) {
var total = total + parseInt(form.d[count].value);
}
}
for (var count = 0; count < 5; count++) {
if (form.e[count].checked) {
var total = total + parseInt(form.e[count].value);
}
}
for (var count = 0; count < 5; count++) {
if (form.f[count].checked) {
var total = total + parseInt(form.f[count].value);
}
}
for (var count = 0; count < 5; count++) {
if (form.g[count].checked) {
var total = total + parseInt(form.g[count].value);
}
}
for (var count = 0; count < 5; count++) {
if (form.h[count].checked) {
var total = total + parseInt(form.h[count].value);
}
}
for (var count = 0; count < 5; count++) {
if (form.i[count].checked) {
var total = total + parseInt(form.i[count].value);
}
}
for (var count = 0; count < 5; count++) {
if (form.j[count].checked) {
var total = total + parseInt(form.j[count].value);
}
}
for (var count = 0; count < 5; count++) {
if (form.k[count].checked) {
var total = total + parseInt(form.k[count].value);
}
}
for (var count = 0; count < 5; count++) {
if (form.l[count].checked) {
var total = total + parseInt(form.l[count].value);
}
}
if (total <= 5) { window.location = "End_Page_1" }
else if (total <= 12) { window.location = "End_Page_2" }
else if (total <= 24) { window.location = "End_Page_3" }
else if (total <= 30) { window.location = "End_Page_4" }
else if (total <= 48) { window.location = "End_Page_5" }
}
</script>
Any ideas how i could do this would be much appreciated.
Andy
Suppose you have a Model
public class Calculator
{
public string Field1 {get;set;}
public string Field2 {get;set;}
public string Field3 {get;set;}
...
}
write a controller which would just send a empty model to the view. Like
public ActionResult FillSurvey()
{
Calculator calci = new Calculator();
return View(calci);
}
now right click this action and choose add view here choose strongly typed view. Choose your Model Calculator and also choose scffold template. choose create. A new View will be generated where in you can enter values and write one more method/Action in controller.Like
[HTTPPOST]
public ActionResult FillSurvey(Calculator calci)
{
//do whatever you want here. You will have all the values entered in UI
//captured in this method
}

Javascript - getElementID from scratch using BFS?

I'm trying to learn javascript, and spent tonight writing a getElementByID() function using Breadth-First Search. In short: I'm lost.
Fiddle: http://jsfiddle.net/timdown/a2Fm6/
Code:
var nodes = [];
function getElementById(node, id) {
alert(nodes.length);
if (node.childNodes[i].id == id) {
return node.childNodes[i];
} else if (node.childNodes[i].length > 0) {
for (var i = 0, len = node.childNodes.length; i < len; ++i) {
nodes.push(node.childNodes[i]);
}
}
if (nodes.length > 0) {
getElementById(nodes[0], id);
}
}
var el = getElementById(document.body, 'id');
Any help?
You're missing a for loop in the top half of your code. Where is i defined?
Here's how I'd write it:
function getElementById(node, id) {
//An array of all the nodes at the same depth
var nodes = [node];
//While the array is not empty
while(nodes.length) {
var newNodes = [];
for(var i = 0; i < nodes.length; i++) {
var children = nodes[i].childNodes;
for(var j = 0; j < children.length; j++) {
var child = children[j];
if(child.id == id) {
return child
}
newNodes.push(child);
}
}
//Replace nodes with an array of the nodes the next level down
nodes = newNodes
}
}

Getting all the active jobs from Quartz.NET scheduler

How I can get all the active jobs scheduled in the Quartz.NET scheduler? I tried the GetCurrentlyExecutingJobs() but it is returning always 0.
That method doesn't seem to work.
The only solution I had found was to loop through all the jobs:
var groups = sched.JobGroupNames;
for (int i = 0; i < groups.Length; i++)
{
string[] names = sched.GetJobNames(groups[i]);
for (int j = 0; j < names.Length; j++)
{
var currentJob = sched.GetJobDetail(names[j], groups[i]);
}
}
When a job is found it means that it is still active.
If you set your job as durable, though, it will never be deleted if there are no associated trigger.
In that situation this code works better:
var groups = sched.JobGroupNames;
for (int i = 0; i < groups.Length; i++)
{
string[] names = sched.GetJobNames(groups[i]);
for (int j = 0; j < names.Length; j++)
{
var currentJob = sched.GetJobDetail(names[j], groups[i]);
if (sched.GetTriggersOfJob(names[j], groups[i]).Count() > 0)
{
// still scheduled.
}
}
}
UPDATE:
I did some debugging to see what happens with GetCurrentlyExecutingJobs().
As a matter of fact it returns the job being executed but the elements are remove from the collection as soon as the job is executed.
You can check the 2 functions JobToBeExecuted and JobWasExecuted in the QuartzScheduler class.
A simpler loop option would be to get all of the job keys and iterate over them. This implementation is for a minimal API example. It gets all JobKeys from the scheduler and then iterates over each on to get the details and execution schedule. More details available in this sample repo: QuartzScheduler. If a job doesn't have a schedule, or it's scheduled execution has completed and there are no future executions planned then the job will not be included in the list of returned jobs.
app.MapGet("/schedules", async (ISchedulerFactory sf) =>
{
var scheduler = await sf.GetScheduler();
var definedJobDetails = new List<JobDetailsDto>();
var jobKeys = await scheduler.GetJobKeys(GroupMatcher<JobKey>.AnyGroup());
foreach (var jobKey in jobKeys)
{
var jobDetail = await scheduler.GetJobDetail(jobKey);
var jobSchedule = await scheduler.GetTriggersOfJob(jobKey);
if (jobDetail != null && jobSchedule != null)
{
definedJobDetails.Add(new JobDetailsDto(
jobDetail.Key.Name,
jobDetail.Key.Group,
jobDetail.Description,
jobSchedule.First().GetPreviousFireTimeUtc(),
jobSchedule.First().GetNextFireTimeUtc())
);
}
}
return definedJobDetails;
})

Resources