Пример #1
0
 public static bool LogGetCountry(ControlFiltersSettingsDto ControlFiltersSettingsDto, out string prefix)
 {
     bool bHasRange = false;
     prefix = string.Empty;
     if (!ControlFiltersSettingsDto.FiltCountryInnerHTML.value.Contains("ALL&")) //ALL check
     {
         string Search = "    ";
         int pos = ControlFiltersSettingsDto.FiltCountryInnerHTML.value.IndexOf(Search);
         prefix = ControlFiltersSettingsDto.FiltCountryInnerHTML.value.Substring(pos + Search.Length);
         bHasRange = true;
     }
     return bHasRange;
 }
Пример #2
0
 public static bool LogGetFrequencyRange(ControlFiltersSettingsDto ControlFiltersSettingsDto, out decimal FreqLow, out decimal FreqHigh)
 {
     bool bHasRange = false;
     FreqLow = 0;
     FreqHigh = 0;
     if (ControlFiltersSettingsDto.FiltBand != "ALL")
     {
         bHasRange = true;
         CatBandEnum CatBandEnum;
         if (Enum.TryParse("_" + ControlFiltersSettingsDto.FiltBand, out CatBandEnum) == true)
         {
             Enum.GetName(typeof(CatBandEnum), CatBandEnum);
             switch (CatBandEnum)
             {
                 case CatBandEnum._160M:
                     FreqLow=  1800.0m;
                     FreqHigh = 2000.0m;
                     break;
                 case CatBandEnum._80M:
                     FreqLow = 3500.0m;
                     FreqHigh = 4000.0m;
                    break;
                 case CatBandEnum._40M:
                     FreqLow = 7000.0m;
                     FreqHigh = 7300.0m;
                     break;
                 case CatBandEnum._20M:
                     FreqLow = 14000.0m;
                     FreqHigh = 14350.0m;
                     break;
                 case CatBandEnum._15M:
                     FreqLow = 21000.0m;
                     FreqHigh = 21450.0m;
                     break;
                 case CatBandEnum._10M:
                     FreqLow = 28000.0m;
                     FreqHigh = 29700.0m;
                     break;
                 default:
                     break;
             }
         }
     }
     //else
     //{
     //    bHasRange = true;
     //    FreqLow = 1800.0m;
     //    FreqHigh = 29700.0m;
     //}
     return bHasRange;
 }
Пример #3
0
        public static bool LogGetContinent(ControlFiltersSettingsDto ControlFiltersSettingsDto, out ContinentEnum ContinentEnum)
        {
            bool bHasRange = false;
            ContinentEnum = mvc.common.Enum.ContinentEnum.ALL;

            if (ControlFiltersSettingsDto.FiltContinent != "ALL")
            {
                if (Enum.TryParse(ControlFiltersSettingsDto.FiltContinent, out ContinentEnum) == true)
                {
                    bHasRange = true;
                }
            }
            return bHasRange;
        }
Пример #4
0
        public static ControlFiltersSettingsDto GetControlFilterSettings(this IRepository<FiltDefaullt> repository, string Username)
        {
            ControlFiltersSettingsDto ControlFiltersSettingsDto = new ControlFiltersSettingsDto();

            //var Settings = repository.GetRepository<FiltDefaullt>().Queryable();
            //var Settings  = repository.Queryable();

            //var fluent = repository.Query(t => t.UserName == Username);
            //fluent.Include(t => t.FiltPrefix);
            var fluent = repository.Query(t => t.UserName == Username).Include(t => t.FiltPrefix);

            FiltDefaullt FiltDefaullt = fluent.Select().First();

            //now we need to get the index of the FiltPrefix
            //No index in DB
            IRepository<FiltPrefix> FiltPrefixRepository = repository.GetRepository<FiltPrefix>();
            IEnumerable<CountryPrefixtype> CountryPrefixtypes = GetFiltPrefixNames(FiltPrefixRepository);
            var CountryPrefixtype  = CountryPrefixtypes.Where(x=>x.value.Contains(FiltDefaullt.FiltPrefix.CountryName) ).FirstOrDefault();
            if (CountryPrefixtype != null)
	        {
                    ControlFiltersSettingsDto.FiltCountryInnerHTML = new mvc.Dto.LogControl.CountryPrefixtype();
                    ControlFiltersSettingsDto.FiltCountryInnerHTML.key = CountryPrefixtype.key;
                    ControlFiltersSettingsDto.FiltCountryInnerHTML.value = CountryPrefixtype.value;
	        }


            ////if (FiltDefaullt.FiltPrefix.CountryName != "ALL")

            ////{
            ////    ControlFiltersSettingsDto.FiltCountryInnerHTML.value = FiltDefaullt.FiltPrefix.CountryName + "&nbsp;&nbsp;&nbsp;&nbsp;" + FiltDefaullt.FiltPref;
            ////}
            ////else
            ////{
            ////    ControlFiltersSettingsDto.FiltCountryInnerHTML.value = FiltDefaullt.FiltPrefix.CountryName + "&nbsp;&nbsp;&nbsp;&nbsp;" + FiltDefaullt.FiltPref;  //no prefix
            ////}
                ////find index
                //var FiltPrefixes = repository.GetRepository < FiltPrefix >(). Queryable();
                ////var index = FiltPrefixes.OrderBy(t => t.CountryName).AsEnumerable().TakeWhile(t => t.CountryName != FiltDefaullt.FiltPrefix.CountryName).ToList();//.Count();
                //// ToList(); is expensive!!!!!!!!!!!!!!!!!!!
                //var query = (from e in FiltPrefixes
                //             orderby e.CountryName
                //             select (e.CountryName )).ToList();
                //ControlFiltersSettingsEntity.FiltCountryIndex = query.IndexOf(ControlFiltersSettingsEntity.FiltCountry);

            ControlFiltersSettingsDto.FiltCQZone = FiltDefaullt.FiltCQZoneVal;

            
            //FiltDefaullt FiltDefaullt = Settings.Where(t=>t.UserName == "default").First();

            ControlFiltersSettingsDto.FiltBand = Enum.GetName(typeof(CatBandEnum), FiltDefaullt.FiltBnd);
            ControlFiltersSettingsDto.FiltContinent = Enum.GetName(typeof(ContinentEnum), FiltDefaullt.FiltCont);
            //ControlFiltersSettingsEntity.FiltCountry = FiltDefaullt.FiltPrefix.CountryName + "&nbsp;&nbsp;&nbsp;&nbsp;" + FiltDefaullt.FiltPref;
            //when setting Val of select, you need to use spaces not &nbsp;


            return ControlFiltersSettingsDto;
        }
Пример #5
0
        public static bool LogGetZone(DataCallInfoDto[] DataCallInfoDtos, ControlFiltersSettingsDto ControlFiltersSettingsDto, out short QsoExchangeNumber)
        {
            bool bHasRange = false;
            QsoExchangeNumber = 0;
            var NoZone = false;
            //check for WPX contest ==> no zone qualifier
            foreach (var item in DataCallInfoDtos)
            {
                if (item.SelectedContestName.Contains("wpx") == true)
                {
                    NoZone = true;
                    break;
                }
            }

            if (NoZone != true)
            {
                if (short.TryParse(ControlFiltersSettingsDto.FiltCQZone, out QsoExchangeNumber) == true)
                {
                    bHasRange = true;
                }
            }
            return bHasRange;
        }
Пример #6
0
        public QSOLogFilter GetQSOFilter(ControlFiltersSettingsDto ControlFiltersSettingsDto, DataCallInfoDto[] DataCallInfoDtos)
        {
            QSOLogFilter Qfilter = new QSOLogFilter();
            Qfilter.Filter = string.Empty;
            Qfilter.QsoCB = ControlFiltersSettingsDto.Disabled;

            if (!Qfilter.QsoCB)
            {
                var NoZone = false;
                //check for WPX contest ==> no zone qualifier
                foreach (var item in DataCallInfoDtos)
                {
                    if ( item.SelectedContestName.Contains("wpx") == true)
                    {
                        NoZone = true;
                        break;
                    }
                }
                //rules
                if (ControlFiltersSettingsDto.FiltContinent != "ALL")
                {
                    ControlFiltersSettingsDto.FiltCountryInnerHTML.value = "ALL&";
                    ControlFiltersSettingsDto.FiltCQZone = "ALL";
                }
                if (ControlFiltersSettingsDto.FiltCountryInnerHTML.value.Contains("ALL&") == false)
                {
                    ControlFiltersSettingsDto.FiltContinent = "ALL";
                    ControlFiltersSettingsDto.FiltCQZone = "ALL";
                }
                if (NoZone == true)
                {
                    ControlFiltersSettingsDto.FiltCQZone = "ALL";
                }
                else
                {
                    if (ControlFiltersSettingsDto.FiltCQZone != "ALL")
                    {
                        ControlFiltersSettingsDto.FiltCountryInnerHTML.value = "ALL&";
                        ControlFiltersSettingsDto.FiltContinent = "ALL";
                    }
                }
            }

            if (!Qfilter.QsoCB)
            {
                if (ControlFiltersSettingsDto.FiltBand != "ALL")
                {
                    CatBandEnum CatBandEnum;
                    if (Enum.TryParse("_" + ControlFiltersSettingsDto.FiltBand, out CatBandEnum) == true)
                    {
                        Enum.GetName(typeof(CatBandEnum), CatBandEnum);
                        switch (CatBandEnum)
                        {
                            case CatBandEnum._160M:
                                Qfilter.Filter = "([Qso].[Frequency] >= 1800.0 AND [Qso].[Frequency] <= 2000.0)";
                                break;
                            case CatBandEnum._80M:
                                Qfilter.Filter = "([Qso].[Frequency] >= 3500.0 AND [Qso].[Frequency] <= 4000.0)";
                                break;
                            case CatBandEnum._40M:
                                Qfilter.Filter = "([Qso].[Frequency] >= 7000.0 AND [Qso].[Frequency] <= 7300.0)";
                                break;
                            case CatBandEnum._20M:
                                Qfilter.Filter = "([Qso].[Frequency] >= 14000.0 and [Qso].[Frequency] <= 14350.0)";
                                break;
                            case CatBandEnum._15M:
                                Qfilter.Filter = "([Qso].[Frequency] >= 21000.0 AND [Qso].[Frequency] <= 21450.0)";
                                break;
                            case CatBandEnum._10M:
                                Qfilter.Filter = "([Qso].[Frequency] >= 28000.0 AND [Qso].[Frequency] <= 28700.0)";
                                break;
                            default:
                                break;
                        }
                    }
                }
                if (ControlFiltersSettingsDto.FiltContinent != "ALL")
                {
                    ContinentEnum ContinentEnum;
                    if (Enum.TryParse(ControlFiltersSettingsDto.FiltContinent, out ContinentEnum) == true)
                    {
                        Enum.GetName(typeof(ContinentEnum), ContinentEnum);
                        if (!string.IsNullOrEmpty(Qfilter.Filter))
                        {
                            Qfilter.Filter += " AND ";
                        }
                        Qfilter.Filter += ("([CallSign].[ContinentEnum] = " + (int)ContinentEnum + " )");
                    }
                }
                if (ControlFiltersSettingsDto.FiltCQZone != "ALL")
                {
                    int QsoExchangeNumber;
                    if (int.TryParse(ControlFiltersSettingsDto.FiltCQZone, out QsoExchangeNumber) == true)
                    {
                        if (!string.IsNullOrEmpty(Qfilter.Filter))
                        {
                            Qfilter.Filter += " AND ";
                        }
                        Qfilter.Filter += ("([Qso].[QsoExchangeNumber] = " + QsoExchangeNumber + " )");
                    }
                }
                if (!ControlFiltersSettingsDto.FiltCountryInnerHTML.value.Contains("ALL&")) //ALL check
                {
                    string Search = "&nbsp;&nbsp;&nbsp;&nbsp;";
                    int pos = ControlFiltersSettingsDto.FiltCountryInnerHTML.value.IndexOf(Search);
                    string prefix = ControlFiltersSettingsDto.FiltCountryInnerHTML.value.Substring(pos + Search.Length);
                    if (!string.IsNullOrEmpty(Qfilter.Filter))
                    {
                        Qfilter.Filter += " AND ";
                    }
                    Qfilter.Filter += " [CallSign].[Prefix] = '" + prefix + "' ";
                }
            }
            return Qfilter;
        }