Question

I want to access the history of task on a remote server. I tried this library and got stuck at the point, where I access the history. At the moment only the scheduled tasks are printed, but I would like to print their history as well. Does someone has an idea what is wrong?

I'm a little concerned about the t.path variable because it looks like this "\taskname". Could this be the problem?

namespace Inbox_Workflow
{
    class Program
    {
        static void Main(string[] args)
        {
            TaskService ts = new TaskService("\\server", "user", "abc", "abc");
            EnumAllTasks(ts);
            Console.ReadKey(true)
        }

        static void EnumAllTasks(TaskService ts)
        {
                EnumFolderTasks(ts.RootFolder);
        }

        static void EnumFolderTasks(TaskFolder fld)
        {
            foreach (Task task in fld.Tasks)
                ActOnTask(task);
        }

       static void ActOnTask(Task t)
        {
            Console.Write(t+" \n");
            TaskEventLog log = new TaskEventLog(t.Path);
            foreach (TaskEvent item in log)
                Console.Write(item + " \n");
        }

    }
}

No correct solution

OTHER TIPS

Nope, the \taskname is just fine, in fact it's required (it's the path).

You're having the same issue I was having until I re-read the docs

If you use the TaskEventLog constructor which specifies a remote machine, you will need to use impersonation to logon to an account with privileges to the remote machine before instantiating the TaskEventLog.

So, Change your ActOnTask from this

TaskEventLog log = new TaskEventLog(t.Path);

To This:

TaskEventLog log = new TaskEventLog("server", t.Path, "Domain", "UserName", "Password");

And you should be good to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top