/// <summary> /// Add Log Information /// </summary> private void Ai(Cx CurrCodeType, string Comments = null, Mx CustomMethodContext = null) { if (C == null || C.L != true) { return; } Ce(CurrCodeType, CustomMethodContext); var r = new Inf() { C = Comments }; if (CurrCodeType != null) { r.X = CurrCodeType.CxId; } if (CustomMethodContext != null) { r.M = CustomMethodContext.CmId; } L.I.Add(r); Rn++; if (Rl > 1 && Rn > Rl) { Sv(); } }
public void writeTo(TextWriter wr) { int cx = medium.Count; if (cx > 0) { EML_Media M0 = (EML_Media)medium[0]; string boundary = M0.mlContentType.boundary; int n = 0; foreach (EML_Media Mx in medium) { if (boundary != null && n != 0) { wr.WriteLine(); wr.WriteLine("--" + boundary); } Mx.writeTo(wr); n++; } if (boundary != null) { wr.WriteLine(); wr.WriteLine("--" + boundary + "--"); } } }
public async Task MxTermErroredIfARecordLookUpFails() { string host1 = "host1"; A.CallTo(() => _dnsClient.GetMxRecords(A<string>._)) .Returns(Task.FromResult(new DnsResult<List<string>> (new List<string> { host1 }, 200))); A.CallTo(() => _dnsClient.GetARecords(A<string>._)) .ReturnsNextFromSequence( Task.FromResult(new DnsResult<List<string>>("Error"))); Mx mx = new Mx("", Qualifier.Pass, new DomainSpec(""), new DualCidrBlock(new Ip4CidrBlock(32), new Ip6CidrBlock(128))); SpfRecords spfRecords = await _spfMxTermExpander.Process("", mx); Assert.That(spfRecords, Is.Null); Assert.That(mx.MxHosts.Count, Is.EqualTo(1)); Assert.That(mx.MxHosts[0].Host, Is.EqualTo(host1)); Assert.That(mx.MxHosts[0].Ip4S, Is.Empty); Assert.That(mx.AllErrors.Count, Is.EqualTo(1)); Assert.AreEqual("Failed A record query for host1 with error Error", mx.AllErrors[0].Message); }
public async Task <SpfRecords> Process(string domain, Term term) { Mx mx = term as Mx; string mxDomain = string.IsNullOrEmpty(mx.DomainSpec.Domain) ? domain : mx.DomainSpec.Domain; DnsResult <List <string> > mxRecords = await _dnsClient.GetMxRecords(mxDomain); if (mxRecords.IsErrored) { string message = string.Format(SpfExpansionResource.FailedMxRecordQueryErrorMessage, mxDomain, mxRecords.Error); string markdown = string.Format(SpfExpansionMarkdownResource.FailedMxRecordQueryErrorMessage, mxDomain, mxRecords.Error); Guid id = Guid.Parse("464F1D16-3945-41D3-9C02-D7B781BCB363"); mx.AddError(new Error(id, ErrorType.Error, message, markdown)); } else { List <MxHost> mxHosts = new List <MxHost>(); foreach (var mxRecord in mxRecords.Value) { DnsResult <List <string> > ips = await _dnsClient.GetARecords(mxRecord); if (ips.IsErrored) { mxHosts.Add(new MxHost(mxRecord, new List <string>())); string message = string.Format(SpfExpansionResource.FailedARecordQueryErrorMessage, mxRecord, ips.Error); string markdown = string.Format(SpfExpansionMarkdownResource.FailedARecordQueryErrorMessage, mxRecord, ips.Error); Guid id = Guid.Parse("DA9C6FF2-5DD0-4AA0-BE66-2E443C93C9A2"); mx.AddError(new Error(id, ErrorType.Error, message, markdown)); } else if (ips.Value.Count > 10) { mxHosts.Add(new MxHost(mxRecord, new List <string>())); string message = string.Format(SpfExpansionResource.TooManyARecordsErrorMessage, ips.Value.Count, mxRecord); string markdown = string.Format(SpfExpansionMarkdownResource.TooManyARecordsErrorMessage, ips.Value.Count, mxRecord); Guid id = Guid.Parse("6ABDDBDE-8147-49C4-A6A2-23DCA683DFDA"); mx.AddError(new Error(id, ErrorType.Error, message, markdown)); } else { mxHosts.Add(new MxHost(mxRecord, ips.Value)); } } mx.MxHosts = mxHosts; } return(null); }
public override string ToString() { return(string.Format("G:({0}, {1}, {2}) M:({3}, {4}, {5})", Gx.ToString(Format), Gy.ToString(Format), Gz.ToString(Format), Mx.ToString(Format), My.ToString(Format), Mz.ToString(Format))); }
/// <summary> /// Add details on contexts with check /// </summary> private void Ce(Cx CurrCodeType = null, Mx CustomMethodContext = null) { if (CurrCodeType != null && !L.X.Contains(CurrCodeType)) { L.X.Add(CurrCodeType); } if (CustomMethodContext != null && !L.C.Contains(CustomMethodContext)) { L.C.Add(CustomMethodContext); } }
public async Task NoInfoMessageWhenMxNotPresent() { Mx mx = null; DomainSpfRecord spfRecord = new DomainSpfRecord("domain1", new SpfRecord(new List <string>(), new Version(string.Empty), new List <Term> { mx })); List <Error> error = await _rule.Evaluate(spfRecord); Assert.That(error.Count, Is.EqualTo(0)); }
public override string ToString() { return ("ID: " + ID.ToString() + "|" + "N: " + N.ToString() + "|" + "My: " + My.ToString() + "|" + "Mz: " + Mz.ToString() + "|" + "Mx: " + Mx.ToString() + "|" + "Vy: " + Vy.ToString() + "|" + "Vz: " + Vz.ToString() + "|" + "IsCritical: " + IsCritical.ToString()); }
public async Task InfoMessageWhenMxPresent() { Mx mx = new Mx(string.Empty, (Qualifier)999, null, null); DomainSpfRecord spfRecord = new DomainSpfRecord("domain1", new SpfRecord(new List <string>(), new Version(string.Empty), new List <Term> { mx })); List <Error> error = await _rule.Evaluate(spfRecord); Assert.That(error.Count, Is.EqualTo(1)); Assert.AreEqual("The use of the mx mechanism is not recommended", error[0].Message); Assert.AreEqual(ErrorType.Info, error[0].ErrorType); }
public async Task MxTermErroredIfMxQueryFails() { A.CallTo(() => _dnsClient.GetMxRecords(A<string>._)) .Returns(Task.FromResult(new DnsResult<List<string>>("Error"))); Mx mx = new Mx("", Qualifier.Pass, new DomainSpec("domain"), new DualCidrBlock(new Ip4CidrBlock(32), new Ip6CidrBlock(128))); SpfRecords spfRecords = await _spfMxTermExpander.Process("", mx); Assert.That(spfRecords, Is.Null); Assert.That(mx.MxHosts, Is.Null); Assert.That(mx.AllErrors.Count, Is.EqualTo(1)); Assert.AreEqual("Failed MX record query for domain with error Error", mx.AllErrors[0].Message); }
public async Task RefreshKeysAsync() { Keys.Clear(); EndPoint[] endpoints = Mx.GetEndPoints(); foreach (EndPoint ep in endpoints) { IServer server = Mx.GetServer(ep); IEnumerable <RedisKey> keys = server.Keys(); foreach (RedisKey key in keys) { RedisType keyType = await Db.KeyTypeAsync(key); Keys.Add(new RedisKeyViewModel(key.ToString(), keyType)); } } }
public async Task MxTermErroredIfARecordHasTooManyResults() { string host1 = "host1"; string ip1 = "192.168.1.1"; string ip2 = "192.168.1.2"; string ip3 = "192.168.1.3"; string ip4 = "192.168.1.4"; string ip5 = "192.168.1.5"; string ip6 = "192.168.1.6"; string ip7 = "192.168.1.7"; string ip8 = "192.168.1.8"; string ip9 = "192.168.1.9"; string ip10 = "192.168.1.10"; string ip11 = "192.168.1.11"; A.CallTo(() => _dnsClient.GetMxRecords(A<string>._)) .Returns(Task.FromResult(new DnsResult<List<string>> (new List<string> { host1 }, 200))); A.CallTo(() => _dnsClient.GetARecords(A<string>._)) .ReturnsNextFromSequence( Task.FromResult(new DnsResult<List<string>>(new List<string> { ip1, ip2, ip3, ip4, ip5, ip6, ip7, ip8, ip9, ip10, ip11 }, 200))); Mx mx = new Mx("", Qualifier.Pass, new DomainSpec(""), new DualCidrBlock(new Ip4CidrBlock(32), new Ip6CidrBlock(128))); SpfRecords spfRecords = await _spfMxTermExpander.Process("", mx); Assert.That(spfRecords, Is.Null); Assert.That(mx.MxHosts.Count, Is.EqualTo(1)); Assert.That(mx.MxHosts[0].Host, Is.EqualTo(host1)); Assert.That(mx.MxHosts[0].Ip4S, Is.Empty); Assert.That(mx.AllErrors.Count, Is.EqualTo(1)); Assert.AreEqual("Too many A records 11 returned for host1. Limit is 10.", mx.AllErrors[0].Message); }
public async Task MxTermExpanded() { string host1 = "host1"; string host2 = "host2"; string ip1 = "192.168.1.1"; string ip2 = "192.168.1.2"; A.CallTo(() => _dnsClient.GetMxRecords(A<string>._)) .Returns(Task.FromResult(new DnsResult<List<string>> (new List<string> { host1, host2 }, 200))); A.CallTo(() => _dnsClient.GetARecords(A<string>._)) .ReturnsNextFromSequence( Task.FromResult(new DnsResult<List<string>>(new List<string> { ip1, ip2 }, 200)), Task.FromResult(new DnsResult<List<string>>(new List<string> { ip1 }, 200))); Mx mx = new Mx("", Qualifier.Pass, new DomainSpec(""), new DualCidrBlock(new Ip4CidrBlock(32), new Ip6CidrBlock(128))); SpfRecords spfRecords = await _spfMxTermExpander.Process("", mx); Assert.That(spfRecords, Is.Null); Assert.That(mx.MxHosts.Count, Is.EqualTo(2)); Assert.That(mx.MxHosts[0].Host, Is.EqualTo(host1)); Assert.That(mx.MxHosts[1].Host, Is.EqualTo(host2)); Assert.That(mx.MxHosts[0].Ip4S.Count, Is.EqualTo(2)); Assert.That(mx.MxHosts[1].Ip4S.Count, Is.EqualTo(1)); Assert.That(mx.MxHosts[0].Ip4S[0], Is.EqualTo(ip1)); Assert.That(mx.MxHosts[0].Ip4S[1], Is.EqualTo(ip2)); Assert.That(mx.MxHosts[1].Ip4S[0], Is.EqualTo(ip1)); Assert.That(mx.AllErrors, Is.Empty); }
/// <summary> /// Create New Log Entry /// </summary> private Prf Pn(Cx CurrCodeType, Mx CustomMethodContext = null) { if (C == null || C.P != true) { return(null); } Ce(CurrCodeType, CustomMethodContext); Prf r = new Prf(); if (C.Pr == true && CurrCodeType != null && CurrCodeType.S != null && CurrCodeType.S.Pr == true) { r.Is = Pp(CurrCodeType); } if (CurrCodeType != null) { r.X = CurrCodeType.CxId; } if (CustomMethodContext != null) { r.M = CustomMethodContext.CmId; } return(r); }
/// <summary> /// Create New Info Log Entry /// </summary> public void I(string Comments = null, Cx CurrCodeType = null, Mx CustomMethodContext = null) { Ai(CurrCodeType, Comments, CustomMethodContext); }
/// <summary> /// Create New Performance Log Entry /// </summary> /// <returns>Performance Log Entry Record</returns> public Prf P(Cx CurrCodeType = null, Mx CustomMethodContext = null) { return(Pn(CurrCodeType, CustomMethodContext)); }
/// <summary> /// Run new Sync common MethodToRunSync using new context with logging settings and save logs after completed /// </summary> public static void r <T>(this Sld Settings, string ConnectionName, IDictionary <T, Cx> Contexts, T ContextKey, v <Ax <T>, Cx> MethodToRunSync, Mx MethodContext = null, bool Ensure = true) { var rs = ConnectionName.Gsl(); var a = Settings.N(async e => await e.ua(ConnectionName), Contexts); var rs1 = a.r(x => { MethodToRunSync(a, x); return(1); }, ContextKey, MethodContext); a.L.Sv(); }
///// <summary> ///// Test Logs Data ///// </summary> //public static Lst[] Tl() //{ // var r = _.l<Lst>(); // var tc = true._Ls(); // tc.G(e => eGsl) // //var a1 = new Lst(); // //a1.C = new Cde() { C = "Class 11", M = new Cme() { G = _.g, M = "Method 1111" }.L(new Cme() { G = _.g, M = "Method 1122" }) } // // .L(new Cde() { C = "Class 22", M = new Cme() { G = _.g, M = "Method 2211" }.L(new Cme() { G = _.g, M = "Method 2222" }) }); // //a1.E = new Err() { As = 4, C = "Err 1111" }.L(new Err() { As = 33, C = "Err 222" }); // //a1.En = new Env() { Ct = 20, Os = "dbs L 1111", S = "server L 11" }.L(new Sq() { T = 30, D = "dbs L 222", S = "server L 22" }); // //a1.Q = new Sq() { T = 20, D = "dbs Q 1111", S = "server Q 11" }.L(new Sq() { T = 30, D = "dbs Q 222", S = "server Q 22" }); // return r.a(); //} #endregion #region common methods /// <summary> /// Run new Async common MethodToRunAsync using new context with logging settings and save logs after completed /// </summary> public static async Task R <T>(this Sld Settings, string ConnectionName, IDictionary <T, Cx> Contexts, T ContextKey, f <Ax <T>, Cx, Task> MethodToRunAsync, Mx MethodContext = null, bool Ensure = true) { var rs = ConnectionName.Gsl(); var a = Settings.N(async e => await e.ua(ConnectionName), Contexts); var rs1 = a.r(async x => { await MethodToRunAsync(a, x); return(1); }, ContextKey, MethodContext); await a.L.Sva(); }
public override int GetHashCode() { return(Gx.GetHashCode() ^ Gy.GetHashCode() ^ Gz.GetHashCode() ^ Mx.GetHashCode() ^ My.GetHashCode() ^ Mz.GetHashCode()); }
/// <summary> /// Add Log Error /// </summary> private void Ae(Cx CurrCodeType, string Comments = null, Exception CurrExc = null, Mx CustomMethodContext = null) { if (C == null || C.L != true) { return; } Ce(CurrCodeType, CustomMethodContext); var r = new Err() { C = Comments }; if (CurrCodeType != null) { r.X = CurrCodeType.CxId; } if (CustomMethodContext != null) { r.M = CustomMethodContext.CmId; } if (CurrExc != null) { r.Esr = CurrExc.Source; r.Em = CurrExc.Message; if (S.S.Ea != true) { r.Et = CurrExc.StackTrace; r.Es = CurrExc.ToString(); r.Ets = CurrExc.TargetSite.ToString(); } } L.E.Add(r); Rn++; if (Rl > 1 && Rn > Rl) { Sv(); } }
public IXEP_EmdElement CreateEmdElement() { IXEP_EmdElement elemEmd = XEP_EmdFactrory.CreateEmdElement(); elemEmd.Name = XEP_EmdNames.s_KeyInternalForces; // elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesID, ID.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesN, N.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesMy, My.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesMz, Mz.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesMx, Mx.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesVy, Vy.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesVz, Vz.ToString())); elemEmd.AddAttribute(XEP_EmdFactrory.CreateEmdAttribute(XEP_EmdNames.s_KeyInternalForcesIsCritical, IsCritical.ToString())); return(elemEmd); }
/// <summary> /// Create New Error Log Entry /// </summary> public void E(string CustomComments = null, Exception CurrExc = null, Cx CurrCodeType = null, Mx CustomMethodContext = null) { Ae(CurrCodeType, CustomComments, CurrExc, CustomMethodContext); }