public MailMessage RealTimeTemplateByDispatch(DispatchChannel dispatch, List <ProjectedLog> logs, string level, int count, string fileName)
        {
            List <MailMessage> mailMessages = new List <MailMessage>();
            var    logsByLevel = logs.GroupBy(x => x.LogLevel).ToDictionary(x => x.Key, y => y.ToList());
            string subject     = "Invitations Notification: ";

            string emailIds = null;

            if (level == "Failure")
            {
                emailIds = dispatch.Notify.F;
                if (!string.IsNullOrEmpty(emailIds))
                {
                    return(FormMailMessage(emailIds, GetrealTimetemplateForfailure(logs, dispatch.DispatchName), subject + "Failure", count, fileName));
                }
            }
            else if (level == "Error")
            {
                emailIds = dispatch.Notify.E;
                if (!string.IsNullOrEmpty(emailIds))
                {
                    return(FormMailMessage(emailIds, GetRealTimeTemplateForError(logs, dispatch.DispatchName), subject + "Error", count, fileName));
                }
            }

            return(null);
        }
        public MailMessage EndOfDayTemplatesByDispatch(DispatchChannel dispatch, List <ProjectedLog> logs, string level, int count, string fileName)
        {
            try
            {
                string subject = "Daily Round For Invitations: ";

                string emailIds = null;
                if (level == "failure")
                {
                    emailIds = dispatch.Notify.F;
                    if (!string.IsNullOrEmpty(emailIds))
                    {
                        return(FormMailMessage(emailIds, GetEODTemplateForFailure(logs, dispatch.DispatchName), subject + "Failure", count, fileName));
                    }
                }
                else if (level == "Error")
                {
                    emailIds = dispatch.Notify.E;
                    if (!string.IsNullOrEmpty(emailIds))
                    {
                        return(FormMailMessage(emailIds, GetEODTemplateForError(logs, dispatch.DispatchName), subject + "Error", count, fileName));
                    }
                }
                else if (level == "Information")
                {
                    emailIds = dispatch.Notify.I;
                    if (!string.IsNullOrEmpty(emailIds))
                    {
                        return(FormMailMessage(emailIds, GetEODTemplateForInfo(logs, dispatch.DispatchName), subject + "Information", count, fileName));
                    }
                }
                else if (level == "Warning")
                {
                    emailIds = dispatch.Notify.W;
                    if (!string.IsNullOrEmpty(emailIds))
                    {
                        return(FormMailMessage(emailIds, GetEODTemplateForWarning(logs, dispatch.DispatchName), subject + "Warning", count, fileName));
                    }
                }
                else if (level == "Debug")
                {
                    emailIds = dispatch.Notify.D;
                    if (!string.IsNullOrEmpty(emailIds))
                    {
                        var debugLogs = GetEODTemplateForDebug(logs, dispatch.DispatchName);
                        return(FormMailMessage(emailIds, debugLogs, subject + "Debug", count, fileName));
                    }
                }

                return(null);
            }
            catch (Exception ex0)
            {
                log.logMessage += $"{ex0.Message}   {ex0.StackTrace}\n";
                return(null);
            }
        }