Exemplo n.º 1
0
 public CSProcService(ILogger <CSProcService> logger, CStat.Models.CStatContext context, IConfiguration configuration, IWebHostEnvironment hostEnv, UserManager <CStatUser> userManager)
 {
     _hostEnv       = hostEnv;
     _logger        = logger;
     _context       = context;
     _configuration = configuration;
     _userManager   = userManager;
     _csSettings    = CSSettings.GetCSSettings(_configuration, userManager);
 }
Exemplo n.º 2
0
        public CSResult NotifyUser(string username, NotifyType nt, string msg, bool allowResend, bool cleanLog)
        {
            var Settings = CSSettings.GetCSSettings(_config, _userManager);

            var u = Settings.GetUser(username);

            if ((u == null) || (u.PhoneNum.Length < 7))
            {
                var csRes = new CSResult();
                csRes.Set(false, ((u == null) ? "No user found" : "No phone # found."), nt.ToString() + ">" + username, "");
                return(csRes);
            }

            return(SendMessage(u.PhoneNum, msg, allowResend, cleanLog));
        }
Exemplo n.º 3
0
        public CSResult NotifyUsers(NotifyType nt, string msg, bool allowResend, bool cleanLog)
        {
            var Settings = CSSettings.GetCSSettings(_config, _userManager);

            List <CSUser> nUsers;

            switch (nt)
            {
            case NotifyType.EquipNT:
                nUsers = Settings.UserSettings.Where(u => u.SendEquipText && (u.PhoneNum.Length > 6)).ToList();
                break;

            case NotifyType.StockNT:
                nUsers = Settings.UserSettings.Where(u => u.SendStockText && (u.PhoneNum.Length > 6)).ToList();
                break;

            case NotifyType.TaskNT:
                nUsers = Settings.UserSettings.Where(u => u.SendTaskText && (u.PhoneNum.Length > 6)).ToList();
                break;

            default:
                nUsers = new List <CSUser>();
                break;
            }

            int sentCount = 0;

            foreach (var u in nUsers)
            {
                CSResult csRes = NotifyUser(u.EMail, nt, msg, allowResend, cleanLog);
                if (csRes.Succeeded)
                {
                    ++sentCount;
                }
                cleanLog = false;
            }

            return(new CSResult(sentCount == nUsers.Count, "NotifyUsers", msg, "All Users"));
        }
Exemplo n.º 4
0
 public CSEMail(IConfiguration config, UserManager <CStatUser> userManager)
 {
     fromPass  = config["CSEMail:SenderPassword"];
     _settings = CSSettings.GetCSSettings(config, userManager);
 }