Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.9 KiB

  1. var MAIL_RESEND_INTERVAL = 30 * 60 * 1000; // Send another error mail after 30 minutes
  2. var MAX_ERRORLOG_LINES = 50; // Maximum number of lines to pull from the error log
  3. function GetBuildInformation()
  4. {
  5. var strMsg = "";
  6. strMsg += 'Build Type: ' + PrivateData.objConfig.Options.BuildType + '\n';
  7. strMsg += 'Build Platform: ' + PrivateData.objConfig.Options.Platform + '\n';
  8. strMsg += 'Incremental Build: ' + (PrivateData.objConfig.Options.fIncremental ? 'true' : 'false') + '\n';
  9. strMsg += 'Build Manager: ' + PrivateData.objEnviron.BuildManager.Name + '\n';
  10. if (PrivateData.objEnviron.BuildManager.PostBuildMachine)
  11. strMsg += 'PostBuild Machine: ' + PrivateData.objEnviron.BuildManager.PostBuildMachine + '\n\n';
  12. return strMsg;
  13. }
  14. /*
  15. SendErrorMail()
  16. Contruct a nicely formatted EMail message with the given
  17. error information and send it.
  18. No attempt to limit the frequency of email is done - this should
  19. be done by the caller.
  20. */
  21. function SendErrorMail(strTitle, strText)
  22. {
  23. var aTo = PrivateData.objEnviron.Options.EmailAliasTo.split(/[,; ]/);
  24. var aCC = PrivateData.objEnviron.Options.EmailAliasCC.split(/[,; ]/);
  25. var strMsg;
  26. var strSubj;
  27. strSubj = 'BC: "' + PrivateData.objConfig.LongName + ' ' + PrivateData.objEnviron.LongName + '" ' + strTitle;
  28. strMsg = 'This is a Build Console message being sent from ' + LocalMachine + '.\n\n';
  29. strMsg += strTitle +'\n\n';
  30. strMsg += GetBuildInformation();
  31. strMsg += strText;
  32. if (aTo.length > 0 && aTo[0].length == 0)
  33. {
  34. return;
  35. }
  36. if (aCC.length > 0 && aCC[0].length == 0)
  37. {
  38. aCC = new Array();
  39. }
  40. LogMsg('Sending mail to =' + aTo.join(' ='));
  41. var iRet = SendMail('=' + aTo.join(' ='),
  42. (aCC.length > 0) ? '=' + aCC.join(' =') : '',
  43. '',
  44. strSubj,
  45. strMsg);
  46. LogMsg("On error EMAIL MESSAGE: " + strSubj + ", " + strMsg);
  47. if (iRet)
  48. {
  49. LogMsg('an error occurred sending Email, return code was ' + iRet);
  50. return false;
  51. }
  52. return true;
  53. }
  54. /*
  55. Create the message subject and body for a task error message, suitable
  56. for emailing.
  57. */
  58. function CreateTaskErrorMail(strMachineName, strDepotName, strTaskName, strDetails, strLogFile)
  59. {
  60. var strMsg;
  61. var strSubj;
  62. strMsg = 'This is a Build Console message being sent from ' + strMachineName + '.\n\n';
  63. strMsg += 'An error occurred doing the ' + strTaskName + ' task on ';
  64. strMsg += 'the ' + strDepotName + ' depot. Some available information ';
  65. strMsg += 'will appear below, but for complete information you will need ';
  66. strMsg += 'to view the full error log. You can do this using the Console UI.\n\n';
  67. strMsg += ' Thanks for using Build Console!\n\n';
  68. strMsg += ' --------------------------------------------------\n\n';
  69. strMsg += strDetails + '\n\n';
  70. if (strLogFile)
  71. {
  72. var FSObj = new ActiveXObject("Scripting.FileSystemObject");
  73. var file;
  74. var cLineCnt = 0;
  75. try
  76. {
  77. file = FSObj.OpenTextFile(strLogFile, 1);
  78. while (!file.AtEndOfStream && cLineCnt <= MAX_ERRORLOG_LINES)
  79. {
  80. strMsg += file.ReadLine() + '\n';
  81. cLineCnt++;
  82. }
  83. strMsg += '\nThe complete error log is located at ' + strLogFile;
  84. file.Close();
  85. }
  86. catch(ex)
  87. {
  88. LogMsg('An error occurred reading the log file "' + strLogFile + '" for email: ' + ex);
  89. strMsg += 'Could not attach error log (' + strLogFile + '): ' + ex;
  90. }
  91. }
  92. strSubj = 'An error occurred during a ' + strTaskName + '!';
  93. SimpleErrorDialog(strSubj, strMsg, true);
  94. }