我想在目录中出现文件时运行处理器。我的文件网址是这样的:
function SendInvoiceNew4() {
var sheet = SpreadsheetApp.getActiveSheet();
// Loop from CELL Number Value to CELL Number Value EQUAL
for(i=sheet.getRange("H11").getValue();i<=sheet.getRange("I11").getValue();i++) {// *************** Enter Start Invoice Serial No Cell Reference & Last Serial No Cell is Auto
sheet.getRange("H11").setValue(i); //Auto Enter Next Loop Serail Number
var InvDate = Utilities.formatDate(new sheet.getRange("H13").getValue(), "GMT+1", "MMM-yyyy") //Set invoice Date Format = MONTH & YEAR
var emailTo = sheet.getRange("B12").getValue(); //Get Email Address from Data
var message = 'Dear' + "\n\n" + 'See attached your attached invoice in PDF format.' + "\n\n" + 'Thanking you' + "\n" + 'www.xyz.in' + "\n" + '[DO NOT REPLY to this Email.]'; //Enter Custom Messagen ************************************************** Message Body
var subject = 'Invoice for Month ' + InvDate; // ************* Enter Cell Reference for Date of Invoice for Subject
// Convert Invoice Sheet to PDF
var originalSpreadsheet = SpreadsheetApp.getActive(); // Set original invoice sheet
var pdf = DriveApp.getFileById(originalSpreadsheet.getId()).getAs('application/pdf').getBytes(); // Convert PDF file
var attach = {fileName:'Invoice',content:pdf, mimeType:'application/pdf'}; //Set File Name
// Send Email with attached PDF file
MailApp.sendEmail(emailTo, subject, message, {attachments:[attach]});
//MailApp.sendEmail(emailTo, subject, message);
SpreadsheetApp.flush(); // Make sure the cell is updated right away in case the script is interrupted
}
}
将url与处理器相关联的过程如下:
file:{{file.root}}in?include=.*\.csv&charset=windows-1251&move=../out/done
MessageProcessor getOrCreateConsumer(CamelContext context, String uri) {
Endpoint endpoint = context.getEndpoint(uri);
endpoint.setCamelContext(context); // added this out of desperation, doesn't help
processor = new MessageProcessor();
try {
Consumer consumer = endpoint.createConsumer(processor);
endpoint.start(); // do we need this at all? works the same without it
consumer.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
return processor;
}
}
是一种处理器,可以为交换做一些事情。
一切似乎都能正常工作,除了文件没有移到MessageProcessor
目录之外。在调试时,无法将端点配置为通过此发布操作提供文件消息交换。
我认为我缺少一些通常由RouteBuilder调用的魔术调用,它将完全配置文件端点。你能帮我吗?