本文整理汇总了C#中Record.ToXml方法的典型用法代码示例。如果您正苦于以下问题:C# Record.ToXml方法的具体用法?C# Record.ToXml怎么用?C# Record.ToXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.ToXml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
{
MailAddress FromMailAddress;
if (string.IsNullOrEmpty(this.FromEmail))
{
var settings = UmbracoConfig.For.UmbracoSettings();
FromMailAddress = new MailAddress(settings.Content.NotificationEmailAddress);
}
else
{
string fromEmailField = this.FromEmail;
string fromNameField = "";
bool fromEmailFound = false;
bool fromNameFound = false;
try
{
foreach (RecordField rf in record.RecordFields.Values)
{
string refinedCaption = "{" + rf.Field.Caption.ToLower().Replace(" ", "") + "}";
if (!fromEmailFound && refinedCaption == this.FromEmail.ToLower())
{
fromEmailField = rf.ValuesAsString();
fromEmailFound = true;
}
else if (!fromNameFound && !String.IsNullOrEmpty(this.FromName) && refinedCaption == this.FromName.ToLower())
{
fromNameField = rf.ValuesAsString();
fromNameFound = true;
}
//dont go any further to not waste time looking for something already there
if (fromEmailFound && fromNameFound)
{
break;
}
}
if (fromNameFound)
{
FromMailAddress = new MailAddress(fromEmailField, fromNameField);
}
else if (!string.IsNullOrEmpty(this.FromName))
{
FromMailAddress = new MailAddress(fromEmailField, this.FromName);
}
else
{
FromMailAddress = new MailAddress(fromEmailField);
}
}
catch (Exception ex)
{
var settings = UmbracoConfig.For.UmbracoSettings();
FromMailAddress = new MailAddress(settings.Content.NotificationEmailAddress);
}
}
var mailMessage = new MailMessage
{
From = FromMailAddress,
Subject = this.Subject,
ReplyTo = FromMailAddress,
IsBodyHtml = true,
BodyEncoding = Encoding.UTF8
};
if (this.Email.Contains(";"))
{
foreach (string email in this.Email.Split(';'))
{
mailMessage.To.Add(email.Trim());
}
}
else
{
mailMessage.To.Add(this.Email);
}
XmlNode xml = record.ToXml(new System.Xml.XmlDocument());
// we will by default set the body to the record xml so if no xslt file is
// present we atleast get the raw data.
string result = xml.OuterXml;
if (!string.IsNullOrEmpty(this.XsltFile))
{
result = XsltHelper.TransformXML(xml, this.XsltFile, null);
}
mailMessage.Body = "<p>" + Message + "</p><br />" + result;
var smtpClient = new SmtpClient { EnableSsl = false };
if (WebConfigurationManager.AppSettings.AllKeys.Contains("contourContribUseSsl") && WebConfigurationManager.AppSettings["contourContribUseSsl"].ToLower() == true.ToString().ToLower())
{
smtpClient.EnableSsl = true;
}
smtpClient.Send(mailMessage);
return WorkflowExecutionStatus.Completed;
//.........这里部分代码省略.........