public Level[] GetLevels()
        {
            _Trace.TraceEvent(TraceEventType.Verbose, -1, "GetAllLevels");

            LevelEntity[] entities = new CriticalResultsEntityManager().GetLevels();
            List<Level> levels = new List<Level>();
            foreach (LevelEntity entity in entities)
            {
                Level level = new Level(entity);
                level.ResolveTransports();
                levels.Add(level);
            }
            return levels.ToArray();
        }
        public bool ResolveLevels()
        {
            if (_Entity == null)
                return false;
            if (_Entity.Levels == null)
            {
                return false;
            }

            _Levels = new List<Level>();
            foreach (LevelEntity e in _Entity.Levels)
            {
                Level level = new Level(e);
                _Levels.Add(level);
            }
            return true;
        }
        public Level CreateLevel(Level level)
        {
            _Trace.TraceEvent(TraceEventType.Verbose, -1, "CreateLevel");

            CriticalResultsEntityManager manager = new CriticalResultsEntityManager();
            LevelEntity entity = manager.CreateLevel(level.Name, level.Description, level.ShortDescription, level.ColorValue, level.EscalationTimeout, level.DueTimeout, level.DirectContactRequired);
            if (level.Transports != null)
            {
                foreach(Transport t in level.Transports){
                    bool mandatory = false;
                    foreach(Transport mT in level.MandatoryTransports)
                    {
                        if(mT.Name == t.Name)
                        {
                            mandatory = true;
                        }
                    }
                    manager.CreateTransportLevelEntity(entity.Uuid, t.Name, mandatory);
                }
                UserEntity[] ues = manager.GetAllUsers();
                entity.TransportLevels.Load();
                foreach (UserEntity ue in ues)
                {
                    ue.UserTransports.Load();

                    foreach (UserTransportEntity te in ue.UserTransports)
                    {

                        foreach (TransportLevelEntity t in entity.TransportLevels)
                        {
                            if (te.Transport != null)
                            {
                                if (t.Transport.Name == te.Transport.Name)
                                {
                                    te.Levels.Add(entity);
                                }
                            }
                        }
                    }
                }
                manager.SaveChanges();
            }
            return new Level(entity);
        }
 public Level CreateLevel_Json(Level level)
 {
     return CreateLevel(level);
 }
 public Level UpdateLevel_Json(Level level)
 {
     return UpdateLevel(level);
 }
        public Level UpdateLevel(Level level)
        {
            _Trace.TraceEvent(TraceEventType.Verbose, -1, "UpdateLevel");

            CriticalResultsEntityManager manager = new CriticalResultsEntityManager();
            LevelEntity entity = manager.UpdateLevel(level.Uuid, level.Name, level.Description, level.ShortDescription, level.ColorValue, level.EscalationTimeout, level.DueTimeout, level.DirectContactRequired);
            if (level.Transports != null)
            {
                List<TransportLevelEntity> transportsToRemove = new List<TransportLevelEntity>();
                transportsToRemove.AddRange(entity.TransportLevels);
                foreach(TransportLevelEntity tle in transportsToRemove)
                {
                    if (!tle.TransportReference.IsLoaded)
                    {
                        tle.TransportReference.Load();
                    }
                    manager.RemoveTransportFromLevel(level.Uuid, tle.Transport.Name);
                }

                foreach (Transport t in level.Transports)
                {
                    bool mandatory = false;
                    foreach (Transport mT in level.MandatoryTransports)
                    {
                        if (t.Name == mT.Name)
                        {
                            mandatory = true;
                        }
                    }
                    manager.CreateTransportLevelEntity(level.Uuid, t.Name, mandatory);
                }

            }
            return new Level(entity);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// Change: 2009-05-31, Jeremy R.
        ///		Mandatory flag was added to TransportLevelEntity.  This change has been propagated by adding a bool? Mandatory flag to the Transport and Level.
        ///		The mandatory flag from the TransportLevelEntity is applied to either of these objects to hide the changes to the Entities and avoid changing the object model.
        ///	Change: 2009-06-01, John C.
        ///		Manadaroty flag removed and replaced with _MandatoryLevels array.
        /// </remarks>
        public bool ResolveLevels()
        {
            if (_Entity == null)
                return false;
            if (_Entity.TransportLevels == null)
                return false;

            _Levels = new List<Level>();
            _MandatoryLevels = new List<Level>();
            foreach (TransportLevelEntity e in _Entity.TransportLevels)
            {
                Level level = new Level(e.Level);
                if (e.Mandatory)
                {
                    _MandatoryLevels.Add(level);
                }
                _Levels.Add(level);
            }
            return true;
        }
예제 #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// Change: 2009-05-31, Jeremy R
        ///		Removed internal call to automatically resolve any level transports.  This doesn't belong in the Result.  
        ///		This can be done by calling Result.ResolveLevel() followed by Result.Levels.ResolveTransport();
        /// 
        /// </remarks>
        public bool ResolveLevel()
        {
            if(_Entity == null )
            {
                return false;
            }
            else if( _Entity.Level == null )
            {
                return false;
            }

            _Level = new Level(_Entity.Level);

            return true;
        }
 public virtual void ExtendUserFromExternalDirectory(User user, Transport[] transports, Level[] levels, string email, string[] proxyAddresses)
 {
 }