private static EtlSessionQuery CreateSessionQuery(EtlMailSubscription subscription) { var query = new EtlSessionQuery { ToDateTime = DateTime.Now, FromDateTime = DateTime.Now.Subtract(TimeSpan.FromSeconds(subscription.OnLastSeconds)), }; query.EtlStatuses.AddRange(subscription.EtlStatuses); return(query); }
private static EtlSessionQuery CreateSessionQuery(EtlMailSubscription subscription) { var query = new EtlSessionQuery { ToDateTime = DateTime.Now, FromDateTime = DateTime.Now.Subtract(TimeSpan.FromSeconds(subscription.OnLastSeconds)), }; query.EtlStatuses.AddRange(subscription.EtlStatuses); return query; }
private static EtlDump GetDump(EtlMailSubscription subscription) { var writer = new EtlDumpWriter(new EtlDumpSettings()); foreach (var agentInfo in subscription.EtlAgents) { var query = CreateSessionQuery(subscription); var agent = EtlAgents.CreateAgent(agentInfo); var logParser = agent.GetEtlLogParser(); writer.Write(query, logParser); } var dump = writer.GetDump(); dump.Sessions.Sort(new Comparison <EtlSessionSummary>(SortSessionsDesc)); return(dump); }
private static void SendMail(EtlMailSubscription subscription, string body) { var message = new MailMessage { From = new MailAddress(subscription.From), Subject = subscription.Subject, Body = body, IsBodyHtml = true, BodyEncoding = Encoding.UTF8, }; foreach (var subscriberInfo in subscription.Subscribers) { message.To.Add(subscriberInfo.Email); } var client = new SmtpClient(); client.EnableSsl = subscription.EnableSsl; client.Send(message); }
private static bool Mail(EtlMailSubscription subscription) { System.Console.WriteLine("Retrieving dump for \"{0}\"...", subscription.Subject); var dump = GetDump(subscription); System.Console.WriteLine("Dump for \"{0}\" retrieved", subscription.Subject); var result = false; if (dump.Sessions.Count > 0 || (dump.Sessions.Count == 0 && subscription.AllowEmptyMail)) { var mailBody = GetMailBody(subscription.Subject, subscription.MailTemplatePath, dump); SendMail(subscription, mailBody); result = true; } else { //todo: localize message System.Console.WriteLine("Empty mail is not allowed due to configuration"); } return(result); }
private static EtlDump GetDump(EtlMailSubscription subscription) { var writer = new EtlDumpWriter(new EtlDumpSettings()); foreach (var agentInfo in subscription.EtlAgents) { var query = CreateSessionQuery(subscription); var agent = EtlAgents.CreateAgent(agentInfo); var logParser = agent.GetEtlLogParser(); writer.Write(query, logParser); } var dump = writer.GetDump(); dump.Sessions.Sort(new Comparison<EtlSessionSummary>(SortSessionsDesc)); return dump; }
private static bool Mail(EtlMailSubscription subscription) { System.Console.WriteLine("Retrieving dump for \"{0}\"...", subscription.Subject); var dump = GetDump(subscription); System.Console.WriteLine("Dump for \"{0}\" retrieved", subscription.Subject); var result = false; if (dump.Sessions.Count > 0 || (dump.Sessions.Count == 0 && subscription.AllowEmptyMail)) { var mailBody = GetMailBody(subscription.Subject, subscription.MailTemplatePath, dump); SendMail(subscription, mailBody); result = true; } else { //todo: localize message System.Console.WriteLine("Empty mail is not allowed due to configuration"); } return result; }