public void Initialize() { _entityHandler = Container.Resolve<IEntityHandler>(); _entitySchemaHandler = Container.Resolve<IEntitySchemaHandler>(); _appSetting = Container.Resolve<IAppSetting>(); InstallSchema(); }
public EmailHandler(IAppSetting appSetting) { _smptServerUrl = appSetting.SMTPServerUrl; _appName = appSetting.AppName; if (appSetting.Settings.ContainsKey("SupportEmail")) _supportEmail = appSetting.Settings["SupportEmail"].ToString(); if (appSetting.Settings.ContainsKey("FromEmail")) _fromEmail = appSetting.Settings["FromEmail"].ToString(); var codeBase = Assembly.GetExecutingAssembly().CodeBase; var uri = new UriBuilder(codeBase); _templatePath = Path.Combine(Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path)), "EmailTemplates"); }
/// <summary> /// Persist the current application settings to the data store. /// </summary> /// <param name="appSetting">An instance of <see cref="IAppSetting"/> to persist to the data store.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="appSetting" /> is null.</exception> public override void AppSetting_Save(IAppSetting appSetting) { if (appSetting == null) throw new ArgumentNullException("appSetting"); Type asType = appSetting.GetType(); // Specify the list of properties we want to save. string[] propertiesToSave = new[] { "MediaObjectDownloadBufferSize", "EncryptMediaObjectUrlOnClient", "EncryptionKey", "JQueryScriptPath", "JQueryUiScriptPath", "MembershipProviderName", "RoleProviderName", "ProductKey", "EnableCache", "AllowGalleryAdminToManageUsersAndRoles", "AllowGalleryAdminToViewAllUsersAndRoles", "MaxNumberErrorItems" }; string boolType = typeof(bool).ToString(); string intType = typeof(int).ToString(); string stringType = typeof(string).ToString(); using (GspContext ctx = new GspContext()) { ctx.AppSettings.Load(); foreach (PropertyInfo prop in asType.GetProperties()) { if ((prop == null) || (prop.PropertyType.FullName == null)) { continue; } if (Array.IndexOf(propertiesToSave, prop.Name) >= 0) { // This is one of the properties we want to save. string propValue; if (prop.PropertyType.FullName.Equals(boolType)) { propValue = Convert.ToBoolean(prop.GetValue(appSetting, null), CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture); } else if (prop.PropertyType.FullName.Equals(intType)) { propValue = Convert.ToInt32(prop.GetValue(appSetting, null), CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture); } else if (prop.PropertyType.FullName.Equals(stringType)) { propValue = Convert.ToString(prop.GetValue(appSetting, null), CultureInfo.InvariantCulture); } else { propValue = prop.GetValue(appSetting, null).ToString(); } // Find the app setting in the DB and update it. var appSettingDto = (from i in ctx.AppSettings.Local where i.SettingName == prop.Name select i).FirstOrDefault(); if (appSettingDto != null) { appSettingDto.SettingValue = propValue; } else { throw new DataException(String.Format(CultureInfo.CurrentCulture, "Cannot update application setting. No record was found in gs_AppSetting with SettingName='{0}'.", prop.Name)); } } } ctx.SaveChanges(); } }
/// <summary> /// Persist information about the specified <paramref name="ex">exception</paramref> to the data store and return /// the ID that is assigned to it. Send an e-mail notification if that option is enabled. /// </summary> /// <param name="ex">The exception to be recorded to the data store.</param> /// <param name="galleryId">The ID of the gallery the <paramref name="ex">exception</paramref> is associated with. /// If the exception is not specific to a particular gallery, specify <see cref="Int32.MinValue"/>.</param> /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify /// null if the value is not known. This value must be specified for e-mail notification to occur.</param> /// <param name="appSettings">The application settings. You may specify null if the value is not known.</param> /// <returns> /// Returns an integer that uniquely identifies this application error (<see cref="IAppError.AppErrorId"/>). /// </returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="ex"/> is null.</exception> public static int Record(Exception ex, int galleryId, IGallerySettingsCollection gallerySettingsCollection, IAppSetting appSettings) { if (ex == null) throw new ArgumentNullException("ex"); IAppError appError = new AppError(ex, galleryId); int appErrorId = DataProviderManager.Provider.AppError_Save(appError); if (gallerySettingsCollection != null) { SendEmail(appError, gallerySettingsCollection); } if (appSettings != null) { ValidateLogSize(appSettings.MaxNumberErrorItems); } return appErrorId; }
/// <summary> /// Persist the current application settings to the data store. /// </summary> /// <param name="appSetting">An instance of <see cref="IAppSetting"/> to persist to the data store.</param> public abstract void AppSetting_Save(IAppSetting appSetting);
/// <summary> /// Sends an e-mail containing details about the <paramref name="ev" /> to all users who are configured to receive e-mail /// notifications in the specified <paramref name="gallerySettings" /> and who have valid e-mail addresses. (That is, e-mails are /// sent to users identified in the property <see cref="IGallerySettings.UsersToNotifyWhenErrorOccurs" />.) A list of usernames /// of those were were notified is returned. No e-mails are sent to any usernames in <paramref name="usersWhoWereAlreadyNotified" />. /// </summary> /// <param name="ev">The application event to be sent to users.</param> /// <param name="appSettings">The application settings containing the e-mail configuration data.</param> /// <param name="gallerySettings">The gallery settings containing configuration data such as the list of users to be notified. /// The users are identified in the <see cref="IGallerySettings.UsersToNotifyWhenErrorOccurs" /> property.</param> /// <param name="usersWhoWereAlreadyNotified">The users who were previously notified about the <paramref name="ev" />.</param> /// <returns>Returns a list of usernames of those were were notified during execution of this function.</returns> /// <exception cref="System.ArgumentNullException">ev</exception> /// <exception cref="ArgumentNullException">Thrown when <paramref name="ev" /> or <paramref name="gallerySettings" /> /// is null.</exception> private static List<string> SendMail(IEvent ev, IAppSetting appSettings, IGallerySettings gallerySettings, List<string> usersWhoWereAlreadyNotified) { #region Validation if (ev == null) throw new ArgumentNullException("ev"); if (appSettings == null) throw new ArgumentNullException("appSettings"); if (gallerySettings == null) throw new ArgumentNullException("gallerySettings"); #endregion if (usersWhoWereAlreadyNotified == null) { usersWhoWereAlreadyNotified = new List<string>(); } var notifiedUsers = new List<string>(); //If email reporting has been turned on, send detailed event report. if (!gallerySettings.SendEmailOnError) { return notifiedUsers; } var emailSender = new MailAddress(appSettings.EmailFromAddress, appSettings.EmailFromName); foreach (var user in gallerySettings.UsersToNotifyWhenErrorOccurs) { if (!usersWhoWereAlreadyNotified.Contains(user.UserName)) { if (SendMail(ev, user, appSettings, emailSender)) { notifiedUsers.Add(user.UserName); } } } return notifiedUsers; }
/// <summary> /// Persist information about the specified <paramref name="msg" /> to the data store and return /// the instance. Send an e-mail notification if that option is enabled. /// </summary> /// <param name="msg">The message to be recorded to the data store.</param> /// <param name="eventType">Type of the event. Defaults to <see cref="EventType.Info" /> if not specified.</param> /// <param name="galleryId">The ID of the gallery the <paramref name="msg" /> is associated with. /// If the message is not specific to a particular gallery, specify null.</param> /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify /// null if the value is not known; however, this value must be specified for e-mail notification to occur.</param> /// <param name="appSettings">The application settings. You may specify null if the value is not known.</param> /// <param name="data">Additional optional data to record. May be null.</param> /// <returns>An instance of <see cref="IEvent" />.</returns> /// <exception cref="System.ArgumentOutOfRangeException">galleryId</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="galleryId" /> is <see cref="Int32.MinValue" />.</exception> public static IEvent RecordEvent(string msg, EventType eventType = EventType.Info, int? galleryId = null, IGallerySettingsCollection gallerySettingsCollection = null, IAppSetting appSettings = null, Dictionary<string, string> data = null) { if (galleryId == Int32.MinValue) throw new ArgumentOutOfRangeException("galleryId", String.Format("The galleryId parameter must represent an existing gallery. Instead, it was {0}", galleryId)); if (galleryId == null) { using (var repo = new GalleryRepository()) { galleryId = repo.Where(g => g.IsTemplate).First().GalleryId; } } var ev = new Event(msg, galleryId.Value, eventType, data); Save(ev); if (appSettings != null && gallerySettingsCollection != null) { SendEmail(ev, appSettings, gallerySettingsCollection); } if (appSettings != null) { ValidateLogSize(appSettings.MaxNumberErrorItems); } return ev; }
/// <summary> /// Persist the current application settings to the data store. /// </summary> /// <param name="appSetting">An instance of <see cref="IAppSetting" /> to persist to the data store.</param> internal static void SaveAppSetting(IAppSetting appSetting) { using (SqlConnection cn = SqlDataProvider.GetDbConnection()) { using (SqlCommand cmd = GetCommandAppSettingUpdate(cn)) { Type asType = appSetting.GetType(); // Specify the list of properties we want to save. string[] propertiesToSave = new[] { "MediaObjectDownloadBufferSize", "EncryptMediaObjectUrlOnClient", "EncryptionKey", "JQueryScriptPath", "JQueryUiScriptPath", "MembershipProviderName", "RoleProviderName", "ProductKey", "EnableCache", "AllowGalleryAdminToManageUsersAndRoles", "AllowGalleryAdminToViewAllUsersAndRoles", "MaxNumberErrorItems" }; string boolType = typeof(bool).ToString(); string intType = typeof(int).ToString(); string stringType = typeof(string).ToString(); cn.Open(); foreach (PropertyInfo prop in asType.GetProperties()) { if (prop.PropertyType.FullName == null) { continue; } if (Array.IndexOf(propertiesToSave, prop.Name) >= 0) { // This is one of the properties we want to save. string propValue; if (prop.PropertyType.FullName.Equals(boolType)) { propValue = Convert.ToBoolean(prop.GetValue(appSetting, null), CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture); } else if (prop.PropertyType.FullName.Equals(intType)) { propValue = Convert.ToInt32(prop.GetValue(appSetting, null), CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture); } else if (prop.PropertyType.FullName.Equals(stringType)) { propValue = Convert.ToString(prop.GetValue(appSetting, null), CultureInfo.InvariantCulture); } else { propValue = prop.GetValue(appSetting, null).ToString(); } // Update the item. cmd.Parameters["@SettingValue"].Value = propValue; cmd.Parameters["@SettingName"].Value = prop.Name; cmd.ExecuteNonQuery(); } } } } }
public static IServiceCollection AddSwaggerDocumentation(this IServiceCollection services, IAppSetting appSetting) { services.AddSwaggerGen(c => { c.SwaggerDoc(appSetting.Version, new OpenApiInfo { Title = appSetting.AppName, Version = appSetting.Version, Description = appSetting.Description }); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { In = ParameterLocation.Header, Description = "Please enter into field the word 'Bearer' following by space and JWT", Name = appSetting.AppName, Type = SecuritySchemeType.ApiKey, Scheme = "Bearer" }); c.AddSecurityRequirement(new OpenApiSecurityRequirement() { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" }, Scheme = "oauth2", Name = "Bearer", In = ParameterLocation.Header }, new List <string>() } }); }); return(services); }
public SetLocalAppSettingCommand(IAppSetting appSetting) { this.AppSetting = appSetting; }
public SetServerAppSettingCommand(IAppSetting appSetting) { this.AppSetting = appSetting; }
public ConnectionStringsOptions(IAppSetting appSettings) : base(appSettings) { }
public RegistrationEngine(IAppSetting configuration, IEncryption encryption) : base(configuration) { this.encryption = encryption; }
public Log4NetServiceFactory(IAppSetting appSetting) { _appSetting = appSetting; LoadLog4NetConfigFile(); }
public LogHandler(IAppSetting appSetting) { _appSetting = appSetting; _listNameSpace = MzdbHelper.GetListNameSpace(appSetting); _listFullName = MzdbHelper.GetListFullName(appSetting, EntityListConstants.AppLogListName); }
public BufferedSingleFileUploadPhysicalModel(IConfiguration config, IAppSetting appSetting) { _fileSizeLimit = config.GetValue <long>("FileSizeLimit"); _appSetting = appSetting; }
public static IApplicationBuilder UseSwaggerDocumentation(this IApplicationBuilder app, IAppSetting appsetting) { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint($"{appsetting.BASEPATH}/swagger/{appsetting.Version}/swagger.json", appsetting.AppName); //c.SwaggerEndpoint($"{appsetting.BASEPATH}/swagger/v1.0/swagger.json", "authv10"); }); return(app); }
/// <summary> /// Persist information about the specified <paramref name="ex">exception</paramref> to the data store and return /// the instance. Send an e-mail notification if that option is enabled. /// </summary> /// <param name="ex">The exception to be recorded to the data store.</param> /// <param name="appSettings">The application settings containing the e-mail configuration data.</param> /// <param name="galleryId">The ID of the gallery the <paramref name="ex">exception</paramref> is associated with. /// If the exception is not specific to a particular gallery, specify null.</param> /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify /// null if the value is not known; however, this value must be specified for e-mail notification to occur.</param> /// <returns>An instance of <see cref="IEvent" />.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="ex"/> is null.</exception> public static IEvent RecordError(Exception ex, IAppSetting appSettings, int? galleryId = null, IGallerySettingsCollection gallerySettingsCollection = null) { if (ex == null) throw new ArgumentNullException("ex"); if (galleryId == null) { using (var repo = new GalleryRepository()) { galleryId = repo.Where(g => g.IsTemplate).First().GalleryId; } } var ev = new Event(ex, galleryId.Value); Save(ev); if (gallerySettingsCollection != null) { SendEmail(ev, appSettings, gallerySettingsCollection); } if (appSettings != null) { ValidateLogSize(appSettings.MaxNumberErrorItems); } return ev; }
public UpdateHandler(IAppSetting appSetting, ILogger logger) { _appSetting = appSetting; _logger = logger; }
/// <summary> /// Sends an e-mail containing details about the <paramref name="ev" /> to all users who are configured to receive event /// notifications in the gallery identified by <see cref="IEvent.GalleryId" />. If the event is not associated with a particular /// gallery (that is, <see cref="IEvent.GalleryId" /> is the ID of the template gallery, then e-mails are sent to users in all /// galleries who are configured to receive e-mailed event reports. The property <see cref="IGallerySettings.UsersToNotifyWhenErrorOccurs" /> /// defines this list of users. /// </summary> /// <param name="ev">The application event to be sent to users.</param> /// <param name="appSettings">The application settings containing the e-mail configuration data.</param> /// <param name="gallerySettingsCollection">The settings for all galleries. If the <paramref name="ev" /> is associated with /// a particular gallery, then only the settings for that gallery are used by this function; otherwise users in all galleries are /// notified.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="ev" />, <paramref name="appSettings" /> or /// <paramref name="gallerySettingsCollection" /> is null.</exception> private static void SendEmail(IEvent ev, IAppSetting appSettings, IGallerySettingsCollection gallerySettingsCollection) { #region Validation if (ev == null) throw new ArgumentNullException("ev"); if (appSettings == null) throw new ArgumentNullException("appSettings"); if (gallerySettingsCollection == null) throw new ArgumentNullException("gallerySettingsCollection"); // We only want to send en email for INFO events. if (ev.EventType == EventType.Info || ev.EventType == EventType.Warning) { return; } #endregion if (gallerySettingsCollection.FindByGalleryId(ev.GalleryId).IsTemplate) { // This is an application-wide event, so loop through every gallery and notify all users, making sure we don't notify anyone more than once. var notifiedUsers = new List<string>(); foreach (var gallerySettings in gallerySettingsCollection) { notifiedUsers.AddRange(SendMail(ev, appSettings, gallerySettings, notifiedUsers)); } } else { // Use settings from the gallery associated with the event. var gallerySettings = gallerySettingsCollection.FindByGalleryId(ev.GalleryId); if (gallerySettings != null) { SendMail(ev, appSettings, gallerySettingsCollection.FindByGalleryId(ev.GalleryId), null); } } }
public ProductExportHandler(IAppSetting appSetting) : base(appSetting) { _productImportServiceUrl = appSetting.Settings["CatalogImportService"].ToString(); _inventoryImportServiceUrl = appSetting.Settings["InventoryImportService"].ToString(); _fileUploadServiceUrl = appSetting.Settings["FileUploadService"].ToString(); }
/// <summary> /// Sends an e-mail containing details about the <paramref name="ev" /> to the specified <paramref name="user" />. Returns /// <c>true</c> if the e-mail is successfully sent. /// </summary> /// <param name="ev">The application event to be sent to users.</param> /// <param name="user">The user to send the e-mail to.</param> /// <param name="appSettings">The application settings containing the e-mail configuration data.</param> /// <param name="emailSender">The account that that will appear in the "From" portion of the e-mail.</param> /// <returns>Returns <c>true</c> if the e-mail is successfully sent; otherwise <c>false</c>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="ev" />, <paramref name="user" />, /// <paramref name="appSettings" />, or <paramref name="emailSender" /> is null.</exception> private static bool SendMail(IEvent ev, IUserAccount user, IAppSetting appSettings, MailAddress emailSender) { #region Validation if (ev == null) throw new ArgumentNullException("ev"); if (user == null) throw new ArgumentNullException("user"); if (appSettings == null) throw new ArgumentNullException("appSettings"); if (emailSender == null) throw new ArgumentNullException("emailSender"); #endregion var emailWasSent = false; if (!IsValidEmail(user.Email)) { return false; } var emailRecipient = new MailAddress(user.Email, user.UserName); try { using (var mail = new MailMessage(emailSender, emailRecipient)) { if (String.IsNullOrEmpty(ev.ExType)) mail.Subject = Resources.Email_Subject_When_No_Ex_Type_Present; else mail.Subject = String.Concat(Resources.Email_Subject_Prefix_When_Ex_Type_Present, " ", ev.ExType); mail.Body = ev.ToHtmlPage(); mail.IsBodyHtml = true; using (var smtpClient = new SmtpClient()) { smtpClient.EnableSsl = appSettings.SendEmailUsingSsl; // Specify SMTP server if it is specified. The server might have been assigned via web.config, // so only update this if we have a config setting. if (!String.IsNullOrEmpty(appSettings.SmtpServer)) { smtpClient.Host = appSettings.SmtpServer; } // Specify port number if it is specified and it's not the default value of 25. The port // might have been assigned via web.config, so only update this if we have a config setting. int smtpServerPort; if (!Int32.TryParse(appSettings.SmtpServerPort, out smtpServerPort)) smtpServerPort = Int32.MinValue; if ((smtpServerPort > 0) && (smtpServerPort != 25)) { smtpClient.Port = smtpServerPort; } smtpClient.Send(mail); } emailWasSent = true; } } catch (Exception ex2) { string eventMsg = String.Concat(ex2.GetType(), ": ", ex2.Message); if (ex2.InnerException != null) eventMsg += String.Concat(" ", ex2.InnerException.GetType(), ": ", ex2.InnerException.Message); ev.EventData.Add(new KeyValuePair<string, string>(Resources.Cannot_Send_Email_Lbl, eventMsg)); } return emailWasSent; }
public EmailService(IAppSetting appSetting) { _appSetting = appSetting; }
/// <summary> /// To Initialize the constructor /// </summary> /// <param name="configuration"></param> public BaseEngine(IAppSetting configuration) { this.setting = configuration; Initialize(configuration); }
public BaseEngine(IAppSetting configuration, ILoggerManager logger) { this.setting = configuration; this.Initialize(configuration); this._logger = logger; }
public EntitySchemaHandler(IAppSetting appSetting) { _appSetting = appSetting; }
/// <summary> /// Sends an e-mail containing details about the <paramref name="ev" /> to the specified <paramref name="user" />. Returns /// <c>true</c> if the e-mail is successfully sent. /// </summary> /// <param name="ev">The application event to be sent to users.</param> /// <param name="user">The user to send the e-mail to.</param> /// <param name="appSettings">The application settings containing the e-mail configuration data.</param> /// <param name="emailSender">The account that that will appear in the "From" portion of the e-mail.</param> /// <returns>Returns <c>true</c> if the e-mail is successfully sent; otherwise <c>false</c>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="ev" />, <paramref name="user" />, /// <paramref name="appSettings" />, or <paramref name="emailSender" /> is null.</exception> private static bool SendMail(IEvent ev, IUserAccount user, IAppSetting appSettings, MailAddress emailSender) { #region Validation if (ev == null) { throw new ArgumentNullException("ev"); } if (user == null) { throw new ArgumentNullException("user"); } if (appSettings == null) { throw new ArgumentNullException("appSettings"); } if (emailSender == null) { throw new ArgumentNullException("emailSender"); } #endregion var emailWasSent = false; if (!IsValidEmail(user.Email)) { return(false); } var emailRecipient = new MailAddress(user.Email, user.UserName); try { using (var mail = new MailMessage(emailSender, emailRecipient)) { if (String.IsNullOrEmpty(ev.ExType)) { mail.Subject = Resources.Email_Subject_When_No_Ex_Type_Present; } else { mail.Subject = String.Concat(Resources.Email_Subject_Prefix_When_Ex_Type_Present, " ", ev.ExType); } mail.Body = ev.ToHtmlPage(); mail.IsBodyHtml = true; using (var smtpClient = new SmtpClient()) { smtpClient.EnableSsl = appSettings.SendEmailUsingSsl; // Specify SMTP server if it is specified. The server might have been assigned via web.config, // so only update this if we have a config setting. if (!String.IsNullOrEmpty(appSettings.SmtpServer)) { smtpClient.Host = appSettings.SmtpServer; } // Specify port number if it is specified and it's not the default value of 25. The port // might have been assigned via web.config, so only update this if we have a config setting. int smtpServerPort; if (!Int32.TryParse(appSettings.SmtpServerPort, out smtpServerPort)) { smtpServerPort = Int32.MinValue; } if ((smtpServerPort > 0) && (smtpServerPort != 25)) { smtpClient.Port = smtpServerPort; } smtpClient.Send(mail); } emailWasSent = true; } } catch (Exception ex2) { string eventMsg = String.Concat(ex2.GetType(), ": ", ex2.Message); if (ex2.InnerException != null) { eventMsg += String.Concat(" ", ex2.InnerException.GetType(), ": ", ex2.InnerException.Message); } ev.EventData.Add(new KeyValuePair <string, string>(Resources.Cannot_Send_Email_Lbl, eventMsg)); } return(emailWasSent); }
/// <summary> /// Persist information about the specified <paramref name="ex">exception</paramref> to the data store and return /// the ID that is assigned to it. /// </summary> /// <param name="ex">The exception to be recorded to the data store.</param> /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify /// null if the value is not known. This value must be specified for e-mail notification to occur.</param> /// <param name="appSettings">The application settings. You may specify null if the value is not known.</param> /// <returns> /// Returns an integer that uniquely identifies this application error (<see cref="IAppError.AppErrorId"/>). /// </returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="ex"/> is null.</exception> public static int Record(Exception ex, IGallerySettingsCollection gallerySettingsCollection, IAppSetting appSettings) { return Record(ex, int.MinValue, gallerySettingsCollection, appSettings); }
/// <summary> /// Persist information about the specified <paramref name="msg" /> to the data store and return /// the instance. Send an e-mail notification if that option is enabled. /// </summary> /// <param name="msg">The message to be recorded to the data store.</param> /// <param name="eventType">Type of the event. Defaults to <see cref="EventType.Info" /> if not specified.</param> /// <param name="galleryId">The ID of the gallery the <paramref name="msg" /> is associated with. /// If the message is not specific to a particular gallery, specify null.</param> /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify /// null if the value is not known; however, this value must be specified for e-mail notification to occur.</param> /// <param name="appSettings">The application settings. You may specify null if the value is not known.</param> /// <param name="data">Additional optional data to record. May be null.</param> /// <returns>An instance of <see cref="IEvent" />.</returns> /// <exception cref="System.ArgumentOutOfRangeException">galleryId</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="galleryId" /> is <see cref="Int32.MinValue" />.</exception> public static IEvent RecordEvent(string msg, EventType eventType = EventType.Info, int?galleryId = null, IGallerySettingsCollection gallerySettingsCollection = null, IAppSetting appSettings = null, Dictionary <string, string> data = null) { if (galleryId == Int32.MinValue) { throw new ArgumentOutOfRangeException("galleryId", String.Format("The galleryId parameter must represent an existing gallery. Instead, it was {0}", galleryId)); } if (galleryId == null) { using (var repo = new GalleryRepository()) { galleryId = repo.Where(g => g.IsTemplate).First().GalleryId; } } var ev = new Event(msg, galleryId.Value, eventType, data); Save(ev); if (appSettings != null && gallerySettingsCollection != null) { SendEmail(ev, appSettings, gallerySettingsCollection); } if (appSettings != null) { ValidateLogSize(appSettings.MaxNumberErrorItems); } return(ev); }
/// <summary> /// Persist the current application settings to the data store. /// </summary> /// <param name="appSetting">An instance of <see cref="IAppSetting"/> to persist to the data store.</param> public override void AppSetting_Save(IAppSetting appSetting) { GalleryData.SaveAppSetting(appSetting); }
public TicketService() { _appSettingService = new AppSettingService(); }