public void SendLockOutEmail(int userId) { //Mail not enabled if (SettingServices.GetSettingValue(SettingStrings.SmtpEnabled) == "0") { return; } var lockedUser = GetUser(userId); foreach (var user in SearchUsers("").Where(x => x.NotifyLockout == 1 && !string.IsNullOrEmpty(x.Email))) { if (user.Membership != "Administrator" && user.Id != userId) { continue; } var mail = new MailServices { MailTo = user.Email, Body = lockedUser.Name + " Has Been Locked For 15 Minutes Because Of Too Many Failed Login Attempts", Subject = "User Locked" }; mail.Send(); } }
public ApiBoolResponseDTO SendEmailTest() { var mail = new MailServices { Subject = "Test Message", Body = "Email Notifications Are Working!", MailTo = SettingServices.GetSettingValue(SettingStrings.SmtpMailTo) }; mail.Send(); return(new ApiBoolResponseDTO { Value = true }); }
private void SendNotificationEmail(SecondaryServerEntity server) { //Mail not enabled if (SettingServices.GetSettingValue(SettingStrings.SmtpEnabled) == "0") { return; } var message = server.IsActive == 1 ? " Status Changed To Active" : " Status Changed To Inactive"; foreach ( var user in new UserServices().SearchUsers("") .Where(x => x.NotifyServerStatusChange == 1 && !string.IsNullOrEmpty(x.Email))) { var mail = new MailServices { MailTo = user.Email, Body = server.Name + message, Subject = server.Name }; mail.Send(); } }
public void SendImageApprovedEmail(int imageId) { //Mail not enabled if (SettingServices.GetSettingValue(SettingStrings.SmtpEnabled) == "0") { return; } var image = GetImage(imageId); foreach ( var user in _userServices.SearchUsers("") .Where(x => x.NotifyImageApproved == 1 && !string.IsNullOrEmpty(x.Email))) { var mail = new MailServices { MailTo = user.Email, Body = image.Name + " Has Been Approved", Subject = "Image Approved" }; mail.Send(); } }
public void SendMulticastCompletedEmail(ActiveMulticastSessionEntity session) { //Mail not enabled if (SettingServices.GetSettingValue(SettingStrings.SmtpEnabled) == "0") { return; } foreach ( var user in _userServices.SearchUsers("").Where(x => x.NotifyComplete == 1 && !string.IsNullOrEmpty(x.Email))) { if (session.UserId == user.Id) { var mail = new MailServices { MailTo = user.Email, Body = session.Name + " Multicast Task Has Completed.", Subject = "Multicast Completed" }; mail.Send(); } } }
public bool SendApprovalRequestReport() { if (ServiceSetting.GetSettingValue(SettingStrings.SmtpEnabled) != "1") { return(true); } var approvalRequests = _uow.ApprovalRequestRepository.Get(); if (approvalRequests.Count == 0) { return(true); } var sb = new StringBuilder(); sb.Append("The Following Computers Are Pending Approval:\r\n\r\n"); foreach (var approvalRequest in approvalRequests) { sb.Append(approvalRequest.ComputerName + "\t" + approvalRequest.RequestTime + "\t" + approvalRequest.IpAddress + Environment.NewLine); } var emailList = new List <string>(); var users = _uow.UserRepository.Get(); foreach (var user in users) { if (user.Membership.Equals("Administrator")) { if (!string.IsNullOrEmpty(user.Email)) { emailList.Add(user.Email); } } else { var rights = new ServiceUser().GetUserRights(user.Id).Select(right => right.Right).ToList(); if (rights.Any(right => right == AuthorizationStrings.EmailReset)) { if (!string.IsNullOrEmpty(user.Email)) { emailList.Add(user.Email); } } } } foreach (var email in emailList) { var mail = new MailServices { Subject = "Approval Request Report", Body = sb.ToString(), MailTo = email }; mail.Send(); } return(true); }
public bool SendSmartReport() { if (ServiceSetting.GetSettingValue(SettingStrings.SmtpEnabled) != "1") { return(true); } var uow = new UnitOfWork(); var computers = uow.ComputerRepository.Get(x => x.ProvisionStatus == EnumProvisionStatus.Status.Provisioned); if (computers.Count == 0) { return(true); } var sb = new StringBuilder(); var errorsFound = false; sb.Append("The Following Hard Drives Have A Failed S.M.A.R.T. Status:\r\n\r\n"); foreach (var computer in computers) { var localComputer = computer; var hdds = uow.HardDriveInventoryRepository.Get(x => x.ComputerId == localComputer.Id); foreach (var hdd in hdds) { if (!hdd.Status.ToLower().Equals("ok")) { errorsFound = true; sb.Append(computer.Name + "\t" + hdd.Model + "\t" + hdd.SerialNumber + "\t" + hdd.Status + Environment.NewLine); } } } if (!errorsFound) { return(true); } var emailList = new List <string>(); var users = uow.UserRepository.Get(); foreach (var user in users) { if (user.Membership.Equals("Administrator")) { if (!string.IsNullOrEmpty(user.Email)) { emailList.Add(user.Email); } } else { var rights = new ServiceUser().GetUserRights(user.Id).Select(right => right.Right).ToList(); if (rights.Any(right => right == AuthorizationStrings.EmailSmart)) { if (!string.IsNullOrEmpty(user.Email)) { emailList.Add(user.Email); } } } } foreach (var email in emailList) { var mail = new MailServices { Subject = "S.M.A.R.T Failure Report", Body = sb.ToString(), MailTo = email }; mail.Send(); } return(true); }
public bool SendLowDiskSpaceReport() { if (ServiceSetting.GetSettingValue(SettingStrings.SmtpEnabled) != "1") { return(true); } var uow = new UnitOfWork(); var sb = new StringBuilder(); var errorsFound = false; var comServers = new Workflows.ComServerFreeSpace().RunAllServers(); sb.Append("The Following Com Servers Have Low Disk Space:\r\n\r\n"); foreach (var comServer in comServers) { if (comServer.freePercent < 20) { errorsFound = true; sb.Append(comServer.name + "\t" + comServer.freePercent + "% Free"); } } if (!errorsFound) { return(true); } var emailList = new List <string>(); var users = uow.UserRepository.Get(); foreach (var user in users) { if (user.Membership.Equals("Administrator")) { if (!string.IsNullOrEmpty(user.Email)) { emailList.Add(user.Email); } } else { var rights = new ServiceUser().GetUserRights(user.Id).Select(right => right.Right).ToList(); if (rights.Any(right => right == AuthorizationStrings.EmailLowDiskSpace)) { if (!string.IsNullOrEmpty(user.Email)) { emailList.Add(user.Email); } } } } foreach (var email in emailList) { var mail = new MailServices { Subject = "Com Server Low Disk Space", Body = sb.ToString(), MailTo = email }; mail.Send(); } return(true); }