public override void OnSave(PersistentObject obj) { var website = Manager.Current.Website; if (website == null || !CheckRules(obj)) { return; } try { var websiteContactTo = website["ContactTo"]; var websiteContactFrom = website["ContactFrom"]; if (string.IsNullOrEmpty(websiteContactTo) || string.IsNullOrEmpty(websiteContactFrom) || !Manager.Current.Mail.SendEmail(StringCipher.Decrypt(websiteContactFrom, Manager.Current.GetSetting("ContactEmailPassphrase")), StringCipher.Decrypt(websiteContactTo, Manager.Current.GetSetting("ContactEmailPassphrase")), "A message has been sent from " + website.Name, "Message from: " + string.Format("{0} <{1}>", (string)obj["Name"], (string)obj["Email"]) + "\n\n" + (string)obj["Message"])) { obj.AddNotification("No website contact information defined. The message could not be delivered", NotificationType.Error); } else { obj.AddNotification(website["ContactConfirmation"] ?? "Thank you for contacting us!", NotificationType.OK); } } catch (Exception e) { ServiceLocator.GetService <IExceptionService>().Log(e); obj.AddNotification("No website contact information defined. The message could not be delivered", NotificationType.Error); } }
public override void OnLoad(PersistentObject obj, PersistentObject parent) { obj["ConnectionString"].SetOriginalValue(ClassifyDataEntityModelContainer.ConnectionString); var exception = ClassifyDataEntityModelContainer.Exception; if (exception != null) { obj.AddNotification(exception, NotificationType.Warning); } }
/// <inheritdoc /> protected override void CheckRules(PersistentObject obj, Type entityType, TEntity entity) { var ruleAttributes = obj.Attributes.Where(a => !a.IsReadOnly && (!string.IsNullOrEmpty(a.Rules) || a.Type == DataTypes.Image)).OrderBy(a => a.Offset).ToArray(); var sb = new StringBuilder(); CheckAttributeRules(entityType, entity, ruleAttributes, sb); if (sb.Length > 0) { obj.AddNotification(sb.ToString(), NotificationType.Error); } }
public override void OnLoad(PersistentObject obj, PersistentObject parent) { // NOTE: By default this would load the entity from the database using the obj.ObjectId and obj.ContextProperty var studioUrl = $"{store.Urls[0]}/studio/index.html#databases/documents?&database={store.Database}"; obj.AddNotification($"[url:Open in Raven.Studio|{studioUrl}]", NotificationType.OK); obj.Actions = null; obj["Contents"].SetValue(File.ReadAllText(Path.Combine(hostEnvironment.ContentRootPath, "README.md"))); }
protected override void SaveNew(PersistentObject obj) { if (!CheckRules(obj)) { return; } obj.Attributes.Run(a => a.SetValue(string.Empty)); obj.AddNotification("Thanks for contacting us. We will get in touch with you shortly!", NotificationType.OK); //base.SaveNew(obj); }