Beispiel #1
0
        static void Main(string[] args)
        {
            var          context = new StagingEntities();
            PropertyData prop    = context.PropertyDatas
                                   .Where(x => x.Status.Equals("success"))
                                   .FirstOrDefault();

            RootObject result = JsonConvert.DeserializeObject <RootObject>(prop.results);
        }
Beispiel #2
0
        static void UpdateTable(string acct, string stat, string res)
        {
            int i       = Int32.Parse(acct);
            var context = new StagingEntities();
            var result  = context.PropertyDatas.Single(x => x.Account_Number == i);

            result.results = res;
            result.Status  = stat;
            context.SaveChanges();
        }
Beispiel #3
0
        static List <string> getAccountIDs(int ct)
        {
            var context = new StagingEntities();
            var i       = context.PropertyDatas
                          .Where(x => x.Status.Equals(null))
                          .OrderBy(x => Guid.NewGuid())
                          .Take(ct);

            return(i.Select(x => x.AcctNumStr)
                   .ToList());
        }
Beispiel #4
0
        static void nonAsync()
        {
            string     sURL;
            WebRequest wrGETURL;
            Stream     objStream;
            string     results;

            for (int i = 0; i < 100000; i++)
            {
                Console.WriteLine(i + ") ");



                var context = new StagingEntities();
                var a       = context.PropertyDatas
                              .Where(x => x.Status.Equals("failed"))
                              .OrderBy(x => Guid.NewGuid())
                              .Take(1);

                string acct = a.First().AcctNumStr;

                try
                {
                    sURL             = "http://api.phila.gov/opa/v1.1/account/" + acct + "?format=json";
                    wrGETURL         = WebRequest.Create(sURL);
                    wrGETURL.Timeout = 10000;
                    objStream        = wrGETURL.GetResponse().GetResponseStream();
                    StreamReader objReader = new StreamReader(objStream);
                    results = objReader.ReadLine();
                    Console.WriteLine("Success: " + sURL);
                    UpdateTable(acct, "success", results);
                    results = null;
                }
                catch (WebException e)
                {
                    using (WebResponse response = e.Response)
                    {
                        // Console.WriteLine("Failed Response: " + response.ResponseUri.AbsoluteUri);
                        Console.WriteLine("Failed Response: ");

                        UpdateTable(acct, "failed", null);
                    }
                }
            }
        }