Пример #1
0
        public static void SendIncidentReport(string startTime, string endTime, double TimeZone, string SendTo)
        {
            double cutTimeZone   = 0 - TimeZone;
            var    StartDateTime = Convert.ToDateTime(startTime).AddHours(cutTimeZone);
            var    EndDateTime   = Convert.ToDateTime(endTime).AddHours(cutTimeZone);

            startTime = StartDateTime.ToString("yyyy-MM-dd HH:mm");
            endTime   = EndDateTime.ToString("yyyy-MM-dd HH:mm");

            string TemplatePath = EmailExtend.MapPath("/Views/Home/IncidentReportTemplate.cshtml");

            var index = File.ReadAllText(TemplatePath, System.Text.Encoding.GetEncoding("GBK"));

            var ModelList      = DbFunction.IncidentHistoryEmail(startTime, endTime, TimeZone);
            var OpenCount      = ModelList.Count(x => x.GuestMood == "--");
            var SatisfiedCount = ModelList.Count(x => x.GuestMood == "Staisfied");
            var AcceptedCount  = ModelList.Count(x => x.GuestMood == "Accepted");
            var AngryCount     = ModelList.Count(x => x.GuestMood == "Angry");
            var ComplaintCount = ModelList.Count(x => x.GuestMood == "Complaint");
            var ImpatientCount = ModelList.Count(x => x.GuestMood == "Impatient");

            var result = Razor.Parse(index, new
            {
                OpenCount      = ModelList.Count(x => x.GuestMood == "--"),
                SatisfiedCount = ModelList.Count(x => x.GuestMood == "Staisfied"),
                AcceptedCount  = ModelList.Count(x => x.GuestMood == "Accepted"),
                AngryCount     = ModelList.Count(x => x.GuestMood == "Angry"),
                ComplaintCount = ModelList.Count(x => x.GuestMood == "Complaint"),
                ImpatientCount = ModelList.Count(x => x.GuestMood == "Impatient"),
                ModelList
            });

            EmailExtend.SendEmail(SendTo, string.Format("Incident Report {0} to {1}", StartDateTime.ToString("MM/dd/yyyy"), EndDateTime.ToString("MM/dd/yyyy")), result);
        }