Advertisement
RandomClear

How to send arbitrary data to bug tracker

Feb 12th, 2013
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.47 KB | None | 0 0
  1. // See also: http://pastebin.com/MfLi4pbj - "how to send arbitrary e-mail with file attaches"
  2. // See also: http://pastebin.com/3Q1ykdSH - "how to send feedback instead of bug report"
  3. // See also: http://pastebin.com/ytYbgAfc - "how to setup send method from code"
  4.  
  5. // This code will work in any project - even without EurekaLog active
  6.  
  7. uses
  8.   EConsts, ETypes, EClasses, EHash, ESysInfo, ESend,
  9.   ESendAPIMantis; // <- be sure to include unit with bug tracker send code
  10.  
  11. procedure TForm1.Button1Click(Sender: TObject);
  12. var
  13.   Options: TEurekaModuleOptions;
  14.   Files: TStringList;
  15. begin
  16.   Options := TEurekaModuleOptions.Create('');
  17.   Files := TStringList.Create;
  18.   try
  19.     Options.SendMantisURL := 'bugs.example.com';
  20.     Options.SendMantisPort := 80;
  21.     Options.SendMantisSSL := False;
  22.  
  23.     Options.SendMantisLogin := 'account';
  24.     Options.SendMantisPassword := 'password';
  25.  
  26.     Options.SendMantisProject := 'ProjectName';
  27.     Options.SendMantisCategory := 'CategoryName';
  28.     Options.SendMantisOwner := 'AssignToAccount';
  29.  
  30.     // 1: store your text message
  31.     Options.CustomField[sifBugText]                := 'Message';
  32.     Options.CustomField[sifBugType]                := 'Subject';
  33.  
  34.     // 2: you have to redefine BugID, so it will unique identify this message
  35.     Options.CustomField[sifBugID]                  := IntToHex(GetCRC32(Options.CustomField[sifBugType] + Options.CustomField[sifBugText]), 8);
  36.  
  37.     // 3: (optional) add additional text, if needed
  38.     Options.CustomField[sifMessage]                := 'bug report content';
  39.     Options.CustomField[sifStepsToReproduce]       := 'steps to reproduce';
  40.  
  41.     // 4: (optional) fill other informational fields
  42.     Options.CustomField[sifBugAppVersion]          := ESysInfo.GetVersionNumber;
  43.     Options.CustomField[sifBuild]                  := ESysInfo.GetVersionNumber;
  44.     Options.CustomField[sifMachineID]              := ESysInfo.GetComputerName;
  45.     Options.CustomField[sifOSBuild]                := ESysInfo.GetOSBuild;
  46.     Options.CustomField[sifOSType]                 := ESysInfo.GetOSTypeStr;
  47.     Options.CustomField[sifPlatform]               := ESysInfo.GetPlatform;
  48.     Options.CustomField[sifUserEMail]              := ESysInfo.GetUserEMail;
  49.  
  50.     // 5: (optional) attach some files, if needed
  51.     Files.Add('C:\FileToSend1.txt');
  52.     Files.Add('C:\FileToSend2.zip');
  53.  
  54.     EurekaLogSend(TELTrackerMantisSender, Options, Files);
  55.   finally
  56.     FreeAndNil(Files);
  57.     FreeAndNil(Options);
  58.   end;
  59. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement