public FamilyTreeStoreMyHeritage() { printDecode = false; printDecode = true; authenticated = false; if (printDecode) { trace.TraceInformation("FamilyTreeStoreMyHeritage"); } accessToken = null; refreshToken = null; expiryTime = 0; authenticationToken = null; authenticationWebBrowser = null; geniTreeSize = null; serializer = new JavaScriptSerializer(); //Authenticate(); //FamilyTreeStoreGeni2 geni2 = new FamilyTreeStoreGeni2(); //geni2.TestIndividualParsing(); cache = new FamilyCache(); //rootPersonXref = FetchRootPerson(); }
private void GetTreeStats() { if (printDecode) { trace.TraceInformation("GetTreeStats() " + " " + DateTime.Now); } string sLine = null; try { string sURL = "https://www.geni.com/api/stats/world-family-tree"; WebRequest wrGETURL; wrGETURL = WebRequest.Create(sURL); if (authenticationToken != null) { wrGETURL.Headers.Add("Authorization", String.Format("Bearer {0}", Uri.EscapeDataString(authenticationToken))); } if (printDecode) { trace.TraceInformation("GetTreeStats() url " + sURL); } Stream objStream = wrGETURL.GetResponse().GetResponseStream(); StreamReader objReader = new StreamReader(objStream); sLine = objReader.ReadToEnd(); } catch { trace.TraceInformation("GetTreeStats() FAIL " + " " + DateTime.Now); return; } if (sLine != null) { if (printDecode) { trace.TraceInformation("**********************************************************-start"); trace.TraceInformation("{0}:{1}", sLine.Length, sLine); trace.TraceInformation("**********************************************************-end"); } if ((sLine.StartsWith("<!DOCTYPE") || sLine.StartsWith("<HTML") || sLine.StartsWith("<html"))) { trace.TraceInformation("Bad format. Don't parse."); trace.TraceInformation("**********************************************************-start"); trace.TraceInformation("{0}:{1}", sLine.Length, sLine); trace.TraceInformation("**********************************************************-end"); trace.TraceInformation("GetTreeStats() FAIL " + " " + DateTime.Now); return; } geniTreeSize = serializer.Deserialize <HttpGeniTreeSize>(sLine); if (printDecode) { trace.TraceInformation("GetTreeStats() OK " + DateTime.Now); } } }