Example #1
0
        public static async System.Threading.Tasks.Task GetEandTFromSPandWriteToFile() // need to decide how many time it will run and update the data file.
        {
            string token = await GetDataHelper.GetAuthenticationToken();

            string    endpoint = "https://avadheshftc.sharepoint.com/sites/EmployeeConnectPrototype/_api/Web/Lists(guid'59c3fe4a-12f2-4ece-bcf2-eb850a0c357d')/items";
            SpfxEandT EandT    = null;

            using (var client = new HttpClient())
            {
                using (var request = new HttpRequestMessage(HttpMethod.Get, endpoint))
                {
                    string location = System.Web.Hosting.HostingEnvironment.MapPath(@"~\TestData\");
                    request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);

                    using (HttpResponseMessage response = await client.SendAsync(request))
                    {
                        if (response.IsSuccessStatusCode)
                        {
                            var json = await response.Content.ReadAsStringAsync();

                            try
                            {
                                EandT = (new JavaScriptSerializer().Deserialize <SpfxEandT>(json));
                                File.WriteAllText(location + "EandTMock.json", json);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        //This method is added as part spfx change. this method brings data from sharepoint and writes in testData files

        public static SpfxEandT ReadEandT()
        {
            string    file  = System.Web.Hosting.HostingEnvironment.MapPath("~/TestData/") + @"/EandTMock.json";
            SpfxEandT EandT = new SpfxEandT();
            string    json  = File.ReadAllText(file).Replace("##BaseURL##", ApplicationSettings.BaseUrl);

            EandT = new JavaScriptSerializer().Deserialize <SpfxEandT>(json);
            return(EandT);
        }