/// <summary>
        /// Determines whether an <see cref="Appointment"/> can be created at the specified <paramref name="start"/> time until the specified <paramref name="end"/> time.
        /// </summary>
        /// <param name="moduleId">The ID of the module in which the appointment is to be created.</param>
        /// <param name="start">The start of the new <see cref="Appointment"/>.</param>
        /// <param name="end">The end of the new <see cref="Appointment"/>.</param>
        /// <param name="max">The maximum appointments allowed for the specified time range</param>
        /// <returns>
        /// <c>true</c> if an <see cref="Appointment"/> can be created at the specified <paramref name="start"/> time until the specified <paramref name="end"/> time; otherwise, <c>false</c>.
        /// </returns>
        public static bool CanCreateAt(int moduleId, DateTime start, DateTime end, int? max)
        {
            var appointments = AppointmentSqlDataProvider.GetConcurrentAppointments(moduleId, start, end);
            var appointmentsInRange = new List<Appointment>(max ?? 10);

            while (appointments.Read())
            {
                appointmentsInRange.Add(Fill(appointments));
            }

            var uniqueStartTimes = appointmentsInRange.Select(apt => apt.StartDateTime).Distinct();
            return uniqueStartTimes.All(time => max > appointmentsInRange.Count(apt => time >= apt.StartDateTime && time < apt.EndDateTime));
        }
示例#2
0
        public int HitsReceived(Entity target, Entity source, bool timed)
        {
            var sourceString = source?.Id.ToString() ?? "";
            var key = "hits_received/" + target + "/" + sourceString + "/" + timed;
            if (_caching.ContainsKey(key)) return (int) _caching[key];

            IEnumerable<Skill> result= new List<Skill>();
            if (TargetSourceSkill.ContainsKey(target))
            {
                if (!timed && source != null)
                {
                    if (TargetSourceSkill[target].ContainsKey(source))
                    {
                        result = from skills in TargetSourceSkill[target][source]
                            where skills.Type == Database.Type.Damage
                            select skills;
                    }
                }
                else
                {
                    result = from skills in TargetSourceSkill[target].Values
                        from skill in skills
                        where skill.Type == Database.Type.Damage
                        select skill;
                }
            }

            var count = result.Count();
            _caching.Add(key, count);
            return count;
        }