Exemplo n.º 1
0
        public RPN_API_Json.InternalData GetUser(string username)
        {
            using (WebClient wb = new WebClient())
            {
                NameValueCollection defaultPost = GetLoginPost();
                defaultPost.Set("action", "getfromusername");
                defaultPost.Set("targetuser", username);

                byte[] response         = wb.UploadValues(BaseURL + "internal.php", "POST", defaultPost);
                string responseInString = Encoding.UTF8.GetString(response);

                // Convert to C# Class typed object
                RPN_API_Json.InternalJSON data = JsonConvert.DeserializeObject <RPN_API_Json.InternalJSON>(responseInString);

                foreach (RPN_API_Json.InternalData internalData in data.Data)
                {
                    if (internalData.Username.Equals(username))
                    {
                        return(internalData);
                    }
                }

                return(null);
            }
        }
Exemplo n.º 2
0
        public Permission GetPermission(string username)
        {
            using (WebClient wb = new WebClient())
            {
                NameValueCollection defaultPost = GetLoginPost();
                defaultPost.Set("action", "get");

                byte[] response         = wb.UploadValues(BaseURL + "internal.php", "POST", defaultPost);
                string responseInString = Encoding.UTF8.GetString(response);

                // Convert to C# Class typed object
                RPN_API_Json.InternalJSON data = JsonConvert.DeserializeObject <RPN_API_Json.InternalJSON>(responseInString);

                foreach (RPN_API_Json.InternalData internalData in data.Data)
                {
                    if (internalData.Username.Equals(username))
                    {
                        if (internalData.Permission.Equals("max"))
                        {
                            return(Permission.Max);
                        }
                        if (internalData.Permission.Equals("med"))
                        {
                            return(Permission.Med);
                        }
                        if (internalData.Permission.Equals("min"))
                        {
                            return(Permission.Min);
                        }
                    }
                }
                return(Permission.Unknown);
            }
        }
Exemplo n.º 3
0
        public List <RPN_API_Json.InternalData> GetAllUsers()
        {
            using (WebClient wb = new WebClient())
            {
                NameValueCollection defaultPost = GetLoginPost();
                defaultPost.Set("action", "get");

                byte[] response         = wb.UploadValues(BaseURL + "internal.php", "POST", defaultPost);
                string responseInString = Encoding.UTF8.GetString(response);

                // Convert to C# Class typed object
                RPN_API_Json.InternalJSON data = JsonConvert.DeserializeObject <RPN_API_Json.InternalJSON>(responseInString);

                return(data.Data.ToList());
            }
        }