Thulasiram pakala

Thulasiram pakala

  • 912
  • 872
  • 115.5k

Hi i having one class file asp.net web application in that they are ca

Feb 10 2021 4:20 AM
Hi i having one class file asp.net web application in that they are send data using web api Httpclient and Json what i want daily need to expoert data button click what i want by using console or windows service i want to create one setup file while click that class method need to call and execute daily in particualr time any body send that type code console application and how to call that class method
  1. public static string PreparePost(object input, string fmodulename)  
  2. {  
  3.     string res = "";  
  4.     string inputJson = "";  
  5.     if (fmodulename == "procurementstage")  
  6.     {  
  7.         inputJson = input.ToString();  
  8.     }  
  9.     else  
  10.     {  
  11.         inputJson = (new JavaScriptSerializer()).Serialize(input);  
  12.     }  
  13.     //string apiUrl = "http://api/" + fmodulename.ToString().Trim();  
  14.     string apiUrl = "http://api/" + fmodulename.ToString().Trim();  
  15.      
  16.     apiUrl = ConfigurationManager.AppSettings["bcturl"].ToString() + fmodulename.ToString().Trim();  
  17.     HttpClient client = new HttpClient();  
  18.     try  
  19.     {  
  20.         HttpContent inputContent = new StringContent(inputJson, Encoding.UTF8, "application/json");  
  21.         HttpResponseMessage response = client.PostAsync(apiUrl, inputContent).Result;  
  22.         if (response.IsSuccessStatusCode)  
  23.         {  
  24.             res = response.Content.ReadAsStringAsync().Result;  
  25.         }  
  26.     }  
  27.     catch (Exception ex)  
  28.     {  
  29.         throw ex;  
  30.     }  
  31.     return res;  
  32.   
  33. }
like other method also i need to call in

Answers (2)