Beispiel #1
0
 public static string GetCurrentPack()
 {
     using (var ct = new CoDRotator())
     {
         return(ct.ServerSettings.OrderByDescending(x => x.PackageDate).Select(x => x.Package).FirstOrDefault());
     }
 }
Beispiel #2
0
        public static void SaveMap(string package, string name, string team1, string team2, int score, string description, Image image)
        {
            using (var ct = new CoDRotator())
            {
                var map = ct.Maps.FirstOrDefault(x => x.Package == package && x.Name == name);

                if (map == null)
                {
                    map = new MapInfo
                    {
                        Package = package,
                        Name    = name
                    };

                    ct.Maps.Add(map);
                }

                if (map.Team1 != team1 || map.Team2 != team2 || (map.Score != score) || map.Description != description || map.Thumbnail != image)
                {
                    map.Thumbnail = image;
                    map.Team1     = team1;
                    map.Team2     = team2;

                    if (score != int.MinValue)
                    {
                        map.Score = score;
                    }

                    map.Description = description;
                    ct.SaveChanges();
                }
            }
        }
Beispiel #3
0
 public static MapInfo GetMap(string package, string name)
 {
     using (var ct = new CoDRotator())
     {
         return(ct.Maps.FirstOrDefault(x => x.Package == package && x.Name == name));
     }
 }
Beispiel #4
0
        public static string GetOriginalConfig()
        {
            using (var ct = new CoDRotator())
            {
                var config = ct.ServerSettings.FirstOrDefault(x => x.Computer == "CONFIG");

                if (config == null)
                {
                    return(null);
                }

                return(config.Package);
            }
        }
Beispiel #5
0
        public static void SaveCurrentPackageConfig(string computer, string pack)
        {
            using (var ct = new CoDRotator())
            {
                var config = ct.ServerSettings.FirstOrDefault(x => x.Computer == computer);
                if (config == null)
                {
                    config          = new ServerSetting();
                    config.Computer = computer;
                    ct.ServerSettings.Add(config);
                }

                config.Package     = pack;
                config.PackageDate = DateTime.Now;

                ct.SaveChanges();
            }
        }
Beispiel #6
0
        public static List <string> SearchMaps(string text)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return(null);
            }

            using (var ct = new CoDRotator())
            {
                var splits = text.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

                return(ct.Maps
                       .OrderByDescending(x => x.Score)
                       .Where(x =>
                              splits.All(y => x.Description.Contains(y) ||
                                         x.Name.Contains(y)))
                       .Select(x => x.Package + " -> " + x.Name)
                       .ToList());
            }
        }
Beispiel #7
0
 public static string GetCurrentPack()
 {
     using (var ct = new CoDRotator())
     {
         return ct.ServerSettings.OrderByDescending(x => x.PackageDate).Select(x => x.Package).FirstOrDefault();
     }
 }
Beispiel #8
0
        public static string GetOriginalConfig()
        {
            using (var ct = new CoDRotator())
            {
                var config = ct.ServerSettings.FirstOrDefault(x => x.Computer == "CONFIG");

                if (config == null)
                    return null;

                return config.Package;
            }
        }
Beispiel #9
0
        public static void SaveCurrentPackageConfig(string computer, string pack)
        {
            using (var ct = new CoDRotator())
            {
                var config = ct.ServerSettings.FirstOrDefault(x => x.Computer == computer);
                if (config == null)
                {
                    config = new ServerSetting();
                    config.Computer = computer;
                    ct.ServerSettings.Add(config);
                }

                config.Package = pack;
                config.PackageDate = DateTime.Now;

                ct.SaveChanges();
            }
        }
Beispiel #10
0
        public static List<string> SearchMaps(string text)
        {
            if (string.IsNullOrWhiteSpace(text))
                return null;

            using (var ct = new CoDRotator())
            {
                var splits = text.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

                return ct.Maps
                    .OrderByDescending(x => x.Score)
                    .Where(x =>
                        splits.All(y => x.Description.Contains(y)
                        || x.Name.Contains(y)))
                    .Select(x => x.Package + " -> " + x.Name)
                    .ToList();
            }
        }
Beispiel #11
0
        public static void SaveMap(string package, string name, string team1, string team2, int score, string description, Image image)
        {
            using (var ct = new CoDRotator())
            {
                var map = ct.Maps.FirstOrDefault(x => x.Package == package && x.Name == name);

                if (map == null)
                {
                    map = new MapInfo
                    {
                        Package = package,
                        Name = name
                    };

                    ct.Maps.Add(map);
                }

                if (map.Team1 != team1 || map.Team2 != team2 || (map.Score != score) || map.Description != description || map.Thumbnail != image)
                {
                    map.Thumbnail = image;
                    map.Team1 = team1;
                    map.Team2 = team2;

                    if (score != int.MinValue)
                        map.Score = score;

                    map.Description = description;
                    ct.SaveChanges();
                }
            }
        }
Beispiel #12
0
 public static MapInfo GetMap(string package, string name)
 {
     using (var ct = new CoDRotator())
     {
         return ct.Maps.FirstOrDefault(x => x.Package == package && x.Name == name);
     }
 }