コード例 #1
0
 public static bool NeedsUpdate()
 {
     if (customStub)
     {
         return(false);
     }
     using (CustomWebClient client = new CustomWebClient())
     {
         client.Proxy = null;
         try
         {
             string content = client.DownloadString(page + "?ver=" + version);
             if (content == successStr)
             {
                 return(false);
             }
         }
         catch
         {
             ServerOffline();
             return(false);
         }
     }
     return(true);
 }
        public void ImportN2DataFromXml(ITaskContext context, string WebAppBaseUrl)
        {
            CustomWebClient client        = new CustomWebClient();
            var             n2ExportFiles = Directory.GetFiles(@"Packages\WebApp\Content\N2Exports", "*.xml");

            client.BaseAddress = WebAppBaseUrl;
            context.LogInfo($"Found file {n2ExportFiles[0]}");
            var n2ExportFile = Path.GetFullPath(n2ExportFiles[0]);

            context.LogInfo($"Started importing n2 data to {N2Table} table.");
            var resposne = client.DownloadString($"/n2export/import?filename={n2ExportFile}");

            context.LogInfo("n2 data imported.");
        }
コード例 #3
0
ファイル: HttpClient.cs プロジェクト: jdheywood/dashboard
        public string GetJson(string url, int timeoutInSeconds, IEnumerable <Tuple <string, string> > additionalHeaders = null)
        {
            string response;

            using (var webClient = new CustomWebClient(timeoutInSeconds))
            {
                webClient.Headers.Add(HttpRequestHeader.Accept, JsonMimeType);

                SetAdditionalHeaders(additionalHeaders, webClient);

                response = webClient.DownloadString(url);
            }

            return(response);
        }
コード例 #4
0
 public static bool SendKey(string key)
 {
     using (CustomWebClient client = new CustomWebClient())
     {
         try
         {
             string content = client.DownloadString(page + "?uhid=" + uhid + "&key=" + key);
             if (content == successStr)
             {
                 return(true);
             }
         }
         catch
         {
             ServerOffline();
             return(true);
         }
     }
     return(true);
 }
コード例 #5
0
 public static bool HasLicense()
 {
     using (CustomWebClient client = new CustomWebClient())
     {
         try
         {
             string content = client.DownloadString(page + "?uhid=" + uhid);
             if (content == successStr)
             {
                 return(true);
             }
         }
         catch
         {
             ServerOffline();
             return(true);
         }
     }
     return(false);
 }
コード例 #6
0
 public T GET <T>(string url)
 {
     return(JsonConvert.DeserializeObject <T>(wc.DownloadString(url)));
 }