private void TestingEnvironment()
        {
            List <SmtpQueue> smtpQueues = SmtpQueueBusiness.GetList();
            SmtpQueue        lastReport = smtpQueues.OrderBy(a => a.Id).LastOrDefault();
            DateTime         date       = Convert.ToDateTime(DateTime.Now.AddDays(-1).ToString("MM/dd/yyyy 00:00:00"));
            string           title      = date.ToString("MM/dd/yyyy 23");

            if (lastReport != null && lastReport.Title == title)
            {
                //已经生成了报表
            }
            else
            {
                string lastTitle = lastReport?.Title;
                if (string.IsNullOrEmpty(lastTitle))
                {
                    title = date.ToString("MM/dd/yyyy HH");
                }
                else
                {
                    DateTime lastDate = DateTime.Parse(lastTitle.Contains(" ") ? lastTitle + ":00:00" : lastTitle);
                    date  = lastDate.AddHours(1);
                    title = date.ToString("MM/dd/yyyy HH");
                }

                //// 每天9开始统计前一天的数据
                //if (DateTime.Now > Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 09:00:00")))
                //{
                List <ZoneEntity> zoneEntities = ZoneBusiness.GetZoneList().Where(a => a.IfEnable).ToList();
                if (zoneEntities != null && zoneEntities.Count > 0)
                {
                    foreach (ZoneEntity zone in zoneEntities)
                    {
                        CreateActiveReportZoneTesting(zone, date);
                    }
                    //插入邮件发送队列
                    SmtpQueueBusiness.Add(new SmtpQueue
                    {
                        Title       = title,
                        Status      = 0,
                        CreatedTime = DateTime.Now,
                        SendedTime  = DateTime.Now,
                        Remark      = "",
                    });
                }
            }
            //}
        }
        /// <summary>
        /// 发送邮件
        /// </summary>
        public void MainQueueDoWork()
        {
            try
            {
                if (!isProcessing)
                {
                    isProcessing = true;
                    List <SmtpQueue> smtpQueues = SmtpQueueBusiness.GetList();
                    List <SmtpQueue> subQueues  = smtpQueues.Where(a => a.Status == 0).ToList();
                    if (subQueues != null && subQueues.Count > 0)
                    {
                        var configuration = GlobalConfigurationBusiness.GetConfigurationList().FirstOrDefault();
                        for (int i = 0; i < subQueues.Count; i++)
                        {
                            SmtpQueue smtp           = subQueues[i];
                            string    title          = smtp.Title;
                            string    bodys          = GeneratedMail(title);
                            string    smtpserver     = ConstValues.emailsmtp;
                            bool      enablessl      = ConstValues.emailssl;
                            string    userName       = ConstValues.emailusername;
                            string    pwd            = Utils.AesDecrypt(ConstValues.emailpassword);
                            string    nickName       = ConstValues.emailnickname;
                            string    strfrom        = ConstValues.emailfrom;
                            string    strto          = configuration.EmailAddForWhiteList;
                            string    subj           = string.Format("IP Action Report {0}", title);
                            int       port           = ConstValues.emailport;
                            bool      authentication = ConstValues.emailauthentication;
                            int       timeout        = ConstValues.emailtimeout;

                            Utils.SendMail(smtpserver, enablessl, userName, pwd, nickName, strfrom, strto, subj, bodys, port, authentication, timeout);

                            smtp.Status = 1;
                            SmtpQueueBusiness.Edit(smtp);
                        }
                    }
                    isProcessing = false;
                }
            }
            catch (Exception e)
            {
                logService.Error(e.StackTrace);
                isProcessing = false;
            }
            finally
            {
            }
        }
        private string GeneratedMail(string title)
        {
            StringBuilder mail      = new StringBuilder();
            SmtpQueue     smtpQueue = SmtpQueueBusiness.GetByTitle(title);

            if (smtpQueue != null && smtpQueue.Id > 0)
            {
                mail.AppendLine("<div id=\"mail\">");
                List <ActionReport> actionReports = ActionReportBusiness.GetListByTitle(title);

                List <ZoneEntity> zoneEntities = ZoneBusiness.GetZoneList().Where(a => a.IfEnable).ToList();
                foreach (ZoneEntity zone in zoneEntities)
                {
                    List <ActionReport> subActionReports = actionReports.Where(a => a.ZoneId == zone.ZoneId && a.Mode == "Action").ToList();
                    string body = CreateMainZone(zone.ZoneName, subActionReports);
                    mail.Append(body);
                }
                mail.AppendLine("</div>");
            }
            return(mail.ToString());
        }
        private void ProductionEnvironment()
        {
            List <SmtpQueue> smtpQueues = SmtpQueueBusiness.GetList();
            SmtpQueue        lastReport = smtpQueues.OrderBy(a => a.Id).LastOrDefault();
            DateTime         date       = DateTime.Now.AddDays(-1);
            string           title      = date.ToString("MM/dd/yyyy");

            if (lastReport != null && lastReport.Title == title)
            {
                //已经生成了报表
            }
            else
            {
                //// 每天9开始统计前一天的数据
                //if (DateTime.Now > Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 09:00:00")))
                //{

                List <ZoneEntity> zoneEntities = ZoneBusiness.GetZoneList().Where(a => a.IfEnable).ToList();
                if (zoneEntities != null && zoneEntities.Count > 0)
                {
                    foreach (ZoneEntity zone in zoneEntities)
                    {
                        CreateActiveReportZoneProduction(zone, date);
                    }
                    //插入邮件发送队列
                    SmtpQueueBusiness.Add(new SmtpQueue
                    {
                        Title       = title,
                        Status      = 0,
                        CreatedTime = DateTime.Now,
                        SendedTime  = DateTime.Now,
                        Remark      = "",
                    });
                }
            }
            //}
        }