基本上这个脚本会被告知每10分钟运行一次,但我只希望脚本在晚上9点到凌晨4点运行,伦敦时间有人可以帮忙吗?
此外,我想限制脚本每小时发送不超过500封电子邮件。
/*Email Client configuration. Here you will need to specify Server, user name and password for your SMTP server, and also testing tag*/
string SMTPServer = "mail.justshipit.net";
int SMTPPort = 26;
string UserName = "no-reply+justshipit.net";
string Password = "00000";
string FromEmail = "no-reply@justshipit.net";
string FromName = "Zoozio @ Amazon";
//email subject and email body
string Subject = "Please Leave feedback for your [{Source}] order from SUPER COOL STORE";
string eBayEmailBody = "Hello, [{Name}].\r\n\r\nYou recently purchased:\r\n\r\n[{ItemList}]\r\n\r\nWe hope everything was satisfactory and would really appriciate it if you could go to www.amazon.co.uk/feedback and leave us some positive feedback\r\nif you had any issues please get in contact with us ASAP as we want to sort things out.\r\n\r\nCall Us:0843 289 2766\r\n\r\nMany Thanks\r\nAdam\r\nCustomer Care Manager ";
/*query syntax. Here we will select all orders processed 14 days ago but not older than 1 month, that don't have FEEDBACK email sent
and order item table. Two queries in one request
*/
string query =@"SELECT pkOrderId,cEmailAddress, cFullName, [Source]
FROM [Order] o
LEFT OUTER JOIN Order_LifeHistory ls on ls.fkOrderId = o.pkOrderID and ls.fkOrderHistoryTypeId='EMAIL_SENT' and ls.Tag='FEEDBACK'
WHERE
o.bProcessed = 1 AND o.HoldOrCancel=0 AND o.dProcessedOn > DATEADD(D,-10,GETDATE()) AND ls.sid_history is null
AND o.Source IN ('AMAZON');
SELECT pkOrderId,ItemNumber = oi.ItemNumber,ItemTitle = sis.cItemName
FROM [Order] o
INNER JOIN [OrderItem] oi on oi.fkOrderID = o.pkOrderID
INNER JOIN [StockItems] sis on sis.pkStockID = oi.fkStockID
LEFT OUTER JOIN Order_LifeHistory ls on ls.fkOrderId = o.pkOrderID and ls.fkOrderHistoryTypeId='EMAIL_SENT' and ls.Tag='FEEDBACK'
WHERE
o.bProcessed = 1 AND o.HoldOrCancel=0 AND o.dProcessedOn > DATEADD(D,-10,GETDATE()) AND ls.sid_history is null
AND o.Source IN ('AMAZON');";
//SELECT pkOrderId,ItemNumber = oi.ItemNumber,ItemTitle = sis.cItemName
//FROM [Order] o
//INNER JOIN [OrderItem] oi on oi.fkOrderID = o.pkOrderID
//INNER JOIN [StockItems] sis on sis.pkStockID = oi.fkStockID
//LEFT OUTER JOIN Order_LifeHistory ls on ls.fkOrderId = o.pkOrderID and //ls.fkOrderHistoryTypeId='EMAIL_SENT' and ls.Tag='FEEDBACK'
//WHERE
//o.bProcessed = 1 AND o.HoldOrCancel=0 AND o.dProcessedOn > DATEADD(D,-10,GETDATE()) //AND ls.sid_history is null
//AND o.Source IN ('AMAZON');";
答案 0 :(得分:0)
我建议一个调度框架。 Quartz.net
对此非常好,并且非常容易学习/实施
答案 1 :(得分:0)
您始终可以使用计划任务/ cron作业来实现计时器。