Catatan: mailTo hanya bisa diisi 1 email, bila lebih, maka hanya email yg pertama saja yg diproses.
void Send_Emailx(str subjectx,str bodyx,str sendtomailx,str sendtonamex)
{
System.Net.Mail.MailMessage mailMessage;
System.Net.Mail.SmtpClient myMail;
System.Net.Mail.MailAddressCollection mailcoll;
System.Net.Mail.MailAddress mailFrom;
System.Net.Mail.MailAddress mailTo,mailTo2;
System.Net.Mail.MailAddress mailCC;
str receiverMailAddress;
str mailBody;
str smtpServer;
str mailSubject;
str CcMailAddress;
int SMTPPort;
#File
str mail,companynamex;
userinfo userInfo;
str pwd;
SysEmailParameters parameters = SysEmailParameters::find();
;
new InteropPermission(InteropKind::ClrInterop).assert();
mailSubject = subjectx;
companynamex = companyinfo::find().Name;
mailFrom = new System.Net.Mail.MailAddress(parameters.SMTPUserName , "AX Server "+companynamex);
mailTo = new System.Net.Mail.MailAddress(sendtomailx,sendtonamex);
mailCC = new System.Net.Mail.MailAddress('mail@gmail.com','mail');
mailcoll = new System.Net.Mail.MailAddressCollection();
mailBody = bodyx;
try
{
smtpServer = SysEmaiLParameters::find(false).SMTPRelayServerName;// using the SMTP server ip mailMessage = new System.Net.Mail.MailMessage(mailFrom,mailTo);
mailmessage.set_Subject(mailSubject);
mailmessage.set_Body(mailBody);
SMTPPort = SysEmaiLParameters::find(false).SMTPPortNumber;
myMail = new System.Net.Mail.SmtpClient(smtpServer, SMTPPort);
//myMail.set_EnableSsl(true);
// Untuk SSL enabled seperti: gmail, smtp.gmail.com, port 465 or 587
myMail.set_EnableSsl(false);
pwd = SysEmaiLParameters::password();
mymail.set_Credentials(New System.Net.NetworkCredential(parameters.SMTPUserName, pwd));
mymail.Send(mailmessage);
}
catch(Exception::CLRError)
{
throw Exception::CLRError;
}
mailMessage.Dispose();
CodeAccessPermission::revertAssert();
}
Thursday, December 27, 2012
Lihat daftar file pada folder
static void Test_ListDirFiles(Args _args)
{
FilePath filePath = 'X:\\DATA\\MyFolder';
FileNameFilter fileFilter = ["*.*", "All files"];
FileName fileName;
int fileHandle;
;
[fileHandle, fileName] = WinAPI::findFirstFile(strFmt("%1\\%2", filePath, conPeek(fileFilter, 1)));
while(fileName)
{
info(strFmt("%1%2", filePath, fileName));
fileName = winAPI::findNextFile(fileHandle);
}
}
{
FilePath filePath = 'X:\\DATA\\MyFolder';
FileNameFilter fileFilter = ["*.*", "All files"];
FileName fileName;
int fileHandle;
;
[fileHandle, fileName] = WinAPI::findFirstFile(strFmt("%1\\%2", filePath, conPeek(fileFilter, 1)));
while(fileName)
{
info(strFmt("%1%2", filePath, fileName));
fileName = winAPI::findNextFile(fileHandle);
}
}
Memindahkan file ke folder lain
static void Test_Move_One_File(Args _args)
{
System.Exception ex;
Set permSet = new Set(Types::Class);
str errorMsg;
FileName _srcFile,_destFile;
;
_srcFile = "c:\\DATA\\Asal\\copy.txt";
_destFile = "c:\\DATA\\Tujuan\\copy.txt";
try
{
permSet.add(new FileIOPermission(_srcFile, 'rw'));
permSet.add(new InteropPermission(InteropKind::ClrInterop));
permSet.add(new FileIOPermission(_destFile, 'rw'));
CodeAccessPermission::assertMultiple(permSet);
if(!System.IO.File::Exists(_srcFile))
{
Info("Source file not exist !! Proces terminated.");
Break;
}
else
{
Info("Source file exist !! File will be moved.");
if(System.IO.File::Exists(_destFile))
{
System.IO.File::Delete(_destFile);
}
}
System.IO.File::Move(strfmt(@"%1",_srcFile), strfmt(@"%1",_destFile));
CodeAccessPermission::revertAssert();
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
//return true;
}
{
System.Exception ex;
Set permSet = new Set(Types::Class);
str errorMsg;
FileName _srcFile,_destFile;
;
_srcFile = "c:\\DATA\\Asal\\copy.txt";
_destFile = "c:\\DATA\\Tujuan\\copy.txt";
try
{
permSet.add(new FileIOPermission(_srcFile, 'rw'));
permSet.add(new InteropPermission(InteropKind::ClrInterop));
permSet.add(new FileIOPermission(_destFile, 'rw'));
CodeAccessPermission::assertMultiple(permSet);
if(!System.IO.File::Exists(_srcFile))
{
Info("Source file not exist !! Proces terminated.");
Break;
}
else
{
Info("Source file exist !! File will be moved.");
if(System.IO.File::Exists(_destFile))
{
System.IO.File::Delete(_destFile);
}
}
System.IO.File::Move(strfmt(@"%1",_srcFile), strfmt(@"%1",_destFile));
CodeAccessPermission::revertAssert();
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
//return true;
}
View Reporting Service SQL Server dari AX 2009
1. Duplicate (copy-paste) form SRSReportView
2. Ganti url pada run(), arahkan pada reporting service sebagai contoh berikut:
public void run()
{
Microsoft.Dynamics.ReportingServices.ReportSettings settings = reportSettings;
Microsoft.Dynamics.ReportingServices.ReportException reportException;
str url;
str errorMessage;
int errorCode;
;
super();
try
{
// url = settings.BuildUrl(); --> ganti
url = http://[server]/Reports/Pages/Report.aspx?ItemPath=/DynamicsAx_AddOn/MyReportService
...
...
}
3. Buka form nya dan Tala.....
4. Bisa dilakukan untuk report service yg koneksi langsung ke raw database.
2. Ganti url pada run(), arahkan pada reporting service sebagai contoh berikut:
public void run()
{
Microsoft.Dynamics.ReportingServices.ReportSettings settings = reportSettings;
Microsoft.Dynamics.ReportingServices.ReportException reportException;
str url;
str errorMessage;
int errorCode;
;
super();
try
{
// url = settings.BuildUrl(); --> ganti
url = http://[server]/Reports/Pages/Report.aspx?ItemPath=/DynamicsAx_AddOn/MyReportService
...
...
}
3. Buka form nya dan Tala.....
4. Bisa dilakukan untuk report service yg koneksi langsung ke raw database.
Wednesday, August 8, 2012
Lookup query 2 table
Buat lookup query yang menggunakan 2 tabel, dalam hal ini table CustVendtExternalItem digunakan sebagai filter.
public void lookup()
{
//super();
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable), this);
Query query = new Query();
QueryBuildDataSource qbds;
AccountNum vendorx;
;
qbds = query.addDataSource(tablenum(InventTable));
//CustVendExternalItem;
// DIP_ItemVendor
//
qbds = qbds.addDataSource(tablenum(CustVendExternalItem));
qbds.addLink(fieldnum(CustVendExternalItem,ItemId),fieldnum(InventTable,ItemId));
qbds.joinMode(JoinMode::ExistsJoin);
qbds.relations(true);
vendorx = PurchTable.OrderAccount;
qbds.addRange(fieldNum(CustVendExternalItem,ModuleType)).value('Vendor');
qbds.addRange(fieldNum(CustVendExternalItem,CustVendRelation)).value(vendorx);
sysTableLookup.addLookupfield(fieldnum(InventTable, ItemId));
sysTableLookup.addLookupfield(fieldnum(InventTable, ItemName));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
public void lookup()
{
//super();
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable), this);
Query query = new Query();
QueryBuildDataSource qbds;
AccountNum vendorx;
;
qbds = query.addDataSource(tablenum(InventTable));
//CustVendExternalItem;
// DIP_ItemVendor
//
qbds = qbds.addDataSource(tablenum(CustVendExternalItem));
qbds.addLink(fieldnum(CustVendExternalItem,ItemId),fieldnum(InventTable,ItemId));
qbds.joinMode(JoinMode::ExistsJoin);
qbds.relations(true);
vendorx = PurchTable.OrderAccount;
qbds.addRange(fieldNum(CustVendExternalItem,ModuleType)).value('Vendor');
qbds.addRange(fieldNum(CustVendExternalItem,CustVendRelation)).value(vendorx);
sysTableLookup.addLookupfield(fieldnum(InventTable, ItemId));
sysTableLookup.addLookupfield(fieldnum(InventTable, ItemName));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Friday, June 8, 2012
Memindahkan file ke folder lain
Sebelumnya, pastikan sudah dapat hak akses untuk bisa hapus folder dan file tersebut
static void Test_Move_One_File(Args _args)
{
System.Exception ex;
Set permSet = new Set(Types::Class);
str errorMsg;
FileName _srcFile,_destFile;
;
_srcFile = "D:\\Move_Src\\File.txt";
_destFile = "D:\\Move_Dst\\File.txt";
try
{
permSet.add(new FileIOPermission(_srcFile, 'rw'));
permSet.add(new InteropPermission(InteropKind::ClrInterop));
permSet.add(new FileIOPermission(_destFile, 'rw'));
CodeAccessPermission::assertMultiple(permSet);
//Kalo file sumber tidak ada, maka batalkan proses
if(!System.IO.File::Exists(_srcFile))
{
Info("Source file not exist !! Proces terminated.");
Break;
}
else
{
Info("Source file exist !! File will be moved.");
if(System.IO.File::Exists(_destFile))
{
System.IO.File::Delete(_destFile);
}
}
System.IO.File::Move(strfmt(@"%1",_srcFile), strfmt(@"%1",_destFile));
CodeAccessPermission::revertAssert();
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
}
static void Test_Move_One_File(Args _args)
{
System.Exception ex;
Set permSet = new Set(Types::Class);
str errorMsg;
FileName _srcFile,_destFile;
;
_srcFile = "D:\\Move_Src\\File.txt";
_destFile = "D:\\Move_Dst\\File.txt";
try
{
permSet.add(new FileIOPermission(_srcFile, 'rw'));
permSet.add(new InteropPermission(InteropKind::ClrInterop));
permSet.add(new FileIOPermission(_destFile, 'rw'));
CodeAccessPermission::assertMultiple(permSet);
//Kalo file sumber tidak ada, maka batalkan proses
if(!System.IO.File::Exists(_srcFile))
{
Info("Source file not exist !! Proces terminated.");
Break;
}
else
{
Info("Source file exist !! File will be moved.");
if(System.IO.File::Exists(_destFile))
{
System.IO.File::Delete(_destFile);
}
}
System.IO.File::Move(strfmt(@"%1",_srcFile), strfmt(@"%1",_destFile));
CodeAccessPermission::revertAssert();
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
}
List nama-nama file dalam folder
static void Test_ListDirFiles(Args _args)
{
FilePath filePath = "d:\\Documents\\Project";
FileNameFilter fileFilter = ["*.*", "All files"];
FileName fileName;
int fileHandle;
;
// Get first file in directory
[fileHandle, fileName] = WinAPI::findFirstFile(strFmt("%1\\%2", filePath, conPeek(fileFilter, 1)));
// While files found
while(fileName)
{
// ------------------------------------------
// Filepath and filename are known here...
// ------------------------------------------
info(strFmt("%1%2", filePath, fileName));
// Get next file
fileName = winAPI::findNextFile(fileHandle);
}
}
{
FilePath filePath = "d:\\Documents\\Project";
FileNameFilter fileFilter = ["*.*", "All files"];
FileName fileName;
int fileHandle;
;
// Get first file in directory
[fileHandle, fileName] = WinAPI::findFirstFile(strFmt("%1\\%2", filePath, conPeek(fileFilter, 1)));
// While files found
while(fileName)
{
// ------------------------------------------
// Filepath and filename are known here...
// ------------------------------------------
info(strFmt("%1%2", filePath, fileName));
// Get next file
fileName = winAPI::findNextFile(fileHandle);
}
}
Sunday, March 18, 2012
Menambah record baru pada kedua company
Berikut ini digunakan untuk melakukan insert data ke 2 company dengan menggunakan class.
Syntax nya changeCompany("HSP").
static void Create_to_2Company(Args _args)
{
AxPurchTable table;
AxPurchLine line;
;
table = new AxPurchTable();
table.parmOrderAccount('');
table.parmInventLocationId('WAREHOUSE');
table.save();
line = new AxPurchLine();
line.axPurchTable(table);
line.parmItemId('A001'); // Item number Q987
line.parmPurchQty(12); // 12 pcs.
line.save();
changeCompany("HSP")
{
table = new AxPurchTable();
table.parmOrderAccount('');
table.parmInventLocationId('WAREHOUSE');
table.save();
line = new AxPurchLine();
line.axPurchTable(table);
line.parmItemId('A001'); // Item number Q987
line.parmPurchQty(12); // 12 pcs.
line.save();
}
}
Syntax nya changeCompany("HSP").
static void Create_to_2Company(Args _args)
{
AxPurchTable table;
AxPurchLine line;
;
table = new AxPurchTable();
table.parmOrderAccount('');
table.parmInventLocationId('WAREHOUSE');
table.save();
line = new AxPurchLine();
line.axPurchTable(table);
line.parmItemId('A001'); // Item number Q987
line.parmPurchQty(12); // 12 pcs.
line.save();
changeCompany("HSP")
{
table = new AxPurchTable();
table.parmOrderAccount('');
table.parmInventLocationId('WAREHOUSE');
table.save();
line = new AxPurchLine();
line.axPurchTable(table);
line.parmItemId('A001'); // Item number Q987
line.parmPurchQty(12); // 12 pcs.
line.save();
}
}
Monday, March 5, 2012
Lookup modifikasi
Berikut ini digunakan untuk membuat lookup sendiri. Kasusnya, nambah form dan EditString, namun tidak ada relasi ke datasource (EdiString lepasan gitu.....)
public void lookup()
{
//super();
//Inisialisasi sysTableLookupClass
sysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventItemgroup), this);
Query query = New Query();
QueryBuildDataSource qbdsTbl1, qbdsTbl2;
QueryBuildRange qbr;
;
//Tambah tabel
qbdsTbl1 = query.addDataSource(tableNum(InventItemgroup));
//Tambah rentang Query untuk membatasi daftar record
qbr = qbdsTbl1.addRange(fieldNum(InventItemgroup,ItemGroupId));
qbr.value();
qbr = qbdsTbl1.addRange(fieldNum(InventItemgroup,Name));
qbr.value();
qbdsTbl1.relations(true);
sysTableLookup.addLookupfield(fieldNum(InventItemgroup, ItemGroupId));
sysTableLookup.addLookupfield(fieldNum(InventItemgroup, Name));
sysTableLookup.parmQuery(query);
//Tampilkan drop down
sysTableLookup.performFormLookup();
}
public void lookup()
{
//super();
//Inisialisasi sysTableLookupClass
sysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventItemgroup), this);
Query query = New Query();
QueryBuildDataSource qbdsTbl1, qbdsTbl2;
QueryBuildRange qbr;
;
//Tambah tabel
qbdsTbl1 = query.addDataSource(tableNum(InventItemgroup));
//Tambah rentang Query untuk membatasi daftar record
qbr = qbdsTbl1.addRange(fieldNum(InventItemgroup,ItemGroupId));
qbr.value();
qbr = qbdsTbl1.addRange(fieldNum(InventItemgroup,Name));
qbr.value();
qbdsTbl1.relations(true);
sysTableLookup.addLookupfield(fieldNum(InventItemgroup, ItemGroupId));
sysTableLookup.addLookupfield(fieldNum(InventItemgroup, Name));
sysTableLookup.parmQuery(query);
//Tampilkan drop down
sysTableLookup.performFormLookup();
}
Wednesday, February 22, 2012
Membuat dialog sederhana dengan lookup dan input value
Berikut ini dialog dasar dengan lookup dan inputan value.
static void OpenDialogItemGroup(Args _args)
{
Dialog dialog = new Dialog("Item grup selection");
DialogField fieldGroup;
DialogField fieldDisc;
ItemgroupId ItemgroupId;
Amount Amount;
;
fieldGroup = dialog.addField(typeid(ItemgroupId));
fieldDisc = dialog.addField(typeid(Amount),"Disc. Pct.");
if (dialog.run())
{
info("You selected: " + fieldGroup.value() + " " +int2str(fieldDisc.value()));
}
}
{
Dialog dialog = new Dialog("Item grup selection");
DialogField fieldGroup;
DialogField fieldDisc;
ItemgroupId ItemgroupId;
Amount Amount;
;
fieldGroup = dialog.addField(typeid(ItemgroupId));
fieldDisc = dialog.addField(typeid(Amount),"Disc. Pct.");
if (dialog.run())
{
info("You selected: " + fieldGroup.value() + " " +int2str(fieldDisc.value()));
}
}
Subscribe to:
Posts (Atom)