Пример #1
0
 public static void SubmitMinerStatistics(string url, Data.Machine machine)
 {
     if (!url.EndsWith("/"))
         url = url + "/";
     string fullUrl = String.Format("{0}machines", url);
     using (WebClient client = new ApiWebClient())
     {
         //specify UTF8 so devices with Unicode characters are posted up properly
         client.Encoding = Encoding.UTF8;
                         
         string jsonData = JsonConvert.SerializeObject(machine);
         client.Headers[HttpRequestHeader.ContentType] = "application/json";
         string response = client.UploadString(fullUrl, jsonData);
     }
 }
Пример #2
0
        public static Data.RemoteCommand DeleteCommand(string url, string apiKey, string emailAddress, string applicationKey, string machineName, long commandId)
        {
            if (!url.EndsWith("/"))
                url = url + "/";
            string fullUrl = String.Format("{0}RemoteCommands?emailAddress={1}&applicationKey={2}&machineName={3}&commandId={4}&apiKey={5}",
                url, emailAddress, applicationKey, machineName, commandId, apiKey);
            using (WebClient client = new ApiWebClient())
            {
                string response = ExecuteWebAction(() =>
                {
                    return client.UploadString(fullUrl, "DELETE", "");
                });

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                return serializer.Deserialize<Data.RemoteCommand>(response);
            }
        }
Пример #3
0
        public static void SubmitNotifications(string url, string apiKey, string emailAddress, string applicationKey, List<Data.Notification> notifications)
        {
            if (!url.EndsWith("/"))
                url = url + "/";
            string fullUrl = String.Format("{0}NotificationsInput?emailAddress={1}&applicationKey={2}&apiKey={3}&detailed=true",
                url, emailAddress, applicationKey, apiKey);
            using (WebClient client = new ApiWebClient())
            {
                string jsonData = JsonConvert.SerializeObject(notifications);
                client.Headers[HttpRequestHeader.ContentType] = "application/json";

                ExecuteWebAction(() =>
                {
                    return client.UploadString(fullUrl, jsonData);
                });
            }
        }
Пример #4
0
        public static void SubmitMachinePools(string url, string apiKey, string emailAddress, string applicationKey,
            Dictionary<string, List<string>> machinePools)
        {
            if (!url.EndsWith("/"))
                url = url + "/";
            string fullUrl = String.Format("{0}PoolsInput?emailAddress={1}&applicationKey={2}&apiKey={3}",
                url, emailAddress, applicationKey, apiKey);
            using (WebClient client = new ApiWebClient())
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                string jsonData = serializer.Serialize(machinePools);
                client.Headers[HttpRequestHeader.ContentType] = "application/json";

                ExecuteWebAction(() =>
                {
                    return client.UploadString(fullUrl, jsonData);
                });
            }
        }
Пример #5
0
        public static List<Data.RemoteCommand> GetCommands(string url, string apiKey, string emailAddress, string applicationKey, List<string> machineNames)
        {
            if (!url.EndsWith("/"))
                url = url + "/";

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string jsonData = serializer.Serialize(machineNames);

            string fullUrl = String.Format("{0}RemoteCommands?emailAddress={1}&applicationKey={2}&apiKey={4}",
                url, emailAddress, applicationKey, jsonData, apiKey);

            using (WebClient client = new ApiWebClient())
            {
                client.Headers[HttpRequestHeader.ContentType] = "application/json";

                string response = ExecuteWebAction(() =>
                {
                    return client.UploadString(fullUrl, jsonData);
                });

                return serializer.Deserialize<List<Data.RemoteCommand>>(response);
            }
        }
Пример #6
0
        public static List<Data.RemoteCommand> SubmitMiningStatistics(string url, string apiKey, string emailAddress, string applicationKey, 
            List<Data.MiningStatistics> miningStatistics, bool fetchCommands)
        {
            if (!url.EndsWith("/"))
                url = url + "/";
            string fullUrl = String.Format("{0}MiningStatisticsInput?emailAddress={1}&applicationKey={2}&apiKey={3}&fetchCommands={4}", 
                url, emailAddress, applicationKey, apiKey, fetchCommands);
            using (WebClient client = new ApiWebClient())
            {
                //specify UTF8 so devices with Unicode characters are posted up properly
                client.Encoding = Encoding.UTF8;

                string jsonData = JsonConvert.SerializeObject(miningStatistics);
                client.Headers[HttpRequestHeader.ContentType] = "application/json";

                string response = ExecuteWebAction(() =>
                {
                    return client.UploadString(fullUrl, jsonData);
                });

                return JsonConvert.DeserializeObject<List<Data.RemoteCommand>>(response);
            }
        }
Пример #7
0
        public static void SubmitMiningStatistics(string url, string apiKey, string emailAddress, string applicationKey, List<Data.MiningStatistics> miningStatistics)
        {
            if (!url.EndsWith("/"))
                url = url + "/";
            string fullUrl = String.Format("{0}MiningStatisticsInput?emailAddress={1}&applicationKey={2}&apiKey={3}",
                url, emailAddress, applicationKey, apiKey);
            using (WebClient client = new ApiWebClient())
            {
                //specify UTF8 so devices with Unicode characters are posted up properly
                client.Encoding = Encoding.UTF8;

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                string jsonData = serializer.Serialize(miningStatistics);
                client.Headers[HttpRequestHeader.ContentType] = "application/json";

                ExecuteWebAction(() =>
                {
                    return client.UploadString(fullUrl, jsonData);
                });

            }
        }