UAN
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Microsoft.Dynamics.BusinessConnectorNet.Axapta DynAx;
DynAx =3D new =
Microsoft.Dynamics.BusinessConnectorNet.Axapta();
// Test the connection to the .NET Business Connector=20
// by using the proxy user.
System.Net.NetworkCredential nc =3D new =
System.Net.NetworkCredential("proxyBCAX", "********");
try
{
DynAx.LogonAs("proxyBCAX", "", nc, "", "", "", =
"C:\\Documents and Settings\\1314\\Escritorio\\BC.AXC");
//DynAx.LogonAs(Environment.UserName, "", null, "", "", =
"", "C:\\Documents and Settings\\1314\\Escritorio\\BC.AXC");
Console.WriteLine( "Success Login OK");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
}
}
CHU
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
label1.Text = "";
Microsoft.Dynamics.BusinessConnectorNet.Axapta DynAx = new
Microsoft.Dynamics.BusinessConnectorNet.Axapta();
Microsoft.Dynamics.BusinessConnectorNet.AxaptaRecord DynRec;
// Authenticate the user and establish a session.
DynAx.Logon(Company.Text, null, AOS.Text, Configuration.Text);
if (DynAx != null)
{
label1.Text = ("Login OK");
}
// Define the record as the AddressState table.
DynRec = DynAx.CreateAxaptaRecord("AddressState");
// Define the query that will run on the AddressState records.
// This will return all the data in the AddressState table with
// the cursor positioned at the first record in the table.
DynRec.ExecuteStmt("select * from %1");
// Check if the query returned any data.
if (DynRec.Found)
{
// Display the record on the form that was retrieved from the query.
textBox1.Text = (string)DynRec.get_Field("Name");
}
}
catch (Exception ex)
{
textBox1.Text = (ex.ToString());
textBox1.Text += (ex.Message);
label1.Text = ("Login Filed");
}
}
}
}
ZRI
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = "";
Microsoft.Dynamics.BusinessConnectorNet.Axapta DynAx = new
Microsoft.Dynamics.BusinessConnectorNet.Axapta();
Microsoft.Dynamics.BusinessConnectorNet.AxaptaRecord DynRec;
// Authenticate the user and establish a session.
System.Net.NetworkCredential nc = new System.Net.NetworkCredential(USER.Text, PASS.Text);
try
{
//"C:\\Documents and Settings\\1314\\Escritorio\\BC.AXC"
DynAx.LogonAs(AXUser.Text, Domain.Text, nc, Company.Text, null, AOS.Text, Configuration.Text);
if (DynAx != null)
{
label1.Text = ("Login OK");
}
// Define the record as the AddressState table.
DynRec = DynAx.CreateAxaptaRecord("AddressState");
// Define the query that will run on the AddressState records.
// This will return all the data in the AddressState table with
// the cursor positioned at the first record in the table.
DynRec.ExecuteStmt("select * from %1");
// Check if the query returned any data.
if (DynRec.Found)
{
// Display the record on the form that was retrieved from the query.
textBox1.Text = (string)DynRec.get_Field("Name");
}
//DynAx.Logoff();
}
catch (Exception ex)
{
textBox1.Text = (ex.ToString());
textBox1.Text += (ex.Message);
label1.Text = ("Login Filed");
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Security.Cryptography;
using System.IO;
using Microsoft.Dynamics.BusinessConnectorNet;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Axapta AX;
AX = new Axapta();
AX.Logon(“CNS”, null, “DYmanicsAx1:2713″ , null);
object[] Parmlist = new object[1];
AxaptaContainer Container = AX.CreateAxaptaContainer();
Container = (AxaptaContainer)AX.CallStaticRecordMethod(“InventDim”, “dimEnabledFieldList”, 1);
Console.WriteLine(BankAccountTable.Call(“balanceCur”, Container));
AX.Logoff();
}
Delete sample
// Execute a query to retrieve an editable record
// where the name is MyStateUpdated.
axRecord.ExecuteStmt(“select forupdate * from %1 where %1.Name ==
‘MyStateUpdated’”);
// If the record is found then delete the record.
if (axRecord.Found)
{
// Start a transaction that can be committed.
ax.TTSBegin();
axRecord.Delete();
// Commit the transaction.
ax.TTSCommit();
}
INSERT
// Create the .NET Business Connector objects.
Axapta ax;
AxaptaRecord axRecord;
string tableName = “AddressState”;
try
{
// Login to Microsoft Dynamics AX.
ax = new Axapta();
ax.Logon(null, null, null, null);
// Create a new AddressState table record.
using (axRecord = ax.CreateAxaptaRecord(tableName));
{
// Provide values for each of the AddressState record fields.
axRecord.set_Field(“NAME”, “MyState”);
axRecord.set_Field(“STATEID”, “MyState”);
axRecord.set_Field(“COUNTRYREGIONID”, “US”);
axRecord.set_Field(“INTRASTATCODE”, “”);
// Commit the record to the database.
axRecord.Insert();
}
}
catch (Exception e)
{
Console.WriteLine(“Error encountered: {0}”, e.Message);
// Take other error action as needed.
}
READ
// Create the .NET Business Connector objects.
Axapta ax;
AxaptaRecord axRecord;
string tableName = “AddressState”;
// The AddressState field names for calls to
// the AxRecord.get_field method.
string strNameField = “NAME”;
string strStateIdField = “STATEID”;
// The output variables for calls to the
// AxRecord.get_Field method.
object fieldName, fieldStateId;
try
{
// Login to Microsoft Dynamics AX.
ax = new Axapta();
ax.Logon(null, null, null, null);
// Create a query using the AxaptaRecord class
// for the StateAddress table.
using (axRecord = ax.CreateAxaptaRecord(tableName));
{
// Execute the query on the table.
axRecord.ExecuteStmt(“select * from %1″);
// Create output with a title and column headings
// for the returned records.
Console.WriteLine(“List of selected records from {0}”,
tableName);
Console.WriteLine(“{0}\t{1}”, strNameField, strStateIdField);
// Loop through the set of retrieved records.
while (axRecord.Found)
{
// Retrieve the record data for the specified fields.
fieldName = axRecord.get_Field(strNameField);
fieldStateId = axRecord.get_Field(strStateIdField);
// Display the retrieved data.
Console.WriteLine(fieldName + “\t” + fieldStateId);
// Advance to the next row.
axRecord.Next();
}
}
}
catch (Exception e)
{
Console.WriteLine(“Error encountered: {0}”, e.Message);
// Take other error action as needed.
}
UPDATE
// Create an Axapta record for the StateAddress table.
axRecord = ax.CreateAxaptaRecord(tableName);
// Execute a query to retrieve an editable record where the name is MyState.
axRecord.ExecuteStmt(“select forupdate * from %1 where %1.Name ==
‘MyState’”);
// If the record is found then update the name.
if (axRecord.Found)
{
// Start a transaction that can be committed.
ax.TTSBegin();
axRecord.set_Field(“Name”, “MyStateUpdated”);
axRecord.Update();
// Commit the transaction.
ax.TTSCommit();
}
Ahora q esta muy de moda lo del cambio contable por la nueva ley vamos a hacer un entorno de desarrollo.
Nos encontramos en algunos casos que una cambio de Service pack o una actualización grave sobre producción representa una incompatibilidad entre el trabajo de los usuarios y las tareas de desarrollo, sin llegar a exagerar como las instalaciones que hacíamos cuando heramos esclavos de las consultoras y a la “grupy” financiera de turno se le ocurría de debíamos tener el entorno de producción, el de preproducción y el de desarrollo. No es mala idea tener un lugar en el que poder trabajar con libertad tanto para desarrollo como para pruebas funcionales.
Axapta básicamente esta compuesto por un código fuente que se almacena en unos directorios dentro de unos archivos específicos y una base de datos. Todo esto no funciona sin un programa que interprete estos archivos y los enlace con la base de datos.
De esta manera para hacer un entorno de desarrollo a partir de producción solo debemos mantener esta coherencia directorio base de datos.
Ejemplo practico.
Tenemos una instalación tipo, 3.0 spX con una base de datos SQL server X.
Nuestra instalación se encuentra situada en “C:\Navision\Axapta Application\Appl” dentro del directorio tenemos los directorios de las diferentes aplicaciones. Normalmente Standard y producción.
Copiando producción y renombrar el directorio como Test ya tendríamos la mitad de nuestro entorno de desarrollo.
Después solo hay que realizar una copia de seguridad de la base de datos completa y restaurarla con otro nombre.
El último paso seria configurar el cliente o el AOS para que accedan al nuevo entorno y sincronicen los posibles cambios.
Para poder crear un archivo tipo bat o cmd con definirlo de esta manera “file = new asciiio(‘c:\\filex.bat’,'w’);” ya tenemos un fichero llamado filex.bat en c:\ . Ahora bien en nuestro c: o en el del sevidor???? Pues eso solo lo sabremos si el metdodo q hemos ejecutado se lanza del lado del cliente o del lado del servidor, y para salir de dudas mejor definir una metodo static y ponerle server para que de fijo se lance en el servidor donde se este ejecutando nuestro AOS (AX32serv.exe).
static server void Start()
{
asciiio file;
str txt;
;
winapi::deleteFile(‘C:\\file2.txt’);
file = new asciiio(‘c:\\filex.bat’,'w’);
if (file)
{
txt = (strfmt(‘net start “Axapta batch 1″ ‘));
file.write(txt);
file = null;
winapi::shellExecute(‘c:\\filex.bat’);
winapi::deleteFile(‘C:\\filex.txt’);
}
}
Args es utiliza para pasar argumentos al constructor de una clase. Args pueden transmitir información como el nombre, y los parámetros que llaman a una nueva clase.
Los formularios, informes y consultas utilizan la clase Args como primer argumento en el constructor.
Pasandole el nombre del objeto a crear a una clase args y despues llamar a classfactory con estos argumentos podemos inicializar fomularios, informes etc.
Args a = new Args(“CustTable”);
formRun fr = ClassFactory.FormRunClass(a);
fr.init();
fr.run();
para recuperar el objeto args en la clase de destino, por regla general existe un metodo que nos devuelve este dato.
elment.args() en el caso de formulario.
El objetivo de esto es poder pasar a traves de args objetos completos a otros contextos de ejecución de forma que podriamos abrir un formulario inicial F1 ejecutar otro formulario secundario F2 y poder ejecutar metodos del formulario 1 desde el formulario 2.
un ejemplo.
Hemos creado un from con un metodo para recuperar el texto de un strignedit y este texto lo vamos a pintar desde un report, utilizando para ello una clase intermedia o el metodo del form que lo ha llamado.
public void init()
{
object ob;
FIR_ReportClas FIR_ReportClas;
super();
//axl si no es la clase entonces es el formmm…
if (classIdGet(element.args().caller()) == classNum(FIR_ReportClas))
{
FIR_ReportClas = element.args().caller();
print FIR_ReportClas.texto();
}
else
{
ob = element.args().caller();
print ob.texto();
}
Desde este blog apostamos más por la utilidad y el buen hacer que por las facturas que van a cobrar las consultoras en ventas de productos Microsoft. Hemos de reconocer que AX es un buen producto como “erp” que ya se ha asentado en nuestro país y que día a día es una solución tanto para la pequeña como media empresa.
os_authent_prefix
Con un prefijo tipo ‘ops$’ nos sevira, de manera que oracle sepa identificar si el usuario del SO que solicita la conexión esta creado en oracle autorizando el acceso.
-- Windows
CREATE USER "OPS$DOMINIO.COM\DBO" IDENTIFIED EXTERNALLY;
GRANT CONNECT TO "OPS$DOMINIO.COM\DBO";
Crearemos un usuario en nuestro dominio en este caso DBO .





