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


nexea.system
2023-11-21T06:58:09Z
Hello support,

I have the following code for .NET API.
I'd like to get more information about the task depending of TaskType and TaskId.
For example, if the task type is "CopyFile", get the values of "Source Folder", "Destination Folder", and "File Mask";
if the task is "Execut" return the value of "Execute", or "PowerShell" return the path of the "Powershell file", etc.

Also, if it possible to get the ifnormation about status of the task (if is Active or not)
How can I return this information?

Best regards,


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualCron;
using VisualCronAPI;
using static VisualCron.JobClass;

namespace VisualCronAPIFrame
{
    internal class Program
    {
        static void Main(string[] args)
        {

            try
            {
                Server s;
                Client c = new Client();
                Connection conn = new Connection();
                conn.ConnectionType = Connection.ConnectionT.Remote;
                conn.Address = "<server>";
                conn.Port = 16444;
                //conn.Token = null;    //Logon Token 
                conn.UserName = "userName";
                conn.PassWord = "securePass";

                Console.WriteLine("Hello " + conn.Address);
                s = c.Connect(conn, true);

                foreach (JobClass j in s.Jobs.GetAll())
                {
                    foreach (TaskClass t in j.Tasks)
                    {
                        Console.WriteLine(j.Id + "¬" + j.Group + "¬" + j.Name + "¬" + t.Name + "¬" + t.Id + "¬" + t.TaskType);
                    }
                }
                s.Disconnect();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
            }
        }
    }
}
Sponsor
Forum information
John Vaden
2023-12-04T20:21:49Z
Each task type has a property in the TaskClass class and they are usually named the same (or very similarly) as the task type. So, for the CopyFile task type, the property is called CopyFile. From there you can loop through the "FileCopyItems" as shown below (pseudo-code):


foreach ( TaskCopyFileItemClass item in t.CopyFile.FileCopyItems )
{
    item.DestinationDirectory;
    ...
}
Scroll to Top