public string CreateMessage(IMessageGeneratorParams msgParams) { string result = msgParams.Template; result = string.Format(result, msgParams.Parameters["UserName"] ); return(result); }
public string CreateMessage(IMessageGeneratorParams msgParams) { string result = msgParams.Template; result = string.Format(result, msgParams.Parameters["UserName"], msgParams.Parameters["RegulatorCode"], msgParams.Parameters["CompanyCode"], msgParams.Parameters["ReportType"], msgParams.Parameters["ReportName"], msgParams.Parameters["ReportSubmitted"] ); return(result); }
private EmailDetails PrepareEmailDetails(string type, string toAddress, Dictionary <string, object> parameters) { EmailDetails emailDetails = new EmailDetails(); emailDetails.AddressTo = toAddress; var msgGen = _compContainer.GetExport <IMessageGenerator>(type); if (msgGen != null) { // getting xml string xmlConfig = Resources.ResourceManager.GetObject(type) as string; if (xmlConfig != null) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlConfig); // extracting subject XmlNode nodeSubject = doc.SelectSingleNode("template/subject"); if (nodeSubject != null) { emailDetails.Subject = nodeSubject.InnerText.Trim(); } // extracting message template XmlNode nodeBody = doc.SelectSingleNode("template/body"); if (nodeBody != null) { IMessageGeneratorParams msgGenParams = msgGen.Value.CreateParams(); msgGenParams.Parameters = parameters; msgGenParams.Template = nodeBody.InnerXml; emailDetails.Body = msgGen.Value.CreateMessage(msgGenParams); } } else { throw new ArgumentException(string.Format("XmlConfig not found for type {0}", type)); } } else { throw new ArgumentException(string.Format("Message Generator of type {0} not found", type)); } return(emailDetails); }