Beispiel #1
0
        public ActionResult FindPassword(string email, string uname)
        {
            User user = userservice.GerUserbyUserName(email, uname);

            if (user == null)
            {
                ViewData["error"] = "<em><span id=\"serverError\" class='error'>" + Resources.SunResource.USER_FINDPASSWORD_EMAIL_NOT_REGISTERED + "</span></em>";
                //显示错误信息,不存在此账号
            }
            else
            {
                MailServerPoolObject obj = EmailConnectionPool.getMailServerPoolObject();
                if (obj == null)
                {
                    ViewData["error"] = "<em><span id=\"serverError\" class='error'>" + Resources.SunResource.USER_CONTROLLER_FINDPASSWORD_ERROR + "</span></em>";
                }
                else
                {
                    Message message = new Message();
                    message.BodyText   = string.Format(Resources.SunResource.USER_CONTROLLER_FINDPASSWORD_EMAIL_BODY, user.username, user.depassword);
                    message.From.Email = obj.accountName;
                    message.To.Add(user.email);
                    message.Subject = Resources.SunResource.USER_CONTROLLER_FINDPASSWORD_EMAIL_SUBJECT;
                    if (obj.SendMail(message))
                    {
                        ViewData["error"] = "<em><span id=\"serverError\" class='success'>" + Resources.SunResource.USER_FINDPASSWORD_CHECK_EMAIL + "</span></em>";
                        //userservice.UpdatePassword(user.id, user.password);
                    }
                    else
                    {
                        ViewData["error"] = "<em><span id=\"serverError\" class='error'>" + Resources.SunResource.USER_CONTROLLER_FINDPASSWORD_EMAIL_ERROR1 + "</span></em> ";
                    }
                    obj.close();
                }
            }


            return(View());
        }
Beispiel #2
0
        public ActionResult Warningpayment()
        {
            #region 获取配置电站付费提醒天数
            int        limitDays = 30;
            ItemConfig config    = ItemConfigService.GetInstance().GetItemConfigByName(ItemConfig.Payment);
            if (config != null && config.value > 0)
            {
                limitDays = (int)config.value;
            }
            #endregion

            //过滤相同的用户ID  Userid
            IList <Plant> plants = PlantService.GetInstance().GetPaymentExpiredList();
            plants = plants.Distinct(new PlantUserIdComparer()).ToList <Plant>();

            User user = null;
            foreach (Plant plant in plants)
            {
                if (plant.userID.Equals(0))
                {
                    continue;
                }
                user = UserService.GetInstance().Get(plant.userID); //根据电站取用户
                if (string.IsNullOrEmpty(user.email))               //邮箱不对跳过
                {
                    continue;
                }

                IList <Plant> expiredPlants = user.ExpiredPlants;
                string        msg           = string.Empty;
                foreach (Plant vo in expiredPlants)
                {
                    msg += string.Format(Resources.SunResource.FEE_EMAILTIPS_DONE_FOMART, vo.name, vo.PaymentLimitDate.ToString("yyyy-MM-dd"));
                }
                MailServerPoolObject obj = EmailConnectionPool.getMailServerPoolObject();
                Message message          = null;
                try
                {
                    message            = new Message();
                    message.BodyHtml   = string.Format(Resources.SunResource.FEE_EMAILTIPS_DONE, user.username, msg);
                    message.From.Email = obj.accountName;
                    message.To.Add(user.email);
                    message.Subject = "SolarInfoBank";
                    if (expiredPlants.Count > 0)
                    {
                        obj.SendMail(message);
                        //更新电站邮件最后发送时间
                        foreach (Plant vo in expiredPlants)
                        {
                            vo.LastEmailRemindDate = DateTime.Now;
                            PlantService.GetInstance().UpdateLastEmailRemindDate(vo);
                        }
                    }
                    obj.close();

                    expiredPlants = user.ExpireSoonPlants(limitDays);
                    if (expiredPlants.Count.Equals(0))
                    {
                        continue;
                    }
                    msg = string.Empty;
                    foreach (Plant vo in expiredPlants)
                    {
                        msg += string.Format(Resources.SunResource.FEE_EMAILTIPS_WILL_FOMART, vo.name, vo.PaymentLimitDate.ToString("yyyy-MM-dd"));
                    }
                    //下面发送即将到期电站邮件
                    obj = EmailConnectionPool.getMailServerPoolObject();
                    message.BodyHtml = string.Format(Resources.SunResource.FEE_EMAILTIPS_WILL, user.username, msg);
                    obj.SendMail(message);
                    obj.close();
                    //更新电站邮件最后发送时间
                    foreach (Plant vo in expiredPlants)
                    {
                        vo.LastEmailRemindDate = DateTime.Now;
                        PlantService.GetInstance().UpdateLastEmailRemindDate(vo);
                    }
                }
                catch
                {
                    obj.close();
                }
            }
            return(Content(""));
        }