Example #1
0
        public void Put_info([ModelBinder] Models.Info putInfo, string endpoint)
        {
            HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.OK);
            bool EndpointExist          = false;

            EndpointExist = Other_methods.The_existence_check(EndpointExist, endpoint);
            if (EndpointExist)
            {
                WorkSQL.UPDATE_info(endpoint, putInfo.name);
                WorkSQL.DELETE_gameModes(endpoint);
                int i = 0;
                while (i < putInfo.gameModes.Length)
                {
                    WorkSQL.Add_advertise_gameModes(endpoint, putInfo.gameModes[i]);
                    i++;
                }
            }
            else
            {
                WorkSQL.Add_advertise_info(endpoint, putInfo.name);
                int j = 0;
                while (j < putInfo.gameModes.Length)
                {
                    WorkSQL.Add_advertise_gameModes(endpoint, putInfo.gameModes[j]);
                    j++;
                }
            }
        }
Example #2
0
        public string Get_endpoint(string endpoint)
        {
            bool EndpointExist = false;

            EndpointExist = Other_methods.The_existence_check(EndpointExist, endpoint);
            if (EndpointExist)
            {
                Models.Info   info1     = new Models.Info();
                List <string> gameModes = WorkSQL.Select_gameModes(endpoint);
                int           i         = 0;
                info1.gameModes = new string[gameModes.Count];
                foreach (var a in gameModes)
                {
                    info1.gameModes[i] = a;
                    i++;
                }
                info1.name = WorkSQL.Select_name(endpoint)[0];
                string serilized = JsonConvert.SerializeObject(info1);
                return(serilized);
            }
            else
            {
                return("404 Not Found");
            }
        }
Example #3
0
        public string Get_matches(string endpoint, string timestamp)
        {
            bool endpoint_exist = false;

            endpoint_exist = Other_methods.The_existence_check(endpoint_exist, endpoint, timestamp);
            if (endpoint_exist)
            {
                Models.Matches matches1         = new Models.Matches();
                string[]       string_parametrs = new string[2];
                matches1.map         = WorkSQL.Select_matche_string_parametrs(endpoint, timestamp)[0][0];
                matches1.gameMode    = WorkSQL.Select_matche_string_parametrs(endpoint, timestamp)[0][1];
                matches1.fragLimit   = WorkSQL.Select_matche_int_parametrs(endpoint, timestamp)[0][1];
                matches1.timeLimit   = WorkSQL.Select_matche_int_parametrs(endpoint, timestamp)[0][0];
                matches1.timeElapsed = WorkSQL.Select_matche_double_parametr(endpoint, timestamp)[0];
                matches1.scoreboard  = new List <Models.class_scoreboard>();
                foreach (var a in WorkSQL.Select_scoreboard_name(endpoint, timestamp))
                {
                    matches1.scoreboard.Add(new Models.class_scoreboard()
                    {
                        name = a, frags = WorkSQL.Select_scoreboard_int_parametrs(endpoint, timestamp, a)[0][0], kills = WorkSQL.Select_scoreboard_int_parametrs(endpoint, timestamp, a)[0][1], deaths = WorkSQL.Select_scoreboard_int_parametrs(endpoint, timestamp, a)[0][2]
                    });
                }

                string serilized = JsonConvert.SerializeObject(matches1);
                return(serilized);
            }
            else
            {
                return("404 Not Found");
            }
        }
Example #4
0
        public HttpResponseMessage Put_matches([FromBody] JToken jsonbody, string endpoint, string timestamp)
        {
            Models.Matches      putMatches = JsonConvert.DeserializeObject <Models.Matches>(jsonbody.ToString());
            HttpResponseMessage message    = Request.CreateResponse(HttpStatusCode.OK);
            bool endpoint_exist            = false;

            endpoint_exist = Other_methods.The_existence_check(endpoint_exist, endpoint);
            if (!endpoint_exist)
            {
                string        output  = "400 Not Found";
                StringContent content = new StringContent(output, Encoding.UTF8, "application/json");
                message         = Request.CreateResponse(HttpStatusCode.NotFound);
                message.Content = content;
            }
            else
            {
                string        output  = "Match add";
                StringContent content = new StringContent(output, Encoding.UTF8, "application/json");
                message         = Request.CreateResponse(HttpStatusCode.OK);
                message.Content = content;
                WorkSQL.Add_match(endpoint, timestamp, putMatches.map, putMatches.gameMode, putMatches.fragLimit, putMatches.timeLimit, putMatches.timeElapsed);
                int g = 0;
                while (g < putMatches.scoreboard.Count)
                {
                    WorkSQL.Add_scoreboard(endpoint, timestamp, putMatches.scoreboard[g].name, putMatches.scoreboard[g].frags, putMatches.scoreboard[g].kills, putMatches.scoreboard[g].deaths);
                    g++;
                }
            }
            return(message);
        }
Example #5
0
        public string Get_stat(string endpoint)
        {
            Models.Stats_match stat = new Models.Stats_match();
            stat.totalMatchesPlayed   = WorkSQL.Select_timestamp_Matches(endpoint).Count;
            stat.maximumMatchesPerDay = 33;
            stat.averageMatchesPerDay = 24.456240;
            stat.maximumPopulation    = 32;
            stat.averagePopulation    = 20.450000;
            string serilized = JsonConvert.SerializeObject(stat);

            return(serilized);
        }
Example #6
0
 public static bool The_existence_check(bool endpoint_exist, string endpoint)
 {
     foreach (var e in WorkSQL.Select_Endpoint())
     {
         if (endpoint.Equals(e))
         {
             endpoint_exist = true;
             break;
         }
         else
         {
             continue;
         }
     }
     return(endpoint_exist);
 }
Example #7
0
 public static bool The_existence_check(bool endpoint_exist, string endpoint, string timestap)
 {
     foreach (var e in WorkSQL.Select_Endpoint_timestamp())
     {
         if (endpoint.Equals(e[0]) && timestap.Equals(e[1]))
         {
             endpoint_exist = true;
             break;
         }
         else
         {
             continue;
         }
     }
     return(endpoint_exist);
 }
Example #8
0
        public string Get_info()
        {
            List <Models.All_Info> servers_info = new List <Models.All_Info>();

            foreach (var e in WorkSQL.Select_Endpoint())
            {
                {
                    List <string> gameModes          = WorkSQL.Select_gameModes(e);
                    int           i                  = 0;
                    string[]      endpoint_gameModes = new string[gameModes.Count];
                    foreach (var a in gameModes)
                    {
                        endpoint_gameModes[i] = a;
                        i++;
                    }
                    servers_info.Add(new Models.All_Info()
                    {
                        endpoint = e, name = WorkSQL.Select_name(e)[0], gameModes = endpoint_gameModes
                    });
                }
            }
            return(JsonConvert.SerializeObject(servers_info));
        }