本文整理汇总了C#中System.Exception.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.Save方法的具体用法?C# Exception.Save怎么用?C# Exception.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Exception
的用法示例。
在下文中一共展示了Exception.Save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Missing
public async Task<ActionResult> Missing()
{
try
{
//Permite somente que a os e-mails sejam enviados a partir da conta da empresa ThisIsOnTop.com
if (oUserProfile.oAccount.id == 1 && oUserProfile.oAccount.IsCompanyAccount)
{
int counter = 0;
//var rs = base.oCore.businessControllers.bcAccount.MissingUsers(DateTime.Now, 30, 0, int.MaxValue);
var rs = oCore.iRepositories.IAccountRepository.Select(AccountRecordStatus.Ative);
foreach (var account in rs.Where(model => model.creationCountry != null && model.creationCountry == 2).ToList())
{
try
{
//Verifica se o usuário está há 30 dias sem entrar no sistema
if (account.lastLogon == null || (DateTime.Now - (DateTime)account.lastLogon).Days >= 30)
{
try
{
//Define o idioma que será usado para envio do e-mail
string cultureName = account.Country.language; //string.IsNullOrEmpty(account.culture) ? (string.IsNullOrEmpty(account.Country.language) ? CultureHelper.GetDefaultCulture() : account.Country.language) : account.culture;
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(CultureHelper.GetImplementedCulture(cultureName));
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
}
catch (Exception ex)
{
//Salva o erro no arquivo de log do sistema
ex.Save(new StackTrace(ex, true), ErrorLog.system);
}
//Define o assunto da mensagem
ViewBag.Title = String.Format(Resources.Resources.M_Missing_Title, account.name);
//Seguidores
ViewBag.Followers = oCore.businessControllers.bcConnection.Followers(account.id, 0, 1);
var message = new MailMessage();
message.From = new MailAddress(TopAppRouter.TopWelcomeEmail, "ThisIsOnTop.com");
message.Subject = ViewBag.Title;
message.Body = this.RenderRazorViewToString("~/Views/Emailing/Missing.cshtml", account);
//Destinatários
foreach (var cont in account.Contact.ToList())
{
if (cont.IsEmail && !cont.Email.address.Contains("@thisisontop.com"))
{
message.To.Add(new MailAddress(cont.Email.address));
await EmailSender.SendMailAsync(message);
counter++;
}
}
}
}
catch (Exception ex)
{
//Salva o erro no arquivo de log do sistema
var _ex = new Exception("Falha ao enviar e-mail de atualizações para o usuário " + account.id, ex);
_ex.Save(new StackTrace(ex, true), ErrorLog.system);
}
}
return Content("E-mail sent. Total sent: " + counter + " of " + rs.Count());
}
throw new HttpException((int)HttpStatusCode.NotFound, string.Empty);
}
catch (Exception ex)
{
//Salva o erro no arquivo de log do sistema
ex.Save(new StackTrace(ex, true), ErrorLog.system);
return Content(ex.Message);
}
}
示例2: Updates
public async Task<ActionResult> Updates()
{
try
{
//Permite somente que a os e-mails sejam enviados a partir da conta da empresa ThisIsOnTop.com
if (oUserProfile.oAccount.id == 1 && oUserProfile.oAccount.IsCompanyAccount)
{
int counter = 0;
var accounts = base.oCore.iRepositories.IAccountRepository.Select(AccountRecordStatus.Ative);
foreach (var account in accounts.ToList())
{
try
{
try
{
//Define o idioma que será usado para envio do e-mail
string cultureName = string.IsNullOrEmpty(account.culture) ? (string.IsNullOrEmpty(account.Country.language) ? CultureHelper.GetDefaultCulture() : account.Country.language) : account.culture;
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(CultureHelper.GetImplementedCulture(cultureName));
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
}
catch (Exception ex)
{
//Salva o erro no arquivo de log do sistema
ex.Save(new StackTrace(ex, true), ErrorLog.system);
}
//Define o assunto da mensagem
ViewBag.Title = String.Format(Resources.Resources.M_Update_Title, account.name);
//Seguidores
ViewBag.Followers = oCore.businessControllers.bcConnection.Followers(account.id, 0, 1);
//User top post
Post topPost;
Country topCountry;
//var top = oCore.businessControllers.bcTop.TopList(oUserProfile.oAccount.id, 0, 1).Item1.Where(model => System.Data.Objects.EntityFunctions.DiffDays(DateTime.Now, model.creationDatetime) <= 6).ToList().FirstOrDefault();
var top = oCore.businessControllers.bcTop.TopList(oUserProfile.oAccount.id, 0, 1).Item1.ToList().FirstOrDefault();
if (top == null)
{
if (account.Country1 == null)
topCountry = account.Location.LastOrDefault().Country;
else
topCountry = account.Country1;
topPost = oCore.iRepositories.IPostRepository.Select(oCore.businessControllers.bcCountry.Boosted(topCountry, null, 0, 1).Item1.ToList().FirstOrDefault().id);
}
else
{
topPost = top.Post;
topCountry = top.Country;
}
ViewBag.TopCountry = topCountry;
ViewBag.TopPost = topPost;
var message = new MailMessage();
message.From = new MailAddress(TopAppRouter.TopWelcomeEmail, "ThisIsOnTop.com");
message.Subject = ViewBag.Title;
message.Body = this.RenderRazorViewToString("~/Views/Emailing/Updates.cshtml", account);
//Destinatários
foreach (var cont in account.Contact.ToList())
{
if (cont.IsEmail && !cont.Email.address.Contains("@thisisontop.com"))
{
message.To.Add(new MailAddress(cont.Email.address));
await EmailSender.SendMailAsync(message);
counter++;
}
}
}
catch (Exception ex)
{
//Salva o erro no arquivo de log do sistema
var _ex = new Exception("Falha ao enviar e-mail de atualizações para o usuário " + account.id, ex);
_ex.Save(new StackTrace(ex, true), ErrorLog.system);
}
}
return Content("E-mail sent. Total sent: " + counter + " of " + accounts.Count());
}
throw new HttpException((int)HttpStatusCode.NotFound, string.Empty);
}
catch (Exception ex)
{
//Salva o erro no arquivo de log do sistema
ex.Save(new StackTrace(ex, true), ErrorLog.system);
return Content(ex.Message);
}
}
示例3: LayoutUpdates
public async Task<ActionResult> LayoutUpdates()
{
try
{
//Permite somente que a os e-mails sejam enviados a partir da conta da empresa ThisIsOnTop.com
if (oUserProfile.oAccount.id == 1 && oUserProfile.oAccount.IsCompanyAccount)
{
int counter = 0;
var accounts = base.oCore.iRepositories.IAccountRepository.Select(AccountRecordStatus.Ative);
foreach (var account in accounts.Where(model => model.creationCountry != null && model.creationCountry == 2).ToList())
{
try
{
//Define o assunto da mensagem
ViewBag.Title = String.Format("{0}, diga olá para o novo layout!", account.name.Split(' ')[0]);
ViewBag.Bg = "https://staticqwehkp3wb9pzv.azurewebsites.net/Content/static/abctdefghi4b9da306co8c3e565pca5164a7f/_i/_mail/new_layout.jpg";
var message = new MailMessage();
message.From = new MailAddress(TopAppRouter.TopWelcomeEmail, "ThisIsOnTop.com");
message.Subject = ViewBag.Title;
message.Body = this.RenderRazorViewToString("~/Views/Emailing/LayoutUpdates.cshtml", account);
//Destinatários
foreach (var cont in account.Contact.ToList())
{
if (cont.IsEmail && !cont.Email.address.Contains("@thisisontop.com"))
{
message.To.Add(new MailAddress(cont.Email.address));
await EmailSender.SendMailAsync(message);
counter++;
}
}
}
catch (Exception ex)
{
//Salva o erro no arquivo de log do sistema
var _ex = new Exception("Falha ao enviar e-mail de atualizações para o usuário " + account.id, ex);
_ex.Save(new StackTrace(ex, true), ErrorLog.system);
}
}
return Content("E-mail sent. Total sent: " + counter + " of " + accounts.Count());
}
throw new HttpException((int)HttpStatusCode.NotFound, string.Empty);
}
catch (Exception ex)
{
//Salva o erro no arquivo de log do sistema
ex.Save(new StackTrace(ex, true), ErrorLog.system);
return Content(ex.Message);
}
}