Exemplo n.º 1
0
 public static void Send(string to, string subject, string templateParth, Dictionary<string, string> parameters, ISmtp smtp)
 {
     try
     {
         Send(smtp.DefaultSender, to, subject, templateParth, parameters, smtp);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw;
     }
 }
Exemplo n.º 2
0
        public static void Send(Mailler mail, ISmtp smtp)
        {
            SmtpClient client = new SmtpClient(smtp.ServerName, smtp.Port);
            if (smtp.UserName != string.Empty
                && smtp.Password != string.Empty)
            {
                client.EnableSsl = smtp.EnableSSL;
                client.UseDefaultCredentials = false;
                client.Credentials = new NetworkCredential(smtp.UserName, smtp.Password);
            }

            client.Send(mail);
        }
Exemplo n.º 3
0
        public AuthenticationService(IRepository <User> repositoryUser, IRepository <SessionHistory> repositorySessionHistory, IRepository <Session> repositorySession, IRepository <RoleUserLine> repositoryRoleUserLine, IRepository <Role> repositoryRole, IRepository <Person> repositoryPerson, IRepository <UserHistory> repositoryUserHistory, ISmtp smtp, IMainService serviceMain)
        {
            _repositoryUser           = repositoryUser;
            _repositorySessionHistory = repositorySessionHistory;
            _repositorySession        = repositorySession;
            _repositoryRoleUserLine   = repositoryRoleUserLine;

            _repositoryRole = repositoryRole;

            _repositoryPerson      = repositoryPerson;
            _repositoryUserHistory = repositoryUserHistory;
            _smtp        = smtp;
            _serviceMain = serviceMain;
        }
Exemplo n.º 4
0
 public UserService(IRepository <User> repositoryUser, IRepository <RolePermissionLine> repositoryRolePermissionLine, IRepository <PermissionMenuLine> repositoryPermissionMenuLine, IRepository <RoleUserLine> repositoryRoleUserLine, IRepository <UserHistory> repositoryUserHistory, ISmtp smtp, IRepository <Person> repositoryPerson, IRepository <PersonHistory> repositoryPersonHistory, IRepository <Role> repositoryRole, IRepository <RoleUserLineHistory> repositoryRoleUserLineHistory, IMainService serviceMain)
 {
     _repositoryUser = repositoryUser;
     _repositoryRolePermissionLine = repositoryRolePermissionLine;
     _repositoryPermissionMenuLine = repositoryPermissionMenuLine;
     _repositoryRoleUserLine       = repositoryRoleUserLine;
     _repositoryUserHistory        = repositoryUserHistory;
     _smtp                          = smtp;
     _repositoryPerson              = repositoryPerson;
     _repositoryPersonHistory       = repositoryPersonHistory;
     _repositoryRole                = repositoryRole;
     _repositoryRoleUserLineHistory = repositoryRoleUserLineHistory;
     _serviceMain                   = serviceMain;
 }
Exemplo n.º 5
0
        public static void Send(string from, string to, string subject, string templateParth, Dictionary<string, string> parameters, ISmtp smtp)
        {
            try
            {
                Logger.InfoWithParam("From:{0}, To:{1},Subject:{2}", from, to, subject);
                Mailler mail = new Mailler(from, to, subject, templateParth, parameters);
                string[] emails;
                if (!string.IsNullOrEmpty(smtp.DefaultCC))
                {
                    emails = smtp.DefaultCC.Split(';');
                    foreach (string emailItem in emails)
                    {
                        try
                        {
                            mail.CC.Add(emailItem.Trim());
                        }
                        catch (Exception ex)
                        {
                            Logger.Error(ex);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(smtp.DefaultBCC))
                {
                    emails = smtp.DefaultBCC.Split(';');
                    foreach (string emailItem in emails)
                    {
                        try
                        {
                            mail.Bcc.Add(emailItem.Trim());
                        }
                        catch (Exception ex)
                        {
                            Logger.Error(ex);
                        }
                    }
                }
                MailHelper.Send(mail, smtp);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw;
            }
        }
Exemplo n.º 6
0
        public UserService(IRepository <User> repositoryUser, IRepository <RolePermissionLine> repositoryRolePermissionLine, IRepository <PermissionMenuLine> repositoryPermissionMenuLine, IRepository <RoleUserLine> repositoryRoleUserLine, IRepository <UserHistory> repositoryUserHistory, ISmtp smtp, IRepository <Person> repositoryPerson, IRepository <PersonHistory> repositoryPersonHistory, IRepository <Role> repositoryRole, IRepository <RoleUserLineHistory> repositoryRoleUserLineHistory, IMainService serviceMain, IRepository <Language> repositoryLanguage)
        {
            _repositoryUser = repositoryUser;
            _repositoryRolePermissionLine = repositoryRolePermissionLine;
            _repositoryPermissionMenuLine = repositoryPermissionMenuLine;
            _repositoryRoleUserLine       = repositoryRoleUserLine;
            _repositoryUserHistory        = repositoryUserHistory;
            _smtp                          = smtp;
            _repositoryPerson              = repositoryPerson;
            _repositoryPersonHistory       = repositoryPersonHistory;
            _repositoryRole                = repositoryRole;
            _repositoryRoleUserLineHistory = repositoryRoleUserLineHistory;
            _serviceMain                   = serviceMain;
            _repositoryLanguage            = repositoryLanguage;

            _languages = _repositoryLanguage.Get().Where(x => x.IsApproved).OrderBy(x => x.DisplayOrder)
                         .Select(t => new IdName(t.Id, t.Name)).ToList();
        }
Exemplo n.º 7
0
        /// <summary>
        /// 初始新实例
        /// 配置:ExceptionMailRecipients, 邮件地址,以逗号分隔
        /// 配置:ExceptionMailSmtp, 实现 ISmtp接口类型
        /// </summary>
        public ExceptionMail()
        {
            var recipients = GlobalConfig.Instance["ExceptionMailRecipients"] ?? "";

            if (string.IsNullOrEmpty(recipients))
            {
                MailRecipients = new string[0];
            }
            else
            {
                var parts = recipients.Split(';');
                var list  = new List <string>(parts.Length);
                foreach (var part in parts)
                {
                    if (string.IsNullOrEmpty(part) == false)
                    {
                        list.Add(part);
                    }
                }
                MailRecipients = list.ToArray();
            }
            //
            var exceptionMailSmtp = GlobalConfig.Instance["ExceptionMailSmtp"] ?? "";

            if (!string.IsNullOrEmpty(exceptionMailSmtp))
            {
                var type = Type.GetType(exceptionMailSmtp, false);
                if (type == null)
                {
                    throw new System.Configuration.ConfigurationErrorsException("AppSetting ExceptionMailSmtp Error");
                }
                Smtp = Activator.CreateInstance(type) as ISmtp;
            }
            else
            {
                Smtp = Adf.Smtp.Instance;
            }
        }
Exemplo n.º 8
0
        public NotificationService()
        {
            _connection                 = new Connection();
            emailVerificationQueues     = new Queue <EmailVerificationQueueModel>();
            emailVerificationLockObject = new object();

            passwordQueues     = new Queue <PasswordQueueModel>();
            passwordLockObject = new object();

            eventQueues     = new Queue <EventQueueModel>();
            eventLockObject = new object();

            eventParticipantRequestQueues = new Queue <EventParticipantRequestQueueModel>();
            eventParticipantLockObject    = new object();

            HubConnection connection = new HubConnectionBuilder().WithUrl(_connection.apiUrl + "/NotificationHub").Build();

            connection.StartAsync().ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Console.WriteLine(task.Exception);
                }
                else
                {
                    Console.WriteLine("SignalR Connected...");
                }
            });

            connection.On <EventQueueModel>("sendEventPushNotification", (item) =>
            {
                eventQueues.Enqueue(item);
            });

            connection.On <EmailVerificationQueueModel>("SendEmailVerification", (item) =>
            {
                emailVerificationQueues.Enqueue(item);
            });

            connection.On <PasswordQueueModel>("SendPassword", (item) =>
            {
                passwordQueues.Enqueue(item);
            });

            connection.On <EventParticipantRequestQueueModel>("sendEventParticipantRequest", (item) =>
            {
                eventParticipantRequestQueues.Enqueue(item);
            });

            emailVerificaitonTimer = new Timer(EmailVerificationTick, emailVerificationLockObject, TimeSpan.Zero, TimeSpan.FromSeconds(15));
            passwordTimer          = new Timer(PasswordTick, passwordLockObject, TimeSpan.Zero, TimeSpan.FromSeconds(15));
            eventTimer             = new Timer(EventTick, eventLockObject, TimeSpan.Zero, TimeSpan.FromSeconds(15));
            eventParticipantTimer  = new Timer(EventParticipantTick, eventParticipantLockObject, TimeSpan.Zero, TimeSpan.FromSeconds(60));

            _SSystemParameter  = new SSystemParameter(new DbContext());
            _SMethod           = new SMethod();
            _SEvent            = new SEvent(new DbContext());
            _SEventParticipant = new SEventParticipant(new DbContext());
            _SUser             = new SUser(new DbContext());


            List <SystemParameter> systemParameters = _SSystemParameter.GetSystemParameter();
            SmtpModel smtpModel = _SMethod.SystemParameterToObject <SmtpModel>(systemParameters);

            if (!String.IsNullOrEmpty(smtpModel.smtp_host))
            {
                _SSmtp = new SSmtp(smtpModel.smtp_host, smtpModel.smtp_port, smtpModel.smtp_sender, smtpModel.smtp_password);
            }
        }
Exemplo n.º 9
0
 public EmailSender(IMainService serviceMain, ISmtp smtp)
 {
     _applicationSettings = serviceMain.ApplicationSettings;
     _smtp = smtp;
 }
Exemplo n.º 10
0
 public EmailSender(ISmtp smtp, IMainService serviceMain)
 {
     _smtp        = smtp;
     _serviceMain = serviceMain;
 }
 public EmailWorker(ISmtp smtp) => _smtp = smtp;
Exemplo n.º 12
0
 public SQueueClient(ISmtp smtp)
 {
     _connection = Connection.CreateConnectionInstance;
     _smtp       = smtp;
 }