Exemplo n.º 1
0
 public OrganizationService()
 {
     _departmentRepository             = new DepartmentRepository();
     _staffRepository                  = new StaffRepository();
     _applicationLoggingRepository     = new ApplicationLoggingRepository();
     _systemConfigDepartmentRepository = new SystemConfigDepartmentRepository();
     _departmentStaffsRepository       = new DepartmentStaffsRepository();
     _userRepository = new AspNetUsersRepository();
 }
Exemplo n.º 2
0
 public ShareService()
 {
     _systemConfigRepository           = new SystemConfigRepository();
     _systemConfigDepartmentRepository = new SystemConfigDepartmentRepository();
     _departmentRepository             = new DepartmentRepository();
     _loginHistoryRepository           = new LoginHistoryRepository();
     _applicationLoggingRepository     = new ApplicationLoggingRepository();
     _userNotificationRepository       = new UserNotificationRepository();
     _notificationCenterRepository     = new NotificationCenterRepository();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Config email
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public async Task configSendGridasync(IdentityMessage message)
        {
            SystemConfigDepartmentQuery      query = new SystemConfigDepartmentQuery();
            SystemConfigDepartmentRepository _systemConfigDepartmentRepository = new SystemConfigDepartmentRepository();

            query.Title = "NOTICEEMAIL";
            string fromEmail = _systemConfigDepartmentRepository.GetSystemConfigDepartmentValue(query);

            query.Title = "NOTICEEMAIL_PASSWORD";
            string  fromEmailPassword = _systemConfigDepartmentRepository.GetSystemConfigDepartmentValue(query);
            dynamic MailMessage       = new MailMessage();

            MailMessage.From = new MailAddress(fromEmail);
            MailMessage.To.Add(message.Destination);
            MailMessage.Subject    = message.Subject;
            MailMessage.IsBodyHtml = true;
            MailMessage.Body       = message.Body;

            SmtpClient SmtpClient = new SmtpClient();

            SmtpClient.Host        = "smtp.gmail.com";
            SmtpClient.EnableSsl   = true;
            SmtpClient.Port        = 587;
            SmtpClient.Credentials = new System.Net.NetworkCredential(fromEmail, fromEmailPassword);

            try
            {
                try
                {
                    SmtpClient.Send(MailMessage);
                }
                catch (Exception ex)
                {
                }
            }
            catch (SmtpFailedRecipientsException ex)
            {
                for (int i = 0; i <= ex.InnerExceptions.Length; i++)
                {
                    SmtpStatusCode status = ex.StatusCode;
                    if ((status == SmtpStatusCode.MailboxBusy) | (status == SmtpStatusCode.MailboxUnavailable))
                    {
                        System.Threading.Thread.Sleep(5000);
                        SmtpClient.Send(MailMessage);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public async Task <IHttpActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByEmailAsync(model.Email);

                if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    return(BadRequest("Either user does not exist or you have not confirmed your email."));
                }

                try
                {
                    // Send an email with this link
                    SystemConfigDepartmentQuery      query = new SystemConfigDepartmentQuery();
                    SystemConfigDepartmentRepository _systemConfigDepartmentRepository = new SystemConfigDepartmentRepository();
                    query.Title = "APP_DOMAIN";
                    string url  = _systemConfigDepartmentRepository.GetSystemConfigDepartmentValue(query);
                    string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);


                    //string callbackUrl = Url.Link("Default", new { controller = "/#!/reset-password", userId = user.Id, code = code });
                    string callbackUrl = url + "/#!/reset-mat-khau?userId=" + user.Id + "&code=" + code;
                    await UserManager.SendEmailAsync(user.Id, "Khôi phục mật khẩu", "Chào bạn, để khôi phục mật khẩu truy cập hệ thống vOffice, xin vui lòng click vào <a href=\"" + callbackUrl + "\">đây</a>");

                    return(Ok());
                }
                catch
                {
                    return(InternalServerError());
                }
            }

            return(BadRequest());
        }