Пример #1
0
        /// <summary>
        /// GetCrunchFinanceOrg retrieves the crunchbase info based on the permalink passed or null if not found.
        /// </summary>
        /// <param name="financeorg">permalink to a firm in the finance-organization namespace on crunchbase</param>
        /// <returns></returns>
        public CrunchFinancial GetCrunchFinanceOrg(string financeorg)
        {
            CrunchJsonStream cjStream   = new CrunchJsonStream();
            string           jsonStream = cjStream.GetJsonStream(financeorg, "financial-organization");

            if (jsonStream != null)
            {
                try
                {
                    JavaScriptSerializer ser = new JavaScriptSerializer();
                    //with the stream, now deserialize into the Crunchbase object
                    CrunchFinancial jsonCrunchBase = ser.Deserialize <CrunchFinancial>(jsonStream);
                    Console.Error.WriteLine("Retrieved info for financial-organization {0}", jsonCrunchBase.name);
                    return(jsonCrunchBase);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Oops, the exception {0} happened with {1}", e.ToString(), financeorg);
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the info about a company in Crunchbase
        /// </summary>
        /// <param name="crunchcompany">string that matches the shortname in crunchbase, for example as in companies collection name</param>
        /// <returns>Data in a CrunchBase class structure</returns>
        public CrunchBase GetCrunchCompany(string crunchcompany)
        {
            CrunchJsonStream cjStream = new CrunchJsonStream();
            string           jsonStream;

            jsonStream = cjStream.GetJsonStream(crunchcompany, "company");
            if (jsonStream != null)
            {
                try
                {
                    string jsonLine;
                    JavaScriptSerializer ser = new JavaScriptSerializer();
                    //with the stream, now deserialize into the Crunchbase object
                    CrunchBase jsonCrunchBase = ser.Deserialize <CrunchBase>(jsonStream);

                    //assuming that worked, we need to clean up and create some additional meta data
                    jsonCrunchBase.FixCrunchBaseURL();
                    jsonCrunchBase.AggregateFunding();
                    jsonCrunchBase.SplitTagString();

                    //and now we build the CSV string and write to file
                    jsonLine = "\t" + jsonCrunchBase.GetImageURL() + "\t" +
                               jsonCrunchBase.name + "\t" +
                               jsonCrunchBase.homepage_url + "\t" +
                               jsonCrunchBase.crunchbase_url + "\t" +
                               jsonCrunchBase.description + "\t" +
                               jsonCrunchBase.category_code + "\t" +
                               jsonCrunchBase.number_of_employees + "\t" +
                               jsonCrunchBase.hqcity + "\t" +
                               jsonCrunchBase.hqstate + "\t" +
                               jsonCrunchBase.hqcountry + "\t" +
                               jsonCrunchBase.founded_year + "\t" +
                               jsonCrunchBase.GetAggregateFunding().ToString() + "\t" +
                               jsonCrunchBase.GetKeywordList(); /* + "\t\"" +  //there are max of 5 keywords I will dump out
                                                                 * jsonCrunchBase.overview + "\"";*/
                    //I really wanted to put the "overview" field into the file, but the XLS import was
                    //blowing up on the HTML...will need to revisit and fix
                    // tw note:  see http://www.blackbeltcoder.com/Articles/strings/convert-html-to-text

                    jsonCrunchBase.tabdelimited = jsonLine;
                    Console.Error.WriteLine("Retrieved info for {0}", jsonCrunchBase.name);
                    return(jsonCrunchBase);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Oops, the exception {0} happened with {1}", e.ToString(), crunchcompany);
                    return(null);
                }
            }
            else
            {
                return(null);
            }                      //if
        } //member get crunch
Пример #3
0
        private List <cbCompanyObject> getallcompanies()
        {
            CrunchJsonStream     cjStream         = new CrunchJsonStream();
            CompanyGenerator     companyGenerator = new CompanyGenerator();
            JavaScriptSerializer ser = new JavaScriptSerializer();

            string jsonStream;


            Console.Error.WriteLine("Getting ready to get the company names");

            //go hit the crunchbase api to get a list of all the companies in their database
            List <cbCompanyObject> companyNames = companyGenerator.GetCompanyNames();

            Console.Error.WriteLine("Back from getting the company names");
        }
Пример #4
0
        public List <cbSearchResults> SearchResults(string querystring)
        {
            CrunchJsonStream sr         = new CrunchJsonStream();
            string           jsonStream = sr.GetJsonSearch(querystring);

            if (jsonStream != null)
            {
                try
                {
                    DiagnosticTimer.StartTimer("firstpage");
                    JavaScriptSerializer ser = new JavaScriptSerializer();
                    //with the stream, now deserialize into the Crunchbase object
                    ResultsPage Results = ser.Deserialize <ResultsPage>(jsonStream);
                    DiagnosticTimer.StopTimer("firstpage");
                    // we got the first page create a big list of all the pages
                    if (Results.total < 11)
                    { // no extra pages
                        return(Results.results);
                    }
                    else //get the other pages
                    {
                        bool ShowProgress = Results.total > 60 ? true : false;
                        SearchingCrunchBaseProgressForm progressdialog = new SearchingCrunchBaseProgressForm();
                        if (ShowProgress) // put up the dialog
                        {
                            progressdialog.TotalFound    = Results.total;
                            progressdialog.Retireved     = 10;
                            progressdialog.EstimatedTime = new TimeSpan(DiagnosticTimer.GetTimerTimeSpan("firstpage").Ticks *(Results.total));
                            progressdialog.Show();
                        }

                        List <cbSearchResults> allresults = Results.results;
                        for (int i = 2; i < (Results.total / 10) + 1; i++)
                        {
                            jsonStream = sr.GetJsonSearch(querystring + "&page=" + i.ToString());
                            if (jsonStream != null)
                            {
                                try
                                {
                                    ser = new JavaScriptSerializer();
                                    //with the stream, now deserialize into the Crunchbase object
                                    Results = ser.Deserialize <ResultsPage>(jsonStream);
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine("Oops, the exception {0} happened with {1}", e.ToString(), querystring);
                                    return(null);
                                }
                                allresults.AddRange(Results.results);
                                if (ShowProgress)
                                {
                                    progressdialog.Retireved     = i * 10;
                                    progressdialog.EstimatedTime = new TimeSpan(DiagnosticTimer.GetTimerTimeSpan("firstpage").Ticks *(Results.total - i));
                                    progressdialog.Update();
                                    if (progressdialog.Canceled)
                                    {
                                        progressdialog.Close();
                                        return(allresults);
                                    }
                                }
                            }
                        }
                        if (ShowProgress)
                        {
                            progressdialog.Close();
                        }
                        return(allresults);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Oops, the exception {0} happened with {1}", e.ToString(), querystring);
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }