Esempio n. 1
0
        //Gets the agent context from cloud
        public string GetEncryptedAgentOptions()
        {
            WebDavClient client = GetWebClient();

            //Requests the agent context from the cloud
            Task <WebDavStreamResponse> t = client.GetRawFile(_cloudConfig.pathToDir + "AgentOptions.json");

            t.Wait();
            WebDavStreamResponse result = t.Result;

            if (result.IsSuccessful)
            {
                using (StreamReader reader = new StreamReader(result.Stream))
                {
                    //Serializes the response stream to string
                    string text = reader.ReadToEnd();
                    return(text);
                }
            }
            else
            {
                // Error handling
                return(null);
            }
        }
Esempio n. 2
0
        //Gets the hash list from cloud
        public List <string> GetHashList()
        {
            WebDavClient client = GetWebClient();

            //Requests the hash list file from the cloud
            Task <WebDavStreamResponse> t = client.GetRawFile(_cloudConfig.pathToDir + "Hashlist.txt");

            t.Wait();
            WebDavStreamResponse result = t.Result;

            if (result.IsSuccessful)
            {
                using (StreamReader reader = new StreamReader(result.Stream))
                {
                    //Serializes the response string to a list
                    string text = reader.ReadToEnd();
                    return(new List <string>(text.Split("\n")).Where(s => !String.IsNullOrEmpty(s)).ToList());;
                }
            }
            else
            {
                // Error handling
                return(null);
            }
        }
Esempio n. 3
0
        //Gets the database file from cloud
        public Byte[] GetCloudVersion()
        {
            WebDavClient client = GetWebClient();

            //Requests the database file from the cloud
            Task <WebDavStreamResponse> t = client.GetRawFile(_cloudConfig.pathToDir + "sqlite.db");

            t.Wait();
            WebDavStreamResponse result = t.Result;

            if (result.IsSuccessful)
            {
                using (var memoryStream = new MemoryStream())
                {
                    //Serializes the response stream to byte array
                    result.Stream.CopyTo(memoryStream);
                    return(memoryStream.ToArray());
                }
            }
            else
            {
                // Error handling
                return(null);
            }
        }