/*
AIF vs Business Connector
AIF is terriblly slow as I have come to realise practically (Note: both have been tested with razor and traditional aspx), go for BC, use the code below to do your "thing"
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using BCN = Microsoft.Dynamics.BusinessConnectorNet;
namespace XXXXX.Controllers
{
public partial class AXConnector:IDisposable
{
protected BCN.Axapta ax;
public string ConnectorClass;
protected string strUserName = "abc", password = "xyz";
public AXConnector(string _connectorClass = "YourClassHapa")
{
try
{
this.ConnectorClass = _connectorClass;
this.ax = new BCN.Axapta();
//ax.Logon(null, null, null, null);
this.ax.LogonAs(this.strUserName.Trim(), "", new NetworkCredential(this.strUserName, this.password), "", "", "", "");
}
catch (Exception e)
{
throw;
}
}
public BCN.Axapta GetAxapta
{
get
{
return this.ax;
}
}
public BCN.AxaptaRecord Execute(string axTableName, string sqlStatement = "select forupdate * from %1")
{
#region hapa ndio vile unatumia the axRecord in your calling-methods
//BCN.AxaptaRecord axRecord = this.GetAxapta.CreateAxaptaRecord(axTableName);
//try
//{
// using (axRecord)
// {
// axRecord.ExecuteStmt(sqlStatement);
// while (axRecord.Found)
// {
// #region Read
// axRecord.get_Field("ID");
// axRecord.get_Field("Value1");
// #endregion
// #region Write
// ax.TTSBegin();
// axRecord.set_Field("ID", "2");
// axRecord.set_Field("Value1", "Testing New");
// axRecord.Update();
// ax.TTSCommit();
// #endregion
// axRecord.Next();
// }
// }
//}
//catch (Exception e)
//{
// throw;
//}
#endregion
return this.GetAxapta.CreateAxaptaRecord(axTableName);
}
public void Dispose()
{
try
{
this.ax.Logoff();
this.ax = null;
}
catch (Exception e)
{
e.Data.Clear();
}
}
}
}
/*
change where you feel appropriate - GEUZA YOTE - happy coding
send your comments/inquiries to onyangofred@yahoo.com;onyangofred@gmail.com
*/
AIF vs Business Connector
AIF is terriblly slow as I have come to realise practically (Note: both have been tested with razor and traditional aspx), go for BC, use the code below to do your "thing"
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using BCN = Microsoft.Dynamics.BusinessConnectorNet;
namespace XXXXX.Controllers
{
public partial class AXConnector:IDisposable
{
protected BCN.Axapta ax;
public string ConnectorClass;
protected string strUserName = "abc", password = "xyz";
public AXConnector(string _connectorClass = "YourClassHapa")
{
try
{
this.ConnectorClass = _connectorClass;
this.ax = new BCN.Axapta();
//ax.Logon(null, null, null, null);
this.ax.LogonAs(this.strUserName.Trim(), "", new NetworkCredential(this.strUserName, this.password), "", "", "", "");
}
catch (Exception e)
{
throw;
}
}
public BCN.Axapta GetAxapta
{
get
{
return this.ax;
}
}
public BCN.AxaptaRecord Execute(string axTableName, string sqlStatement = "select forupdate * from %1")
{
#region hapa ndio vile unatumia the axRecord in your calling-methods
//BCN.AxaptaRecord axRecord = this.GetAxapta.CreateAxaptaRecord(axTableName);
//try
//{
// using (axRecord)
// {
// axRecord.ExecuteStmt(sqlStatement);
// while (axRecord.Found)
// {
// #region Read
// axRecord.get_Field("ID");
// axRecord.get_Field("Value1");
// #endregion
// #region Write
// ax.TTSBegin();
// axRecord.set_Field("ID", "2");
// axRecord.set_Field("Value1", "Testing New");
// axRecord.Update();
// ax.TTSCommit();
// #endregion
// axRecord.Next();
// }
// }
//}
//catch (Exception e)
//{
// throw;
//}
#endregion
return this.GetAxapta.CreateAxaptaRecord(axTableName);
}
public void Dispose()
{
try
{
this.ax.Logoff();
this.ax = null;
}
catch (Exception e)
{
e.Data.Clear();
}
}
}
}
/*
change where you feel appropriate - GEUZA YOTE - happy coding
send your comments/inquiries to onyangofred@yahoo.com;onyangofred@gmail.com
*/
using System;
ReplyDeleteusing System.Net;
using BCN = Microsoft.Dynamics.BusinessConnectorNet;
public partial class AXConnector:IDisposable
{
protected BCN.Axapta ax;
protected string strUserName = "ogl", password = "Kenya123",
domain = "kenya.com", company = "kenya_company", aos = "serverName:2712";
public AXConnector()
{
try
{
this.ax = new BCN.Axapta();
this.ax.LogonAs(this.strUserName, domain,
new NetworkCredential(this.strUserName, this.password, domain),
company, "en-us", aos, "");
}
catch (Exception e)
{
throw;
}
}
public BCN.Axapta GetAxapta
{
get
{
return this.ax;
}
}
public void Dispose()
{
try
{
this.ax.Logoff();
this.ax = null;
}
catch (Exception e)
{
e.Data.Clear();
}
}
}