private EmailAddress RenderEmailAddress(string email, MessageContext ctx, bool required = true) { string parsed = null; try { parsed = RenderTemplate(email, ctx, required); if (required || parsed.HasValue()) { return(parsed.Convert <EmailAddress>()); } else { return(null); } } catch (Exception ex) { if (ctx.TestMode) { return(new EmailAddress("*****@*****.**", "John Doe")); } var ex2 = new SmartException($"Failed to parse email address for variable '{email}'. Value was '{parsed.EmptyNull()}': {ex.Message}", ex); _services.Notifier.Error(ex2.Message); throw ex2; } }
private void Backup() { var source = new DirectoryInfo(CommonHelper.MapPath("~/")); var tempPath = CommonHelper.MapPath("~/App_Data/_Backup/App/SmartStore"); string localTempPath = null; for (int i = 0; i < 50; i++) { localTempPath = tempPath + (i == 0 ? "" : "." + i.ToString()); if (!Directory.Exists(localTempPath)) { Directory.CreateDirectory(localTempPath); break; } localTempPath = null; } if (localTempPath == null) { var exception = new SmartException("Too many backups in '{0}'.".FormatInvariant(tempPath)); _logger.Error(exception.Message, exception); throw exception; } var backupFolder = new DirectoryInfo(localTempPath); var folderUpdater = new FolderUpdater(_logger); folderUpdater.Backup(source, backupFolder, "App_Data", "Media"); _logger.Information("Backup successfully created in folder '{0}'.".FormatInvariant(localTempPath)); }
private static void HandlePluginActivationException(Exception ex, PluginDescriptor plugin, string msg, ICollection <string> incompatiblePlugins) { msg = "Error loading plugin '{0}'".FormatInvariant(plugin.SystemName) + Environment.NewLine + msg; var fail = new SmartException(msg, ex); Debug.WriteLine(fail.Message); if (plugin.ReferencedAssembly != null) { _inactiveAssemblies.Add(plugin.ReferencedAssembly); } plugin.ActivationException = fail; incompatiblePlugins.Add(plugin.SystemName); }