コード例 #1
0
        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      = "",
                    });
                }
            }
            //}
        }
コード例 #2
0
        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      = "",
                    });
                }
            }
            //}
        }