Exemple #1
0
        public void Logout()
        {
            string          urlParams   = "/auth/logout";
            string          method      = "POST";
            string          contentType = "application/json";
            List <string[]> headers     = new List <string[]>();

            headers.Add(new string[] { "Cookie", cookie });
            webRespFac = new WebResponseFactory(webReqFac.BuildRequest(urlParams, method, contentType, headers, ""));
            webRespFac.ExecuteRequest();
        }
Exemple #2
0
        private static string Login()
        {
            string          urlParams = "/auth/login";
            string          method    = "POST";
            List <string[]> headers   = new List <string[]>();
            //headers.Add(new string[] { "Content-type", "application/x-www-form-urlencoded" });
            string contentType = "application/x-www-form-urlencoded";
            string body        = "username=admin&password=administrator";

            webRespFac = new WebResponseFactory(webReqFac.BuildRequest(urlParams, method, contentType, headers, body));
            HttpWebResponse response     = webRespFac.ExecuteRequest();
            string          cookieHolder = response.GetResponseHeader("set-cookie");

            string[] cookieHolderPieces = cookieHolder.Split(new string[] { "; " }, StringSplitOptions.None);
            return(cookieHolderPieces[0]);
        }
Exemple #3
0
        public Dictionary <string, bool> CheckDownloadStatus(List <string> folders)
        {
            Dictionary <string, bool> downloadFinished = new Dictionary <string, bool>();
            string          urlParams = "/torrents/info";
            string          method    = "POST";
            List <string[]> headers   = new List <string[]>();

            headers.Add(new string[] { "Cookie", cookie });
            string contentType = "application/json";

            webRespFac = new WebResponseFactory(webReqFac.BuildRequest(urlParams, method, contentType, headers, ""));
            string       responseBody = webRespFac.GetResponseBody(webRespFac.ExecuteRequest());
            IJsonManager jManager     = new JsonManager();
            JArray       jsonArray    = jManager.DeserializeArray(responseBody);

            foreach (JObject jsonObject in jsonArray)
            {
                string name = jManager.SelectStringTokensInTopLevelJObject(jsonObject, "name");
                foreach (string s in folders)
                {
                    if (String.Equals(name, s))
                    {
                        int amount_left = jManager.SelectIntTokensInTopLevelJObject(jsonObject, "amount_left");
                        if (amount_left == 0)
                        {
                            downloadFinished.Add(name, true);
                        }
                        else
                        {
                            downloadFinished.Add(name, false);
                        }
                        break;
                    }
                }
            }
            return(downloadFinished);
        }