Class name is "AXLog_ext". "CreateLine" is the Method
I'm calling the class in executesection of the report.
public void executeSection()
{
AXLog_ext aXLog_ext = new AXLog_ext();
Set permissionSet;
InteropPermission interopPermission;
;
interopPermission = new InteropPermission(InteropKind::ComInterop);
permissionSet = new Set(Types::Class);
permissionSet.add(interopPermission);
CodeAccessPermission::assertMultiple(permissionSet);
aXLog_ext.CreateLine(startdatetime, ObjecttName ,enum2str(element.report().applObjectType()));
super();
}
The method of class " AXLog_ext " contains the below code.
public void CreateLine(utcdatetime _startdatetime, str _ObjectName, str _ObjectType)
{
COM adoConn;
COM recordSet;
COM fields;
COM field;
COMVariant fieldValue;
System.String hostName = System.Net.Dns::GetHostName();
System.Net.IPHostEntry hostEntry = System.Net.Dns::GetHostEntry(hostName);
System.Net.IPAddress[] addresses = hostEntry.get_AddressList();
System.Net.IPAddress address;
System.Net.Sockets.AddressFamily addressFamily;
System.Collections.IEnumerator enumerator = addresses.GetEnumerator();
str IPaddress, hname, sqlquery;
;
while (enumerator.MoveNext())
{
address = enumerator.get_Current();
addressFamily = address.get_AddressFamily();
if (addressFamily == System.Net.Sockets.AddressFamily::InterNetwork)
{
IPaddress = address.ToString();
}
}
hname = hostname;
try
{
sqlquery = "insert into AxReportUsageDetails(UserId, StartDateTime, EndDateTime, Timelapsed, ObjectName, ObjectType, ClientsIP, HostName)";
sqlquery += " values ('" + XUserInfo::find(false, curUserId()).name + "','"
+ datetime2Str(_startdatetime) + "','" + datetime2Str(DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(), TimeZone::GMTPLUS0530CHENNAI_KOLKATA_MUMBAI)) + "','"
+ int2str(DateTimeUtil::getDifference(DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(), TimeZone::GMTPLUS0530CHENNAI_KOLKATA_MUMBAI), _startdatetime)) + "', '"
+ _ObjectName + "', '" + _ObjectType + "', '" + IPaddress + "', '" + hname + "')";
adoConn = new COM("ADODB.Connection");
adoConn.open(@"Provider=SQLOLEDB;Integrated Security=SSPI;Data Source=ITSD-01\SQLEXPRESS;Initial Catalog=AxaptaReportUsage;");
recordSet = adoConn.execute(sqlquery);
}
catch(Exception::Error)
{
}
adoConn.close();
}