1 // 2 // Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net> 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a copy 5 // of this software and associated documentation files (the "Software"), to deal 6 // in the Software without restriction, including without limitation the rights 7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 // copies of the Software, and to permit persons to whom the Software is 9 // furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 // THE SOFTWARE. 21 22 using Ntp.Analyzer.Config.Attribute; 23 using Ntp.Analyzer.Config.Table; 24 using Ntp.Common.Process; 25 26 namespace Ntp.Analyzer.Config.Node 27 { 28 public sealed class NotifyConfiguration : ConfigurationNode, IJobConfiguration 29 { NotifyConfiguration( string configName, bool? initialRun, bool? fixedRun, int? frequency, string mail, string subject, string sender, string server, int? port, string user, string pass, bool? ssl)30 internal NotifyConfiguration( 31 string configName, 32 bool? initialRun, 33 bool? fixedRun, 34 int? frequency, 35 string mail, 36 string subject, 37 string sender, 38 string server, 39 int? port, 40 string user, 41 string pass, 42 bool? ssl) 43 : base(configName) 44 { 45 this.frequency = frequency; 46 this.initialRun = initialRun; 47 this.fixedRun = fixedRun; 48 Mail = mail; 49 Subject = subject; 50 Sender = sender; 51 SmptServer = server; 52 this.port = port; 53 SmtpUser = user; 54 SmtpPass = pass; 55 this.ssl = ssl; 56 } 57 58 private readonly bool? fixedRun; 59 60 private readonly int? frequency; 61 private readonly bool? initialRun; 62 private readonly int? port; 63 private readonly bool? ssl; 64 65 [NtpaIndex(10)] 66 [NtpaSetting(Symbol.KeywordRecipient)] 67 public string Mail { get; } 68 69 [NtpaIndex(12)] 70 [NtpaSetting(Symbol.KeywordSubject, Layout = Layout.Quoted)] 71 public string Subject { get; } 72 73 [NtpaIndex(11)] 74 [NtpaSetting(Symbol.KeywordSender)] 75 public string Sender { get; } 76 77 [NtpaIndex(20)] 78 [NtpaSetting(Symbol.KeywordHost)] 79 public string SmptServer { get; } 80 81 [NtpaIndex(21)] 82 [NtpaSetting(Symbol.KeywordPort, 25)] 83 public int SmtpPort => port ?? 25; 84 85 [NtpaIndex(22)] 86 [NtpaSetting(Symbol.KeywordUser)] 87 public string SmtpUser { get; } 88 89 [NtpaIndex(23)] 90 [NtpaSetting(Symbol.KeywordPass)] 91 public string SmtpPass { get; } 92 93 [NtpaIndex(24)] 94 [NtpaSetting(Symbol.KeywordEnableSsl, false)] 95 public bool EnableSsl => ssl ?? false; 96 97 [NtpaIndex(1)] 98 [NtpaSetting(Symbol.KeywordFrequency, 1440)] 99 public int Frequency => frequency ?? 1440; 100 101 [NtpaIndex(2)] 102 [NtpaSetting(Symbol.KeywordInitialRun, true)] 103 public bool InitialRun => initialRun ?? true; 104 105 [NtpaIndex(3)] 106 [NtpaSetting(Symbol.KeywordFixedRun, true)] 107 public bool FixedRun => fixedRun ?? true; 108 } 109 }