/// <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
Example #2
0
        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            string            company = FreeSearch.Text;
            CrunchBaseConnect cbc     = new CrunchBaseConnect();
            CrunchBase        cbentry = cbc.GetCrunchCompany(company);

            if (cbentry != null)
            {
                int num_cols = 18;
                Object[,] companyrow = new Object[1, num_cols];
                //headerstring if needed

                /*  string[] cpny ={"Company Logo URL","Company Name","Homepage URL","Crunchbase URL",
                 *                       "Short Description","Category","Number of Employees","City","State",
                 *                       "Country","Year Founded","Total Funding",,"keyword tags"}; */
                companyrow[0, 0]  = cbentry.GetImageURL();
                companyrow[0, 1]  = cbentry.name;
                companyrow[0, 2]  = cbentry.homepage_url;
                companyrow[0, 3]  = cbentry.crunchbase_url;
                companyrow[0, 4]  = cbentry.description;
                companyrow[0, 5]  = cbentry.category_code;
                companyrow[0, 6]  = cbentry.number_of_employees;
                companyrow[0, 7]  = cbentry.offices[0].city;
                companyrow[0, 8]  = cbentry.offices[0].state_code;
                companyrow[0, 9]  = cbentry.offices[0].country_code;
                companyrow[0, 10] = cbentry.founded_year;
                companyrow[0, 11] = cbentry.GetAggregateFunding();
                companyrow[0, 12] = cbentry.tag_list;

                var curr       = Globals.ThisAddIn.Application.ActiveSheet;
                var startCell  = Globals.ThisAddIn.Application.ActiveCell;
                var endCell    = curr.Cells[startCell.Row, startCell.Column + num_cols];
                var writeRange = curr.Range[startCell, endCell];
                writeRange.Value2 = companyrow;
            }
            else // it's not a company
            {
                CrunchFinancial cfc = cbc.GetCrunchFinanceOrg(company);
            }
        }
Example #3
0
        private void CompanyDetailsButton_Click_1(object sender, RibbonControlEventArgs e)
        {
            Range             permalinkrange = Globals.ThisAddIn.Application.Selection;
            CrunchBaseConnect cbc            = new CrunchBaseConnect();

            foreach (Range c in permalinkrange.Cells)
            {
                if (c != null)
                {
                    CrunchBase company = cbc.GetCrunchCompany(c.Value2);
                    if (company != null)
                    {
                        object[,] detailrow = new object[1, company.aggregateheaders.Count()];
                        for (int i = 0; i < company.aggregaterow.Count(); i++)
                        {
                            detailrow[0, i] = company.aggregaterow[i];
                        }
                        Range startCell = c.Worksheet.Cells[c.Row, c.Column + 1];
                        Range details   = ThisAddIn.OutputArrayToExcel(startCell, detailrow);
                    }
                }
            }
        }
Example #4
0
        private void AggregateButton_Click(object sender, EventArgs e)
        {
            var reportsheet = Globals.ThisAddIn.Application.ActiveSheet;

            if (NewSheetCheck.Checked)
            {
                reportsheet = Globals.ThisAddIn.Application.ActiveWorkbook.Worksheets.Add();
                reportsheet.Activate();
            }
            var startCell = Globals.ThisAddIn.Application.ActiveCell;
            // normalize into entity lists companies and finance orgs; ignore others for now
            SearchResultsList financecompanies = new SearchResultsList();
            SearchResultsList nonfincompanies  = new SearchResultsList();
            SearchResultsList entitiesnotfound = new SearchResultsList();  // add companies that we can't find in crunchbase to this list

            foreach (cbSearchResults entry in EntityList)
            {
                switch (entry.Namespace)
                {
                case "financial-organization": {
                    financecompanies.Add(entry);
                    break;
                }

                case "company":
                {
                    nonfincompanies.Add(entry);
                    break;
                }

                default:
                    break;
                }
            }
            // output the finance org table
            startCell.Value2 = "Crunchbase Search on " + DateTime.Now.ToLongTimeString() + " Scope: " + ScopeDesc.Text;
            // move startcell one cell lower
            startCell = reportsheet.Cells[startCell.Row + 1, startCell.Column];
            if (financecompanies.Count > 0)
            {
                // output a finance orgs table, first the headers
                CrunchFinancial cfh = new CrunchFinancial();
                object[,] excelout = new object[financecompanies.Count + 1, cfh.headersaggregate.Count()];
                // put the header in row 0
                for (int i = 0; i < cfh.headersaggregate.Count(); i++)
                {
                    excelout[0, i] = cfh.headersaggregate[i];
                }
                int currrow           = 1;
                CrunchBaseConnect cbc = new CrunchBaseConnect();
                foreach (cbSearchResults f in financecompanies)
                {
                    CrunchFinancial fc = cbc.GetCrunchFinanceOrg(f.permalink);

                    if (fc != null)
                    {
                        for (int i = 0; i < fc.headersaggregate.Count(); i++)
                        {
                            excelout[currrow, i] = fc.aggregateitems[i];
                        }
                        currrow++;
                    }
                    else
                    { // add to not found list
                        entitiesnotfound.Add(f);
                    }
                }
                //now output to excel
                Range financerange = ThisAddIn.OutputArrayToExcel(startCell, excelout);
                // now move startCell below the financerange
                startCell = reportsheet.Cells[startCell.Row + financerange.Rows.Count + 1, startCell.Column];
            }

            // now do companies entity
            if (nonfincompanies.Count > 0)
            {
                CrunchBaseConnect cbc = new CrunchBaseConnect();
                CrunchBase        cb  = new CrunchBase();
                int currow            = 1; // 0 has the header
                object[,] excelout = new object[nonfincompanies.Count + 1, cb.aggregateheaders.Count()];
                // output headers to row 0
                for (int i = 0; i < cb.aggregateheaders.Count(); i++)
                {
                    excelout[0, i] = cb.aggregateheaders[i];
                }
                foreach (cbSearchResults c in nonfincompanies)
                {
                    CrunchBase cp = cbc.GetCrunchCompany(c.permalink);
                    if (cp != null)
                    {
                        for (int i = 0; i < cp.aggregateheaders.Count(); i++)
                        {
                            excelout[currow, i] = cp.aggregaterow[i];
                        }
                        currow++;
                    }
                    else
                    {
                        entitiesnotfound.Add(c);
                    }
                }
                Range companyrange = ThisAddIn.OutputArrayToExcel(startCell, excelout);
                this.Close();
            }
        }   //aggregate button click method