Hello -
- I am trying to call a job from C# .NET and am not seeing the behaviour I was thinking of.
- I would like to call the AX job frmo a .NET program to run periodially on a schedule, but not using AX Batch.
- It seems so simple that I’m not sure what I am missing.
A. When I use this one (null for server and config) , it works, but I cannot tell which config it is choosing. (somewhere in the registry?)
ax.Logon(“100”, “en-us”, null, null);
B. When I use this style it seems to ignore the config file and again, just use some default.
AxConfig = @"\AXSERVER\AxConfigs\AX4TEST.axc";
ax.Logon(“100”, “en-us”, “myobjectserver”, AxConfig);
Perhaps the correct answer is just to use the Business Connector Proxy.
However, either way I need to specify which config to use.
Question 1 : when using “Logon” how does it choose the AX config to use?
Question 2: Does the proxy use up an AX license - I.e. require a dedicated AX user account?
Thanks for any guidance you can provide.
Don
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Dynamics.BusinessConnectorNet;
namespace Mynamespace
{
class RunAxJob
{
static void Main(string[] args)
{
Axapta ax;
String AxConfig, AxJob;
AxConfig = @"\AXSERVER\AxConfigs\AX4TEST.axc";
AxJob = “MyAxJob”;
ax = new Axapta();
try
{
ax.Logon(“100”, “en-us”, “myobjectserver”, AxConfig);
// ax.Logon(“100”, “en-us”, null, null);
}
catch (Exception)
{
Console.WriteLine(“Exception occurred during logon: {0}”, AxConfig);
}
Console.WriteLine(“Start - run AX job: {0}”,AxJob);
try
{
ax.CallJob(AxJob);
}
catch (Exception myException)
{
Console.WriteLine(“Exception occurred during job call”);
Console.WriteLine(myException.Message);
}
Console.WriteLine(“Press any key to continue”);
Console.ReadKey(); // pause the console for unser input
ax.Logoff();
}
}
}