SHARE
TWEET

How to save/capture ZIP/ELP file

RandomClear Feb 26th, 2013 (edited) 440 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // See also: http://pastebin.com/WBYbtbSn - "how to always create ZIP/ELP file"
  2. // See also: http://pastebin.com/kkb5xkST - "'Save' report instead of sending"
  3.  
  4. // Zipped bug report (.elp) is created only for sending.
  5. // Therefore, only send code has access to zipped bug report.
  6. // It's not created if no sending is used.
  7. // This means that if we want to capture/save this file - then we can only do this from send code.
  8.  
  9. uses
  10.   ETypes, ESend, EModules;
  11.  
  12. type
  13.   // Create a new "send engine".
  14.   // It will be dummy that will perform no actual sending.
  15.   // Instead - it will save all files attachments to folder.
  16.   TDummySender = class(TELUniversalSender)
  17.   public
  18.     function SendMessage: TResponse; override;
  19.   end;
  20.  
  21. { TDummySender }
  22.  
  23. function TDummySender.SendMessage: TResponse;
  24. var
  25.   X: Integer;
  26. begin
  27.   // Copy all files attachments to some folder.
  28.   // Of course, folder must exist and be writable.
  29.   // Usually there is only one file (.elp), but it can be few files - depends on your project options
  30.   for X := 0 to AttachedFiles.Count - 1 do
  31.     CopyFile(PChar(AttachedFiles[X]), PChar('C:\Users\UserName\Documents\BugReports\' + ExtractFileName(AttachedFiles[X])), False);
  32.  
  33.   // Indicate that "send" was a failure.
  34.   // This will cause EurekaLog to try next send method (if it was set up).
  35.   // If there is no next method - a send error will be reported.
  36.   Finalize(Result);
  37.   FillChar(Result, SizeOf(Result), 0);
  38.   Result.SendResult := srUnknownError;
  39.   // Result.ErrorMessage := ''; // <- you can also customize error message to show to user (if there is no next method configured)
  40. end;
  41.  
  42. initialization
  43.   // Register our class to be used by EurekaLog
  44.   RegisterSender(TDummySender);
  45.   // Ask EurekaLog to send via our class first
  46.   CurrentEurekaLogOptions.AddSenderClass(TDummySender.ClassName, 0 { <- our class will be invoked first });
  47. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top