コード例 #1
0
        private void UpdateActiveAlerts()
        {
            var customers        = new List <Customer>();
            var alertDefinitions = new AlertDefinitionRepository(_monilyzerContext).GetAlertDefinitions(DateTime.UtcNow);
            var activeAlerts     = new List <ActiveAlert>();

            foreach (var alertDefinition in alertDefinitions)
            {
                if (alertDefinition.AlertObjectType == MonilyzerObjectType.Customer)
                {
                    if (customers.Count == 0)
                    {
                        customers = new CustomerRepository(_monilyzerContext).GetCustomers().ToList();
                    }

                    foreach (var customer in customers)
                    {
                        activeAlerts.AddRange(AlertService.EvaluateCustomerAlerts(customer, alertDefinitions));
                    }
                }
            }

            new ActiveAlertRepository(_monilyzerContext).InsertUpdateActiveAlerts(activeAlerts);
        }