Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


damienv
2008-03-17T13:53:57Z
Hello,

I'm doing an application to allow me to run a task from Visual Cron through a web service but ... i can't receive the list of tasks presents on the server.

Here a small piece of my code:


Client c = new Client();
c.LogToFile = false;
Connection conn = new Connection();
conn.Address = "myserver";
conn.UserName = "username";
conn.PassWord = "pwd";
conn.Port = 16444;
conn.ConnectionType = Connection.ConnectionT.Remote;
Server s = c.Connect(conn,true);
🅱s.Jobs.GetAll()[/b]


s.Jobs.GetAll() always returns me 0 but it's not true: there are tasks on my server.

Can you help me ?

Thx,

DAMIEN
Sponsor
Forum information
Support
2008-03-18T17:14:05Z
Have you tried the sample code and just add specifying the server name?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
damienv
2008-03-19T09:41:02Z
Yes, i have tried the sample but i have the same issue: no jobs found.

The connection to the server works because the properties "Connected" of my server object has "true" as value.

Where can i specify a "server name"?

Maybe, there is an existing solution to allow me to run a job from Visual Cron by calling a url or a web service?

Thx
adutoit
2008-03-19T13:18:02Z
I have experienced exactly the same problem with the API. The only way I got around it was to insert a delay between the Connect() and GetAll()

System.Threading.Thread.Sleep(1000).

There must be a timing issue in the API whereby if you execute the code under debug it functions correctly – compile and install on a fast server with a remote server connection and the GetAll() returns 0 items



damienv
2008-03-19T14:00:01Z
adutoit wrote:

I have experienced exactly the same problem with the API. The only way I got around it was to insert a delay between the Connect() and GetAll()

System.Threading.Thread.Sleep(1000).

There must be a timing issue in the API whereby if you execute the code under debug it functions correctly – compile and install on a fast server with a remote server connection and the GetAll() returns 0 items



Thx a lot!

Indeed with a "Sleep", i can retrieve the list of jobs

=d>
Support
2008-03-19T14:04:53Z
Thanks for the heads up. We will investigate that. It should wait until the connection has been made. We will get back to you.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
vbaranov
2008-04-30T17:03:48Z
I am having a similar issue. The code iterates between showing 0 jobs and no jobs and even

[NullReferenceException: Object reference not set to an instance of an object.]
VisualCronAPI.Jobs.Get(String id) +83


I know I have specified the id correctly, but the code still treats me the same. I have tried the delay too, but can't find the right combination of when it works.

billweh
2008-05-08T03:54:34Z
I'm having this issue too. It was working fine, when I load the VisualCron Client - it connects and shows me all 62 of my jobs. However, my app which had been showing the jobs now comes back with 0 jobs.

I've tried adding a Sleep(1000) in between the connect and the request and that didn't do the trick.

I tried adding an event on the DelegateOnConnected() and that didn't do the trick - it did fire, but I still got 0 jobs.

Does the VC app use these API DLLS? If not, can we have access to the actual calls that are being made?

I'm trying to put something together that will eventually feed a Sharepoint Portal and I need to have this stuff be reliable.

I pulled the DLLs out of my references, deleted them from my debug directory and re-added them and rebuilt and still no cigar.

I wish I could say it was after I added the event that it started to go in the crapper, but it was happening before that. I rebooted and that did the trick, but obviously that's not a long term (or short term for that matter) solution. :)

I'm using the latest and greatest version of the program and VS 2005 SP1.

I'm running on Vista Business Edition if that matters. (I hope not).

Support
2008-05-08T08:03:24Z
Hi all,

try downloading the latest version from the site. We are updating the page today. It still says 4.8.4 but you get 4.9.1 when you downloading it from the server.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
billweh
2008-05-08T16:30:47Z
When I went to install the new version on my local machine, it informed me that I had to uninstall the old version first and then install the new one.

Is there anyway to get this to do an inplace update? I'm concerned that going forward when I have this in production, to update it I'm going to have to remove the product before I can install an update?

Will my scheduled jobs remain or am I going to have to save them, then uninstall, install and restore the jobs?


*** Update ****

That didn't fix it either. I am calling a Server.Disconnect() (off of the variable I'm using for the Server instance) on the form closing, and that doesn't seem to matter either.

Support
2008-05-08T16:35:06Z
Unfortunately not, as a lot of dll:s has been updated since then and you will get reference problems. But you could install it on another machine and copy the dll:s to use in a local directory.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2008-05-08T17:08:13Z
I am not sure what you mean with the ** update ** - what you are referring to. But upgrading should keep the Jobs. I only recommend that you do a backup before.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
billweh
2008-05-08T17:08:36Z
I am copying the DLLs locally to my project executable directory. But that doesn't seem to be helping matters either.

I will be able to run the program and connect and get all of the jobs several times in a row, then I run it again and it stops grabbing the jobs. If I wait a while - perhaps it starts working again, I try rebuilding the solution - doesn't always work.

Here is my code:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using VisualCronAPI;
using VisualCron;

namespace TestApp
{
  public partial class Form1 : Form
  {
    private DataTable dtStatus = new DataTable();
    private Server s = null;

    public Form1()
    {
      InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
      txtServer.Text = "myServer";
      txtUser.Text = "myName";
      txtPassword.Text = "myPassword";
      txtPort.Text = "16444";

      dtStatus.Columns.Add(new DataColumn("Name", typeof(string)));
      dtStatus.Columns.Add(new DataColumn("Description", typeof(string)));
      dtStatus.Columns.Add(new DataColumn("Active", typeof(string)));
      dtStatus.Columns.Add(new DataColumn("Last Exec", typeof(DateTime)));
      dtStatus.Columns.Add(new DataColumn("Next Exec", typeof(DateTime)));
      dtStatus.Columns.Add(new DataColumn("Run Time", typeof(double)));
      dtStatus.Columns.Add(new DataColumn("Status", typeof(string)));
      dgStatus.DataSource = dtStatus;
    }

    void Client_EventOnConnected(Client c, Server s)
    {
      tssLabel.Text = "Connected to Server: " + txtServer.Text + " Server Time: " + s.ServerTime.ToShortDateString() + " " + s.ServerTime.ToShortTimeString();
      
      ArrayList jobs = s.Jobs.GetAll();
      DataRow dr;
      int i = 1;
      double iCnt = (double)jobs.Count;
      tssLabel.Text = "Retrieving Jobs...";
      foreach (JobClass j in jobs)
      {
        tssProgress.Value = (int)(i / iCnt) * 100;
        dr = dtStatus.NewRow();
        dr["Name"] = j.Name;
        dr["Description"] = j.Description;
        dr["Active"] = j.Stats.Active.ToString();
        dr["Last Exec"] = j.Stats.DateLastExecution;
        dr["Next Exec"] = j.Stats.DateNextExecution;
        dr["Run Time"] = j.Stats.ExecutionTime;
        dr["Status"] = j.Stats.Status.ToString();
        dtStatus.Rows.Add(dr);
        i++;
      }
      tssLabel.Text = "";
    }

    private void button1_Click(object sender, EventArgs e)
    {
      Client.EventOnConnected += new Client.DelegateOnConnected(Client_EventOnConnected);
      Client c = new Client();
      c.LogToFile = false;
      Connection conn = new Connection();
      conn.Address = txtServer.Text;
      conn.UserName = txtUser.Text;
      conn.PassWord = txtPassword.Text;
      conn.Port = Convert.ToInt32(txtPort.Text);
      conn.ConnectionType = Connection.ConnectionT.Remote;
      try
      {
        s = c.Connect(conn, true);
      }
      catch (Client.ClientLoginFailedException ex)
      {
        MessageBox.Show(ex.Message);
      }
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
      s.Disconnect();
    }
  }
}
Support
2008-05-08T17:10:39Z
I think you need to try this remotely on a new install to be sure that all dlls are updated.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
billweh
2008-05-08T17:42:14Z
I am connecting to a remote server, not one locally.

Are you saying I need to set up yet another development environment so that I can be sure I have new versions of the DLLs? What do I do the next time you come out with a release? Build another dev machine and move everything over there?

Is there anything I can turn on (logging wise) that might give us a better understanding of why it's not giving me a list of jobs? It's saying it's connected, it's giving me the proper server time - so I know it's connecting, it just doesn't always return the list of jobs.
billweh
2008-05-08T17:55:52Z
I just tried installing the server onto a virtual machine on my desktop - thinking that maybe it was network latency that was the issue, and when I ran the app, this time I noticed that I'm getting this in the Output window in VS:

Socket connected.
Error in GetAll, ex: System.NullReferenceException: Object reference not set to an instance of an object.
at VisualCronAPI.Jobs.GetAll()
'TestApp.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.ServiceProcess\2.0.0.0__b03f5f7f11d50a3a\System.ServiceProcess.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
IN: PROTOCOL
'TestApp.vshost.exe' (Managed): Loaded 'jvvao7zc', No symbols loaded.

So while I'm connected - the Jobs object doesn't seem to be initialized.
Support
2008-05-08T18:44:22Z
We will test your code but have you tested the sample client?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
billweh
2008-05-08T20:27:54Z
Yes and I get exactly the same response from the sample client.

I went through and deleted all copies of VisualCron*.dll off of my system (Except for the ones that are in the \program files\visualcron 4 directory).

One thing I also noticed - when I had an event handler on the OnConnected event, the Server object that was passed in was ALWAYS null. Now this may have been a side effect to it not getting any of the jobs, but after I pulled everything back out of the event, I did find that sometimes when I looked at the "Connected" property of the Server - it was set to false and even when it was true - I was not always able to get the jobs back.
Support
2008-05-08T20:54:37Z
I see a problem with your code. Even though you are connected it hasn't been synced. The event is not supposed to be used that way. It is just for information. So, what you should do is to move the things in the connect event under the:

s = c.Connect(conn, true);

What we can do is to implement a sync event which is more interesting if you want to use it that way.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
billweh
2008-05-08T21:59:18Z
Hmm, the reason I tried moving my code to the connected event was because I wasn't getting any jobs back when I had the code right after the call: s = c.Connect(conn, true);

I lifted that code right from the sample app, and other than specifying the "Address" of the remote server - it's almost identical.

I have the code back under the Connect call and it still doesn't return any jobs.

After the connect call - the values of the "s" variable are:

? s
{VisualCronAPI.Server}
Authenticated: true
ClientConnections: {VisualCronAPI.ClientConnections}
Conditions: {VisualCronAPI.Conditions}
Connected: true
ConnectionHandler: {VisualCronAPI.Connection}
Connections: {VisualCronAPI.Connections}
Credentials: {VisualCronAPI.Credentials}
InSync: true
InvokeControl: null
Jobs: {VisualCronAPI.Jobs}
License: {VisualCronAPI.License}
Notifications: {VisualCronAPI.Notifications}
Permissions: {VisualCronAPI.Permissions}
Processes: {VisualCronAPI.Processes}
Protocol: "4.7.0"
ServerTime: {5/8/2008 2:16:47 PM}
ServerTimeDiff: -2425409
Settings: {VisualCron.ServerSettingsClass}
Status: Disconnected
TimeExceptions: {VisualCronAPI.TimeExceptions}

Calling s.Jobs.GetAll() results in 0 jobs - even though I have 62 defined.


Support
2008-05-08T22:55:13Z
Is there any possibility we can see this in action. Using Yuuguu or similar?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2008-05-09T16:25:17Z
Sorry, I think it was an "update of the webpage problem". I guess you are still using 4.8.4? Please re-download again.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
billweh
2008-05-09T17:34:23Z
I grabbed the new version and ran the app twice in a row and it worked both times. So that's a good thing.

As for the web meeting - I forgot I have a conference I'm scheduled for this afternoon and won't be back until later this evening. Perhaps if I am still having problems on Monday we can confer.

I'll let you know.
billweh
2008-05-13T22:22:17Z
The new version seems to have done the trick.

One other question - I want to get a report of every job I have scheduled and the times that I have those jobs scheduled. Is there an easy way to get this information from the API in a "readable" format?

I have seen by looking at the Triggers array and then at the TTime object within the trigger, I get a list of the time triggers that are set, but there are a ton of fields in there and what I'm really just looking for is something that says:

Every 4 hrs from 12:00am to 11:59:59pm

Or something to that effect.

Thanks.
Support
2008-05-14T09:36:10Z
No, not yet. Please add that as a feature request.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top