// See also: http://pastebin.com/WBYbtbSn - "how to always create ZIP/ELP file"
// See also: http://pastebin.com/kkb5xkST - "'Save' report instead of sending"
// Zipped bug report (.elp) is created only for sending.
// Therefore, only send code has access to zipped bug report.
// It's not created if no sending is used.
// This means that if we want to capture/save this file - then we can only do this from send code.
uses
ETypes, ESend, EModules;
type
// Create a new "send engine".
// It will be dummy that will perform no actual sending.
// Instead - it will save all files attachments to folder.
TDummySender = class(TELUniversalSender)
public
function SendMessage: TResponse; override;
end;
{ TDummySender }
function TDummySender.SendMessage: TResponse;
var
X: Integer;
begin
// Copy all files attachments to some folder.
// Of course, folder must exist and be writable.
// Usually there is only one file (.elp), but it can be few files - depends on your project options
for X := 0 to AttachedFiles.Count - 1 do
CopyFile(PChar(AttachedFiles[X]), PChar('C:\Users\UserName\Documents\BugReports\' + ExtractFileName(AttachedFiles[X])), False);
// Indicate that "send" was a failure.
// This will cause EurekaLog to try next send method (if it was set up).
// If there is no next method - a send error will be reported.
Finalize(Result);
FillChar(Result, SizeOf(Result), 0);
Result.SendResult := srUnknownError;
// Result.ErrorMessage := ''; // <- you can also customize error message to show to user (if there is no next method configured)
end;
initialization
// Register our class to be used by EurekaLog
RegisterSender(TDummySender);
// Ask EurekaLog to send via our class first
CurrentEurekaLogOptions.AddSenderClass(TDummySender.ClassName, 0 { <- our class will be invoked first });
end.
Comments