Пример #1
0
        public RPN_API_Json.RenseignementData GetRenseignement(int id)
        {
            using (WebClient wb = new WebClient())
            {
                NameValueCollection defaultPost = GetLoginPost();
                defaultPost.Set("action", "getfromid");
                defaultPost.Set("id", id.ToString());

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

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

                return(data.Data[0]);
            }
        }
Пример #2
0
        /* END Relation */

        /* Renseignement */
        public List <RPN_API_Json.RenseignementData> GetRenseignements(bool full)
        {
            using (WebClient wb = new WebClient())
            {
                NameValueCollection defaultPost = GetLoginPost();
                if (full)
                {
                    defaultPost.Set("action", "getfull");
                }
                else
                {
                    defaultPost.Set("action", "getlite");
                }

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

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

                return(data.Data.ToList());
            }
        }
Пример #3
0
        /// <summary>
        /// To not filter the date, simply pass the min_last_edit_date argument to DateTime.Min
        /// </summary>
        public List <RPN_API_Json.RenseignementData> SearchRenseignement(string nickname, string name, string pseudo, string tel,
                                                                         string affiliation, string old_affiliation, string position, string license_plate, string known_vehicle,
                                                                         string financial_situation, string behaviour, string dead_boolean, string wanted_boolean, string fake_nickname,
                                                                         string fake_name, DateTime min_last_edit_date)
        {
            using (WebClient wb = new WebClient())
            {
                NameValueCollection defaultPost = GetLoginPost();
                defaultPost.Set("action", "search");

                if (!string.IsNullOrEmpty(nickname))
                {
                    defaultPost.Set("nickname", nickname);
                }
                if (!string.IsNullOrEmpty(name))
                {
                    defaultPost.Set("name", name);
                }
                if (!string.IsNullOrEmpty(pseudo))
                {
                    defaultPost.Set("pseudo", pseudo);
                }
                if (!string.IsNullOrEmpty(tel))
                {
                    defaultPost.Set("tel", tel);
                }
                if (!string.IsNullOrEmpty(affiliation))
                {
                    defaultPost.Set("affiliation", affiliation);
                }
                if (!string.IsNullOrEmpty(old_affiliation))
                {
                    defaultPost.Set("old_affiliation", old_affiliation);
                }
                if (!string.IsNullOrEmpty(position))
                {
                    defaultPost.Set("position", position);
                }
                if (!string.IsNullOrEmpty(license_plate))
                {
                    defaultPost.Set("license_plate", license_plate);
                }
                if (!string.IsNullOrEmpty(known_vehicle))
                {
                    defaultPost.Set("known_vehicle", known_vehicle);
                }
                if (!string.IsNullOrEmpty(financial_situation))
                {
                    defaultPost.Set("financial_situation", financial_situation);
                }
                if (!string.IsNullOrEmpty(behaviour))
                {
                    defaultPost.Set("behaviour", behaviour);
                }

                if (!string.IsNullOrEmpty(dead_boolean))
                {
                    defaultPost.Set("dead", (bool.Parse(dead_boolean) ? 1 : 0).ToString());
                }
                if (!string.IsNullOrEmpty(wanted_boolean))
                {
                    defaultPost.Set("wanted", (bool.Parse(wanted_boolean) ? 1 : 0).ToString());
                }

                if (!string.IsNullOrEmpty(fake_nickname))
                {
                    defaultPost.Set("fake_nickname", fake_nickname);
                }
                if (!string.IsNullOrEmpty(fake_name))
                {
                    defaultPost.Set("fake_name", fake_name);
                }

                if (min_last_edit_date != null && min_last_edit_date != DateTime.MinValue)
                {
                    defaultPost.Set("min_last_edit_date", min_last_edit_date.ToString("yyyy-MM-dd HH:mm:ss"));
                }


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

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

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