C# Class ReviewNotifier.MailTemplates

Implements support for notifier email customizations. To customize email that notifier sends, create the following text files, and drop them in the same directory where ReviewNotifier.exe lives: Request.txt, Invite.txt, Iteration.txt, Response.txt, and Subjects.txt. The files should contain the text which is sent, respectively, when a reviewer is asked to join code review, when the code invitation is sent, when a reviewer makes comments, and when reviewee responds to the comments. The files should contain the following macros which are replaced whith real values (macro names are case-sensitive): Request.txt: {Reviewer} - the alias of the reviewer to which email is sent. {Webserver} - the server name where Malevich web site lives. {WebRoot} - the application's path on the site (e.g. Malevich) {MalevichId} - the id of the change in Malevich. {Reviewee} - the person requesting code review. {Details} - the description of the change list. The default template: Dear {Reviewer}, I would like a code review. Please go to http://{Webserver}{WebRoot}/default.aspx?cid={MalevichId} to comment. If you are super busy and cannot do the review soon, kindly notify me immediately so I could plan for contingencies. -- {Reviewee} --------- {Details} Invite.txt: {Webserver} - the server name where Malevich web site lives. {WebRoot} - the application's path on the site (e.g. Malevich) {MalevichId} - the id of the change in Malevich. {Reviewee} - the person requesting code review. {Details} - the description of the change list. The default template: Dear potential reviewer, I am in need of your professional opinion. Could you do a code review for me? To accept the review request (thank you! thank you! thank you!), click on this link: http://{Webserver}{WebRoot}/default.aspx?cid={MalevichId}&action=makemereviewer To learn more about this change, please go to http://{Webserver}{WebRoot}/default.aspx?cid={MalevichId} You can add yourself as a reviewer there as well. Thank you very, very much! -- {Reviewee} --------- {Details} Iteration.txt: {Reviewee} - the person requesting code review. {Verdict} - What is the final verdict (needs work/LGTM/etc). This is a full sentence supplied by the notifier. {Webserver} - the server name where Malevich web site lives. {WebRoot} - the application's path on the site (e.g. Malevich) {MalevichId} - the id of the change in Malevich. {Reviewer} - the alias of the reviewer to which email is sent. {Details} - the list of comments (formatted my notifier) made by the reviewer The default template: Dear {Reviewee}, Thank you for giving me the opportunity to review your code. {Verdict} Please see the detailed comments at http://{Webserver}{WebRoot}/default.aspx?cid={MalevichId} -- {Reviewer} --------- {Details} Response.txt: {Webserver} - the server name where Malevich web site lives. {WebRoot} - the application's path on the site (e.g. Malevich) {MalevichId} - the id of the change in Malevich. {Reviewee} - the person requesting code review. {Details} - the list of comments (formatted my notifier) made by the reviewer The default template: Dear reviewers, Thank you for your comments. Please see my responses at http://{Webserver}{WebRoot}/default.aspx?cid={MalevichId} -- {Reviewee} --------- {Details} Reminder.txt: {Webserver} - the server name where Malevich web site lives. {WebRoot} - the application's path on the site (e.g. Malevich) {MalevichId} - the id of the change in Malevich. {CL} - change list. {Reviewee} - the person requesting code review. {Details} - the description of the change list. The default template: Dear {Reviewee}, Your code review (http://{Webserver}{WebRoot}/default.aspx?cid={MalevichId}) for the change list {CL} is now very, very old! Chances are that the change has already been submitted and you just need to close the review: review close {CL} Or delete it if the change has been abandoned: review delete {CL} Otherwise consider reminding your reviewers about it! -- Malevich --------- {Details} Subjects.txt: {CL} - change list. {Reviewee} - the person requesting code review. {Details} - abbreviated change list description. {Verdict} - the vote (only in the iteration template). The default template: REQUEST: Code review for CL {CL} by {Reviewee} INVITE: Looking for reviewers for CL {CL} by {Reviewee} RESPONSE: Code review for CL {CL} by {Reviewee} ITERATION: Code review for CL {CL} by {Reviewee} REMINDER: Code review for CL {CL} by {Reviewee}
ファイルを表示 Open project: daptiv/Malevich Class Usage Examples

Public Methods

Method Description
CreateMail ( MailType mailType, int malevichId, string reviewer, string reviewee, string webserver, string webRoot, string verdict, string details, string CL ) : string

Given parameters, formats the email. Not all parameters are used in all templates - pass only what you need, null everything else. This is an overload used if the caller knows what type (text or HTML) template is used, and

CreateMail ( MailType mailType, int malevichId, string reviewer, string reviewee, string webserver, string webRoot, string verdict, string details, string CL, bool &isHtml ) : string

Given parameters, formats the email. Not all parameters are used in all templates - pass only what you need, null everything else.

CreateMailSubject ( MailType mailType, string CL, string reviewee, string details, string verdict ) : string

Given parameters, formats the email subject. Not all parameters are used in all templates - pass only what you need, null everything else.

IsTemplateHtml ( MailType mailType ) : bool

Returns whether the template is HTML or not.

MailTemplates ( ILog logger ) : System

Initalizes an instance of MailTemplates class.

Private Methods

Method Description
GetSubjectTemplate ( MailType mailType ) : string

Retrieves the template for the mail subject.

GetTemplate ( MailType mailType, bool &isHtml ) : string

Retrieves the template for the mail.

PrepSubjectTemplate ( string template ) : string

Converts the subject template name to arguments that string formatting understands. Currently: {CL} => {0} {Reviewee} => {1} {Details} => {2} {Verdict} => {3} Not every item must be present in the review template.

PrepTemplate ( string template ) : string

Converts the template name to arguments that string formatting understands. Currently: {MalevichId} => {0} {Reviewer} => {1} {Reviewee} => {2} {Webserver} => {3} {WebRoot} => {4} {Verdict} => {5} {Details} => {6} {CL} => {7} Not every item must be present in the review template.

Method Details

CreateMail() public method

Given parameters, formats the email. Not all parameters are used in all templates - pass only what you need, null everything else. This is an overload used if the caller knows what type (text or HTML) template is used, and
public CreateMail ( MailType mailType, int malevichId, string reviewer, string reviewee, string webserver, string webRoot, string verdict, string details, string CL ) : string
mailType MailType Which template to use.
malevichId int CID of the review.
reviewer string User name for the reviewer.
reviewee string User name for the reviewee.
webserver string The name of the web server where Malevich web site is hosted.
webRoot string The application name on the server.
verdict string The verdict.
details string The details. Assumed to be HTML encoded if the template is HTML.
CL string The change list.
return string

CreateMail() public method

Given parameters, formats the email. Not all parameters are used in all templates - pass only what you need, null everything else.
public CreateMail ( MailType mailType, int malevichId, string reviewer, string reviewee, string webserver, string webRoot, string verdict, string details, string CL, bool &isHtml ) : string
mailType MailType Which template to use.
malevichId int CID of the review.
reviewer string User name for the reviewer.
reviewee string User name for the reviewee.
webserver string The name of the web server where Malevich web site is hosted.
webRoot string The application name on the server.
verdict string The verdict.
details string The details. Assumed to be text that would be HTML encoded if necessary.
CL string The change list.
isHtml bool Output: whether the body is HTML.
return string

CreateMailSubject() public method

Given parameters, formats the email subject. Not all parameters are used in all templates - pass only what you need, null everything else.
public CreateMailSubject ( MailType mailType, string CL, string reviewee, string details, string verdict ) : string
mailType MailType Which template to use.
CL string CL of the review.
reviewee string User name for the reviewee.
details string The details.
verdict string The verdict.
return string

IsTemplateHtml() public method

Returns whether the template is HTML or not.
public IsTemplateHtml ( MailType mailType ) : bool
mailType MailType Which template to use.
return bool

MailTemplates() public method

Initalizes an instance of MailTemplates class.
public MailTemplates ( ILog logger ) : System
logger ILog The logger.
return System