AX 2012 ile PDF rapor oluşturma için Martin Drab'ın blog sayfasını kullandım:
void CreatePDF(Str60 _Subject,Notes _Body)
{
MYReportPurchController controller;
MYReportPurchContract rdpContract = new MyReportPurchContract();
SRSPrintDestinationSettings settings;
Args args = new args();
str fileName;
args.record(this);
controller = MYReportPurchController::construct(args);
// Define report and report design to use
controller.parmReportName(ssrsReportStr(EtgPurchOrderForm,PrecisionDesign1));
// Use execution mode appropriate to your situation
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
// Suppress report dialog
// Explicitly provide all required parameters
controller.parmReportContract().parmRdpContract(rdpContract);
//rdpContract.
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.overwriteFile(true);
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
//settings.
#WinAPI
fileName = WinApi::getTempPath() +this.PurchOrderDocNum+".PDF";
settings.fileName(fileName);
// Execute the report
controller.parmShowDialog(false);
controller.startOperation();
}
Veya seçili kayıtları RDP rapordan PDF olarak mail gönderme:
SMAServiceOrderTable serviceOrder;
MultiSelectionHelper helper;
FormRun caller = _args.caller();
FormDataSource SMAServiceOrderTable_DS;
SRSPrintDestinationSettings settings;
ETGServiceReportContract contract = new ETGServiceReportContract();
SrsReportRunController controller;
Filename fileName;
int counter;
SysMailer mailer = new SysMailer();
SysEmailParameters parameters = SysEmailParameters::find();
Dialog dialog;
DialogField field;
Email email;
dialog = new Dialog("Servis Raporu Gönderme");
field = dialog.addField(ExtendedTypeStr(email));
dialog.run();
if (!dialog.closedOK())
return;
email = field.value();
if (email == "")
throw error("Bir mail adresi girmelisiniz!..");
SMAServiceOrderTable_DS = caller.dataSource();
helper = MultiSelectionHelper::createFromCaller(caller);
if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
mailer.fromAddress('noreply@sinbo.com.tr');
mailer.tos().appendAddress(email);
mailer.htmlBody('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">Sayın Yetkili,<br><br> Servis raporu kopyanız ektedir.<br><br>Saygılarımızla,<br><br><br>Sinbo');
mailer.subject('Sinbo Servis Raporu');
mailer.bodyCharSet("Windows-1254");
helper.createQueryRanges(SMAServiceOrderTable_DS.queryBuildDataSource(),fieldStr(SMAServiceOrderTable,RecId));
serviceOrder = helper.getFirst();
while(serviceOrder)
{
controller = new SrsReportRunController();
controller.parmReportName(ssrsReportStr(ETGServiceReport, Report));
contract = controller.parmReportContract().parmRdpContract();
controller.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Screen);
controller.parmShowDialog(false);
contract.parmServiceOrderId(serviceOrder.ServiceOrderId);
counter++;
fileName = WinApi::getTempPath() + strFmt("Servis Raporu %1.PDF",counter);
settings = controller.parmReportContract().parmPrintSettings();
settings.overwriteFile(true);
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.fileName(fileName);
controller.startOperation();
mailer.attachments().add(fileName);
serviceOrder = helper.getNext();
}
if (counter == 0)
return;
infolog.clear();
mailer.sendMail();
Blog Listem
6 Ocak 2014 Pazartesi
AXAPTA - Email gönderme
private void SendMail2(str _FileName,Str60 _Subject,Notes _Body)
{
str Toaddress;
System.Net.Mail.MailMessage Msg = new System.Net.Mail.MailMessage();
System.Net.Mail.MailAddress fromMail;
System.Net.Mail.MailAddressCollection toadrr;
System.Net.Mail.SmtpClient smCL = new System.Net.Mail.SmtpClient();
System.Net.NetworkCredential credential;
str bodygrd,sSmtpServer;
CLRObject exc;
CLRObject innerExc;
CLRObject clrExcMessage;
str strError;
SysEmailParameters EmailParm;
str pass;
System.Net.Mail.AttachmentCollection mailAttachementCollection;
System.Net.Mail.Attachment mailAttachment;
;
toaddress="test@hotmail.com";
EmailParm = SysEmailParameters::find();
pass = SysEmailParameters::password();
credential = new System.Net.NetworkCredential(EmailParm.SMTPUserName,pass);
fromMail = new System.Net.Mail.MailAddress(EmailParm.SMTPUserName);
new InteropPermission(InteropKind::ClrInterop).assert();
try
{
Msg.set_From(fromMail);
toadrr = Msg.get_To();
toadrr.Add(new System.Net.Mail.MailAddress(toaddress));
Msg.set_Subject(_Subject);
Msg.set_Body(_body);
Msg.set_IsBodyHtml(true);
sSmtpServer = EmailParm.SMTPRelayServerName;
smCL.set_Host(sSmtpServer);
mailAttachementCollection = msg.get_Attachments();
mailAttachment = new System.Net.Mail.Attachment(_fileName);
mailAttachementCollection.Add(mailAttachment);
smCL.set_Port(EmailParm.SMTPPortNumber);
smCL.set_EnableSsl(true);
smCL.set_Credentials(credential);
smCL.Send(Msg);
} catch( Exception::CLRError )
{
exc = CLRInterop::getLastException();
if( exc )
{
clrExcMessage = exc.get_Message();
innerExc = exc.get_InnerException();
while(innerExc != null)
{
clrExcMessage = innerExc.get_Message();
innerExc = innerExc.get_InnerException();
}
strError = CLRInterop::getAnyTypeForObject( clrExcMessage );
throw error(strError);
}
}
}
{
str Toaddress;
System.Net.Mail.MailMessage Msg = new System.Net.Mail.MailMessage();
System.Net.Mail.MailAddress fromMail;
System.Net.Mail.MailAddressCollection toadrr;
System.Net.Mail.SmtpClient smCL = new System.Net.Mail.SmtpClient();
System.Net.NetworkCredential credential;
str bodygrd,sSmtpServer;
CLRObject exc;
CLRObject innerExc;
CLRObject clrExcMessage;
str strError;
SysEmailParameters EmailParm;
str pass;
System.Net.Mail.AttachmentCollection mailAttachementCollection;
System.Net.Mail.Attachment mailAttachment;
;
toaddress="test@hotmail.com";
EmailParm = SysEmailParameters::find();
pass = SysEmailParameters::password();
credential = new System.Net.NetworkCredential(EmailParm.SMTPUserName,pass);
fromMail = new System.Net.Mail.MailAddress(EmailParm.SMTPUserName);
new InteropPermission(InteropKind::ClrInterop).assert();
try
{
Msg.set_From(fromMail);
toadrr = Msg.get_To();
toadrr.Add(new System.Net.Mail.MailAddress(toaddress));
Msg.set_Subject(_Subject);
Msg.set_Body(_body);
Msg.set_IsBodyHtml(true);
sSmtpServer = EmailParm.SMTPRelayServerName;
smCL.set_Host(sSmtpServer);
mailAttachementCollection = msg.get_Attachments();
mailAttachment = new System.Net.Mail.Attachment(_fileName);
mailAttachementCollection.Add(mailAttachment);
smCL.set_Port(EmailParm.SMTPPortNumber);
smCL.set_EnableSsl(true);
smCL.set_Credentials(credential);
smCL.Send(Msg);
} catch( Exception::CLRError )
{
exc = CLRInterop::getLastException();
if( exc )
{
clrExcMessage = exc.get_Message();
innerExc = exc.get_InnerException();
while(innerExc != null)
{
clrExcMessage = innerExc.get_Message();
innerExc = innerExc.get_InnerException();
}
strError = CLRInterop::getAnyTypeForObject( clrExcMessage );
throw error(strError);
}
}
}
3 Ocak 2014 Cuma
AXAPTA - Birden fazla alış siparişinin bazı satırlarını birleştirip PurchEditLines formunda göstermek
Args args = new Args();
PurchFormLetter purchFormLetter;
purchTable purchTable;
VendReceiptsListTrans ListTrans;
PurchParmLine purchParmLine;
PurchParmTable purchParmTable;
Object dialog;
vendReceiptsListJour Jour;
boolean err;
VendPackingSlipTrans PackingTrans;
;
select purchTable where purchTable.PurchId == this.PurchId; //select first purchtable record
//-------------- prepare purchformletter class -----
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
purchFormLetter.parmSourceTable(purchTable);
purchFormLetter.initLinesQuery();
purchformletter.createParmUpdate();
purchFormLetter.transDate(this.PackingSlipDate);
// purchformletter.documentNum(
purchformletter.chooseLines();
//--------------- add other purchtable records -----
while select OrigpurchId from ListTrans
group by ListTrans.OrigPurchId
where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId != this.PurchId
{
select purchTable where purchTable.PurchId == ListTrans.OrigPurchId;
purchformletter.updateQueryAndChooseLines(purchTable);
}
//---------------- delete unnecessary purchase lines --------------------
select firstonly forupdate purchParmLine
where purchParmLine.ParmId == purchformletter.parmId();
if (purchParmLine.RecId == 0)
{
box::stop("There isn't any purchline applicable");
return;
}
// box::warning("111");
ttsbegin;
while select forupdate purchParmLine
where purchParmLine.ParmId == purchformletter.parmId()
{
select firstonly ListTrans where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId == purchParmLine.OrigPurchId &&
ListTrans.ItemId == purchParmLine.ItemId && purchParmLine.InventTransId == ListTrans.InventTransId;
// info(strfmt("%1 %2",purchparmline.ItemId,listtrans.ItemId));
//---eğer bu sipariş satırı giriş listesinde yoksa sil-------------
if (ListTrans.RecId == 0)
{
// info("---sil---");
purchParmLine.delete();
continue;
}
//----miktarı giriş listesinden al----------------------------------
purchParmLine.ReceiveNow = ListTrans.PurchQty;
purchParmLine.InventNow = ListTrans.PurchQty;
// purchParmLine.modifiedReceiveNow();
purchParmLine.setQty(DocumentStatus::PackingSlip, false, true);
purchParmLine.setLineAmount();
purchParmLine.update();
}
update_recordset purchParmTable setting num = this.packingSlipId,
TransDate = this.PackingSlipDate,
DocumentDate = this.PackingSlipDate
where purchParmTable.ParmId == purchformletter.parmId();
ttscommit;
if (this.packingSlipId)
purchformletter.reArrange(true); //------------ merge purchases like push rearrange button at purcheditlines form ----
dialog = purchformletter.dialog();
dialog.run() ;
dialog.wait();
if (dialog.closedOk())
{
purchFormLetter.proforma(false);
purchFormLetter.printFormLetter(true);
purchFormLetter.specQty(PurchUpdate::ReceiveNow);
purchFormLetter.progressHide();
purchformletter.run();
select firstonly PackingTrans join ListTrans
where PackingTrans.purchId == ListTrans.OrigPurchId &&
ListTrans.ReceiptsListId == this.ReceiptsListId;
if (PackingTrans.RecId != 0)
{
ttsbegin;
update_recordset Jour setting VendReceiptsListJourStatus = DTVendReceiptsListJourStatus::PackingSlip
where Jour.RecId == this.RecId;
ttscommit;
}
}
PurchFormLetter purchFormLetter;
purchTable purchTable;
VendReceiptsListTrans ListTrans;
PurchParmLine purchParmLine;
PurchParmTable purchParmTable;
Object dialog;
vendReceiptsListJour Jour;
boolean err;
VendPackingSlipTrans PackingTrans;
;
select purchTable where purchTable.PurchId == this.PurchId; //select first purchtable record
//-------------- prepare purchformletter class -----
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
purchFormLetter.parmSourceTable(purchTable);
purchFormLetter.initLinesQuery();
purchformletter.createParmUpdate();
purchFormLetter.transDate(this.PackingSlipDate);
// purchformletter.documentNum(
purchformletter.chooseLines();
//--------------- add other purchtable records -----
while select OrigpurchId from ListTrans
group by ListTrans.OrigPurchId
where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId != this.PurchId
{
select purchTable where purchTable.PurchId == ListTrans.OrigPurchId;
purchformletter.updateQueryAndChooseLines(purchTable);
}
//---------------- delete unnecessary purchase lines --------------------
select firstonly forupdate purchParmLine
where purchParmLine.ParmId == purchformletter.parmId();
if (purchParmLine.RecId == 0)
{
box::stop("There isn't any purchline applicable");
return;
}
// box::warning("111");
ttsbegin;
while select forupdate purchParmLine
where purchParmLine.ParmId == purchformletter.parmId()
{
select firstonly ListTrans where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId == purchParmLine.OrigPurchId &&
ListTrans.ItemId == purchParmLine.ItemId && purchParmLine.InventTransId == ListTrans.InventTransId;
// info(strfmt("%1 %2",purchparmline.ItemId,listtrans.ItemId));
//---eğer bu sipariş satırı giriş listesinde yoksa sil-------------
if (ListTrans.RecId == 0)
{
// info("---sil---");
purchParmLine.delete();
continue;
}
//----miktarı giriş listesinden al----------------------------------
purchParmLine.ReceiveNow = ListTrans.PurchQty;
purchParmLine.InventNow = ListTrans.PurchQty;
// purchParmLine.modifiedReceiveNow();
purchParmLine.setQty(DocumentStatus::PackingSlip, false, true);
purchParmLine.setLineAmount();
purchParmLine.update();
}
update_recordset purchParmTable setting num = this.packingSlipId,
TransDate = this.PackingSlipDate,
DocumentDate = this.PackingSlipDate
where purchParmTable.ParmId == purchformletter.parmId();
ttscommit;
if (this.packingSlipId)
purchformletter.reArrange(true); //------------ merge purchases like push rearrange button at purcheditlines form ----
dialog = purchformletter.dialog();
dialog.run() ;
dialog.wait();
if (dialog.closedOk())
{
purchFormLetter.proforma(false);
purchFormLetter.printFormLetter(true);
purchFormLetter.specQty(PurchUpdate::ReceiveNow);
purchFormLetter.progressHide();
purchformletter.run();
select firstonly PackingTrans join ListTrans
where PackingTrans.purchId == ListTrans.OrigPurchId &&
ListTrans.ReceiptsListId == this.ReceiptsListId;
if (PackingTrans.RecId != 0)
{
ttsbegin;
update_recordset Jour setting VendReceiptsListJourStatus = DTVendReceiptsListJourStatus::PackingSlip
where Jour.RecId == this.RecId;
ttscommit;
}
}
Etiketler:
ax,
AXAPTA,
birden,
birleştir,
fazla,
form,
getir,
purcheditlines,
purchformletter,
purchtable,
sipariş
Kaydol:
Kayıtlar (Atom)