RandomClear icon

How to send arbitrary data to bug tracker

RandomClear | PRO | 02/12/13 05:25:34 AM UTC | 0 ⭐ | 598 👁️ | Never ⏰ | []
Delphi |

2.47 KB

|

None

|

0 👍

/

0 👎

// See also: http://pastebin.com/MfLi4pbj - "how to send arbitrary e-mail with file attaches"
// See also: http://pastebin.com/3Q1ykdSH - "how to send feedback instead of bug report"
// See also: http://pastebin.com/ytYbgAfc - "how to setup send method from code"
 
// This code will work in any project - even without EurekaLog active
 
uses
  EConsts, ETypes, EClasses, EHash, ESysInfo, ESend,
  ESendAPIMantis; // <- be sure to include unit with bug tracker send code
 
procedure TForm1.Button1Click(Sender: TObject);
var
  Options: TEurekaModuleOptions;
  Files: TStringList;
begin
  Options := TEurekaModuleOptions.Create('');
  Files := TStringList.Create;
  try
    Options.SendMantisURL := 'bugs.example.com';
    Options.SendMantisPort := 80;
    Options.SendMantisSSL := False;
 
    Options.SendMantisLogin := 'account';
    Options.SendMantisPassword := 'password';
 
    Options.SendMantisProject := 'ProjectName';
    Options.SendMantisCategory := 'CategoryName';
    Options.SendMantisOwner := 'AssignToAccount';
 
    // 1: store your text message
    Options.CustomField[sifBugText]                := 'Message';
    Options.CustomField[sifBugType]                := 'Subject';
 
    // 2: you have to redefine BugID, so it will unique identify this message
    Options.CustomField[sifBugID]                  := IntToHex(GetCRC32(Options.CustomField[sifBugType] + Options.CustomField[sifBugText]), 8);
 
    // 3: (optional) add additional text, if needed
    Options.CustomField[sifMessage]                := 'bug report content';
    Options.CustomField[sifStepsToReproduce]       := 'steps to reproduce';
 
    // 4: (optional) fill other informational fields
    Options.CustomField[sifBugAppVersion]          := ESysInfo.GetVersionNumber;
    Options.CustomField[sifBuild]                  := ESysInfo.GetVersionNumber;
    Options.CustomField[sifMachineID]              := ESysInfo.GetComputerName;
    Options.CustomField[sifOSBuild]                := ESysInfo.GetOSBuild;
    Options.CustomField[sifOSType]                 := ESysInfo.GetOSTypeStr;
    Options.CustomField[sifPlatform]               := ESysInfo.GetPlatform;
    Options.CustomField[sifUserEMail]              := ESysInfo.GetUserEMail;
 
    // 5: (optional) attach some files, if needed
    Files.Add('C:\FileToSend1.txt');
    Files.Add('C:\FileToSend2.zip');
 
    EurekaLogSend(TELTrackerMantisSender, Options, Files);
  finally
    FreeAndNil(Files);
    FreeAndNil(Options);
  end;
end;

Comments