Пример #1
0
 public void OnStatusChanged(string provider, [GeneratedEnum] Availability status, Bundle extras)
 {
     if (status.Equals(Availability.Available))
     {
         if (Disponibilidade != GPSDisponibilidadeEnum.Disponivel)
         {
             MensagemUtils.notificar(5, "Radar+", "Sinal de GPS encontrado!", audio: "sinal_gps_encontrado");
             Disponibilidade = GPSDisponibilidadeEnum.Disponivel;
         }
     }
     else if (status.Equals(Availability.OutOfService))
     {
         if (Disponibilidade != GPSDisponibilidadeEnum.ForaDoAr)
         {
             MensagemUtils.notificar(5, "Radar+", "Sinal de GPS fora do ar!", audio: "sinal_gps_fora_do_ar");
             Disponibilidade = GPSDisponibilidadeEnum.ForaDoAr;
         }
     }
     else if (status.Equals(Availability.TemporarilyUnavailable))
     {
         if (Disponibilidade != GPSDisponibilidadeEnum.IndisponivelTemporariamente)
         {
             MensagemUtils.notificar(5, "Radar+", "Sinal de GPS fora do ar!", audio: "sinal_gps_perdido");
             Disponibilidade = GPSDisponibilidadeEnum.IndisponivelTemporariamente;
         }
     }
 }
Пример #2
0
        public bool CheckRoleAvailability(ulong userId, string role, Availability availability, out string resultMessage)
        {
            resultMessage = string.Empty;
            if (!RoleExists(role))
            {
                resultMessage = $"No role named {role} found.";
                return(false);
            }

            if (availability.Equals(Availability.Flex))
            {
                if (!IsFlexAllowed(userId))
                {
                    resultMessage = $"max allowed flex roles are {MaxFlexRoles}";
                    return(false);
                }
            }
            else
            {
                if (Users.ContainsKey(userId))
                {
                    resultMessage = $"user {Users[userId].Nickname} is already signed up";
                    return(false);
                }
                if (!GetFreeRoles().Contains(role, StringComparer.OrdinalIgnoreCase))
                {
                    resultMessage = $"no free role named {role} found";
                    return(false);
                }
            }
            return(true);
        }
Пример #3
0
 private string PrintAvailability(Availability availability)
 {
     if (availability.Equals(Availability.Yes))
     {
         return(String.Empty);
     }
     return($" - {availability}");
 }
Пример #4
0
        public bool IsAvailabilityChangeAllowed(ulong userId, Availability availability)
        {
            bool isCurrentlyRestrictedAvailability = Users[userId].Availability.Equals(Availability.Yes);
            bool IsChangeToRestrictedAvailability  = availability.Equals(Availability.Yes);

            //user is signed up with yes, or there are free spots, or user doesn't want to change to yes
            return(isCurrentlyRestrictedAvailability || GetFreeRoles().Contains(Users[userId].Role, StringComparer.OrdinalIgnoreCase) || !IsChangeToRestrictedAvailability);
        }
        /// <summary>
        /// Returns true if ResponseMetricsListData instances are equal
        /// </summary>
        /// <param name="other">Instance of ResponseMetricsListData to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ResponseMetricsListData other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     RequestTime == other.RequestTime ||
                     RequestTime != null &&
                     RequestTime.Equals(other.RequestTime)
                     ) &&
                 (
                     Availability == other.Availability ||
                     Availability != null &&
                     Availability.Equals(other.Availability)
                 ) &&
                 (
                     Invocations == other.Invocations ||
                     Invocations != null &&
                     Invocations.Equals(other.Invocations)
                 ) &&
                 (
                     AverageResponse == other.AverageResponse ||
                     AverageResponse != null &&
                     AverageResponse.Equals(other.AverageResponse)
                 ) &&
                 (
                     AverageTps == other.AverageTps ||
                     AverageTps != null &&
                     AverageTps.Equals(other.AverageTps)
                 ) &&
                 (
                     PeakTps == other.PeakTps ||
                     PeakTps != null &&
                     PeakTps.Equals(other.PeakTps)
                 ) &&
                 (
                     Errors == other.Errors ||
                     Errors != null &&
                     Errors.Equals(other.Errors)
                 ) &&
                 (
                     Rejections == other.Rejections ||
                     Rejections != null &&
                     Rejections.Equals(other.Rejections)
                 ));
        }
Пример #6
0
        private string PrintUsers(Role role, Availability availability, ref int signedUpUsers)
        {
            string rolesString = string.Empty;

            foreach (var user in Users)
            {
                //print if the user has the now processed role.
                if (role.Name.Equals(user.Value.Role, StringComparison.OrdinalIgnoreCase))
                {
                    if (availability.Equals(user.Value.Availability))
                    {
                        rolesString += $"\t{user.Value.Nickname} ({user.Value.UsedAccount}) {PrintAvailability(user.Value.Availability)}\n";
                        if (blockingRole.Contains(user.Value.Availability))
                        {
                            signedUpUsers++;
                        }
                    }
                }
            }
            return(rolesString);
        }